@axway/axway-cli-oum
Version:
Axway Amplify platform organization and user management CLI
51 lines (44 loc) • 1.31 kB
JavaScript
import { initPlatformAccount } from '@axway/amplify-cli-utils';
import snooplogg from 'snooplogg';
var rename = {
args: [
{
name: 'org',
desc: 'The organization name, id, or guid; defaults to the current org',
required: true
},
{
name: 'name',
desc: 'The new organization name',
required: true
}
],
desc: 'Rename an organization',
options: {
'--account [name]': 'The platform account to use',
'--json': {
callback: ({ ctx, value }) => ctx.jsonMode = value,
desc: 'Outputs the result as JSON'
}
},
async action({ argv, cli, console }) {
const { highlight } = snooplogg.styles;
const { account, org, sdk } = await initPlatformAccount(argv.account, argv.org, argv.env);
if (!org.userRoles.includes('administrator')) {
throw new Error('You do not have administrative access to rename the organization');
}
const result = await sdk.org.rename(account, org, argv.name);
if (argv.json) {
console.log(JSON.stringify({
account: account.name,
...result
}, null, 2));
} else {
console.log(`Account: ${highlight(account.name)}\n`);
console.log(`Successfully renamed "${result.oldName}" to "${result.name}"`);
}
await cli.emitAction('axway:oum:org:rename', result);
}
};
export { rename as default };
//# sourceMappingURL=rename.js.map