|
| 1 | +/* |
| 2 | +Copyright 2023 Adobe. All rights reserved. |
| 3 | +This file is licensed to you under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. You may obtain a copy |
| 5 | +of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +
|
| 7 | +Unless required by applicable law or agreed to in writing, software distributed under |
| 8 | +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS |
| 9 | +OF ANY KIND, either express or implied. See the License for the specific language |
| 10 | +governing permissions and limitations under the License. |
| 11 | +*/ |
| 12 | + |
| 13 | +const { initSdk, getProgramId, sanitizeEnvironmentId } = require('../../../cloudmanager-helpers') |
| 14 | +const { cli } = require('cli-ux') |
| 15 | +const commonFlags = require('../../../common-flags') |
| 16 | +const commonArgs = require('../../../common-args') |
| 17 | +const BaseCommand = require('../../../base-command') |
| 18 | + |
| 19 | +class CreateContentFlowCommand extends BaseCommand { |
| 20 | + async run () { |
| 21 | + const { args, flags } = this.parse(CreateContentFlowCommand) |
| 22 | + const programId = getProgramId(flags) |
| 23 | + |
| 24 | + const environmentId = sanitizeEnvironmentId(args.environmentId) |
| 25 | + |
| 26 | + const createInfo = { |
| 27 | + contentSetId: args.contentSetId, |
| 28 | + destEnvironmentId: args.destEnvironmentId, |
| 29 | + includeACL: args.includeACL, |
| 30 | + tier: args.tier, |
| 31 | + mergeExcludePaths: 'false', |
| 32 | + } |
| 33 | + cli.action.start(`Creating content flow for pid: ${programId} env: ${environmentId} values: ${JSON.stringify(createInfo)}.`) |
| 34 | + |
| 35 | + const result = await this.createContentFlow(programId, environmentId, createInfo, flags.imsContextName) |
| 36 | + |
| 37 | + cli.action.stop(`Created content flow ${result.contentFlowId}`) |
| 38 | + |
| 39 | + return result |
| 40 | + } |
| 41 | + |
| 42 | + async createContentFlow (programId, environmentId, contentSet, imsContextName = null) { |
| 43 | + const sdk = await initSdk(imsContextName) |
| 44 | + return sdk.createContentFlow(programId, environmentId, contentSet) |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +CreateContentFlowCommand.description = 'Create a content flow' |
| 49 | + |
| 50 | +CreateContentFlowCommand.args = [ |
| 51 | + commonArgs.environmentId, |
| 52 | + { name: 'contentSetId', required: true, description: 'Id of content set to use' }, |
| 53 | + { name: 'destEnvironmentId', required: true, description: 'The destination environment id' }, |
| 54 | + { name: 'includeACL', required: true, description: 'Include ACLs' }, |
| 55 | + { name: 'tier', required: false, description: 'The tier, for example author', default: 'author' }, |
| 56 | +] |
| 57 | + |
| 58 | +CreateContentFlowCommand.flags = { |
| 59 | + ...commonFlags.global, |
| 60 | + ...commonFlags.programId, |
| 61 | +} |
| 62 | + |
| 63 | +CreateContentFlowCommand.aliases = [ |
| 64 | + 'cloudmanager:create-content-flow', |
| 65 | +] |
| 66 | + |
| 67 | +CreateContentFlowCommand.permissionInfo = { |
| 68 | + operation: 'createContentFlow', |
| 69 | +} |
| 70 | + |
| 71 | +module.exports = CreateContentFlowCommand |
0 commit comments