@bussolabs/closeyourit-cli 0.0.7 → 0.0.9

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.
Files changed (32) hide show
  1. package/README.md +10 -0
  2. package/dist/commands/monitors/create.d.ts +2 -0
  3. package/dist/commands/monitors/create.js +6 -0
  4. package/dist/commands/monitors/update.d.ts +2 -0
  5. package/dist/commands/monitors/update.js +6 -0
  6. package/dist/commands/projects/set-platforms.d.ts +11 -0
  7. package/dist/commands/projects/set-platforms.js +42 -0
  8. package/dist/commands/servers/delete.d.ts +12 -0
  9. package/dist/commands/servers/delete.js +25 -0
  10. package/dist/commands/servers/list.d.ts +10 -0
  11. package/dist/commands/servers/list.js +41 -0
  12. package/dist/commands/servers/pause.d.ts +9 -0
  13. package/dist/commands/servers/pause.js +19 -0
  14. package/dist/commands/servers/rename.d.ts +12 -0
  15. package/dist/commands/servers/rename.js +22 -0
  16. package/dist/commands/servers/resume.d.ts +9 -0
  17. package/dist/commands/servers/resume.js +19 -0
  18. package/dist/commands/servers/revoke.d.ts +12 -0
  19. package/dist/commands/servers/revoke.js +25 -0
  20. package/dist/commands/servers/show.d.ts +9 -0
  21. package/dist/commands/servers/show.js +21 -0
  22. package/dist/commands/servers/tokens/create.d.ts +9 -0
  23. package/dist/commands/servers/tokens/create.js +25 -0
  24. package/dist/commands/servers/tokens/list.d.ts +9 -0
  25. package/dist/commands/servers/tokens/list.js +25 -0
  26. package/dist/commands/servers/tokens/revoke.d.ts +12 -0
  27. package/dist/commands/servers/tokens/revoke.js +25 -0
  28. package/dist/commands/servers/unrevoke.d.ts +9 -0
  29. package/dist/commands/servers/unrevoke.js +19 -0
  30. package/oclif.manifest.json +1126 -575
  31. package/opencli.json +658 -59
  32. package/package.json +4 -1
package/README.md CHANGED
@@ -62,6 +62,16 @@ 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. |
65
75
 
66
76
  Every command accepts `--json` for machine-readable output and `--help` for usage details.
67
77
  `--project` accepts either a project UUID or its key (matched case-insensitively).
@@ -9,6 +9,8 @@ export default class MonitorsCreate extends BaseCommand {
9
9
  'interval-seconds': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
10
  'expected-status': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
11
  'timeout-seconds': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ 'expected-body-keyword': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ 'ssl-expiry-warn-days': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
14
  project: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
13
15
  };
14
16
  run(): Promise<unknown>;
@@ -17,6 +17,8 @@ class MonitorsCreate extends base_1.BaseCommand {
17
17
  'interval-seconds': core_1.Flags.integer({ description: 'Seconds between checks' }),
18
18
  'expected-status': core_1.Flags.integer({ description: 'Expected HTTP status code' }),
19
19
  'timeout-seconds': core_1.Flags.integer({ description: 'Request timeout in seconds' }),
20
+ 'expected-body-keyword': core_1.Flags.string({ description: 'Keyword expected in the response body (check fails without it; not with HEAD)' }),
21
+ 'ssl-expiry-warn-days': core_1.Flags.integer({ description: 'Alert when the TLS certificate has at most N days left (empty = off)' }),
20
22
  };
21
23
  async run() {
22
24
  const { flags } = await this.parse(MonitorsCreate);
@@ -32,6 +34,10 @@ class MonitorsCreate extends base_1.BaseCommand {
32
34
  body.expected_status = flags['expected-status'];
33
35
  if (flags['timeout-seconds'] !== undefined)
34
36
  body.timeout_seconds = flags['timeout-seconds'];
37
+ if (flags['expected-body-keyword'] !== undefined)
38
+ body.expected_body_keyword = flags['expected-body-keyword'];
39
+ if (flags['ssl-expiry-warn-days'] !== undefined)
40
+ body.ssl_expiry_warn_days = flags['ssl-expiry-warn-days'];
35
41
  const res = await this.api.post(`/cli/v1/projects/${encodeURIComponent(projectId)}/monitors`, body);
36
42
  if (!this.jsonEnabled()) {
37
43
  this.log('Monitor created:');
@@ -11,6 +11,8 @@ export default class MonitorsUpdate extends BaseCommand {
11
11
  'interval-seconds': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  'expected-status': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
13
  'timeout-seconds': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
+ 'expected-body-keyword': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
15
+ 'ssl-expiry-warn-days': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
16
  project: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
15
17
  };
16
18
  run(): Promise<unknown>;
@@ -19,6 +19,8 @@ class MonitorsUpdate extends base_1.BaseCommand {
19
19
  'interval-seconds': core_1.Flags.integer({ description: 'Seconds between checks' }),
20
20
  'expected-status': core_1.Flags.integer({ description: 'Expected HTTP status code' }),
21
21
  'timeout-seconds': core_1.Flags.integer({ description: 'Request timeout in seconds' }),
22
+ 'expected-body-keyword': core_1.Flags.string({ description: 'Keyword expected in the response body (check fails without it; not with HEAD)' }),
23
+ 'ssl-expiry-warn-days': core_1.Flags.integer({ description: 'Alert when the TLS certificate has at most N days left (empty = off)' }),
22
24
  };
23
25
  async run() {
24
26
  const { args, flags } = await this.parse(MonitorsUpdate);
@@ -34,6 +36,10 @@ class MonitorsUpdate extends base_1.BaseCommand {
34
36
  body.expected_status = flags['expected-status'];
35
37
  if (flags['timeout-seconds'] !== undefined)
36
38
  body.timeout_seconds = flags['timeout-seconds'];
39
+ if (flags['expected-body-keyword'] !== undefined)
40
+ body.expected_body_keyword = flags['expected-body-keyword'];
41
+ if (flags['ssl-expiry-warn-days'] !== undefined)
42
+ body.ssl_expiry_warn_days = flags['ssl-expiry-warn-days'];
37
43
  const res = await this.api.put(`/cli/v1/projects/${encodeURIComponent(projectId)}/monitors/${encodeURIComponent(args.id)}`, body);
38
44
  if (!this.jsonEnabled()) {
39
45
  this.log('Monitor updated:');
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class ProjectsSetPlatforms extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ code: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ 'platform-id': import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ project: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ };
10
+ run(): Promise<unknown>;
11
+ }
@@ -0,0 +1,42 @@
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 ProjectsSetPlatforms extends base_1.BaseCommand {
6
+ static description = 'Declare the platforms of a project (replaces the current set)';
7
+ static examples = [
8
+ '<%= config.bin %> projects set-platforms --project legalbloom-rails --code web',
9
+ '<%= config.bin %> projects set-platforms -p LBRA --code web --code ios',
10
+ ];
11
+ static flags = {
12
+ ...base_1.projectFlag,
13
+ code: core_1.Flags.string({
14
+ description: 'Platform code, e.g. web (repeatable)',
15
+ multiple: true,
16
+ default: [],
17
+ }),
18
+ 'platform-id': core_1.Flags.string({
19
+ description: 'Platform id / UUID (repeatable)',
20
+ multiple: true,
21
+ default: [],
22
+ }),
23
+ };
24
+ async run() {
25
+ const { flags } = await this.parse(ProjectsSetPlatforms);
26
+ const projectId = await this.resolveProjectId(flags.project);
27
+ const res = await this.api.put(`/cli/v1/projects/${projectId}/platforms`, { codes: flags.code, platform_ids: flags['platform-id'] });
28
+ const platforms = res.data ?? [];
29
+ if (!this.jsonEnabled()) {
30
+ if (platforms.length === 0) {
31
+ this.log('Project now declares no platforms.');
32
+ }
33
+ else {
34
+ this.log('Declared platforms:');
35
+ for (const p of platforms)
36
+ this.log(` ${p.code}${p.label ? ` — ${p.label}` : ''}`);
37
+ }
38
+ }
39
+ return res;
40
+ }
41
+ }
42
+ exports.default = ProjectsSetPlatforms;
@@ -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;
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from '../../base';
2
+ export default class ServersUnrevoke 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 ServersUnrevoke extends base_1.BaseCommand {
6
+ static args = {
7
+ id: core_1.Args.string({ description: 'Server id', required: true }),
8
+ };
9
+ static description = 'Restore a revoked server (its agent can push again)';
10
+ static examples = ['<%= config.bin %> servers unrevoke <server-id>'];
11
+ async run() {
12
+ const { args } = await this.parse(ServersUnrevoke);
13
+ const res = await this.api.put(`/cli/v1/servers/${encodeURIComponent(args.id)}/unrevoke`);
14
+ if (!this.jsonEnabled())
15
+ this.log(`Restored server ${args.id}`);
16
+ return res;
17
+ }
18
+ }
19
+ exports.default = ServersUnrevoke;