@bussolabs/closeyourit-cli 0.0.9 → 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 CHANGED
@@ -72,6 +72,9 @@ organization are stored locally.
72
72
  | `servers tokens list` | List the fleet enrollment tokens. |
73
73
  | `servers tokens create <name>` | Create an enrollment token (secret shown once). |
74
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. |
75
78
 
76
79
  Every command accepts `--json` for machine-readable output and `--help` for usage details.
77
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: EVENT_TYPES, required: true }),
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: EVENT_TYPES }),
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,2 @@
1
+ /** Event types accepted by alert rules — mirror of the backend enum (Alerting::Rule). */
2
+ export declare const ALERT_EVENT_TYPES: string[];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALERT_EVENT_TYPES = void 0;
4
+ /** Event types accepted by alert rules — mirror of the backend enum (Alerting::Rule). */
5
+ exports.ALERT_EVENT_TYPES = [
6
+ 'error_new',
7
+ 'error_regression',
8
+ 'uptime_down',
9
+ 'uptime_up',
10
+ 'metric_threshold',
11
+ 'uptime_ssl_expiring',
12
+ 'cron_missed',
13
+ 'server_down',
14
+ 'server_up',
15
+ 'server_cpu',
16
+ 'server_mem',
17
+ 'server_disk',
18
+ 'server_temp',
19
+ 'server_service_failed',
20
+ 'server_smart_failing',
21
+ ];