@bussolabs/closeyourit-cli 0.0.8 → 0.0.10
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/README.md +13 -0
- package/dist/commands/alerts/channels/create.d.ts +16 -0
- package/dist/commands/alerts/channels/create.js +41 -0
- package/dist/commands/alerts/channels/delete.d.ts +12 -0
- package/dist/commands/alerts/channels/delete.js +25 -0
- package/dist/commands/alerts/channels/list.d.ts +9 -0
- package/dist/commands/alerts/channels/list.js +25 -0
- package/dist/commands/alerts/create.d.ts +2 -0
- package/dist/commands/alerts/create.js +8 -2
- package/dist/commands/alerts/update.d.ts +2 -0
- package/dist/commands/alerts/update.js +8 -2
- package/dist/commands/servers/delete.d.ts +12 -0
- package/dist/commands/servers/delete.js +25 -0
- package/dist/commands/servers/list.d.ts +10 -0
- package/dist/commands/servers/list.js +41 -0
- package/dist/commands/servers/pause.d.ts +9 -0
- package/dist/commands/servers/pause.js +19 -0
- package/dist/commands/servers/rename.d.ts +12 -0
- package/dist/commands/servers/rename.js +22 -0
- package/dist/commands/servers/resume.d.ts +9 -0
- package/dist/commands/servers/resume.js +19 -0
- package/dist/commands/servers/revoke.d.ts +12 -0
- package/dist/commands/servers/revoke.js +25 -0
- package/dist/commands/servers/show.d.ts +9 -0
- package/dist/commands/servers/show.js +21 -0
- package/dist/commands/servers/tokens/create.d.ts +9 -0
- package/dist/commands/servers/tokens/create.js +25 -0
- package/dist/commands/servers/tokens/list.d.ts +9 -0
- package/dist/commands/servers/tokens/list.js +25 -0
- package/dist/commands/servers/tokens/revoke.d.ts +12 -0
- package/dist/commands/servers/tokens/revoke.js +25 -0
- package/dist/commands/servers/unrevoke.d.ts +9 -0
- package/dist/commands/servers/unrevoke.js +19 -0
- package/dist/lib/alert-events.d.ts +2 -0
- package/dist/lib/alert-events.js +21 -0
- package/oclif.manifest.json +1258 -579
- package/opencli.json +658 -59
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -62,6 +62,19 @@ organization are stored locally.
|
|
|
62
62
|
| `metrics list --project <id\|key> [--kind] [--page]` | List metric groups. |
|
|
63
63
|
| `metrics show <id> --project <id\|key>` | Show one metric group. |
|
|
64
64
|
| `logs list [--project <id\|key>] [--level] [--trace-id] [--environment] [--page]` | List structured log entries. Cross-app: omit `--project` for the full visible stream. |
|
|
65
|
+
| `servers list [--status] [--page]` | List the monitored servers (fleet snapshot: status, cpu/mem/disk, last seen). |
|
|
66
|
+
| `servers show <id>` | Show a monitored server (latest snapshot + machine details). |
|
|
67
|
+
| `servers rename <id> --name <name>` | Rename a server (display name only). |
|
|
68
|
+
| `servers pause\|resume <id>` | Pause (no staleness/alerts) / resume a server. |
|
|
69
|
+
| `servers revoke <id> --confirm` | Revoke a server: its agent gets 403 and stops (reversible with `unrevoke`). |
|
|
70
|
+
| `servers unrevoke <id>` | Restore a revoked server. |
|
|
71
|
+
| `servers delete <id> --confirm` | Delete a server and all its metrics. |
|
|
72
|
+
| `servers tokens list` | List the fleet enrollment tokens. |
|
|
73
|
+
| `servers tokens create <name>` | Create an enrollment token (secret shown once). |
|
|
74
|
+
| `servers tokens revoke <id> --confirm` | Revoke an enrollment token. |
|
|
75
|
+
| `alerts channels list` | List the external alert channels (webhook / Telegram). |
|
|
76
|
+
| `alerts channels create <name> --kind telegram\|webhook …` | Create a channel (`--bot-token`/`--chat-id` or `--url`/`--secret`). |
|
|
77
|
+
| `alerts channels delete <id> --confirm` | Delete a channel. |
|
|
65
78
|
|
|
66
79
|
Every command accepts `--json` for machine-readable output and `--help` for usage details.
|
|
67
80
|
`--project` accepts either a project UUID or its key (matched case-insensitively).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base';
|
|
2
|
+
export default class AlertsChannelsCreate extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
kind: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
url: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
secret: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
'bot-token': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
'chat-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../../base");
|
|
5
|
+
const output_1 = require("../../../lib/output");
|
|
6
|
+
class AlertsChannelsCreate extends base_1.BaseCommand {
|
|
7
|
+
static args = {
|
|
8
|
+
name: core_1.Args.string({ description: 'Channel name', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Create an external alert channel (webhook or Telegram)';
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> alerts channels create "Ops Telegram" --kind telegram --bot-token <token> --chat-id <id>',
|
|
13
|
+
'<%= config.bin %> alerts channels create "Ops hook" --kind webhook --url https://example.com/hook --secret s3cret',
|
|
14
|
+
];
|
|
15
|
+
static flags = {
|
|
16
|
+
kind: core_1.Flags.string({ description: 'Channel kind', options: ['webhook', 'telegram'], required: true }),
|
|
17
|
+
url: core_1.Flags.string({ description: 'Webhook URL (kind webhook)' }),
|
|
18
|
+
secret: core_1.Flags.string({ description: 'Webhook signing secret (kind webhook, optional)' }),
|
|
19
|
+
'bot-token': core_1.Flags.string({ description: 'Telegram bot token from @BotFather (kind telegram)' }),
|
|
20
|
+
'chat-id': core_1.Flags.string({ description: 'Telegram chat id receiving the messages (kind telegram)' }),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
const { args, flags } = await this.parse(AlertsChannelsCreate);
|
|
24
|
+
const body = { name: args.name, kind: flags.kind };
|
|
25
|
+
if (flags.url !== undefined)
|
|
26
|
+
body.webhook_url = flags.url;
|
|
27
|
+
if (flags.secret !== undefined)
|
|
28
|
+
body.webhook_secret = flags.secret;
|
|
29
|
+
if (flags['bot-token'] !== undefined)
|
|
30
|
+
body.telegram_bot_token = flags['bot-token'];
|
|
31
|
+
if (flags['chat-id'] !== undefined)
|
|
32
|
+
body.telegram_chat_id = flags['chat-id'];
|
|
33
|
+
const res = await this.api.post('/cli/v1/alert_channels', body);
|
|
34
|
+
if (!this.jsonEnabled()) {
|
|
35
|
+
this.log('Channel created:');
|
|
36
|
+
this.log((0, output_1.renderRecord)(res.data ?? {}));
|
|
37
|
+
}
|
|
38
|
+
return res;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.default = AlertsChannelsCreate;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base';
|
|
2
|
+
export default class AlertsChannelsDelete extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
confirm: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../../base");
|
|
5
|
+
class AlertsChannelsDelete extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Channel id', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Delete an external alert channel (rules keep delivering in-app/email)';
|
|
10
|
+
static examples = ['<%= config.bin %> alerts channels delete <channel-id> --confirm'];
|
|
11
|
+
static flags = {
|
|
12
|
+
confirm: core_1.Flags.boolean({ description: 'Required: confirm the deletion' }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(AlertsChannelsDelete);
|
|
16
|
+
if (!flags.confirm) {
|
|
17
|
+
this.error('Refusing to delete without --confirm.', { exit: 2 });
|
|
18
|
+
}
|
|
19
|
+
await this.api.delete(`/cli/v1/alert_channels/${encodeURIComponent(args.id)}`);
|
|
20
|
+
if (!this.jsonEnabled())
|
|
21
|
+
this.log(`Deleted channel ${args.id}`);
|
|
22
|
+
return { deleted: args.id };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = AlertsChannelsDelete;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base';
|
|
2
|
+
export default class AlertsChannelsList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
page: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../../../base");
|
|
4
|
+
const output_1 = require("../../../lib/output");
|
|
5
|
+
class AlertsChannelsList extends base_1.BaseCommand {
|
|
6
|
+
static description = 'List the external alert channels (webhook / Telegram)';
|
|
7
|
+
static examples = ['<%= config.bin %> alerts channels list'];
|
|
8
|
+
static flags = { ...base_1.pageFlag };
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(AlertsChannelsList);
|
|
11
|
+
const res = await this.api.get(`/cli/v1/alert_channels?page=${flags.page}`);
|
|
12
|
+
const channels = res.data ?? [];
|
|
13
|
+
if (!this.jsonEnabled()) {
|
|
14
|
+
this.log((0, output_1.renderTable)(['NAME', 'KIND', 'TARGET', 'ENABLED', 'ID'], channels.map((channel) => [
|
|
15
|
+
String(channel.name ?? ''),
|
|
16
|
+
String(channel.kind ?? ''),
|
|
17
|
+
String(channel.target ?? '-'),
|
|
18
|
+
String(channel.enabled ?? ''),
|
|
19
|
+
String(channel.id ?? ''),
|
|
20
|
+
])));
|
|
21
|
+
}
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = AlertsChannelsList;
|
|
@@ -9,6 +9,8 @@ export default class AlertsCreate extends BaseCommand {
|
|
|
9
9
|
'event-type': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
'min-level': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
11
|
'threshold-ms': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
threshold: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
channel: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
14
|
'throttle-minutes': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
15
|
enabled: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
16
|
project: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const base_1 = require("../../base");
|
|
5
|
+
const alert_events_1 = require("../../lib/alert-events");
|
|
5
6
|
const output_1 = require("../../lib/output");
|
|
6
|
-
const EVENT_TYPES = ['error_new', 'error_regression', 'uptime_down', 'uptime_up', 'metric_threshold'];
|
|
7
7
|
class AlertsCreate extends base_1.BaseCommand {
|
|
8
8
|
static args = {
|
|
9
9
|
name: core_1.Args.string({ description: 'Rule name', required: true }),
|
|
@@ -14,9 +14,11 @@ class AlertsCreate extends base_1.BaseCommand {
|
|
|
14
14
|
'<%= config.bin %> alerts create "API down" --event-type uptime_down --project acme-api --throttle-minutes 30',
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
|
-
'event-type': core_1.Flags.string({ description: 'Event that triggers the rule', options:
|
|
17
|
+
'event-type': core_1.Flags.string({ description: 'Event that triggers the rule', options: alert_events_1.ALERT_EVENT_TYPES, required: true }),
|
|
18
18
|
'min-level': core_1.Flags.string({ description: 'Minimum error level that triggers the rule' }),
|
|
19
19
|
'threshold-ms': core_1.Flags.integer({ description: 'Duration threshold in milliseconds (metric rules)' }),
|
|
20
|
+
threshold: core_1.Flags.integer({ description: 'Server threshold: percent for cpu/mem/disk, °C for temp' }),
|
|
21
|
+
channel: core_1.Flags.string({ description: 'External channel id to deliver to (repeatable; REPLACES the set)', multiple: true }),
|
|
20
22
|
'throttle-minutes': core_1.Flags.integer({ description: 'Minimum minutes between notifications' }),
|
|
21
23
|
enabled: core_1.Flags.boolean({ allowNo: true, description: 'Whether the rule is enabled' }),
|
|
22
24
|
project: core_1.Flags.string({ description: 'Scope the rule to a project id (UUID)' }),
|
|
@@ -29,6 +31,10 @@ class AlertsCreate extends base_1.BaseCommand {
|
|
|
29
31
|
body.min_level = flags['min-level'];
|
|
30
32
|
if (flags['threshold-ms'] !== undefined)
|
|
31
33
|
body.threshold_ms = flags['threshold-ms'];
|
|
34
|
+
if (flags.threshold !== undefined)
|
|
35
|
+
body.threshold = flags.threshold;
|
|
36
|
+
if (flags.channel !== undefined)
|
|
37
|
+
body.channel_ids = flags.channel;
|
|
32
38
|
if (flags['throttle-minutes'] !== undefined)
|
|
33
39
|
body.throttle_minutes = flags['throttle-minutes'];
|
|
34
40
|
if (flags.enabled !== undefined)
|
|
@@ -10,6 +10,8 @@ export default class AlertsUpdate extends BaseCommand {
|
|
|
10
10
|
'event-type': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
11
|
'min-level': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
12
|
'threshold-ms': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
threshold: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
channel: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
15
|
'throttle-minutes': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
16
|
enabled: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
17
|
project: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const base_1 = require("../../base");
|
|
5
|
+
const alert_events_1 = require("../../lib/alert-events");
|
|
5
6
|
const output_1 = require("../../lib/output");
|
|
6
|
-
const EVENT_TYPES = ['error_new', 'error_regression', 'uptime_down', 'uptime_up', 'metric_threshold'];
|
|
7
7
|
class AlertsUpdate extends base_1.BaseCommand {
|
|
8
8
|
static args = {
|
|
9
9
|
id: core_1.Args.string({ description: 'Alert rule id', required: true }),
|
|
@@ -15,9 +15,11 @@ class AlertsUpdate extends base_1.BaseCommand {
|
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
17
|
name: core_1.Flags.string({ description: 'Rule name' }),
|
|
18
|
-
'event-type': core_1.Flags.string({ description: 'Event that triggers the rule', options:
|
|
18
|
+
'event-type': core_1.Flags.string({ description: 'Event that triggers the rule', options: alert_events_1.ALERT_EVENT_TYPES }),
|
|
19
19
|
'min-level': core_1.Flags.string({ description: 'Minimum error level that triggers the rule' }),
|
|
20
20
|
'threshold-ms': core_1.Flags.integer({ description: 'Duration threshold in milliseconds (metric rules)' }),
|
|
21
|
+
threshold: core_1.Flags.integer({ description: 'Server threshold: percent for cpu/mem/disk, °C for temp' }),
|
|
22
|
+
channel: core_1.Flags.string({ description: 'External channel id to deliver to (repeatable; REPLACES the set)', multiple: true }),
|
|
21
23
|
'throttle-minutes': core_1.Flags.integer({ description: 'Minimum minutes between notifications' }),
|
|
22
24
|
enabled: core_1.Flags.boolean({ allowNo: true, description: 'Whether the rule is enabled' }),
|
|
23
25
|
project: core_1.Flags.string({ description: 'Scope the rule to a project id (UUID)' }),
|
|
@@ -34,6 +36,10 @@ class AlertsUpdate extends base_1.BaseCommand {
|
|
|
34
36
|
body.min_level = flags['min-level'];
|
|
35
37
|
if (flags['threshold-ms'] !== undefined)
|
|
36
38
|
body.threshold_ms = flags['threshold-ms'];
|
|
39
|
+
if (flags.threshold !== undefined)
|
|
40
|
+
body.threshold = flags.threshold;
|
|
41
|
+
if (flags.channel !== undefined)
|
|
42
|
+
body.channel_ids = flags.channel;
|
|
37
43
|
if (flags['throttle-minutes'] !== undefined)
|
|
38
44
|
body.throttle_minutes = flags['throttle-minutes'];
|
|
39
45
|
if (flags.enabled !== undefined)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ServersDelete extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
confirm: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class ServersDelete extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Server id', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Delete a server and all its metrics (a live agent would re-register it)';
|
|
10
|
+
static examples = ['<%= config.bin %> servers delete <server-id> --confirm'];
|
|
11
|
+
static flags = {
|
|
12
|
+
confirm: core_1.Flags.boolean({ description: 'Required: confirm the deletion' }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(ServersDelete);
|
|
16
|
+
if (!flags.confirm) {
|
|
17
|
+
this.error('Refusing to delete without --confirm.', { exit: 2 });
|
|
18
|
+
}
|
|
19
|
+
await this.api.delete(`/cli/v1/servers/${encodeURIComponent(args.id)}`);
|
|
20
|
+
if (!this.jsonEnabled())
|
|
21
|
+
this.log(`Deleted server ${args.id}`);
|
|
22
|
+
return { deleted: args.id };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = ServersDelete;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ServersList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
status: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
page: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<unknown>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class ServersList extends base_1.BaseCommand {
|
|
7
|
+
static description = 'List the monitored servers in your organization (fleet snapshot)';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> servers list',
|
|
10
|
+
'<%= config.bin %> servers list --status down --json',
|
|
11
|
+
];
|
|
12
|
+
static flags = {
|
|
13
|
+
...base_1.pageFlag,
|
|
14
|
+
status: core_1.Flags.string({
|
|
15
|
+
description: 'Filter by status (repeatable)',
|
|
16
|
+
multiple: true,
|
|
17
|
+
options: ['pending', 'up', 'down', 'paused'],
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const { flags } = await this.parse(ServersList);
|
|
22
|
+
const params = new URLSearchParams({ page: String(flags.page) });
|
|
23
|
+
for (const status of flags.status ?? [])
|
|
24
|
+
params.append('status[]', status);
|
|
25
|
+
const res = await this.api.get(`/cli/v1/servers?${params.toString()}`);
|
|
26
|
+
const hosts = res.data ?? [];
|
|
27
|
+
if (!this.jsonEnabled()) {
|
|
28
|
+
this.log((0, output_1.renderTable)(['NAME', 'STATUS', 'CPU%', 'MEM%', 'DISK%', 'LAST SEEN', 'ID'], hosts.map((host) => [
|
|
29
|
+
String(host.name ?? ''),
|
|
30
|
+
String(host.status ?? ''),
|
|
31
|
+
String(host.cpu_pct ?? '-'),
|
|
32
|
+
String(host.mem_pct ?? '-'),
|
|
33
|
+
String(host.disk_pct ?? '-'),
|
|
34
|
+
String(host.last_seen_at ?? '-'),
|
|
35
|
+
String(host.id ?? ''),
|
|
36
|
+
])));
|
|
37
|
+
}
|
|
38
|
+
return res;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.default = ServersList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ServersPause extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class ServersPause extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Server id', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Pause a server (no staleness checks or alerts until resumed)';
|
|
10
|
+
static examples = ['<%= config.bin %> servers pause <server-id>'];
|
|
11
|
+
async run() {
|
|
12
|
+
const { args } = await this.parse(ServersPause);
|
|
13
|
+
const res = await this.api.put(`/cli/v1/servers/${encodeURIComponent(args.id)}/pause`);
|
|
14
|
+
if (!this.jsonEnabled())
|
|
15
|
+
this.log(`Paused server ${args.id}`);
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = ServersPause;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ServersRename extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class ServersRename extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Server id', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Rename a monitored server (display name only)';
|
|
10
|
+
static examples = ['<%= config.bin %> servers rename <server-id> --name apps-prod'];
|
|
11
|
+
static flags = {
|
|
12
|
+
name: core_1.Flags.string({ description: 'New display name', required: true }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(ServersRename);
|
|
16
|
+
const res = await this.api.put(`/cli/v1/servers/${encodeURIComponent(args.id)}`, { name: flags.name });
|
|
17
|
+
if (!this.jsonEnabled())
|
|
18
|
+
this.log(`Renamed server ${args.id} to ${flags.name}`);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = ServersRename;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ServersResume extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class ServersResume extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Server id', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Resume a paused server (back up at the next agent push)';
|
|
10
|
+
static examples = ['<%= config.bin %> servers resume <server-id>'];
|
|
11
|
+
async run() {
|
|
12
|
+
const { args } = await this.parse(ServersResume);
|
|
13
|
+
const res = await this.api.put(`/cli/v1/servers/${encodeURIComponent(args.id)}/resume`);
|
|
14
|
+
if (!this.jsonEnabled())
|
|
15
|
+
this.log(`Resumed server ${args.id}`);
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = ServersResume;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ServersRevoke extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
confirm: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
class ServersRevoke extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Server id', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Revoke a server: its agent gets 403 and stops (host stays, reversible)';
|
|
10
|
+
static examples = ['<%= config.bin %> servers revoke <server-id> --confirm'];
|
|
11
|
+
static flags = {
|
|
12
|
+
confirm: core_1.Flags.boolean({ description: 'Required: confirm the revocation' }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(ServersRevoke);
|
|
16
|
+
if (!flags.confirm) {
|
|
17
|
+
this.error('Refusing to revoke without --confirm.', { exit: 2 });
|
|
18
|
+
}
|
|
19
|
+
const res = await this.api.put(`/cli/v1/servers/${encodeURIComponent(args.id)}/revoke`);
|
|
20
|
+
if (!this.jsonEnabled())
|
|
21
|
+
this.log(`Revoked server ${args.id} — its agent now receives 403.`);
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = ServersRevoke;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base';
|
|
2
|
+
export default class ServersShow extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../base");
|
|
5
|
+
const output_1 = require("../../lib/output");
|
|
6
|
+
class ServersShow extends base_1.BaseCommand {
|
|
7
|
+
static args = {
|
|
8
|
+
id: core_1.Args.string({ description: 'Server id', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static description = 'Show a monitored server (latest snapshot)';
|
|
11
|
+
static examples = ['<%= config.bin %> servers show <server-id>'];
|
|
12
|
+
async run() {
|
|
13
|
+
const { args } = await this.parse(ServersShow);
|
|
14
|
+
const res = await this.api.get(`/cli/v1/servers/${encodeURIComponent(args.id)}`);
|
|
15
|
+
if (!this.jsonEnabled()) {
|
|
16
|
+
this.log((0, output_1.renderRecord)(res.data ?? {}));
|
|
17
|
+
}
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = ServersShow;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base';
|
|
2
|
+
export default class ServersTokensCreate extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../../base");
|
|
5
|
+
class ServersTokensCreate extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
name: core_1.Args.string({ description: 'Token name (e.g. fleet)', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Create a fleet enrollment token (the secret is shown only once)';
|
|
10
|
+
static examples = ['<%= config.bin %> servers tokens create fleet'];
|
|
11
|
+
async run() {
|
|
12
|
+
const { args } = await this.parse(ServersTokensCreate);
|
|
13
|
+
const res = await this.api.post('/cli/v1/server_tokens', { name: args.name });
|
|
14
|
+
const token = res.data ?? {};
|
|
15
|
+
if (!this.jsonEnabled()) {
|
|
16
|
+
this.log('Enrollment token created. Store the secret now — it is shown only once:');
|
|
17
|
+
this.log('');
|
|
18
|
+
this.log(` secret: ${token.secret ?? '-'}`);
|
|
19
|
+
this.log('');
|
|
20
|
+
this.warn('The secret cannot be retrieved again. If you lose it, revoke and create a new one.');
|
|
21
|
+
}
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = ServersTokensCreate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base';
|
|
2
|
+
export default class ServersTokensList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
page: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const base_1 = require("../../../base");
|
|
4
|
+
const output_1 = require("../../../lib/output");
|
|
5
|
+
class ServersTokensList extends base_1.BaseCommand {
|
|
6
|
+
static description = 'List the fleet enrollment tokens (agents authenticate with these)';
|
|
7
|
+
static examples = ['<%= config.bin %> servers tokens list'];
|
|
8
|
+
static flags = { ...base_1.pageFlag };
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(ServersTokensList);
|
|
11
|
+
const res = await this.api.get(`/cli/v1/server_tokens?page=${flags.page}`);
|
|
12
|
+
const tokens = res.data ?? [];
|
|
13
|
+
if (!this.jsonEnabled()) {
|
|
14
|
+
this.log((0, output_1.renderTable)(['NAME', 'PREFIX', 'LAST USED', 'REVOKED', 'ID'], tokens.map((token) => [
|
|
15
|
+
String(token.name ?? ''),
|
|
16
|
+
String(token.token_prefix ?? ''),
|
|
17
|
+
String(token.last_used_at ?? '-'),
|
|
18
|
+
String(token.revoked_at ?? '-'),
|
|
19
|
+
String(token.id ?? ''),
|
|
20
|
+
])));
|
|
21
|
+
}
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = ServersTokensList;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base';
|
|
2
|
+
export default class ServersTokensRevoke extends BaseCommand {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
confirm: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_1 = require("../../../base");
|
|
5
|
+
class ServersTokensRevoke extends base_1.BaseCommand {
|
|
6
|
+
static args = {
|
|
7
|
+
id: core_1.Args.string({ description: 'Enrollment token id', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Revoke a fleet enrollment token (agents using it stop pushing)';
|
|
10
|
+
static examples = ['<%= config.bin %> servers tokens revoke <token-id> --confirm'];
|
|
11
|
+
static flags = {
|
|
12
|
+
confirm: core_1.Flags.boolean({ description: 'Required: confirm the revocation' }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(ServersTokensRevoke);
|
|
16
|
+
if (!flags.confirm) {
|
|
17
|
+
this.error('Refusing to revoke without --confirm.', { exit: 2 });
|
|
18
|
+
}
|
|
19
|
+
await this.api.delete(`/cli/v1/server_tokens/${encodeURIComponent(args.id)}`);
|
|
20
|
+
if (!this.jsonEnabled())
|
|
21
|
+
this.log(`Revoked enrollment token ${args.id}`);
|
|
22
|
+
return { revoked: args.id };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = ServersTokensRevoke;
|