@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.
- package/LICENSE +21 -0
- package/README.md +1066 -2
- package/dist/auction/cache.d.ts +6 -0
- package/dist/auction/cache.js +55 -0
- package/dist/auction/client.d.ts +24 -0
- package/dist/auction/client.js +236 -0
- package/dist/auction/commands.d.ts +2 -0
- package/dist/auction/commands.js +440 -0
- package/dist/auction/diff-formatter.d.ts +3 -0
- package/dist/auction/diff-formatter.js +61 -0
- package/dist/auction/diff.d.ts +11 -0
- package/dist/auction/diff.js +28 -0
- package/dist/auction/formatter.d.ts +21 -0
- package/dist/auction/formatter.js +182 -0
- package/dist/auction/store.d.ts +24 -0
- package/dist/auction/store.js +177 -0
- package/dist/auction/types.d.ts +74 -0
- package/dist/auction/types.js +5 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +74 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +4 -0
- package/dist/cloud/browser-bootstrap.d.ts +16 -0
- package/dist/cloud/browser-bootstrap.js +438 -0
- package/dist/cloud/client.d.ts +520 -0
- package/dist/cloud/client.js +755 -0
- package/dist/cloud/commands/certificate.d.ts +2 -0
- package/dist/cloud/commands/certificate.js +108 -0
- package/dist/cloud/commands/context.d.ts +2 -0
- package/dist/cloud/commands/context.js +133 -0
- package/dist/cloud/commands/datacenter.d.ts +2 -0
- package/dist/cloud/commands/datacenter.js +24 -0
- package/dist/cloud/commands/firewall.d.ts +2 -0
- package/dist/cloud/commands/firewall.js +142 -0
- package/dist/cloud/commands/floating-ip.d.ts +2 -0
- package/dist/cloud/commands/floating-ip.js +138 -0
- package/dist/cloud/commands/image.d.ts +2 -0
- package/dist/cloud/commands/image.js +98 -0
- package/dist/cloud/commands/index.d.ts +2 -0
- package/dist/cloud/commands/index.js +47 -0
- package/dist/cloud/commands/inventory.d.ts +2 -0
- package/dist/cloud/commands/inventory.js +13 -0
- package/dist/cloud/commands/iso.d.ts +2 -0
- package/dist/cloud/commands/iso.js +27 -0
- package/dist/cloud/commands/load-balancer-type.d.ts +2 -0
- package/dist/cloud/commands/load-balancer-type.js +24 -0
- package/dist/cloud/commands/load-balancer.d.ts +2 -0
- package/dist/cloud/commands/load-balancer.js +269 -0
- package/dist/cloud/commands/location.d.ts +2 -0
- package/dist/cloud/commands/location.js +24 -0
- package/dist/cloud/commands/network.d.ts +2 -0
- package/dist/cloud/commands/network.js +157 -0
- package/dist/cloud/commands/placement-group.d.ts +2 -0
- package/dist/cloud/commands/placement-group.js +79 -0
- package/dist/cloud/commands/pricing.d.ts +2 -0
- package/dist/cloud/commands/pricing.js +15 -0
- package/dist/cloud/commands/primary-ip.d.ts +2 -0
- package/dist/cloud/commands/primary-ip.js +139 -0
- package/dist/cloud/commands/server-type.d.ts +2 -0
- package/dist/cloud/commands/server-type.js +24 -0
- package/dist/cloud/commands/server.d.ts +2 -0
- package/dist/cloud/commands/server.js +346 -0
- package/dist/cloud/commands/ssh-key.d.ts +2 -0
- package/dist/cloud/commands/ssh-key.js +94 -0
- package/dist/cloud/commands/volume.d.ts +2 -0
- package/dist/cloud/commands/volume.js +138 -0
- package/dist/cloud/context.d.ts +34 -0
- package/dist/cloud/context.js +215 -0
- package/dist/cloud/formatter.d.ts +40 -0
- package/dist/cloud/formatter.js +824 -0
- package/dist/cloud/helpers.d.ts +27 -0
- package/dist/cloud/helpers.js +67 -0
- package/dist/cloud/inventory.d.ts +100 -0
- package/dist/cloud/inventory.js +229 -0
- package/dist/cloud/pricing.d.ts +27 -0
- package/dist/cloud/pricing.js +103 -0
- package/dist/cloud/token-instructions.d.ts +2 -0
- package/dist/cloud/token-instructions.js +21 -0
- package/dist/cloud/types.d.ts +437 -0
- package/dist/cloud/types.js +5 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/formatter.d.ts +3 -0
- package/dist/formatter.js +6 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +21 -0
- package/dist/robot/client.d.ts +246 -0
- package/dist/robot/client.js +719 -0
- package/dist/robot/commands/auth.d.ts +2 -0
- package/dist/robot/commands/auth.js +54 -0
- package/dist/robot/commands/boot.d.ts +2 -0
- package/dist/robot/commands/boot.js +76 -0
- package/dist/robot/commands/cancel.d.ts +2 -0
- package/dist/robot/commands/cancel.js +37 -0
- package/dist/robot/commands/failover.d.ts +2 -0
- package/dist/robot/commands/failover.js +46 -0
- package/dist/robot/commands/firewall.d.ts +2 -0
- package/dist/robot/commands/firewall.js +72 -0
- package/dist/robot/commands/index.d.ts +2 -0
- package/dist/robot/commands/index.js +36 -0
- package/dist/robot/commands/interactive.d.ts +2 -0
- package/dist/robot/commands/interactive.js +152 -0
- package/dist/robot/commands/ip.d.ts +2 -0
- package/dist/robot/commands/ip.js +55 -0
- package/dist/robot/commands/key.d.ts +2 -0
- package/dist/robot/commands/key.js +68 -0
- package/dist/robot/commands/order.d.ts +2 -0
- package/dist/robot/commands/order.js +33 -0
- package/dist/robot/commands/rdns.d.ts +2 -0
- package/dist/robot/commands/rdns.js +41 -0
- package/dist/robot/commands/reset.d.ts +2 -0
- package/dist/robot/commands/reset.js +77 -0
- package/dist/robot/commands/server.d.ts +2 -0
- package/dist/robot/commands/server.js +32 -0
- package/dist/robot/commands/storagebox.d.ts +2 -0
- package/dist/robot/commands/storagebox.js +126 -0
- package/dist/robot/commands/subnet.d.ts +2 -0
- package/dist/robot/commands/subnet.js +24 -0
- package/dist/robot/commands/traffic.d.ts +2 -0
- package/dist/robot/commands/traffic.js +23 -0
- package/dist/robot/commands/vswitch.d.ts +2 -0
- package/dist/robot/commands/vswitch.js +65 -0
- package/dist/robot/commands/wol.d.ts +2 -0
- package/dist/robot/commands/wol.js +20 -0
- package/dist/robot/formatter.d.ts +56 -0
- package/dist/robot/formatter.js +546 -0
- package/dist/robot/types.d.ts +353 -0
- package/dist/robot/types.js +5 -0
- package/dist/shared/config.d.ts +86 -0
- package/dist/shared/config.js +289 -0
- package/dist/shared/formatter.d.ts +29 -0
- package/dist/shared/formatter.js +121 -0
- package/dist/shared/helpers.d.ts +39 -0
- package/dist/shared/helpers.js +86 -0
- package/dist/shared/init.d.ts +2 -0
- package/dist/shared/init.js +107 -0
- package/dist/shared/reference.d.ts +5 -0
- package/dist/shared/reference.js +688 -0
- package/dist/shared/schemas.d.ts +1 -0
- package/dist/shared/schemas.js +1022 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -0
- package/package.json +131 -4
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Hetzner Robot API Client
|
|
3
|
+
// Base URL: https://robot-ws.your-server.de
|
|
4
|
+
// Auth: HTTP Basic Authentication
|
|
5
|
+
// ============================================================================
|
|
6
|
+
const BASE_URL = "https://robot-ws.your-server.de";
|
|
7
|
+
export class HetznerRobotClient {
|
|
8
|
+
auth;
|
|
9
|
+
constructor(username, password) {
|
|
10
|
+
this.auth = Buffer.from(`${username}:${password}`).toString("base64");
|
|
11
|
+
}
|
|
12
|
+
async request(endpoint, options = {}) {
|
|
13
|
+
const url = `${BASE_URL}${endpoint}`;
|
|
14
|
+
const headers = {
|
|
15
|
+
Authorization: `Basic ${this.auth}`,
|
|
16
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
17
|
+
Accept: "application/json",
|
|
18
|
+
...options.headers,
|
|
19
|
+
};
|
|
20
|
+
const response = await fetch(url, {
|
|
21
|
+
...options,
|
|
22
|
+
headers,
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
26
|
+
try {
|
|
27
|
+
const errorBody = (await response.json());
|
|
28
|
+
if (errorBody.error) {
|
|
29
|
+
errorMessage = `${errorBody.error.code ?? "ERROR"}: ${errorBody.error.message ?? "Unknown error"}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Use default error message
|
|
34
|
+
}
|
|
35
|
+
throw new Error(errorMessage);
|
|
36
|
+
}
|
|
37
|
+
// Handle empty responses (204 No Content, or 200 with empty body)
|
|
38
|
+
const text = await response.text();
|
|
39
|
+
if (!text) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
return JSON.parse(text);
|
|
43
|
+
}
|
|
44
|
+
encodeParams(params) {
|
|
45
|
+
const parts = [];
|
|
46
|
+
for (const [key, value] of Object.entries(params)) {
|
|
47
|
+
if (value === undefined) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
for (const v of value) {
|
|
52
|
+
parts.push(`${encodeURIComponent(key)}[]=${encodeURIComponent(v)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return parts.join("&");
|
|
60
|
+
}
|
|
61
|
+
buildTrafficParams(trafficWarnings, trafficHourly, trafficDaily, trafficMonthly) {
|
|
62
|
+
return {
|
|
63
|
+
traffic_warnings: trafficWarnings,
|
|
64
|
+
traffic_hourly: trafficHourly,
|
|
65
|
+
traffic_daily: trafficDaily,
|
|
66
|
+
traffic_monthly: trafficMonthly,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// =========================================================================
|
|
70
|
+
// Server Management
|
|
71
|
+
// =========================================================================
|
|
72
|
+
async listServers() {
|
|
73
|
+
return await this.request("/server");
|
|
74
|
+
}
|
|
75
|
+
async getServer(serverIpOrNumber) {
|
|
76
|
+
return await this.request(`/server/${serverIpOrNumber}`);
|
|
77
|
+
}
|
|
78
|
+
async updateServerName(serverIpOrNumber, name) {
|
|
79
|
+
return await this.request(`/server/${serverIpOrNumber}`, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
body: this.encodeParams({ server_name: name }),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// =========================================================================
|
|
85
|
+
// Cancellation
|
|
86
|
+
// =========================================================================
|
|
87
|
+
async getCancellation(serverIpOrNumber) {
|
|
88
|
+
return await this.request(`/server/${serverIpOrNumber}/cancellation`);
|
|
89
|
+
}
|
|
90
|
+
async cancelServer(serverIpOrNumber, cancellationDate, cancellationReason) {
|
|
91
|
+
const params = {};
|
|
92
|
+
if (cancellationDate) {
|
|
93
|
+
params.cancellation_date = cancellationDate;
|
|
94
|
+
}
|
|
95
|
+
if (cancellationReason) {
|
|
96
|
+
params.cancellation_reason = cancellationReason;
|
|
97
|
+
}
|
|
98
|
+
return await this.request(`/server/${serverIpOrNumber}/cancellation`, {
|
|
99
|
+
method: "POST",
|
|
100
|
+
body: this.encodeParams(params),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async revokeCancellation(serverIpOrNumber) {
|
|
104
|
+
await this.request(`/server/${serverIpOrNumber}/cancellation`, {
|
|
105
|
+
method: "DELETE",
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// =========================================================================
|
|
109
|
+
// Reset
|
|
110
|
+
// =========================================================================
|
|
111
|
+
async listResetOptions() {
|
|
112
|
+
return await this.request("/reset");
|
|
113
|
+
}
|
|
114
|
+
async getResetOptions(serverIpOrNumber) {
|
|
115
|
+
return await this.request(`/reset/${serverIpOrNumber}`);
|
|
116
|
+
}
|
|
117
|
+
async resetServer(serverIpOrNumber, type = "sw") {
|
|
118
|
+
return await this.request(`/reset/${serverIpOrNumber}`, {
|
|
119
|
+
method: "POST",
|
|
120
|
+
body: this.encodeParams({ type }),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// =========================================================================
|
|
124
|
+
// Boot Configuration
|
|
125
|
+
// =========================================================================
|
|
126
|
+
async getBootConfig(serverIpOrNumber) {
|
|
127
|
+
return await this.request(`/boot/${serverIpOrNumber}`);
|
|
128
|
+
}
|
|
129
|
+
// Rescue System
|
|
130
|
+
async getRescue(serverIpOrNumber) {
|
|
131
|
+
return await this.request(`/boot/${serverIpOrNumber}/rescue`);
|
|
132
|
+
}
|
|
133
|
+
async activateRescue(serverIpOrNumber, os, arch, authorizedKeys) {
|
|
134
|
+
const params = {
|
|
135
|
+
os,
|
|
136
|
+
};
|
|
137
|
+
if (arch) {
|
|
138
|
+
params.arch = arch;
|
|
139
|
+
}
|
|
140
|
+
if (authorizedKeys) {
|
|
141
|
+
params.authorized_key = authorizedKeys;
|
|
142
|
+
}
|
|
143
|
+
return await this.request(`/boot/${serverIpOrNumber}/rescue`, {
|
|
144
|
+
method: "POST",
|
|
145
|
+
body: this.encodeParams(params),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async deactivateRescue(serverIpOrNumber) {
|
|
149
|
+
return await this.request(`/boot/${serverIpOrNumber}/rescue`, {
|
|
150
|
+
method: "DELETE",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async getLastRescue(serverIpOrNumber) {
|
|
154
|
+
return await this.request(`/boot/${serverIpOrNumber}/rescue/last`);
|
|
155
|
+
}
|
|
156
|
+
// Linux Install
|
|
157
|
+
async getLinux(serverIpOrNumber) {
|
|
158
|
+
return await this.request(`/boot/${serverIpOrNumber}/linux`);
|
|
159
|
+
}
|
|
160
|
+
async activateLinux(serverIpOrNumber, dist, arch, lang, authorizedKeys) {
|
|
161
|
+
const params = {
|
|
162
|
+
dist,
|
|
163
|
+
};
|
|
164
|
+
if (arch) {
|
|
165
|
+
params.arch = arch;
|
|
166
|
+
}
|
|
167
|
+
if (lang) {
|
|
168
|
+
params.lang = lang;
|
|
169
|
+
}
|
|
170
|
+
if (authorizedKeys) {
|
|
171
|
+
params.authorized_key = authorizedKeys;
|
|
172
|
+
}
|
|
173
|
+
return await this.request(`/boot/${serverIpOrNumber}/linux`, {
|
|
174
|
+
method: "POST",
|
|
175
|
+
body: this.encodeParams(params),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async deactivateLinux(serverIpOrNumber) {
|
|
179
|
+
return await this.request(`/boot/${serverIpOrNumber}/linux`, {
|
|
180
|
+
method: "DELETE",
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
async getLastLinux(serverIpOrNumber) {
|
|
184
|
+
return await this.request(`/boot/${serverIpOrNumber}/linux/last`);
|
|
185
|
+
}
|
|
186
|
+
// VNC Install
|
|
187
|
+
async getVnc(serverIpOrNumber) {
|
|
188
|
+
return await this.request(`/boot/${serverIpOrNumber}/vnc`);
|
|
189
|
+
}
|
|
190
|
+
async activateVnc(serverIpOrNumber, dist, arch, lang) {
|
|
191
|
+
const params = { dist };
|
|
192
|
+
if (arch) {
|
|
193
|
+
params.arch = arch;
|
|
194
|
+
}
|
|
195
|
+
if (lang) {
|
|
196
|
+
params.lang = lang;
|
|
197
|
+
}
|
|
198
|
+
return await this.request(`/boot/${serverIpOrNumber}/vnc`, {
|
|
199
|
+
method: "POST",
|
|
200
|
+
body: this.encodeParams(params),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
async deactivateVnc(serverIpOrNumber) {
|
|
204
|
+
return await this.request(`/boot/${serverIpOrNumber}/vnc`, {
|
|
205
|
+
method: "DELETE",
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// Windows Install
|
|
209
|
+
async getWindows(serverIpOrNumber) {
|
|
210
|
+
return await this.request(`/boot/${serverIpOrNumber}/windows`);
|
|
211
|
+
}
|
|
212
|
+
async activateWindows(serverIpOrNumber, dist, lang) {
|
|
213
|
+
const params = { dist };
|
|
214
|
+
if (lang) {
|
|
215
|
+
params.lang = lang;
|
|
216
|
+
}
|
|
217
|
+
return await this.request(`/boot/${serverIpOrNumber}/windows`, {
|
|
218
|
+
method: "POST",
|
|
219
|
+
body: this.encodeParams(params),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async deactivateWindows(serverIpOrNumber) {
|
|
223
|
+
return await this.request(`/boot/${serverIpOrNumber}/windows`, {
|
|
224
|
+
method: "DELETE",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
// =========================================================================
|
|
228
|
+
// IP Management
|
|
229
|
+
// =========================================================================
|
|
230
|
+
async listIps() {
|
|
231
|
+
return await this.request("/ip");
|
|
232
|
+
}
|
|
233
|
+
async getIp(ip) {
|
|
234
|
+
return await this.request(`/ip/${ip}`);
|
|
235
|
+
}
|
|
236
|
+
async updateIp(ip, trafficWarnings, trafficHourly, trafficDaily, trafficMonthly) {
|
|
237
|
+
return await this.request(`/ip/${ip}`, {
|
|
238
|
+
method: "POST",
|
|
239
|
+
body: this.encodeParams(this.buildTrafficParams(trafficWarnings, trafficHourly, trafficDaily, trafficMonthly)),
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
async getIpMac(ip) {
|
|
243
|
+
return await this.request(`/ip/${ip}/mac`);
|
|
244
|
+
}
|
|
245
|
+
async generateIpMac(ip) {
|
|
246
|
+
return await this.request(`/ip/${ip}/mac`, {
|
|
247
|
+
method: "PUT",
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
async deleteIpMac(ip) {
|
|
251
|
+
await this.request(`/ip/${ip}/mac`, {
|
|
252
|
+
method: "DELETE",
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
// =========================================================================
|
|
256
|
+
// Subnet Management
|
|
257
|
+
// =========================================================================
|
|
258
|
+
async listSubnets() {
|
|
259
|
+
return await this.request("/subnet");
|
|
260
|
+
}
|
|
261
|
+
async getSubnet(netIp) {
|
|
262
|
+
return await this.request(`/subnet/${netIp}`);
|
|
263
|
+
}
|
|
264
|
+
async updateSubnet(netIp, trafficWarnings, trafficHourly, trafficDaily, trafficMonthly) {
|
|
265
|
+
return await this.request(`/subnet/${netIp}`, {
|
|
266
|
+
method: "POST",
|
|
267
|
+
body: this.encodeParams(this.buildTrafficParams(trafficWarnings, trafficHourly, trafficDaily, trafficMonthly)),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
async getSubnetMac(netIp) {
|
|
271
|
+
return await this.request(`/subnet/${netIp}/mac`);
|
|
272
|
+
}
|
|
273
|
+
async generateSubnetMac(netIp) {
|
|
274
|
+
return await this.request(`/subnet/${netIp}/mac`, {
|
|
275
|
+
method: "PUT",
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
async deleteSubnetMac(netIp) {
|
|
279
|
+
await this.request(`/subnet/${netIp}/mac`, {
|
|
280
|
+
method: "DELETE",
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
// =========================================================================
|
|
284
|
+
// Failover
|
|
285
|
+
// =========================================================================
|
|
286
|
+
async listFailovers() {
|
|
287
|
+
return await this.request("/failover");
|
|
288
|
+
}
|
|
289
|
+
async getFailover(failoverIp) {
|
|
290
|
+
return await this.request(`/failover/${failoverIp}`);
|
|
291
|
+
}
|
|
292
|
+
async switchFailover(failoverIp, activeServerIp) {
|
|
293
|
+
return await this.request(`/failover/${failoverIp}`, {
|
|
294
|
+
method: "POST",
|
|
295
|
+
body: this.encodeParams({ active_server_ip: activeServerIp }),
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
async deleteFailoverRouting(failoverIp) {
|
|
299
|
+
await this.request(`/failover/${failoverIp}`, {
|
|
300
|
+
method: "DELETE",
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
// =========================================================================
|
|
304
|
+
// Reverse DNS
|
|
305
|
+
// =========================================================================
|
|
306
|
+
async listRdns() {
|
|
307
|
+
return await this.request("/rdns");
|
|
308
|
+
}
|
|
309
|
+
async getRdns(ip) {
|
|
310
|
+
return await this.request(`/rdns/${ip}`);
|
|
311
|
+
}
|
|
312
|
+
async createRdns(ip, ptr) {
|
|
313
|
+
return await this.request(`/rdns/${ip}`, {
|
|
314
|
+
method: "PUT",
|
|
315
|
+
body: this.encodeParams({ ptr }),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async updateRdns(ip, ptr) {
|
|
319
|
+
return await this.request(`/rdns/${ip}`, {
|
|
320
|
+
method: "POST",
|
|
321
|
+
body: this.encodeParams({ ptr }),
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async deleteRdns(ip) {
|
|
325
|
+
await this.request(`/rdns/${ip}`, {
|
|
326
|
+
method: "DELETE",
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// =========================================================================
|
|
330
|
+
// SSH Keys
|
|
331
|
+
// =========================================================================
|
|
332
|
+
async listSshKeys() {
|
|
333
|
+
return await this.request("/key");
|
|
334
|
+
}
|
|
335
|
+
async getSshKey(fingerprint) {
|
|
336
|
+
return await this.request(`/key/${fingerprint}`);
|
|
337
|
+
}
|
|
338
|
+
async createSshKey(name, data) {
|
|
339
|
+
return await this.request("/key", {
|
|
340
|
+
method: "POST",
|
|
341
|
+
body: this.encodeParams({ name, data }),
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
async updateSshKey(fingerprint, name) {
|
|
345
|
+
return await this.request(`/key/${fingerprint}`, {
|
|
346
|
+
method: "POST",
|
|
347
|
+
body: this.encodeParams({ name }),
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
async deleteSshKey(fingerprint) {
|
|
351
|
+
await this.request(`/key/${fingerprint}`, {
|
|
352
|
+
method: "DELETE",
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
// =========================================================================
|
|
356
|
+
// Firewall
|
|
357
|
+
// =========================================================================
|
|
358
|
+
async getFirewall(serverIpOrNumber) {
|
|
359
|
+
return await this.request(`/firewall/${serverIpOrNumber}`);
|
|
360
|
+
}
|
|
361
|
+
async updateFirewall(serverIpOrNumber, status, rules) {
|
|
362
|
+
const params = { status };
|
|
363
|
+
if (rules) {
|
|
364
|
+
params["rules[input]"] = JSON.stringify(rules.input);
|
|
365
|
+
}
|
|
366
|
+
return await this.request(`/firewall/${serverIpOrNumber}`, {
|
|
367
|
+
method: "POST",
|
|
368
|
+
body: this.encodeParams(params),
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
async deleteFirewall(serverIpOrNumber) {
|
|
372
|
+
await this.request(`/firewall/${serverIpOrNumber}`, {
|
|
373
|
+
method: "DELETE",
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
// Firewall Templates
|
|
377
|
+
async listFirewallTemplates() {
|
|
378
|
+
return await this.request("/firewall/template");
|
|
379
|
+
}
|
|
380
|
+
async getFirewallTemplate(templateId) {
|
|
381
|
+
return await this.request(`/firewall/template/${templateId}`);
|
|
382
|
+
}
|
|
383
|
+
async createFirewallTemplate(name, filterIpv6, whitelistHos, isDefault, rules) {
|
|
384
|
+
const params = { name };
|
|
385
|
+
if (filterIpv6 !== undefined) {
|
|
386
|
+
params.filter_ipv6 = filterIpv6;
|
|
387
|
+
}
|
|
388
|
+
if (whitelistHos !== undefined) {
|
|
389
|
+
params.whitelist_hos = whitelistHos;
|
|
390
|
+
}
|
|
391
|
+
if (isDefault !== undefined) {
|
|
392
|
+
params.is_default = isDefault;
|
|
393
|
+
}
|
|
394
|
+
if (rules) {
|
|
395
|
+
params["rules[input]"] = JSON.stringify(rules.input);
|
|
396
|
+
}
|
|
397
|
+
return await this.request("/firewall/template", {
|
|
398
|
+
method: "POST",
|
|
399
|
+
body: this.encodeParams(params),
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
async updateFirewallTemplate(templateId, name, filterIpv6, whitelistHos, isDefault, rules) {
|
|
403
|
+
const params = {};
|
|
404
|
+
if (name) {
|
|
405
|
+
params.name = name;
|
|
406
|
+
}
|
|
407
|
+
if (filterIpv6 !== undefined) {
|
|
408
|
+
params.filter_ipv6 = filterIpv6;
|
|
409
|
+
}
|
|
410
|
+
if (whitelistHos !== undefined) {
|
|
411
|
+
params.whitelist_hos = whitelistHos;
|
|
412
|
+
}
|
|
413
|
+
if (isDefault !== undefined) {
|
|
414
|
+
params.is_default = isDefault;
|
|
415
|
+
}
|
|
416
|
+
if (rules) {
|
|
417
|
+
params["rules[input]"] = JSON.stringify(rules.input);
|
|
418
|
+
}
|
|
419
|
+
return await this.request(`/firewall/template/${templateId}`, {
|
|
420
|
+
method: "POST",
|
|
421
|
+
body: this.encodeParams(params),
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
async deleteFirewallTemplate(templateId) {
|
|
425
|
+
await this.request(`/firewall/template/${templateId}`, {
|
|
426
|
+
method: "DELETE",
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
// =========================================================================
|
|
430
|
+
// vSwitch
|
|
431
|
+
// =========================================================================
|
|
432
|
+
async listVSwitches() {
|
|
433
|
+
return await this.request("/vswitch");
|
|
434
|
+
}
|
|
435
|
+
async getVSwitch(id) {
|
|
436
|
+
return await this.request(`/vswitch/${id}`);
|
|
437
|
+
}
|
|
438
|
+
async createVSwitch(name, vlan) {
|
|
439
|
+
return await this.request("/vswitch", {
|
|
440
|
+
method: "POST",
|
|
441
|
+
body: this.encodeParams({ name, vlan }),
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
async updateVSwitch(id, name, vlan) {
|
|
445
|
+
const params = {};
|
|
446
|
+
if (name) {
|
|
447
|
+
params.name = name;
|
|
448
|
+
}
|
|
449
|
+
if (vlan !== undefined) {
|
|
450
|
+
params.vlan = vlan;
|
|
451
|
+
}
|
|
452
|
+
await this.request(`/vswitch/${id}`, {
|
|
453
|
+
method: "POST",
|
|
454
|
+
body: this.encodeParams(params),
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
async deleteVSwitch(id, cancellationDate) {
|
|
458
|
+
const params = {};
|
|
459
|
+
if (cancellationDate) {
|
|
460
|
+
params.cancellation_date = cancellationDate;
|
|
461
|
+
}
|
|
462
|
+
await this.request(`/vswitch/${id}`, {
|
|
463
|
+
method: "DELETE",
|
|
464
|
+
body: this.encodeParams(params),
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
async addServerToVSwitch(vswitchId, serverIpOrNumber) {
|
|
468
|
+
await this.request(`/vswitch/${vswitchId}/server`, {
|
|
469
|
+
method: "POST",
|
|
470
|
+
body: this.encodeParams({ server: String(serverIpOrNumber) }),
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
async removeServerFromVSwitch(vswitchId, serverIpOrNumber) {
|
|
474
|
+
await this.request(`/vswitch/${vswitchId}/server`, {
|
|
475
|
+
method: "DELETE",
|
|
476
|
+
body: this.encodeParams({ server: String(serverIpOrNumber) }),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
// =========================================================================
|
|
480
|
+
// Storage Box
|
|
481
|
+
// =========================================================================
|
|
482
|
+
async listStorageBoxes() {
|
|
483
|
+
return await this.request("/storagebox");
|
|
484
|
+
}
|
|
485
|
+
async getStorageBox(id) {
|
|
486
|
+
return await this.request(`/storagebox/${id}`);
|
|
487
|
+
}
|
|
488
|
+
async updateStorageBox(id, name, webdav, samba, ssh, externalReachability, zfs) {
|
|
489
|
+
const params = {};
|
|
490
|
+
if (name) {
|
|
491
|
+
params.storagebox_name = name;
|
|
492
|
+
}
|
|
493
|
+
if (webdav !== undefined) {
|
|
494
|
+
params.webdav = webdav;
|
|
495
|
+
}
|
|
496
|
+
if (samba !== undefined) {
|
|
497
|
+
params.samba = samba;
|
|
498
|
+
}
|
|
499
|
+
if (ssh !== undefined) {
|
|
500
|
+
params.ssh = ssh;
|
|
501
|
+
}
|
|
502
|
+
if (externalReachability !== undefined) {
|
|
503
|
+
params.external_reachability = externalReachability;
|
|
504
|
+
}
|
|
505
|
+
if (zfs !== undefined) {
|
|
506
|
+
params.zfs = zfs;
|
|
507
|
+
}
|
|
508
|
+
return await this.request(`/storagebox/${id}`, {
|
|
509
|
+
method: "POST",
|
|
510
|
+
body: this.encodeParams(params),
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
async resetStorageBoxPassword(id) {
|
|
514
|
+
return await this.request(`/storagebox/${id}/password`, {
|
|
515
|
+
method: "POST",
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
// Snapshots
|
|
519
|
+
async listStorageBoxSnapshots(id) {
|
|
520
|
+
return await this.request(`/storagebox/${id}/snapshot`);
|
|
521
|
+
}
|
|
522
|
+
async createStorageBoxSnapshot(id) {
|
|
523
|
+
return await this.request(`/storagebox/${id}/snapshot`, {
|
|
524
|
+
method: "POST",
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
async deleteStorageBoxSnapshot(id, snapshotName) {
|
|
528
|
+
await this.request(`/storagebox/${id}/snapshot/${snapshotName}`, {
|
|
529
|
+
method: "DELETE",
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
async revertStorageBoxSnapshot(id, snapshotName) {
|
|
533
|
+
await this.request(`/storagebox/${id}/snapshot/${snapshotName}/revert`, {
|
|
534
|
+
method: "POST",
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
// Snapshot Plan
|
|
538
|
+
async getStorageBoxSnapshotPlan(id) {
|
|
539
|
+
return await this.request(`/storagebox/${id}/snapshotplan`);
|
|
540
|
+
}
|
|
541
|
+
async updateStorageBoxSnapshotPlan(id, status, minute, hour, dayOfWeek, dayOfMonth, maxSnapshots) {
|
|
542
|
+
const params = { status };
|
|
543
|
+
if (minute !== undefined) {
|
|
544
|
+
params.minute = minute;
|
|
545
|
+
}
|
|
546
|
+
if (hour !== undefined) {
|
|
547
|
+
params.hour = hour;
|
|
548
|
+
}
|
|
549
|
+
if (dayOfWeek !== undefined) {
|
|
550
|
+
params.day_of_week = dayOfWeek;
|
|
551
|
+
}
|
|
552
|
+
if (dayOfMonth !== undefined) {
|
|
553
|
+
params.day_of_month = dayOfMonth;
|
|
554
|
+
}
|
|
555
|
+
if (maxSnapshots !== undefined) {
|
|
556
|
+
params.max_snapshots = maxSnapshots;
|
|
557
|
+
}
|
|
558
|
+
return await this.request(`/storagebox/${id}/snapshotplan`, {
|
|
559
|
+
method: "POST",
|
|
560
|
+
body: this.encodeParams(params),
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
// Subaccounts
|
|
564
|
+
async listStorageBoxSubaccounts(id) {
|
|
565
|
+
return await this.request(`/storagebox/${id}/subaccount`);
|
|
566
|
+
}
|
|
567
|
+
async createStorageBoxSubaccount(id, homedirectory, samba, ssh, externalReachability, webdav, readonly, comment) {
|
|
568
|
+
const params = {
|
|
569
|
+
homedirectory,
|
|
570
|
+
};
|
|
571
|
+
if (samba !== undefined) {
|
|
572
|
+
params.samba = samba;
|
|
573
|
+
}
|
|
574
|
+
if (ssh !== undefined) {
|
|
575
|
+
params.ssh = ssh;
|
|
576
|
+
}
|
|
577
|
+
if (externalReachability !== undefined) {
|
|
578
|
+
params.external_reachability = externalReachability;
|
|
579
|
+
}
|
|
580
|
+
if (webdav !== undefined) {
|
|
581
|
+
params.webdav = webdav;
|
|
582
|
+
}
|
|
583
|
+
if (readonly !== undefined) {
|
|
584
|
+
params.readonly = readonly;
|
|
585
|
+
}
|
|
586
|
+
if (comment) {
|
|
587
|
+
params.comment = comment;
|
|
588
|
+
}
|
|
589
|
+
return await this.request(`/storagebox/${id}/subaccount`, {
|
|
590
|
+
method: "POST",
|
|
591
|
+
body: this.encodeParams(params),
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
async updateStorageBoxSubaccount(id, username, samba, ssh, externalReachability, webdav, readonly, comment) {
|
|
595
|
+
const params = {};
|
|
596
|
+
if (samba !== undefined) {
|
|
597
|
+
params.samba = samba;
|
|
598
|
+
}
|
|
599
|
+
if (ssh !== undefined) {
|
|
600
|
+
params.ssh = ssh;
|
|
601
|
+
}
|
|
602
|
+
if (externalReachability !== undefined) {
|
|
603
|
+
params.external_reachability = externalReachability;
|
|
604
|
+
}
|
|
605
|
+
if (webdav !== undefined) {
|
|
606
|
+
params.webdav = webdav;
|
|
607
|
+
}
|
|
608
|
+
if (readonly !== undefined) {
|
|
609
|
+
params.readonly = readonly;
|
|
610
|
+
}
|
|
611
|
+
if (comment !== undefined) {
|
|
612
|
+
params.comment = comment;
|
|
613
|
+
}
|
|
614
|
+
return await this.request(`/storagebox/${id}/subaccount/${username}`, {
|
|
615
|
+
method: "PUT",
|
|
616
|
+
body: this.encodeParams(params),
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
async deleteStorageBoxSubaccount(id, username) {
|
|
620
|
+
await this.request(`/storagebox/${id}/subaccount/${username}`, {
|
|
621
|
+
method: "DELETE",
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
async resetStorageBoxSubaccountPassword(id, username) {
|
|
625
|
+
return await this.request(`/storagebox/${id}/subaccount/${username}/password`, {
|
|
626
|
+
method: "POST",
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
// =========================================================================
|
|
630
|
+
// Traffic
|
|
631
|
+
// =========================================================================
|
|
632
|
+
async getTraffic(ips, subnets, from, to, type = "month") {
|
|
633
|
+
const params = {
|
|
634
|
+
type,
|
|
635
|
+
from,
|
|
636
|
+
to,
|
|
637
|
+
};
|
|
638
|
+
if (ips.length > 0) {
|
|
639
|
+
params.ip = ips;
|
|
640
|
+
}
|
|
641
|
+
if (subnets.length > 0) {
|
|
642
|
+
params.subnet = subnets;
|
|
643
|
+
}
|
|
644
|
+
return await this.request("/traffic", {
|
|
645
|
+
method: "POST",
|
|
646
|
+
body: this.encodeParams(params),
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
// =========================================================================
|
|
650
|
+
// Wake on LAN
|
|
651
|
+
// =========================================================================
|
|
652
|
+
async getWol(serverIpOrNumber) {
|
|
653
|
+
return await this.request(`/wol/${serverIpOrNumber}`);
|
|
654
|
+
}
|
|
655
|
+
async sendWol(serverIpOrNumber) {
|
|
656
|
+
return await this.request(`/wol/${serverIpOrNumber}`, {
|
|
657
|
+
method: "POST",
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
// =========================================================================
|
|
661
|
+
// Server Ordering
|
|
662
|
+
// =========================================================================
|
|
663
|
+
async listServerProducts() {
|
|
664
|
+
return await this.request("/order/server/product");
|
|
665
|
+
}
|
|
666
|
+
async listServerMarketProducts() {
|
|
667
|
+
return await this.request("/order/server_market/product");
|
|
668
|
+
}
|
|
669
|
+
async listServerTransactions() {
|
|
670
|
+
return await this.request("/order/server/transaction");
|
|
671
|
+
}
|
|
672
|
+
async getServerTransaction(transactionId) {
|
|
673
|
+
return await this.request(`/order/server/transaction/${transactionId}`);
|
|
674
|
+
}
|
|
675
|
+
async orderServer(productId, authorizedKeys, password, dist, arch, lang, location, addons, test) {
|
|
676
|
+
const params = this.buildOrderParams(productId, authorizedKeys, password, dist, arch, lang, addons, test);
|
|
677
|
+
if (location) {
|
|
678
|
+
params.location = location;
|
|
679
|
+
}
|
|
680
|
+
return await this.request("/order/server/transaction", {
|
|
681
|
+
method: "POST",
|
|
682
|
+
body: this.encodeParams(params),
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
async orderServerMarket(productId, authorizedKeys, password, dist, arch, lang, addons, test) {
|
|
686
|
+
const params = this.buildOrderParams(productId, authorizedKeys, password, dist, arch, lang, addons, test);
|
|
687
|
+
return await this.request("/order/server_market/transaction", {
|
|
688
|
+
method: "POST",
|
|
689
|
+
body: this.encodeParams(params),
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
buildOrderParams(productId, authorizedKeys, password, dist, arch, lang, addons, test) {
|
|
693
|
+
const params = {
|
|
694
|
+
product_id: productId,
|
|
695
|
+
};
|
|
696
|
+
if (authorizedKeys) {
|
|
697
|
+
params.authorized_key = authorizedKeys;
|
|
698
|
+
}
|
|
699
|
+
if (password) {
|
|
700
|
+
params.password = password;
|
|
701
|
+
}
|
|
702
|
+
if (dist) {
|
|
703
|
+
params.dist = dist;
|
|
704
|
+
}
|
|
705
|
+
if (arch) {
|
|
706
|
+
params.arch = arch;
|
|
707
|
+
}
|
|
708
|
+
if (lang) {
|
|
709
|
+
params.lang = lang;
|
|
710
|
+
}
|
|
711
|
+
if (addons) {
|
|
712
|
+
params.addon = addons;
|
|
713
|
+
}
|
|
714
|
+
if (test !== undefined) {
|
|
715
|
+
params.test = test;
|
|
716
|
+
}
|
|
717
|
+
return params;
|
|
718
|
+
}
|
|
719
|
+
}
|