Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x | import { z } from 'zod';
import { defineArgument } from '../../lib/define-argument.js';
import { defineCommand } from '../../lib/define-command.js';
import { defineOption } from '../../lib/define-option.js';
import { styleText } from '../../lib/style-text.js';
import { Logger } from '../../logger.js';
import * as networkGroup from '../../models/ng.js';
import { ngResourceType, tags } from '../../parsers.js';
import { orgaIdOrNameOption } from '../global.options.js';
export const ngCreateCommand = defineCommand({
description: 'Create a Network Group',
since: '3.12.0',
options: {
link: defineOption({
name: 'link',
schema: z
.string()
.transform((v) => v.split(','))
.optional(),
description:
'Comma separated list of members IDs to link to a Network Group (app_xxx, external_xxx, mysql_xxx, postgresql_xxx, redis_xxx, etc.)',
placeholder: 'members-ids',
}),
description: defineOption({
name: 'description',
schema: z.string().optional(),
description: 'Network Group description',
placeholder: 'description',
}),
tags: defineOption({
name: 'tags',
schema: z.string().transform(tags).optional(),
description: 'List of tags, separated by a comma',
placeholder: 'tags',
}),
org: orgaIdOrNameOption,
},
args: [
defineArgument({
schema: z.string().transform(ngResourceType),
description: 'Network Group label',
placeholder: 'ng-label',
}),
],
async handler(options, ngLabel) {
const label = ngLabel.ngResourceLabel;
const { description, link: membersIds, org, tags } = options;
await networkGroup.create(label, description, tags, membersIds, org);
const successMessage = `Network Group ${styleText('green', label)} successfully created`;
if (membersIds == null) {
Logger.printSuccess(`${successMessage}!`);
} else {
Logger.printSuccess(`${successMessage} with member(s):`);
Logger.println(membersIds.map((id) => styleText('grey', ` - ${id}`)).join('\n'));
}
},
});
|