@rollupdate/hctl 0.0.0-stage → 3.0.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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1066 -2
  3. package/dist/auction/cache.d.ts +6 -0
  4. package/dist/auction/cache.js +55 -0
  5. package/dist/auction/client.d.ts +24 -0
  6. package/dist/auction/client.js +236 -0
  7. package/dist/auction/commands.d.ts +2 -0
  8. package/dist/auction/commands.js +440 -0
  9. package/dist/auction/diff-formatter.d.ts +3 -0
  10. package/dist/auction/diff-formatter.js +61 -0
  11. package/dist/auction/diff.d.ts +11 -0
  12. package/dist/auction/diff.js +28 -0
  13. package/dist/auction/formatter.d.ts +21 -0
  14. package/dist/auction/formatter.js +182 -0
  15. package/dist/auction/store.d.ts +24 -0
  16. package/dist/auction/store.js +177 -0
  17. package/dist/auction/types.d.ts +74 -0
  18. package/dist/auction/types.js +5 -0
  19. package/dist/cli.d.ts +2 -0
  20. package/dist/cli.js +74 -0
  21. package/dist/client.d.ts +2 -0
  22. package/dist/client.js +4 -0
  23. package/dist/cloud/browser-bootstrap.d.ts +16 -0
  24. package/dist/cloud/browser-bootstrap.js +438 -0
  25. package/dist/cloud/client.d.ts +520 -0
  26. package/dist/cloud/client.js +755 -0
  27. package/dist/cloud/commands/certificate.d.ts +2 -0
  28. package/dist/cloud/commands/certificate.js +108 -0
  29. package/dist/cloud/commands/context.d.ts +2 -0
  30. package/dist/cloud/commands/context.js +133 -0
  31. package/dist/cloud/commands/datacenter.d.ts +2 -0
  32. package/dist/cloud/commands/datacenter.js +24 -0
  33. package/dist/cloud/commands/firewall.d.ts +2 -0
  34. package/dist/cloud/commands/firewall.js +142 -0
  35. package/dist/cloud/commands/floating-ip.d.ts +2 -0
  36. package/dist/cloud/commands/floating-ip.js +138 -0
  37. package/dist/cloud/commands/image.d.ts +2 -0
  38. package/dist/cloud/commands/image.js +98 -0
  39. package/dist/cloud/commands/index.d.ts +2 -0
  40. package/dist/cloud/commands/index.js +47 -0
  41. package/dist/cloud/commands/inventory.d.ts +2 -0
  42. package/dist/cloud/commands/inventory.js +13 -0
  43. package/dist/cloud/commands/iso.d.ts +2 -0
  44. package/dist/cloud/commands/iso.js +27 -0
  45. package/dist/cloud/commands/load-balancer-type.d.ts +2 -0
  46. package/dist/cloud/commands/load-balancer-type.js +24 -0
  47. package/dist/cloud/commands/load-balancer.d.ts +2 -0
  48. package/dist/cloud/commands/load-balancer.js +269 -0
  49. package/dist/cloud/commands/location.d.ts +2 -0
  50. package/dist/cloud/commands/location.js +24 -0
  51. package/dist/cloud/commands/network.d.ts +2 -0
  52. package/dist/cloud/commands/network.js +157 -0
  53. package/dist/cloud/commands/placement-group.d.ts +2 -0
  54. package/dist/cloud/commands/placement-group.js +79 -0
  55. package/dist/cloud/commands/pricing.d.ts +2 -0
  56. package/dist/cloud/commands/pricing.js +15 -0
  57. package/dist/cloud/commands/primary-ip.d.ts +2 -0
  58. package/dist/cloud/commands/primary-ip.js +139 -0
  59. package/dist/cloud/commands/server-type.d.ts +2 -0
  60. package/dist/cloud/commands/server-type.js +24 -0
  61. package/dist/cloud/commands/server.d.ts +2 -0
  62. package/dist/cloud/commands/server.js +346 -0
  63. package/dist/cloud/commands/ssh-key.d.ts +2 -0
  64. package/dist/cloud/commands/ssh-key.js +94 -0
  65. package/dist/cloud/commands/volume.d.ts +2 -0
  66. package/dist/cloud/commands/volume.js +138 -0
  67. package/dist/cloud/context.d.ts +34 -0
  68. package/dist/cloud/context.js +215 -0
  69. package/dist/cloud/formatter.d.ts +40 -0
  70. package/dist/cloud/formatter.js +824 -0
  71. package/dist/cloud/helpers.d.ts +27 -0
  72. package/dist/cloud/helpers.js +67 -0
  73. package/dist/cloud/inventory.d.ts +100 -0
  74. package/dist/cloud/inventory.js +229 -0
  75. package/dist/cloud/pricing.d.ts +27 -0
  76. package/dist/cloud/pricing.js +103 -0
  77. package/dist/cloud/token-instructions.d.ts +2 -0
  78. package/dist/cloud/token-instructions.js +21 -0
  79. package/dist/cloud/types.d.ts +437 -0
  80. package/dist/cloud/types.js +5 -0
  81. package/dist/config.d.ts +1 -0
  82. package/dist/config.js +2 -0
  83. package/dist/formatter.d.ts +3 -0
  84. package/dist/formatter.js +6 -0
  85. package/dist/index.d.ts +12 -0
  86. package/dist/index.js +21 -0
  87. package/dist/robot/client.d.ts +246 -0
  88. package/dist/robot/client.js +719 -0
  89. package/dist/robot/commands/auth.d.ts +2 -0
  90. package/dist/robot/commands/auth.js +54 -0
  91. package/dist/robot/commands/boot.d.ts +2 -0
  92. package/dist/robot/commands/boot.js +76 -0
  93. package/dist/robot/commands/cancel.d.ts +2 -0
  94. package/dist/robot/commands/cancel.js +37 -0
  95. package/dist/robot/commands/failover.d.ts +2 -0
  96. package/dist/robot/commands/failover.js +46 -0
  97. package/dist/robot/commands/firewall.d.ts +2 -0
  98. package/dist/robot/commands/firewall.js +72 -0
  99. package/dist/robot/commands/index.d.ts +2 -0
  100. package/dist/robot/commands/index.js +36 -0
  101. package/dist/robot/commands/interactive.d.ts +2 -0
  102. package/dist/robot/commands/interactive.js +152 -0
  103. package/dist/robot/commands/ip.d.ts +2 -0
  104. package/dist/robot/commands/ip.js +55 -0
  105. package/dist/robot/commands/key.d.ts +2 -0
  106. package/dist/robot/commands/key.js +68 -0
  107. package/dist/robot/commands/order.d.ts +2 -0
  108. package/dist/robot/commands/order.js +33 -0
  109. package/dist/robot/commands/rdns.d.ts +2 -0
  110. package/dist/robot/commands/rdns.js +41 -0
  111. package/dist/robot/commands/reset.d.ts +2 -0
  112. package/dist/robot/commands/reset.js +77 -0
  113. package/dist/robot/commands/server.d.ts +2 -0
  114. package/dist/robot/commands/server.js +32 -0
  115. package/dist/robot/commands/storagebox.d.ts +2 -0
  116. package/dist/robot/commands/storagebox.js +126 -0
  117. package/dist/robot/commands/subnet.d.ts +2 -0
  118. package/dist/robot/commands/subnet.js +24 -0
  119. package/dist/robot/commands/traffic.d.ts +2 -0
  120. package/dist/robot/commands/traffic.js +23 -0
  121. package/dist/robot/commands/vswitch.d.ts +2 -0
  122. package/dist/robot/commands/vswitch.js +65 -0
  123. package/dist/robot/commands/wol.d.ts +2 -0
  124. package/dist/robot/commands/wol.js +20 -0
  125. package/dist/robot/formatter.d.ts +56 -0
  126. package/dist/robot/formatter.js +546 -0
  127. package/dist/robot/types.d.ts +353 -0
  128. package/dist/robot/types.js +5 -0
  129. package/dist/shared/config.d.ts +86 -0
  130. package/dist/shared/config.js +289 -0
  131. package/dist/shared/formatter.d.ts +29 -0
  132. package/dist/shared/formatter.js +121 -0
  133. package/dist/shared/helpers.d.ts +39 -0
  134. package/dist/shared/helpers.js +86 -0
  135. package/dist/shared/init.d.ts +2 -0
  136. package/dist/shared/init.js +107 -0
  137. package/dist/shared/reference.d.ts +5 -0
  138. package/dist/shared/reference.js +688 -0
  139. package/dist/shared/schemas.d.ts +1 -0
  140. package/dist/shared/schemas.js +1022 -0
  141. package/dist/types.d.ts +2 -0
  142. package/dist/types.js +2 -0
  143. package/package.json +131 -4
@@ -0,0 +1,33 @@
1
+ import { asyncAction, output, } from "../../shared/helpers.js";
2
+ import { formatServerMarketProductList, formatServerProductList, formatTransactionList, } from "../formatter.js";
3
+ export function registerOrderCommands(parent) {
4
+ const order = parent.command("order").description("Server ordering");
5
+ order
6
+ .command("products")
7
+ .description("List available server products")
8
+ .action(asyncAction(async (client, options) => {
9
+ const products = await client.listServerProducts();
10
+ output(products, formatServerProductList, options);
11
+ }));
12
+ order
13
+ .command("market")
14
+ .description("List server market (auction) products")
15
+ .action(asyncAction(async (client, options) => {
16
+ const products = await client.listServerMarketProducts();
17
+ output(products, formatServerMarketProductList, options);
18
+ }));
19
+ order
20
+ .command("transactions")
21
+ .description("List order transactions")
22
+ .action(asyncAction(async (client, options) => {
23
+ const transactions = await client.listServerTransactions();
24
+ output(transactions, formatTransactionList, options);
25
+ }));
26
+ order
27
+ .command("transaction <id>")
28
+ .description("Get order transaction details")
29
+ .action(asyncAction(async (client, transactionId, options) => {
30
+ const { transaction } = await client.getServerTransaction(transactionId);
31
+ output(transaction, (t) => formatTransactionList([{ transaction: t }]), options);
32
+ }));
33
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerRdnsCommands(parent: Command): void;
@@ -0,0 +1,41 @@
1
+ import { success } from "../../shared/formatter.js";
2
+ import { asyncAction, output, } from "../../shared/helpers.js";
3
+ import { formatRdnsList } from "../formatter.js";
4
+ export function registerRdnsCommands(parent) {
5
+ const rdns = parent.command("rdns").description("Reverse DNS management");
6
+ rdns
7
+ .command("list")
8
+ .alias("ls")
9
+ .description("List all reverse DNS entries")
10
+ .action(asyncAction(async (client, options) => {
11
+ const entries = await client.listRdns();
12
+ output(entries, formatRdnsList, options);
13
+ }));
14
+ rdns
15
+ .command("get <ip>")
16
+ .alias("show")
17
+ .description("Get reverse DNS entry for IP")
18
+ .action(asyncAction(async (client, ipAddr, options) => {
19
+ const { rdns: entry } = await client.getRdns(ipAddr);
20
+ output(entry, (e) => `IP: ${e.ip}\nPTR: ${e.ptr}`, options);
21
+ }));
22
+ rdns
23
+ .command("set <ip> <ptr>")
24
+ .description("Create or update reverse DNS entry")
25
+ .action(asyncAction(async (client, ipAddr, ptr) => {
26
+ try {
27
+ await client.createRdns(ipAddr, ptr);
28
+ }
29
+ catch {
30
+ await client.updateRdns(ipAddr, ptr);
31
+ }
32
+ console.log(success(`rDNS set: ${ipAddr} -> ${ptr}`));
33
+ }));
34
+ rdns
35
+ .command("delete <ip>")
36
+ .description("Delete reverse DNS entry")
37
+ .action(asyncAction(async (client, ipAddr) => {
38
+ await client.deleteRdns(ipAddr);
39
+ console.log(success("rDNS entry deleted."));
40
+ }));
41
+ }
@@ -0,0 +1,2 @@
1
+ import { type Command } from "commander";
2
+ export declare function registerResetCommands(parent: Command): void;
@@ -0,0 +1,77 @@
1
+ import { confirm, select } from "@inquirer/prompts";
2
+ import { Option } from "commander";
3
+ import { error as fmtError, formatJson, warning, } from "../../shared/formatter.js";
4
+ import { asyncAction, output, } from "../../shared/helpers.js";
5
+ import { formatResetOptions, formatResetResult } from "../formatter.js";
6
+ export function registerResetCommands(parent) {
7
+ const reset = parent.command("reset").description("Server reset operations");
8
+ reset
9
+ .command("options [server]")
10
+ .description("Show reset options for server(s)")
11
+ .action(asyncAction(async (client, serverIdOrIp, options) => {
12
+ if (serverIdOrIp) {
13
+ const { reset: rst } = await client.getResetOptions(serverIdOrIp);
14
+ output(rst, formatResetOptions, options);
15
+ }
16
+ else {
17
+ const resets = await client.listResetOptions();
18
+ if (options.json) {
19
+ console.log(formatJson(resets));
20
+ }
21
+ else {
22
+ for (const { reset: rst } of resets) {
23
+ console.log(formatResetOptions(rst));
24
+ console.log("");
25
+ }
26
+ }
27
+ }
28
+ }));
29
+ reset
30
+ .command("execute <servers...>")
31
+ .alias("run")
32
+ .description("Reset one or more servers")
33
+ .addOption(new Option("-t, --type <type>", "Reset type")
34
+ .choices(["sw", "hw", "man", "power", "power_long"])
35
+ .default("sw"))
36
+ .option("-i, --interactive", "Interactively select reset type")
37
+ .option("-y, --yes", "Skip confirmation")
38
+ .action(asyncAction(async (client, servers, options) => {
39
+ let resetType = options.type;
40
+ if (options.interactive) {
41
+ resetType = await select({
42
+ message: "Select reset type:",
43
+ choices: [
44
+ { value: "sw", name: "Software reset (ACPI) - Recommended" },
45
+ { value: "hw", name: "Hardware reset (forced)" },
46
+ { value: "power", name: "Power cycle" },
47
+ { value: "power_long", name: "Long power cycle (10+ seconds)" },
48
+ { value: "man", name: "Manual reset (technician)" },
49
+ ],
50
+ });
51
+ }
52
+ if (!options.yes) {
53
+ console.log("");
54
+ console.log(warning(`About to reset ${servers.length} server(s) with type: ${resetType}`));
55
+ console.log(`Servers: ${servers.join(", ")}`);
56
+ console.log("");
57
+ const confirmed = await confirm({
58
+ message: "Are you sure you want to proceed?",
59
+ default: false,
60
+ });
61
+ if (!confirmed) {
62
+ console.log("Aborted.");
63
+ return;
64
+ }
65
+ }
66
+ console.log("");
67
+ for (const srv of servers) {
68
+ try {
69
+ const { reset: rst } = await client.resetServer(srv, resetType);
70
+ console.log(formatResetResult(rst, resetType));
71
+ }
72
+ catch (error) {
73
+ console.log(fmtError(`Failed to reset ${srv}: ${error instanceof Error ? error.message : "Unknown error"}`));
74
+ }
75
+ }
76
+ }));
77
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerServerCommands(parent: Command): void;
@@ -0,0 +1,32 @@
1
+ import { success } from "../../shared/formatter.js";
2
+ import { asyncAction, output, } from "../../shared/helpers.js";
3
+ import { formatServerDetails, formatServerList } from "../formatter.js";
4
+ export function registerServerCommands(parent) {
5
+ const server = parent
6
+ .command("server")
7
+ .alias("servers")
8
+ .description("Server management");
9
+ server
10
+ .command("list")
11
+ .alias("ls")
12
+ .description("List all servers")
13
+ .action(asyncAction(async (client, options) => {
14
+ const servers = await client.listServers();
15
+ output(servers, formatServerList, options);
16
+ }));
17
+ server
18
+ .command("get <server>")
19
+ .alias("show")
20
+ .description("Get server details")
21
+ .action(asyncAction(async (client, serverIdOrIp, options) => {
22
+ const { server: srv } = await client.getServer(serverIdOrIp);
23
+ output(srv, formatServerDetails, options);
24
+ }));
25
+ server
26
+ .command("rename <server> <name>")
27
+ .description("Rename a server")
28
+ .action(asyncAction(async (client, serverIdOrIp, name) => {
29
+ await client.updateServerName(serverIdOrIp, name);
30
+ console.log(success(`Server renamed to: ${name}`));
31
+ }));
32
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerStorageBoxCommands(parent: Command): void;
@@ -0,0 +1,126 @@
1
+ import { colorize, success, warning } from "../../shared/formatter.js";
2
+ import { asyncAction, confirmAction, output, } from "../../shared/helpers.js";
3
+ import { formatStorageBoxDetails, formatStorageBoxList, formatStorageBoxSnapshots, formatStorageBoxSubaccounts, } from "../formatter.js";
4
+ export function registerStorageBoxCommands(parent) {
5
+ const storagebox = parent
6
+ .command("storagebox")
7
+ .alias("storage")
8
+ .description("Storage Box management");
9
+ storagebox
10
+ .command("list")
11
+ .alias("ls")
12
+ .description("List all storage boxes")
13
+ .action(asyncAction(async (client, options) => {
14
+ const boxes = await client.listStorageBoxes();
15
+ output(boxes, formatStorageBoxList, options);
16
+ }));
17
+ storagebox
18
+ .command("get <id>")
19
+ .alias("show")
20
+ .description("Get storage box details")
21
+ .action(asyncAction(async (client, boxId, options) => {
22
+ const { storagebox: box } = await client.getStorageBox(Number.parseInt(boxId, 10));
23
+ output(box, formatStorageBoxDetails, options);
24
+ }));
25
+ storagebox
26
+ .command("update <id>")
27
+ .description("Update storage box settings")
28
+ .option("-n, --name <name>", "Storage box name")
29
+ .option("--webdav <enabled>", "Enable/disable WebDAV")
30
+ .option("--samba <enabled>", "Enable/disable Samba/CIFS")
31
+ .option("--ssh <enabled>", "Enable/disable SSH/SFTP")
32
+ .option("--external <enabled>", "Enable/disable external reachability")
33
+ .option("--zfs <enabled>", "Enable/disable ZFS")
34
+ .action(asyncAction(async (client, boxId, options) => {
35
+ await client.updateStorageBox(Number.parseInt(boxId, 10), options.name, options.webdav ? options.webdav === "true" : undefined, options.samba ? options.samba === "true" : undefined, options.ssh ? options.ssh === "true" : undefined, options.external ? options.external === "true" : undefined, options.zfs ? options.zfs === "true" : undefined);
36
+ console.log(success("Storage box updated."));
37
+ }));
38
+ storagebox
39
+ .command("reset-password <id>")
40
+ .description("Reset storage box password")
41
+ .action(asyncAction(async (client, boxId) => {
42
+ const { password } = await client.resetStorageBoxPassword(Number.parseInt(boxId, 10));
43
+ console.log(success("Password reset."));
44
+ console.log(`New password: ${colorize(password, "yellow")}`);
45
+ }));
46
+ const snapshot = storagebox
47
+ .command("snapshot")
48
+ .description("Storage box snapshot management");
49
+ snapshot
50
+ .command("list <box-id>")
51
+ .alias("ls")
52
+ .description("List storage box snapshots")
53
+ .action(asyncAction(async (client, boxId, options) => {
54
+ const snapshots = await client.listStorageBoxSnapshots(Number.parseInt(boxId, 10));
55
+ output(snapshots, formatStorageBoxSnapshots, options);
56
+ }));
57
+ snapshot
58
+ .command("create <box-id>")
59
+ .description("Create a new snapshot")
60
+ .action(asyncAction(async (client, boxId) => {
61
+ const { snapshot: snap } = await client.createStorageBoxSnapshot(Number.parseInt(boxId, 10));
62
+ console.log(success(`Snapshot created: ${snap.name}`));
63
+ }));
64
+ snapshot
65
+ .command("delete <box-id> <name>")
66
+ .alias("rm")
67
+ .description("Delete a snapshot")
68
+ .option("-y, --yes", "Skip confirmation")
69
+ .action(asyncAction(async (client, boxId, snapshotName, options) => {
70
+ if (!(await confirmAction(`Delete snapshot ${snapshotName}?`, options))) {
71
+ return;
72
+ }
73
+ await client.deleteStorageBoxSnapshot(Number.parseInt(boxId, 10), snapshotName);
74
+ console.log(success("Snapshot deleted."));
75
+ }));
76
+ snapshot
77
+ .command("revert <box-id> <name>")
78
+ .description("Revert to a snapshot")
79
+ .option("-y, --yes", "Skip confirmation")
80
+ .action(asyncAction(async (client, boxId, snapshotName, options) => {
81
+ if (!options.yes) {
82
+ console.log(warning("This will revert your storage box to the snapshot state."));
83
+ }
84
+ if (!(await confirmAction(`Revert to snapshot ${snapshotName}?`, options))) {
85
+ return;
86
+ }
87
+ await client.revertStorageBoxSnapshot(Number.parseInt(boxId, 10), snapshotName);
88
+ console.log(success("Reverted to snapshot."));
89
+ }));
90
+ const subaccount = storagebox
91
+ .command("subaccount")
92
+ .description("Storage box subaccount management");
93
+ subaccount
94
+ .command("list <box-id>")
95
+ .alias("ls")
96
+ .description("List storage box subaccounts")
97
+ .action(asyncAction(async (client, boxId, options) => {
98
+ const subaccounts = await client.listStorageBoxSubaccounts(Number.parseInt(boxId, 10));
99
+ output(subaccounts, formatStorageBoxSubaccounts, options);
100
+ }));
101
+ subaccount
102
+ .command("create <box-id> <home-directory>")
103
+ .description("Create a new subaccount")
104
+ .option("--samba <enabled>", "Enable Samba")
105
+ .option("--ssh <enabled>", "Enable SSH")
106
+ .option("--webdav <enabled>", "Enable WebDAV")
107
+ .option("--external <enabled>", "Enable external reachability")
108
+ .option("--readonly <enabled>", "Read-only access")
109
+ .option("--comment <comment>", "Comment")
110
+ .action(asyncAction(async (client, boxId, homeDir, options) => {
111
+ const { subaccount: sub } = await client.createStorageBoxSubaccount(Number.parseInt(boxId, 10), homeDir, options.samba ? options.samba === "true" : undefined, options.ssh ? options.ssh === "true" : undefined, options.external ? options.external === "true" : undefined, options.webdav ? options.webdav === "true" : undefined, options.readonly ? options.readonly === "true" : undefined, options.comment);
112
+ console.log(success(`Subaccount created: ${sub.username}`));
113
+ }));
114
+ subaccount
115
+ .command("delete <box-id> <username>")
116
+ .alias("rm")
117
+ .description("Delete a subaccount")
118
+ .option("-y, --yes", "Skip confirmation")
119
+ .action(asyncAction(async (client, boxId, username, options) => {
120
+ if (!(await confirmAction(`Delete subaccount ${username}?`, options))) {
121
+ return;
122
+ }
123
+ await client.deleteStorageBoxSubaccount(Number.parseInt(boxId, 10), username);
124
+ console.log(success("Subaccount deleted."));
125
+ }));
126
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerSubnetCommands(parent: Command): void;
@@ -0,0 +1,24 @@
1
+ import { asyncAction, output, } from "../../shared/helpers.js";
2
+ import { formatSubnetList } from "../formatter.js";
3
+ export function registerSubnetCommands(parent) {
4
+ const subnet = parent
5
+ .command("subnet")
6
+ .alias("subnets")
7
+ .description("Subnet management");
8
+ subnet
9
+ .command("list")
10
+ .alias("ls")
11
+ .description("List all subnets")
12
+ .action(asyncAction(async (client, options) => {
13
+ const subnets = await client.listSubnets();
14
+ output(subnets, formatSubnetList, options);
15
+ }));
16
+ subnet
17
+ .command("get <subnet>")
18
+ .alias("show")
19
+ .description("Get subnet details")
20
+ .action(asyncAction(async (client, netIp, options) => {
21
+ const { subnet: subnetData } = await client.getSubnet(netIp);
22
+ output(subnetData, (s) => formatSubnetList([{ subnet: s }]), options);
23
+ }));
24
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerTrafficCommands(parent: Command): void;
@@ -0,0 +1,23 @@
1
+ import { asyncAction, output, } from "../../shared/helpers.js";
2
+ import { formatTraffic } from "../formatter.js";
3
+ export function registerTrafficCommands(parent) {
4
+ const traffic = parent.command("traffic").description("Traffic analytics");
5
+ traffic
6
+ .command("query")
7
+ .description("Query traffic data")
8
+ .option("-i, --ip <ips...>", "IP addresses to query")
9
+ .option("-s, --subnet <subnets...>", "Subnets to query")
10
+ .option("--from <date>", "Start date (YYYY-MM-DD)")
11
+ .option("--to <date>", "End date (YYYY-MM-DD)")
12
+ .option("-t, --type <type>", "Query type (day, month, year)", "month")
13
+ .action(asyncAction(async (client, options) => {
14
+ const now = new Date();
15
+ const from = options.from ||
16
+ new Date(now.getFullYear(), now.getMonth(), 1)
17
+ .toISOString()
18
+ .split("T")[0];
19
+ const to = options.to || now.toISOString().split("T")[0];
20
+ const { traffic: trafficData } = await client.getTraffic(options.ip || [], options.subnet || [], from, to, options.type);
21
+ output(trafficData, formatTraffic, options);
22
+ }));
23
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerVSwitchCommands(parent: Command): void;
@@ -0,0 +1,65 @@
1
+ import { success } from "../../shared/formatter.js";
2
+ import { asyncAction, confirmAction, output, } from "../../shared/helpers.js";
3
+ import { formatVSwitchDetails, formatVSwitchList } from "../formatter.js";
4
+ export function registerVSwitchCommands(parent) {
5
+ const vswitch = parent.command("vswitch").description("vSwitch management");
6
+ vswitch
7
+ .command("list")
8
+ .alias("ls")
9
+ .description("List all vSwitches")
10
+ .action(asyncAction(async (client, options) => {
11
+ const vswitches = await client.listVSwitches();
12
+ output(vswitches, formatVSwitchList, options);
13
+ }));
14
+ vswitch
15
+ .command("get <id>")
16
+ .alias("show")
17
+ .description("Get vSwitch details")
18
+ .action(asyncAction(async (client, vswitchId, options) => {
19
+ const vs = await client.getVSwitch(Number.parseInt(vswitchId, 10));
20
+ output(vs, formatVSwitchDetails, options);
21
+ }));
22
+ vswitch
23
+ .command("create <name> <vlan>")
24
+ .description("Create a new vSwitch")
25
+ .action(asyncAction(async (client, name, vlan) => {
26
+ const vs = await client.createVSwitch(name, Number.parseInt(vlan, 10));
27
+ console.log(success(`vSwitch created: ID ${vs.id}`));
28
+ }));
29
+ vswitch
30
+ .command("update <id>")
31
+ .description("Update vSwitch")
32
+ .option("-n, --name <name>", "New name")
33
+ .option("-v, --vlan <vlan>", "New VLAN ID")
34
+ .action(asyncAction(async (client, vswitchId, options) => {
35
+ await client.updateVSwitch(Number.parseInt(vswitchId, 10), options.name, options.vlan ? Number.parseInt(options.vlan, 10) : undefined);
36
+ console.log(success("vSwitch updated."));
37
+ }));
38
+ vswitch
39
+ .command("delete <id>")
40
+ .alias("rm")
41
+ .description("Delete vSwitch")
42
+ .option("-y, --yes", "Skip confirmation")
43
+ .option("--date <date>", "Cancellation date (YYYY-MM-DD)")
44
+ .action(asyncAction(async (client, vswitchId, options) => {
45
+ if (!(await confirmAction(`Delete vSwitch ${vswitchId}?`, options))) {
46
+ return;
47
+ }
48
+ await client.deleteVSwitch(Number.parseInt(vswitchId, 10), options.date);
49
+ console.log(success("vSwitch deleted."));
50
+ }));
51
+ vswitch
52
+ .command("add-server <vswitch-id> <server>")
53
+ .description("Add server to vSwitch")
54
+ .action(asyncAction(async (client, vswitchId, serverIdOrIp) => {
55
+ await client.addServerToVSwitch(Number.parseInt(vswitchId, 10), serverIdOrIp);
56
+ console.log(success("Server added to vSwitch."));
57
+ }));
58
+ vswitch
59
+ .command("remove-server <vswitch-id> <server>")
60
+ .description("Remove server from vSwitch")
61
+ .action(asyncAction(async (client, vswitchId, serverIdOrIp) => {
62
+ await client.removeServerFromVSwitch(Number.parseInt(vswitchId, 10), serverIdOrIp);
63
+ console.log(success("Server removed from vSwitch."));
64
+ }));
65
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare function registerWolCommands(parent: Command): void;
@@ -0,0 +1,20 @@
1
+ import { info } from "../../shared/formatter.js";
2
+ import { asyncAction, output, } from "../../shared/helpers.js";
3
+ import { formatWolResult } from "../formatter.js";
4
+ export function registerWolCommands(parent) {
5
+ const wol = parent.command("wol").description("Wake on LAN");
6
+ wol
7
+ .command("status <server>")
8
+ .description("Check WoL status for server")
9
+ .action(asyncAction(async (client, serverIdOrIp, options) => {
10
+ const { wol: wolData } = await client.getWol(serverIdOrIp);
11
+ output(wolData, (w) => `Server: ${w.server_number} (${w.server_ip})\n${info("Wake on LAN is available for this server.")}`, options);
12
+ }));
13
+ wol
14
+ .command("send <server>")
15
+ .description("Send Wake on LAN packet")
16
+ .action(asyncAction(async (client, serverIdOrIp) => {
17
+ const { wol: wolData } = await client.sendWol(serverIdOrIp);
18
+ console.log(formatWolResult(wolData));
19
+ }));
20
+ }
@@ -0,0 +1,56 @@
1
+ import type { BootConfig, Cancellation, Failover, Firewall, FirewallTemplate, IP, LinuxConfig, Rdns, RescueConfig, Reset, Server, ServerDetails, ServerMarketProduct, ServerProduct, ServerTransaction, SshKey, StorageBox, StorageBoxSnapshot, StorageBoxSubaccount, Subnet, Traffic, VSwitch, VSwitchSummary, Wol } from "./types.js";
2
+ export declare function formatServerList(servers: {
3
+ server: Server;
4
+ }[]): string;
5
+ export declare function formatServerDetails(server: ServerDetails): string;
6
+ export declare function formatResetOptions(reset: Reset): string;
7
+ export declare function formatResetResult(reset: Reset, type: string): string;
8
+ export declare function formatBootConfig(config: BootConfig, serverNumber: number): string;
9
+ export declare function formatRescueActivation(rescue: RescueConfig): string;
10
+ export declare function formatLinuxActivation(linux: LinuxConfig): string;
11
+ export declare function formatIpList(ips: {
12
+ ip: IP;
13
+ }[]): string;
14
+ export declare function formatIpDetails(ip: IP): string;
15
+ export declare function formatSubnetList(subnets: {
16
+ subnet: Subnet;
17
+ }[]): string;
18
+ export declare function formatFailoverList(failovers: {
19
+ failover: Failover;
20
+ }[]): string;
21
+ export declare function formatFailoverSwitch(failover: Failover): string;
22
+ export declare function formatRdnsList(entries: {
23
+ rdns: Rdns;
24
+ }[]): string;
25
+ export declare function formatSshKeyList(keys: {
26
+ key: SshKey;
27
+ }[]): string;
28
+ export declare function formatSshKeyDetails(key: SshKey): string;
29
+ export declare function formatFirewall(firewall: Firewall): string;
30
+ export declare function formatFirewallTemplateList(templates: {
31
+ firewall_template: FirewallTemplate;
32
+ }[]): string;
33
+ export declare function formatVSwitchList(vswitches: VSwitchSummary[]): string;
34
+ export declare function formatVSwitchDetails(vswitch: VSwitch): string;
35
+ export declare function formatStorageBoxList(boxes: {
36
+ storagebox: StorageBox;
37
+ }[]): string;
38
+ export declare function formatStorageBoxDetails(box: StorageBox): string;
39
+ export declare function formatStorageBoxSnapshots(snapshots: {
40
+ snapshot: StorageBoxSnapshot;
41
+ }[]): string;
42
+ export declare function formatStorageBoxSubaccounts(subaccounts: {
43
+ subaccount: StorageBoxSubaccount;
44
+ }[]): string;
45
+ export declare function formatTraffic(traffic: Traffic): string;
46
+ export declare function formatWolResult(wol: Wol): string;
47
+ export declare function formatServerProductList(products: {
48
+ product: ServerProduct;
49
+ }[]): string;
50
+ export declare function formatServerMarketProductList(products: {
51
+ product: ServerMarketProduct;
52
+ }[]): string;
53
+ export declare function formatTransactionList(transactions: {
54
+ transaction: ServerTransaction;
55
+ }[]): string;
56
+ export declare function formatCancellation(cancellation: Cancellation): string;