UNPKG

@controlplane/cli

Version:

Control Plane Corporation CLI

91 lines 3.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuditContext = void 0; const generic_1 = require("./generic"); const command_1 = require("../cli/command"); const query_1 = require("./query"); const resolver_1 = require("./resolver"); const options_1 = require("./options"); const functions_1 = require("../util/functions"); class AuditContext extends command_1.Command { constructor() { super(...arguments); this.command = 'auditctx'; this.describe = 'Manage audit contexts'; } builder(yargs) { const resolver = (0, resolver_1.kindResolver)('auditctx'); const ctxSchema = { props: [...query_1.defaultProps, 'origin'], }; const opts = [options_1.withOrgOptions, options_1.withStandardOptions]; const commandName = 'audit context'; const commandNamePlural = 'audit contexts'; const commandNameA = 'an audit context'; return (yargs .demandCommand() .version(false) .help() // generic .command(new generic_1.Get(commandNamePlural, resolver, ...opts).toYargs()) .command(new generic_1.Edit(commandName, resolver, ...opts).toYargs()) .command(new generic_1.Query(commandNamePlural, resolver, ctxSchema, ...opts).toYargs()) //.command(new Delete(resolver, ...opts).toYargs()) .command(new generic_1.Eventlog(commandName, resolver, ...opts).toYargs()) .command(new generic_1.Tag(commandNamePlural, resolver, ...opts).toYargs()) .command(new generic_1.Patch(commandName, resolver, ...opts).toYargs()) .command(new generic_1.ListPermissions(commandNameA, resolver, ...opts).toYargs()) .command(new generic_1.ViewAccessReport(commandName, resolver, ...opts).toYargs()) .command(new generic_1.Clone(commandName, resolver, ...opts).toYargs()) .command(new generic_1.Update(commandName, resolver, [ { path: 'description', }, { path: 'tags.<key>', }, ], ...opts).toYargs()) // specific .command(new Create(resolver).toYargs())); } handle() { } } exports.AuditContext = AuditContext; class Create extends command_1.Command { constructor(resolve) { super(); this.resolve = resolve; this.command = 'create'; this.describe = 'Create a new audit context'; } withCreateOptions(yargs) { return yargs.options({ name: { describe: 'Name of the new audit context', demandOption: true, requiresArg: true, }, description: { alias: 'desc', requiresArg: true, describe: 'Optional description, defaults to the name if not set', }, }); } builder(yargs) { return (0, functions_1.pipe)( // this.withCreateOptions, generic_1.withTagOptions, options_1.withOrgOptions, options_1.withStandardOptions)(yargs); } async handle(args) { const body = { name: args.name, description: args.description, tags: (0, generic_1.fromTagOptions)(args), }; const path = this.resolve.homeLink(this.session.context); const data = await this.client.create(path, body); this.session.outFormat(data); } } //# sourceMappingURL=auditctx.js.map