UNPKG

@axway/axway-cli-oum

Version:

Axway Amplify platform organization and user management CLI

64 lines (55 loc) 1.69 kB
import { initPlatformAccount } from '@axway/amplify-cli-utils'; import snooplogg from 'snooplogg'; var update = { args: [ { name: 'org', desc: 'The organization name, id, or guid', required: true }, { name: 'user', desc: 'The user guid or email address', required: true } ], desc: 'Update an user\'s organization roles', options: { '--account [name]': 'The platform account to use', '--json': { callback: ({ ctx, value }) => ctx.jsonMode = value, desc: 'Outputs the result as JSON' }, '--role [role]': { desc: 'Assign one or more organization roles to a user', multiple: true, redact: false } }, async action({ argv, cli, console }) { let { account, org, sdk } = await initPlatformAccount(argv.account, argv.org, argv.env); const { highlight, note } = snooplogg.styles; if (!org.userRoles.includes('administrator')) { throw new Error('You do not have administrative access to update an organization\'s user roles'); } if (!argv.json) { console.log(`Account: ${highlight(account.name)}`); console.log(`Organization: ${highlight(org.name)} ${note(`(${org.guid})`)}\n`); } const { roles, user } = await sdk.org.user.update(account, org, argv.user, argv.role); const results = { account: account.name, org, user }; if (argv.json) { console.log(JSON.stringify(results, null, 2)); } else { const name = `${user.firstname} ${user.lastname}`.trim(); console.log(`Successfully updated role${roles === 1 ? '' : 's'} for ${highlight(name)}`); } await cli.emitAction('axway:oum:org:user:update', results); } }; export { update as default }; //# sourceMappingURL=update.js.map