@axway/axway-cli-auth
Version:
Authenticate machines with the Axway Amplify platform
74 lines (63 loc) • 2.17 kB
JavaScript
import { initPlatformAccount } from '@axway/amplify-cli-utils';
import snooplogg from 'snooplogg';
var removeTeam = {
args: [
{
desc: 'The service account client id or name',
hint: 'client-id/name',
name: 'client-id',
required: true
},
{
desc: 'The team name or guid',
hint: 'team-guid/name',
name: 'team-guid',
required: true
}
],
desc: 'Remove a team from a service account',
help: {
header() {
return `${this.desc}.`;
}
},
options: {
'--account [name]': 'The platform account to use',
'--json': {
callback: ({ ctx, value }) => ctx.jsonMode = value,
desc: 'Outputs the result as JSON'
},
'--org [name|id|guid]': 'The organization name, id, or guid'
},
async action({ argv, cli, console }) {
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 modify a service account in the "${org.name}" organization`);
}
// get the service account and team
const { client: existing } = await sdk.client.find(account, org, argv.clientId);
const { team } = await sdk.team.find(account, org, argv.teamGuid);
// add the team to the existing list of teams
const teams = (existing.teams || [])
.map(({ guid, roles }) => ({ guid, roles }))
.filter(t => t.guid !== team.guid);
// update the service account
const results = await sdk.client.update(account, org, {
client: existing,
teams
});
results.account = account;
if (argv.json) {
console.log(JSON.stringify(results, null, 2));
} else {
const { highlight, note } = snooplogg.styles;
console.log(`Account: ${highlight(account.name)}`);
console.log(`Organization: ${highlight(org.name)} ${note(`(${org.guid})`)}\n`);
const { client_id, name } = results.client;
console.log(`Successfully removed team ${highlight(team.name)} from service account ${highlight(name)} ${note(`(${client_id})`)}`);
}
await cli.emitAction('axway:auth:service-account:remove-team', results);
}
};
export { removeTeam as default };
//# sourceMappingURL=remove-team.js.map