clever-tools 4.4.1 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/clever.js +208 -2125
- package/package.json +33 -25
- package/src/commands/README.md +65 -0
- package/src/commands/accesslogs/accesslogs.command.js +158 -0
- package/src/commands/accesslogs/accesslogs.docs.md +20 -0
- package/src/commands/{activity.js → activity/activity.command.js} +74 -44
- package/src/commands/activity/activity.docs.md +19 -0
- package/src/commands/addon/addon.args.js +14 -0
- package/src/commands/addon/addon.command.js +7 -0
- package/src/commands/addon/addon.create.command.js +236 -0
- package/src/commands/addon/addon.delete.command.js +32 -0
- package/src/commands/addon/addon.docs.md +156 -0
- package/src/commands/addon/addon.env.command.js +50 -0
- package/src/commands/addon/addon.list.command.js +55 -0
- package/src/commands/addon/addon.providers.command.js +45 -0
- package/src/commands/addon/addon.providers.show.command.js +99 -0
- package/src/commands/addon/addon.rename.command.js +24 -0
- package/src/commands/applications/applications.command.js +59 -0
- package/src/commands/applications/applications.docs.md +31 -0
- package/src/commands/applications/applications.list.command.js +100 -0
- package/src/commands/cancel-deploy/cancel-deploy.command.js +30 -0
- package/src/commands/cancel-deploy/cancel-deploy.docs.md +16 -0
- package/src/commands/config/config.args.js +10 -0
- package/src/commands/config/config.command.js +20 -0
- package/src/commands/config/config.docs.md +86 -0
- package/src/commands/config/config.get.command.js +21 -0
- package/src/commands/config/config.set.command.js +38 -0
- package/src/commands/config/config.update.command.js +88 -0
- package/src/commands/console/console.command.js +31 -0
- package/src/commands/console/console.docs.md +16 -0
- package/src/commands/create/create.command.js +173 -0
- package/src/commands/create/create.docs.md +27 -0
- package/src/commands/{curl.js → curl/curl.command.js} +10 -3
- package/src/commands/curl/curl.docs.md +9 -0
- package/src/commands/database/database.args.js +8 -0
- package/src/commands/database/database.backups.command.js +60 -0
- package/src/commands/database/database.backups.download.command.js +55 -0
- package/src/commands/database/database.command.js +10 -0
- package/src/commands/database/database.docs.md +52 -0
- package/src/commands/delete/delete.command.js +43 -0
- package/src/commands/delete/delete.docs.md +17 -0
- package/src/commands/deploy/deploy.command.js +166 -0
- package/src/commands/deploy/deploy.docs.md +22 -0
- package/src/commands/diag/diag.command.js +136 -0
- package/src/commands/diag/diag.docs.md +15 -0
- package/src/commands/domain/domain.add.command.js +25 -0
- package/src/commands/domain/domain.args.js +8 -0
- package/src/commands/domain/domain.command.js +38 -0
- package/src/commands/domain/domain.diag.command.js +204 -0
- package/src/commands/domain/domain.docs.md +143 -0
- package/src/commands/domain/domain.favourite.command.js +35 -0
- package/src/commands/domain/domain.favourite.set.command.js +24 -0
- package/src/commands/domain/domain.favourite.unset.command.js +23 -0
- package/src/commands/domain/domain.overview.command.js +157 -0
- package/src/commands/domain/domain.rm.command.js +25 -0
- package/src/commands/drain/drain.args.js +8 -0
- package/src/commands/drain/drain.command.js +56 -0
- package/src/commands/drain/drain.create.command.js +128 -0
- package/src/commands/drain/drain.disable.command.js +27 -0
- package/src/commands/drain/drain.docs.md +129 -0
- package/src/commands/drain/drain.enable.command.js +27 -0
- package/src/commands/drain/drain.get.command.js +38 -0
- package/src/commands/drain/drain.remove.command.js +26 -0
- package/src/commands/emails/emails.add.command.js +32 -0
- package/src/commands/emails/emails.args.js +8 -0
- package/src/commands/emails/emails.command.js +35 -0
- package/src/commands/emails/emails.docs.md +79 -0
- package/src/commands/emails/emails.open.command.js +15 -0
- package/src/commands/emails/emails.primary.command.js +29 -0
- package/src/commands/emails/emails.remove-all.command.js +54 -0
- package/src/commands/emails/emails.remove.command.js +25 -0
- package/src/commands/env/env.command.js +77 -0
- package/src/commands/env/env.docs.md +99 -0
- package/src/commands/env/env.import-vars.command.js +45 -0
- package/src/commands/env/env.import.command.js +29 -0
- package/src/commands/env/env.rm.command.js +25 -0
- package/src/commands/env/env.set.command.js +32 -0
- package/src/commands/features/features.args.js +9 -0
- package/src/commands/features/features.command.js +7 -0
- package/src/commands/features/features.disable.command.js +25 -0
- package/src/commands/features/features.docs.md +71 -0
- package/src/commands/features/features.enable.command.js +32 -0
- package/src/commands/features/features.info.command.js +27 -0
- package/src/commands/features/features.list.command.js +49 -0
- package/src/commands/global.args.js +45 -0
- package/src/commands/global.commands.js +461 -0
- package/src/commands/global.options.js +186 -0
- package/src/commands/help/help.command.js +9 -0
- package/src/commands/help/help.docs.md +9 -0
- package/src/commands/k8s/k8s.add-persistent-storage.command.js +39 -0
- package/src/commands/k8s/k8s.args.js +9 -0
- package/src/commands/k8s/k8s.command.js +12 -0
- package/src/commands/k8s/k8s.create.command.js +86 -0
- package/src/commands/k8s/k8s.delete.command.js +40 -0
- package/src/commands/k8s/k8s.docs.md +131 -0
- package/src/commands/k8s/k8s.get-kubeconfig.command.js +32 -0
- package/src/commands/k8s/k8s.get.command.js +43 -0
- package/src/commands/k8s/k8s.list.command.js +38 -0
- package/src/commands/keycloak/keycloak.command.js +17 -0
- package/src/commands/keycloak/keycloak.disable-ng.command.js +13 -0
- package/src/commands/keycloak/keycloak.docs.md +197 -0
- package/src/commands/keycloak/keycloak.enable-ng.command.js +13 -0
- package/src/commands/keycloak/keycloak.get.command.js +17 -0
- package/src/commands/keycloak/keycloak.open.command.js +13 -0
- package/src/commands/keycloak/keycloak.open.logs.command.js +13 -0
- package/src/commands/keycloak/keycloak.open.webui.command.js +13 -0
- package/src/commands/keycloak/keycloak.rebuild.command.js +13 -0
- package/src/commands/keycloak/keycloak.restart.command.js +13 -0
- package/src/commands/keycloak/keycloak.version.check.command.js +17 -0
- package/src/commands/keycloak/keycloak.version.command.js +17 -0
- package/src/commands/keycloak/keycloak.version.update.command.js +17 -0
- package/src/commands/kv/kv.command.js +99 -0
- package/src/commands/kv/kv.docs.md +27 -0
- package/src/commands/link/link.command.js +31 -0
- package/src/commands/link/link.docs.md +22 -0
- package/src/commands/{login.js → login/login.command.js} +44 -22
- package/src/commands/login/login.docs.md +16 -0
- package/src/commands/logout/logout.command.js +15 -0
- package/src/commands/logout/logout.docs.md +9 -0
- package/src/commands/logs/logs.command.js +81 -0
- package/src/commands/logs/logs.docs.md +22 -0
- package/src/commands/make-default/make-default.command.js +17 -0
- package/src/commands/make-default/make-default.docs.md +15 -0
- package/src/commands/matomo/matomo.command.js +17 -0
- package/src/commands/matomo/matomo.docs.md +109 -0
- package/src/commands/matomo/matomo.get.command.js +17 -0
- package/src/commands/matomo/matomo.open.command.js +13 -0
- package/src/commands/matomo/matomo.open.logs.command.js +13 -0
- package/src/commands/matomo/matomo.open.webui.command.js +13 -0
- package/src/commands/matomo/matomo.rebuild.command.js +13 -0
- package/src/commands/matomo/matomo.restart.command.js +13 -0
- package/src/commands/metabase/metabase.command.js +17 -0
- package/src/commands/metabase/metabase.docs.md +169 -0
- package/src/commands/metabase/metabase.get.command.js +17 -0
- package/src/commands/metabase/metabase.open.command.js +13 -0
- package/src/commands/metabase/metabase.open.logs.command.js +13 -0
- package/src/commands/metabase/metabase.open.webui.command.js +13 -0
- package/src/commands/metabase/metabase.rebuild.command.js +13 -0
- package/src/commands/metabase/metabase.restart.command.js +13 -0
- package/src/commands/metabase/metabase.version.check.command.js +17 -0
- package/src/commands/metabase/metabase.version.command.js +17 -0
- package/src/commands/metabase/metabase.version.update.command.js +17 -0
- package/src/commands/ng/ng.args.js +27 -0
- package/src/commands/ng/ng.command.js +45 -0
- package/src/commands/ng/ng.create.command.js +60 -0
- package/src/commands/ng/ng.create.external.command.js +44 -0
- package/src/commands/ng/ng.delete.command.js +22 -0
- package/src/commands/ng/ng.delete.external.command.js +25 -0
- package/src/commands/ng/ng.docs.md +214 -0
- package/src/commands/ng/ng.get-config.command.js +32 -0
- package/src/commands/ng/ng.get.command.js +22 -0
- package/src/commands/ng/ng.link.command.js +25 -0
- package/src/commands/ng/ng.options.js +9 -0
- package/src/commands/ng/ng.search.command.js +22 -0
- package/src/commands/ng/ng.unlink.command.js +25 -0
- package/src/commands/notify-email/notify-email.add.command.js +65 -0
- package/src/commands/notify-email/notify-email.command.js +61 -0
- package/src/commands/notify-email/notify-email.docs.md +60 -0
- package/src/commands/notify-email/notify-email.remove.command.js +24 -0
- package/src/commands/open/open.command.js +24 -0
- package/src/commands/open/open.docs.md +16 -0
- package/src/commands/otoroshi/otoroshi.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.disable-ng.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.docs.md +211 -0
- package/src/commands/otoroshi/otoroshi.enable-ng.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.get-config.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.get.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.open.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.open.logs.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.open.webui.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.rebuild.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.restart.command.js +13 -0
- package/src/commands/otoroshi/otoroshi.version.check.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.version.command.js +17 -0
- package/src/commands/otoroshi/otoroshi.version.update.command.js +17 -0
- package/src/commands/profile/profile.command.js +60 -0
- package/src/commands/profile/profile.docs.md +23 -0
- package/src/commands/profile/profile.open.command.js +12 -0
- package/src/commands/published-config/published-config.command.js +40 -0
- package/src/commands/published-config/published-config.docs.md +77 -0
- package/src/commands/published-config/published-config.import.command.js +29 -0
- package/src/commands/published-config/published-config.rm.command.js +27 -0
- package/src/commands/published-config/published-config.set.command.js +34 -0
- package/src/commands/restart/restart.command.js +77 -0
- package/src/commands/restart/restart.docs.md +21 -0
- package/src/commands/scale/scale.command.js +121 -0
- package/src/commands/scale/scale.docs.md +23 -0
- package/src/commands/service/service.command.js +91 -0
- package/src/commands/service/service.docs.md +104 -0
- package/src/commands/service/service.link-addon.command.js +24 -0
- package/src/commands/service/service.link-app.command.js +23 -0
- package/src/commands/service/service.unlink-addon.command.js +24 -0
- package/src/commands/service/service.unlink-app.command.js +23 -0
- package/src/commands/ssh/ssh.command.js +40 -0
- package/src/commands/ssh/ssh.docs.md +17 -0
- package/src/commands/ssh-keys/ssh-keys.add.command.js +41 -0
- package/src/commands/ssh-keys/ssh-keys.args.js +8 -0
- package/src/commands/ssh-keys/ssh-keys.command.js +50 -0
- package/src/commands/ssh-keys/ssh-keys.docs.md +66 -0
- package/src/commands/ssh-keys/ssh-keys.open.command.js +12 -0
- package/src/commands/ssh-keys/ssh-keys.remove-all.command.js +54 -0
- package/src/commands/ssh-keys/ssh-keys.remove.command.js +26 -0
- package/src/commands/status/status.command.js +122 -0
- package/src/commands/status/status.docs.md +17 -0
- package/src/commands/stop/stop.command.js +23 -0
- package/src/commands/stop/stop.docs.md +16 -0
- package/src/commands/tcp-redirs/tcp-redirs.add.command.js +24 -0
- package/src/commands/tcp-redirs/tcp-redirs.command.js +41 -0
- package/src/commands/tcp-redirs/tcp-redirs.docs.md +71 -0
- package/src/commands/tcp-redirs/tcp-redirs.list-namespaces.command.js +48 -0
- package/src/commands/tcp-redirs/tcp-redirs.options.js +11 -0
- package/src/commands/tcp-redirs/tcp-redirs.remove.command.js +34 -0
- package/src/commands/tokens/tokens.command.js +43 -0
- package/src/commands/tokens/tokens.create.command.js +108 -0
- package/src/commands/tokens/tokens.docs.md +50 -0
- package/src/commands/tokens/tokens.revoke.command.js +25 -0
- package/src/commands/unlink/unlink.command.js +21 -0
- package/src/commands/unlink/unlink.docs.md +15 -0
- package/src/commands/version/version.command.js +13 -0
- package/src/commands/version/version.docs.md +9 -0
- package/src/commands/webhooks/webhooks.add.command.js +51 -0
- package/src/commands/webhooks/webhooks.command.js +57 -0
- package/src/commands/webhooks/webhooks.docs.md +61 -0
- package/src/commands/webhooks/webhooks.remove.command.js +24 -0
- package/src/lib/cliparse-patched.js +192 -0
- package/src/lib/define-argument.js +7 -0
- package/src/lib/define-argument.types.d.ts +23 -0
- package/src/lib/define-command.js +7 -0
- package/src/lib/define-command.types.d.ts +85 -0
- package/src/lib/define-common.types.d.ts +18 -0
- package/src/lib/define-option.js +7 -0
- package/src/lib/define-option.types.d.ts +29 -0
- package/src/lib/get-command-info.js +86 -0
- package/src/lib/get-command-info.types.d.ts +42 -0
- package/src/lib/zod-utils.js +66 -0
- package/src/models/addon.js +2 -3
- package/src/models/application.js +4 -5
- package/src/models/application_configuration.js +5 -23
- package/src/models/domain.js +34 -2
- package/src/models/exit-strategy-option.js +0 -9
- package/src/models/git.js +1 -4
- package/src/models/log-v4.js +5 -0
- package/src/models/log.js +5 -0
- package/src/models/namespaces.js +1 -2
- package/src/models/notification.js +1 -7
- package/src/parsers.js +33 -92
- package/src/command-options.js +0 -55
- package/src/command-promise-handler.js +0 -16
- package/src/commands/accesslogs.js +0 -138
- package/src/commands/addon.js +0 -391
- package/src/commands/applications.js +0 -123
- package/src/commands/cancel-deploy.js +0 -19
- package/src/commands/config.js +0 -47
- package/src/commands/console.js +0 -20
- package/src/commands/create.js +0 -129
- package/src/commands/database.js +0 -73
- package/src/commands/delete.js +0 -24
- package/src/commands/deploy.js +0 -133
- package/src/commands/diag.js +0 -126
- package/src/commands/domain.js +0 -445
- package/src/commands/drain.js +0 -164
- package/src/commands/emails.js +0 -156
- package/src/commands/env.js +0 -124
- package/src/commands/features.js +0 -87
- package/src/commands/k8s.js +0 -193
- package/src/commands/keycloak.js +0 -138
- package/src/commands/kv.js +0 -93
- package/src/commands/link.js +0 -20
- package/src/commands/logout.js +0 -8
- package/src/commands/logs.js +0 -45
- package/src/commands/makeDefault.js +0 -11
- package/src/commands/matomo.js +0 -85
- package/src/commands/metabase.js +0 -112
- package/src/commands/ng.js +0 -202
- package/src/commands/notify-email.js +0 -99
- package/src/commands/open.js +0 -13
- package/src/commands/otoroshi.js +0 -149
- package/src/commands/profile.js +0 -55
- package/src/commands/published-config.js +0 -70
- package/src/commands/restart.js +0 -52
- package/src/commands/scale.js +0 -66
- package/src/commands/service.js +0 -105
- package/src/commands/ssh-keys.js +0 -144
- package/src/commands/ssh.js +0 -20
- package/src/commands/status.js +0 -115
- package/src/commands/stop.js +0 -12
- package/src/commands/tcp-redirs.js +0 -80
- package/src/commands/tokens.js +0 -144
- package/src/commands/unlink.js +0 -14
- package/src/commands/version.js +0 -6
- package/src/commands/webhooks.js +0 -74
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { operatorUpdateVersion } from '../../lib/operator-commands.js';
|
|
3
|
+
import { addonIdOrNameArg } from '../global.args.js';
|
|
4
|
+
import { targetVersionOption } from '../global.options.js';
|
|
5
|
+
|
|
6
|
+
export const metabaseVersionUpdateCommand = defineCommand({
|
|
7
|
+
description: 'Update Metabase deployed version',
|
|
8
|
+
since: '3.13.0',
|
|
9
|
+
options: {
|
|
10
|
+
target: targetVersionOption,
|
|
11
|
+
},
|
|
12
|
+
args: [addonIdOrNameArg],
|
|
13
|
+
async handler(options, addonIdOrName) {
|
|
14
|
+
const { target } = options;
|
|
15
|
+
await operatorUpdateVersion('metabase', target, addonIdOrName);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineArgument } from '../../lib/define-argument.js';
|
|
3
|
+
import { ngResourceType } from '../../parsers.js';
|
|
4
|
+
|
|
5
|
+
export const ngIdOrLabelArg = defineArgument({
|
|
6
|
+
schema: z.string().transform(ngResourceType),
|
|
7
|
+
description: 'Network Group ID or label',
|
|
8
|
+
placeholder: 'ng-id|ng-label',
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const ngExternalIdOrLabelArg = defineArgument({
|
|
12
|
+
schema: z.string().transform(ngResourceType),
|
|
13
|
+
description: 'External peer ID or label',
|
|
14
|
+
placeholder: 'peer-id|peer-label',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const ngResourceIdArg = defineArgument({
|
|
18
|
+
schema: z.string().transform(ngResourceType),
|
|
19
|
+
description: 'ID of a resource to (un)link to a Network Group',
|
|
20
|
+
placeholder: 'id',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const ngAnyIdOrLabelArg = defineArgument({
|
|
24
|
+
schema: z.string().transform(ngResourceType),
|
|
25
|
+
description: 'ID or Label of a Network Group, a member or an (external) peer',
|
|
26
|
+
placeholder: 'id|label',
|
|
27
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { styleText } from '../../lib/style-text.js';
|
|
3
|
+
import { Logger } from '../../logger.js';
|
|
4
|
+
import * as networkGroup from '../../models/ng.js';
|
|
5
|
+
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
6
|
+
|
|
7
|
+
export const ngCommand = defineCommand({
|
|
8
|
+
description: 'List Network Groups',
|
|
9
|
+
since: '3.12.0',
|
|
10
|
+
isExperimental: true,
|
|
11
|
+
featureFlag: 'ng',
|
|
12
|
+
options: {
|
|
13
|
+
org: orgaIdOrNameOption,
|
|
14
|
+
format: humanJsonOutputFormatOption,
|
|
15
|
+
},
|
|
16
|
+
args: [],
|
|
17
|
+
async handler(options) {
|
|
18
|
+
const { org, format } = options;
|
|
19
|
+
|
|
20
|
+
const ngs = await networkGroup.getAllNGs(org);
|
|
21
|
+
|
|
22
|
+
switch (format) {
|
|
23
|
+
case 'json': {
|
|
24
|
+
Logger.printJson(ngs);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case 'human':
|
|
28
|
+
default: {
|
|
29
|
+
if (!ngs.length) {
|
|
30
|
+
Logger.println(`ℹ️ No Network Group found, create one with ${styleText('blue', 'clever ng create')} command`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const ngList = ngs.map(({ id, label, networkIp, members, peers }) => ({
|
|
34
|
+
ID: id,
|
|
35
|
+
Label: label,
|
|
36
|
+
'Network CIDR': networkIp,
|
|
37
|
+
Members: Object.keys(members).length,
|
|
38
|
+
Peers: Object.keys(peers).length,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
console.table(ngList);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineArgument } from '../../lib/define-argument.js';
|
|
3
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
4
|
+
import { defineOption } from '../../lib/define-option.js';
|
|
5
|
+
import { styleText } from '../../lib/style-text.js';
|
|
6
|
+
import { Logger } from '../../logger.js';
|
|
7
|
+
import * as networkGroup from '../../models/ng.js';
|
|
8
|
+
import { ngResourceType, tags } from '../../parsers.js';
|
|
9
|
+
import { orgaIdOrNameOption } from '../global.options.js';
|
|
10
|
+
|
|
11
|
+
export const ngCreateCommand = defineCommand({
|
|
12
|
+
description: 'Create a Network Group',
|
|
13
|
+
since: '3.12.0',
|
|
14
|
+
options: {
|
|
15
|
+
link: defineOption({
|
|
16
|
+
name: 'link',
|
|
17
|
+
schema: z
|
|
18
|
+
.string()
|
|
19
|
+
.transform((v) => v.split(','))
|
|
20
|
+
.optional(),
|
|
21
|
+
description:
|
|
22
|
+
'Comma separated list of members IDs to link to a Network Group (app_xxx, external_xxx, mysql_xxx, postgresql_xxx, redis_xxx, etc.)',
|
|
23
|
+
placeholder: 'members-ids',
|
|
24
|
+
}),
|
|
25
|
+
description: defineOption({
|
|
26
|
+
name: 'description',
|
|
27
|
+
schema: z.string().optional(),
|
|
28
|
+
description: 'Network Group description',
|
|
29
|
+
placeholder: 'description',
|
|
30
|
+
}),
|
|
31
|
+
tags: defineOption({
|
|
32
|
+
name: 'tags',
|
|
33
|
+
schema: z.string().transform(tags).optional(),
|
|
34
|
+
description: 'List of tags, separated by a comma',
|
|
35
|
+
placeholder: 'tags',
|
|
36
|
+
}),
|
|
37
|
+
org: orgaIdOrNameOption,
|
|
38
|
+
},
|
|
39
|
+
args: [
|
|
40
|
+
defineArgument({
|
|
41
|
+
schema: z.string().transform(ngResourceType),
|
|
42
|
+
description: 'Network Group label',
|
|
43
|
+
placeholder: 'ng-label',
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
async handler(options, ngLabel) {
|
|
47
|
+
const label = ngLabel.ngResourceLabel;
|
|
48
|
+
const { description, link: membersIds, org, tags } = options;
|
|
49
|
+
|
|
50
|
+
await networkGroup.create(label, description, tags, membersIds, org);
|
|
51
|
+
|
|
52
|
+
const successMessage = `Network Group ${styleText('green', label)} successfully created`;
|
|
53
|
+
if (membersIds == null) {
|
|
54
|
+
Logger.printSuccess(`${successMessage}!`);
|
|
55
|
+
} else {
|
|
56
|
+
Logger.printSuccess(`${successMessage} with member(s):`);
|
|
57
|
+
Logger.println(membersIds.map((id) => styleText('grey', ` - ${id}`)).join('\n'));
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineArgument } from '../../lib/define-argument.js';
|
|
3
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
4
|
+
import { styleText } from '../../lib/style-text.js';
|
|
5
|
+
import { Logger } from '../../logger.js';
|
|
6
|
+
import * as networkGroupResources from '../../models/ng-resources.js';
|
|
7
|
+
import { ngResourceType } from '../../parsers.js';
|
|
8
|
+
import { orgaIdOrNameOption } from '../global.options.js';
|
|
9
|
+
import { ngIdOrLabelArg } from './ng.args.js';
|
|
10
|
+
|
|
11
|
+
export const ngCreateExternalCommand = defineCommand({
|
|
12
|
+
description: 'Create an external peer in a Network Group',
|
|
13
|
+
since: '3.12.0',
|
|
14
|
+
options: {
|
|
15
|
+
org: orgaIdOrNameOption,
|
|
16
|
+
},
|
|
17
|
+
args: [
|
|
18
|
+
defineArgument({
|
|
19
|
+
schema: z.string().transform(ngResourceType),
|
|
20
|
+
description: 'External peer label',
|
|
21
|
+
placeholder: 'external-peer-label',
|
|
22
|
+
}),
|
|
23
|
+
ngIdOrLabelArg,
|
|
24
|
+
defineArgument({
|
|
25
|
+
schema: z.string(),
|
|
26
|
+
description: 'WireGuard public key of the external peer to link to a Network Group',
|
|
27
|
+
placeholder: 'public-key',
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
async handler(options, peerIdOrLabel, ngIdOrLabel, publicKey) {
|
|
31
|
+
const { org } = options;
|
|
32
|
+
|
|
33
|
+
await networkGroupResources.createExternalPeerWithParent(
|
|
34
|
+
ngIdOrLabel,
|
|
35
|
+
peerIdOrLabel.ngResourceLabel,
|
|
36
|
+
publicKey,
|
|
37
|
+
org,
|
|
38
|
+
);
|
|
39
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
40
|
+
Logger.printSuccess(
|
|
41
|
+
`External peer ${styleText('green', peerIdOrLabel.ngResourceLabel)} successfully created in Network Group ${styleText('green', ngText)}`,
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { styleText } from '../../lib/style-text.js';
|
|
3
|
+
import { Logger } from '../../logger.js';
|
|
4
|
+
import * as networkGroup from '../../models/ng.js';
|
|
5
|
+
import { orgaIdOrNameOption } from '../global.options.js';
|
|
6
|
+
import { ngIdOrLabelArg } from './ng.args.js';
|
|
7
|
+
|
|
8
|
+
export const ngDeleteCommand = defineCommand({
|
|
9
|
+
description: 'Delete a Network Group',
|
|
10
|
+
since: '3.12.0',
|
|
11
|
+
options: {
|
|
12
|
+
org: orgaIdOrNameOption,
|
|
13
|
+
},
|
|
14
|
+
args: [ngIdOrLabelArg],
|
|
15
|
+
async handler(options, ngIdOrLabel) {
|
|
16
|
+
const { org } = options;
|
|
17
|
+
|
|
18
|
+
await networkGroup.destroy(ngIdOrLabel, org);
|
|
19
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
20
|
+
Logger.printSuccess(`Network Group ${styleText('green', ngText)} successfully deleted!`);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { styleText } from '../../lib/style-text.js';
|
|
3
|
+
import { Logger } from '../../logger.js';
|
|
4
|
+
import * as networkGroupResources from '../../models/ng-resources.js';
|
|
5
|
+
import { orgaIdOrNameOption } from '../global.options.js';
|
|
6
|
+
import { ngExternalIdOrLabelArg, ngIdOrLabelArg } from './ng.args.js';
|
|
7
|
+
|
|
8
|
+
export const ngDeleteExternalCommand = defineCommand({
|
|
9
|
+
description: 'Delete an external peer from a Network Group',
|
|
10
|
+
since: '3.12.0',
|
|
11
|
+
options: {
|
|
12
|
+
org: orgaIdOrNameOption,
|
|
13
|
+
},
|
|
14
|
+
args: [ngExternalIdOrLabelArg, ngIdOrLabelArg],
|
|
15
|
+
async handler(options, peerIdOrLabel, ngIdOrLabel) {
|
|
16
|
+
const { org } = options;
|
|
17
|
+
|
|
18
|
+
const peerText = peerIdOrLabel.ngResourceLabel ?? peerIdOrLabel.memberId;
|
|
19
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
20
|
+
await networkGroupResources.deleteExternalPeerWithParent(ngIdOrLabel, peerText, org);
|
|
21
|
+
Logger.printSuccess(
|
|
22
|
+
`External peer ${styleText('green', peerText)} successfully deleted from Network Group ${styleText('green', ngText)}`,
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# 📖 `clever ng` command reference
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> 🧪 **Experimental**: This command may change or be removed in future versions.
|
|
5
|
+
> Enable with: `clever features enable ng`
|
|
6
|
+
|
|
7
|
+
## ➡️ `clever ng` <kbd>Since 3.12.0</kbd>
|
|
8
|
+
|
|
9
|
+
List Network Groups
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
clever ng [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### ⚙️ Options
|
|
16
|
+
|
|
17
|
+
|Name|Description|
|
|
18
|
+
|---|---|
|
|
19
|
+
|`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
|
|
20
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
21
|
+
|
|
22
|
+
## ➡️ `clever ng create` <kbd>Since 3.12.0</kbd>
|
|
23
|
+
|
|
24
|
+
Create a Network Group
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
clever ng create <ng-label> [options]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 📥 Arguments
|
|
31
|
+
|
|
32
|
+
|Name|Description|
|
|
33
|
+
|---|---|
|
|
34
|
+
|`ng-label`|Network Group label|
|
|
35
|
+
|
|
36
|
+
### ⚙️ Options
|
|
37
|
+
|
|
38
|
+
|Name|Description|
|
|
39
|
+
|---|---|
|
|
40
|
+
|`--description` `<description>`|Network Group description|
|
|
41
|
+
|`--link` `<members-ids>`|Comma separated list of members IDs to link to a Network Group (app_xxx, external_xxx, mysql_xxx, postgresql_xxx, redis_xxx, etc.)|
|
|
42
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
43
|
+
|`--tags` `<tags>`|List of tags, separated by a comma|
|
|
44
|
+
|
|
45
|
+
## ➡️ `clever ng create external` <kbd>Since 3.12.0</kbd>
|
|
46
|
+
|
|
47
|
+
Create an external peer in a Network Group
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
clever ng create external <external-peer-label> <ng-id|ng-label> <public-key> [options]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 📥 Arguments
|
|
54
|
+
|
|
55
|
+
|Name|Description|
|
|
56
|
+
|---|---|
|
|
57
|
+
|`external-peer-label`|External peer label|
|
|
58
|
+
|`ng-id|ng-label`|Network Group ID or label|
|
|
59
|
+
|`public-key`|WireGuard public key of the external peer to link to a Network Group|
|
|
60
|
+
|
|
61
|
+
### ⚙️ Options
|
|
62
|
+
|
|
63
|
+
|Name|Description|
|
|
64
|
+
|---|---|
|
|
65
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
66
|
+
|
|
67
|
+
## ➡️ `clever ng delete` <kbd>Since 3.12.0</kbd>
|
|
68
|
+
|
|
69
|
+
Delete a Network Group
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
clever ng delete <ng-id|ng-label> [options]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 📥 Arguments
|
|
76
|
+
|
|
77
|
+
|Name|Description|
|
|
78
|
+
|---|---|
|
|
79
|
+
|`ng-id|ng-label`|Network Group ID or label|
|
|
80
|
+
|
|
81
|
+
### ⚙️ Options
|
|
82
|
+
|
|
83
|
+
|Name|Description|
|
|
84
|
+
|---|---|
|
|
85
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
86
|
+
|
|
87
|
+
## ➡️ `clever ng delete external` <kbd>Since 3.12.0</kbd>
|
|
88
|
+
|
|
89
|
+
Delete an external peer from a Network Group
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
clever ng delete external <peer-id|peer-label> <ng-id|ng-label> [options]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 📥 Arguments
|
|
96
|
+
|
|
97
|
+
|Name|Description|
|
|
98
|
+
|---|---|
|
|
99
|
+
|`peer-id|peer-label`|External peer ID or label|
|
|
100
|
+
|`ng-id|ng-label`|Network Group ID or label|
|
|
101
|
+
|
|
102
|
+
### ⚙️ Options
|
|
103
|
+
|
|
104
|
+
|Name|Description|
|
|
105
|
+
|---|---|
|
|
106
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
107
|
+
|
|
108
|
+
## ➡️ `clever ng get` <kbd>Since 3.12.0</kbd>
|
|
109
|
+
|
|
110
|
+
Get details about a Network Group, a member or a peer
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
clever ng get <id|label> [options]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 📥 Arguments
|
|
117
|
+
|
|
118
|
+
|Name|Description|
|
|
119
|
+
|---|---|
|
|
120
|
+
|`id|label`|ID or Label of a Network Group, a member or an (external) peer|
|
|
121
|
+
|
|
122
|
+
### ⚙️ Options
|
|
123
|
+
|
|
124
|
+
|Name|Description|
|
|
125
|
+
|---|---|
|
|
126
|
+
|`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
|
|
127
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
128
|
+
|`--type` `<resource-type>`|Type of resource to look for (NetworkGroup, Member, CleverPeer, ExternalPeer)|
|
|
129
|
+
|
|
130
|
+
## ➡️ `clever ng get-config` <kbd>Since 3.12.0</kbd>
|
|
131
|
+
|
|
132
|
+
Get the WireGuard configuration of a peer in a Network Group
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
clever ng get-config <peer-id|peer-label> <ng-id|ng-label> [options]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 📥 Arguments
|
|
139
|
+
|
|
140
|
+
|Name|Description|
|
|
141
|
+
|---|---|
|
|
142
|
+
|`peer-id|peer-label`|External peer ID or label|
|
|
143
|
+
|`ng-id|ng-label`|Network Group ID or label|
|
|
144
|
+
|
|
145
|
+
### ⚙️ Options
|
|
146
|
+
|
|
147
|
+
|Name|Description|
|
|
148
|
+
|---|---|
|
|
149
|
+
|`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
|
|
150
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
151
|
+
|
|
152
|
+
## ➡️ `clever ng link` <kbd>Since 3.12.0</kbd>
|
|
153
|
+
|
|
154
|
+
Link a resource by its ID (app_xxx, external_xxx, mysql_xxx, postgresql_xxx, redis_xxx, etc.) to a Network Group
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
clever ng link <id> <ng-id|ng-label> [options]
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 📥 Arguments
|
|
161
|
+
|
|
162
|
+
|Name|Description|
|
|
163
|
+
|---|---|
|
|
164
|
+
|`id`|ID of a resource to (un)link to a Network Group|
|
|
165
|
+
|`ng-id|ng-label`|Network Group ID or label|
|
|
166
|
+
|
|
167
|
+
### ⚙️ Options
|
|
168
|
+
|
|
169
|
+
|Name|Description|
|
|
170
|
+
|---|---|
|
|
171
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
172
|
+
|
|
173
|
+
## ➡️ `clever ng search` <kbd>Since 3.12.0</kbd>
|
|
174
|
+
|
|
175
|
+
Search Network Groups, members or peers and get their details
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
clever ng search <id|label> [options]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 📥 Arguments
|
|
182
|
+
|
|
183
|
+
|Name|Description|
|
|
184
|
+
|---|---|
|
|
185
|
+
|`id|label`|ID or Label of a Network Group, a member or an (external) peer|
|
|
186
|
+
|
|
187
|
+
### ⚙️ Options
|
|
188
|
+
|
|
189
|
+
|Name|Description|
|
|
190
|
+
|---|---|
|
|
191
|
+
|`-F`, `--format` `<format>`|Output format (human, json) (default: human)|
|
|
192
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
193
|
+
|`--type` `<resource-type>`|Type of resource to look for (NetworkGroup, Member, CleverPeer, ExternalPeer)|
|
|
194
|
+
|
|
195
|
+
## ➡️ `clever ng unlink` <kbd>Since 3.12.0</kbd>
|
|
196
|
+
|
|
197
|
+
Unlink a resource by its ID (app_xxx, external_xxx, mysql_xxx, postgresql_xxx, redis_xxx, etc.) from a Network Group
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
clever ng unlink <id> <ng-id|ng-label> [options]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### 📥 Arguments
|
|
204
|
+
|
|
205
|
+
|Name|Description|
|
|
206
|
+
|---|---|
|
|
207
|
+
|`id`|ID of a resource to (un)link to a Network Group|
|
|
208
|
+
|`ng-id|ng-label`|Network Group ID or label|
|
|
209
|
+
|
|
210
|
+
### ⚙️ Options
|
|
211
|
+
|
|
212
|
+
|Name|Description|
|
|
213
|
+
|---|---|
|
|
214
|
+
|`-o`, `--org`, `--owner` `<org-id\|org-name>`|Organisation to target by its ID (or name, if unambiguous)|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { Logger } from '../../logger.js';
|
|
3
|
+
import * as networkGroup from '../../models/ng.js';
|
|
4
|
+
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
5
|
+
import { ngExternalIdOrLabelArg, ngIdOrLabelArg } from './ng.args.js';
|
|
6
|
+
|
|
7
|
+
export const ngGetConfigCommand = defineCommand({
|
|
8
|
+
description: 'Get the WireGuard configuration of a peer in a Network Group',
|
|
9
|
+
since: '3.12.0',
|
|
10
|
+
options: {
|
|
11
|
+
org: orgaIdOrNameOption,
|
|
12
|
+
format: humanJsonOutputFormatOption,
|
|
13
|
+
},
|
|
14
|
+
args: [ngExternalIdOrLabelArg, ngIdOrLabelArg],
|
|
15
|
+
async handler(options, peerIdOrLabel, ngIdOrLabel) {
|
|
16
|
+
const { org, format } = options;
|
|
17
|
+
|
|
18
|
+
const config = await networkGroup.getPeerConfig(peerIdOrLabel, ngIdOrLabel, org);
|
|
19
|
+
|
|
20
|
+
switch (format) {
|
|
21
|
+
case 'json': {
|
|
22
|
+
Logger.printJson(config);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case 'human':
|
|
26
|
+
default: {
|
|
27
|
+
const decodedConfiguration = Buffer.from(config.configuration, 'base64').toString('utf8');
|
|
28
|
+
Logger.println(decodedConfiguration);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { printResults } from '../../lib/ng-print.js';
|
|
3
|
+
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
4
|
+
import { ngAnyIdOrLabelArg } from './ng.args.js';
|
|
5
|
+
import { ngResourceTypeOption } from './ng.options.js';
|
|
6
|
+
|
|
7
|
+
export const ngGetCommand = defineCommand({
|
|
8
|
+
description: 'Get details about a Network Group, a member or a peer',
|
|
9
|
+
since: '3.12.0',
|
|
10
|
+
options: {
|
|
11
|
+
type: ngResourceTypeOption,
|
|
12
|
+
org: orgaIdOrNameOption,
|
|
13
|
+
format: humanJsonOutputFormatOption,
|
|
14
|
+
},
|
|
15
|
+
args: [ngAnyIdOrLabelArg],
|
|
16
|
+
async handler(options, idOrLabel) {
|
|
17
|
+
const { org, format } = options;
|
|
18
|
+
const type = options.type ?? 'single';
|
|
19
|
+
|
|
20
|
+
await printResults(idOrLabel, org, format, 'get', type);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { styleText } from '../../lib/style-text.js';
|
|
3
|
+
import { Logger } from '../../logger.js';
|
|
4
|
+
import * as networkGroupResources from '../../models/ng-resources.js';
|
|
5
|
+
import { orgaIdOrNameOption } from '../global.options.js';
|
|
6
|
+
import { ngIdOrLabelArg, ngResourceIdArg } from './ng.args.js';
|
|
7
|
+
|
|
8
|
+
export const ngLinkCommand = defineCommand({
|
|
9
|
+
description:
|
|
10
|
+
'Link a resource by its ID (app_xxx, external_xxx, mysql_xxx, postgresql_xxx, redis_xxx, etc.) to a Network Group',
|
|
11
|
+
since: '3.12.0',
|
|
12
|
+
options: {
|
|
13
|
+
org: orgaIdOrNameOption,
|
|
14
|
+
},
|
|
15
|
+
args: [ngResourceIdArg, ngIdOrLabelArg],
|
|
16
|
+
async handler(options, resourceId, ngIdOrLabel) {
|
|
17
|
+
const { org } = options;
|
|
18
|
+
|
|
19
|
+
await networkGroupResources.linkMember(ngIdOrLabel, resourceId.memberId, org);
|
|
20
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
21
|
+
Logger.printSuccess(
|
|
22
|
+
`Member ${styleText('green', resourceId.memberId)} successfully linked to Network Group ${styleText('green', ngText)}`,
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineOption } from '../../lib/define-option.js';
|
|
3
|
+
|
|
4
|
+
export const ngResourceTypeOption = defineOption({
|
|
5
|
+
name: 'type',
|
|
6
|
+
schema: z.enum(['NetworkGroup', 'Member', 'CleverPeer', 'ExternalPeer']).optional(),
|
|
7
|
+
description: 'Type of resource to look for (NetworkGroup, Member, CleverPeer, ExternalPeer)',
|
|
8
|
+
placeholder: 'resource-type',
|
|
9
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { printResults } from '../../lib/ng-print.js';
|
|
3
|
+
import { humanJsonOutputFormatOption, orgaIdOrNameOption } from '../global.options.js';
|
|
4
|
+
import { ngAnyIdOrLabelArg } from './ng.args.js';
|
|
5
|
+
import { ngResourceTypeOption } from './ng.options.js';
|
|
6
|
+
|
|
7
|
+
export const ngSearchCommand = defineCommand({
|
|
8
|
+
description: 'Search Network Groups, members or peers and get their details',
|
|
9
|
+
since: '3.12.0',
|
|
10
|
+
options: {
|
|
11
|
+
type: ngResourceTypeOption,
|
|
12
|
+
org: orgaIdOrNameOption,
|
|
13
|
+
format: humanJsonOutputFormatOption,
|
|
14
|
+
},
|
|
15
|
+
args: [ngAnyIdOrLabelArg],
|
|
16
|
+
async handler(options, idOrLabel) {
|
|
17
|
+
const { org, format } = options;
|
|
18
|
+
const type = options.type;
|
|
19
|
+
|
|
20
|
+
await printResults(idOrLabel, org, format, 'search', type);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
2
|
+
import { styleText } from '../../lib/style-text.js';
|
|
3
|
+
import { Logger } from '../../logger.js';
|
|
4
|
+
import * as networkGroupResources from '../../models/ng-resources.js';
|
|
5
|
+
import { orgaIdOrNameOption } from '../global.options.js';
|
|
6
|
+
import { ngIdOrLabelArg, ngResourceIdArg } from './ng.args.js';
|
|
7
|
+
|
|
8
|
+
export const ngUnlinkCommand = defineCommand({
|
|
9
|
+
description:
|
|
10
|
+
'Unlink a resource by its ID (app_xxx, external_xxx, mysql_xxx, postgresql_xxx, redis_xxx, etc.) from a Network Group',
|
|
11
|
+
since: '3.12.0',
|
|
12
|
+
options: {
|
|
13
|
+
org: orgaIdOrNameOption,
|
|
14
|
+
},
|
|
15
|
+
args: [ngResourceIdArg, ngIdOrLabelArg],
|
|
16
|
+
async handler(options, resourceId, ngIdOrLabel) {
|
|
17
|
+
const { org } = options;
|
|
18
|
+
|
|
19
|
+
await networkGroupResources.unlinkMember(ngIdOrLabel, resourceId.memberId, org);
|
|
20
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
21
|
+
Logger.printSuccess(
|
|
22
|
+
`Member ${styleText('green', resourceId.memberId)} successfully unlinked from Network Group ${styleText('green', ngText)}`,
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createEmailhook } from '@clevercloud/client/esm/api/v2/notification.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { defineCommand } from '../../lib/define-command.js';
|
|
4
|
+
import { defineOption } from '../../lib/define-option.js';
|
|
5
|
+
import { Logger } from '../../logger.js';
|
|
6
|
+
import { getOwnerAndApp } from '../../models/notification.js';
|
|
7
|
+
import { sendToApi } from '../../models/send-to-api.js';
|
|
8
|
+
import { notificationNameArg } from '../global.args.js';
|
|
9
|
+
import { notificationEventTypeOption, notificationScopeOption, orgaIdOrNameOption } from '../global.options.js';
|
|
10
|
+
|
|
11
|
+
function getEmailNotificationTargets(notifTargets) {
|
|
12
|
+
if (notifTargets == null) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return notifTargets
|
|
17
|
+
.map((el) => {
|
|
18
|
+
if (el.includes('@')) {
|
|
19
|
+
return { type: 'email', target: el };
|
|
20
|
+
}
|
|
21
|
+
if (el.startsWith('user_')) {
|
|
22
|
+
return { type: 'userid', target: el };
|
|
23
|
+
}
|
|
24
|
+
if (el.toLowerCase() === 'organisation') {
|
|
25
|
+
return { type: 'organisation' };
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
})
|
|
29
|
+
.filter((e) => e != null);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const notifyEmailAddCommand = defineCommand({
|
|
33
|
+
description: 'Add a new email notification',
|
|
34
|
+
since: '0.6.1',
|
|
35
|
+
options: {
|
|
36
|
+
notify: defineOption({
|
|
37
|
+
name: 'notify',
|
|
38
|
+
schema: z.string().transform((v) => v.split(',')),
|
|
39
|
+
description:
|
|
40
|
+
'Notify a user, a specific email address or the whole organisation (multiple values allowed, comma separated)',
|
|
41
|
+
placeholder: 'email-address|user-id|organisation',
|
|
42
|
+
}),
|
|
43
|
+
org: orgaIdOrNameOption,
|
|
44
|
+
event: notificationEventTypeOption,
|
|
45
|
+
service: notificationScopeOption,
|
|
46
|
+
},
|
|
47
|
+
args: [notificationNameArg],
|
|
48
|
+
async handler(options, name) {
|
|
49
|
+
const { org, event: events, service, notify: notifTargets } = options;
|
|
50
|
+
|
|
51
|
+
// TODO: fix alias option
|
|
52
|
+
const { ownerId, appId } = await getOwnerAndApp(null, org, !org && !service);
|
|
53
|
+
|
|
54
|
+
const body = {
|
|
55
|
+
name,
|
|
56
|
+
notified: getEmailNotificationTargets(notifTargets),
|
|
57
|
+
scope: appId != null && service == null ? [appId] : service,
|
|
58
|
+
events,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
await createEmailhook({ ownerId }, body).then(sendToApi);
|
|
62
|
+
|
|
63
|
+
Logger.println('The webhook has been added');
|
|
64
|
+
},
|
|
65
|
+
});
|