UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

48 lines 2.31 kB
import { z } from 'zod'; import { globalOptionsZod } from '../../../Command.js'; import request from '../../../request.js'; import { formatting } from '../../../utils/formatting.js'; import PowerAutomateCommand from '../../base/PowerAutomateCommand.js'; import commands from '../commands.js'; export const options = z.strictObject({ ...globalOptionsZod.shape, environmentName: z.string().alias('e'), name: z.string().alias('n'), asAdmin: z.boolean().optional() }); class FlowGetCommand extends PowerAutomateCommand { get name() { return commands.GET; } get description() { return 'Gets information about the specified Microsoft Flow'; } get schema() { return options; } async commandAction(logger, args) { if (this.verbose) { await logger.logToStderr(`Retrieving information about Microsoft Flow ${args.options.name}...`); } const requestOptions = { url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01&$expand=swagger,properties.connectionreferences.apidefinition,properties.definitionsummary.operations.apioperation,operationDefinition,plan,properties.throttleData,properties.estimatedsuspensiondata,properties.licenseData`, headers: { accept: 'application/json' }, responseType: 'json' }; try { const res = await request.get(requestOptions); res.displayName = res.properties.displayName; res.description = res.properties.definitionSummary.description || ''; res.triggers = res.properties.definitionSummary.triggers.map((t) => (t.type + (t.kind ? "-" + t.kind : ''))).join(', '); res.actions = res.properties.definitionSummary.actions.map((a) => (a.type + (a.swaggerOperationId ? "-" + a.swaggerOperationId : ''))).join(', '); await logger.log(res); } catch (err) { this.handleRejectedODataJsonPromise(err); } } } export default new FlowGetCommand(); //# sourceMappingURL=flow-get.js.map