@leaflow/sdk 0.0.0-dev.407.g035f1ea → 0.0.0-dev.410.gb8719fe
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/routes.d.ts +128 -0
- package/dist/routes.js +144 -0
- package/dist/swas-legacy/v1/generated/functions.d.ts +652 -0
- package/dist/swas-legacy/v1/generated/functions.js +438 -0
- package/dist/swas-legacy/v1/generated/models.d.ts +0 -0
- package/dist/swas-legacy/v1/generated/models.js +98 -0
- package/dist/swas-legacy/v1/generated/schemas.zod.d.ts +257 -0
- package/dist/swas-legacy/v1/generated/schemas.zod.js +288 -0
- package/dist/swas-legacy/v1/generated/validators/capabilities.zod.d.ts +16 -0
- package/dist/swas-legacy/v1/generated/validators/capabilities.zod.js +14 -0
- package/dist/swas-legacy/v1/generated/validators/console.zod.d.ts +16 -0
- package/dist/swas-legacy/v1/generated/validators/console.zod.js +16 -0
- package/dist/swas-legacy/v1/generated/validators/createInstanceConsoleHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/createInstanceConsoleHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/createInstanceFirewallRuleHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/createInstanceFirewallRuleHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/decimal.zod.d.ts +12 -0
- package/dist/swas-legacy/v1/generated/validators/decimal.zod.js +10 -0
- package/dist/swas-legacy/v1/generated/validators/deleteInstanceFirewallRuleHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/deleteInstanceFirewallRuleHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/error.zod.d.ts +21 -0
- package/dist/swas-legacy/v1/generated/validators/error.zod.js +19 -0
- package/dist/swas-legacy/v1/generated/validators/firewallRule.zod.d.ts +24 -0
- package/dist/swas-legacy/v1/generated/validators/firewallRule.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/firewallRuleList.zod.d.ts +29 -0
- package/dist/swas-legacy/v1/generated/validators/firewallRuleList.zod.js +14 -0
- package/dist/swas-legacy/v1/generated/validators/firewallWriteRequest.zod.d.ts +28 -0
- package/dist/swas-legacy/v1/generated/validators/firewallWriteRequest.zod.js +0 -0
- package/dist/swas-legacy/v1/generated/validators/generationRequest.zod.d.ts +13 -0
- package/dist/swas-legacy/v1/generated/validators/generationRequest.zod.js +11 -0
- package/dist/swas-legacy/v1/generated/validators/image.zod.d.ts +20 -0
- package/dist/swas-legacy/v1/generated/validators/image.zod.js +18 -0
- package/dist/swas-legacy/v1/generated/validators/imageList.zod.d.ts +24 -0
- package/dist/swas-legacy/v1/generated/validators/imageList.zod.js +14 -0
- package/dist/swas-legacy/v1/generated/validators/instance.zod.d.ts +82 -0
- package/dist/swas-legacy/v1/generated/validators/instance.zod.js +33 -0
- package/dist/swas-legacy/v1/generated/validators/instanceList.zod.d.ts +88 -0
- package/dist/swas-legacy/v1/generated/validators/instanceList.zod.js +14 -0
- package/dist/swas-legacy/v1/generated/validators/lastOperation.zod.d.ts +33 -0
- package/dist/swas-legacy/v1/generated/validators/lastOperation.zod.js +31 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceFirewallRulesParams.zod.d.ts +18 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceFirewallRulesParams.zod.js +24 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceMetricsParams.zod.d.ts +19 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceMetricsParams.zod.js +12 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceOperationsParams.zod.d.ts +18 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceOperationsParams.zod.js +24 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceReinstallImagesParams.zod.d.ts +18 -0
- package/dist/swas-legacy/v1/generated/validators/listInstanceReinstallImagesParams.zod.js +24 -0
- package/dist/swas-legacy/v1/generated/validators/listInstancesParams.zod.d.ts +18 -0
- package/dist/swas-legacy/v1/generated/validators/listInstancesParams.zod.js +20 -0
- package/dist/swas-legacy/v1/generated/validators/metricPoint.zod.d.ts +14 -0
- package/dist/swas-legacy/v1/generated/validators/metricPoint.zod.js +13 -0
- package/dist/swas-legacy/v1/generated/validators/metricSeries.zod.d.ts +30 -0
- package/dist/swas-legacy/v1/generated/validators/metricSeries.zod.js +23 -0
- package/dist/swas-legacy/v1/generated/validators/metrics.zod.d.ts +41 -0
- package/dist/swas-legacy/v1/generated/validators/metrics.zod.js +19 -0
- package/dist/swas-legacy/v1/generated/validators/operation.zod.d.ts +35 -0
- package/dist/swas-legacy/v1/generated/validators/operation.zod.js +33 -0
- package/dist/swas-legacy/v1/generated/validators/operationLogList.zod.d.ts +39 -0
- package/dist/swas-legacy/v1/generated/validators/operationLogList.zod.js +16 -0
- package/dist/swas-legacy/v1/generated/validators/pagination.zod.d.ts +18 -0
- package/dist/swas-legacy/v1/generated/validators/pagination.zod.js +18 -0
- package/dist/swas-legacy/v1/generated/validators/passwordRequest.zod.d.ts +17 -0
- package/dist/swas-legacy/v1/generated/validators/passwordRequest.zod.js +0 -0
- package/dist/swas-legacy/v1/generated/validators/rebootInstanceHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/rebootInstanceHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/reinstallInstanceHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/reinstallInstanceHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/reinstallRequest.zod.d.ts +17 -0
- package/dist/swas-legacy/v1/generated/validators/reinstallRequest.zod.js +19 -0
- package/dist/swas-legacy/v1/generated/validators/setInstancePasswordHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/setInstancePasswordHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/startInstanceHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/startInstanceHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/stopInstanceHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/stopInstanceHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/generated/validators/traffic.zod.d.ts +22 -0
- package/dist/swas-legacy/v1/generated/validators/traffic.zod.js +20 -0
- package/dist/swas-legacy/v1/generated/validators/updateInstanceFirewallRuleHeaders.zod.d.ts +15 -0
- package/dist/swas-legacy/v1/generated/validators/updateInstanceFirewallRuleHeaders.zod.js +17 -0
- package/dist/swas-legacy/v1/index.d.ts +3 -0
- package/dist/swas-legacy/v1/index.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
export const getListInstancesUrl = (params) => {
|
|
2
|
+
const normalizedParams = new URLSearchParams();
|
|
3
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
4
|
+
if (value !== undefined) {
|
|
5
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const stringifiedParams = normalizedParams.toString();
|
|
9
|
+
return stringifiedParams.length > 0
|
|
10
|
+
? `/api/v1/instances?${stringifiedParams}`
|
|
11
|
+
: `/api/v1/instances`;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @summary List instances
|
|
15
|
+
*/
|
|
16
|
+
export const listInstances = async (params, options, fetchFn) => {
|
|
17
|
+
const res = await (fetchFn ?? fetch)(getListInstancesUrl(params), {
|
|
18
|
+
...options,
|
|
19
|
+
method: "GET",
|
|
20
|
+
});
|
|
21
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
22
|
+
const data = body ? JSON.parse(body) : {};
|
|
23
|
+
return { data, status: res.status, headers: res.headers };
|
|
24
|
+
};
|
|
25
|
+
export const getGetInstanceUrl = (instanceId) => {
|
|
26
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}`;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @summary Get instance
|
|
30
|
+
*/
|
|
31
|
+
export const getInstance = async (instanceId, options, fetchFn) => {
|
|
32
|
+
const res = await (fetchFn ?? fetch)(getGetInstanceUrl(instanceId), {
|
|
33
|
+
...options,
|
|
34
|
+
method: "GET",
|
|
35
|
+
});
|
|
36
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
37
|
+
const data = body ? JSON.parse(body) : {};
|
|
38
|
+
return { data, status: res.status, headers: res.headers };
|
|
39
|
+
};
|
|
40
|
+
export const getStartInstanceUrl = (instanceId) => {
|
|
41
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/start`;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* @summary Start instance
|
|
45
|
+
*/
|
|
46
|
+
export const startInstance = async (instanceId, generationRequest, headers, options, fetchFn) => {
|
|
47
|
+
const getHeaders = (h) => {
|
|
48
|
+
if (!h)
|
|
49
|
+
return {};
|
|
50
|
+
if (h instanceof Headers)
|
|
51
|
+
return Object.fromEntries(h.entries());
|
|
52
|
+
if (Symbol.iterator in h) {
|
|
53
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
54
|
+
}
|
|
55
|
+
const headers = {};
|
|
56
|
+
for (const [name, value] of Object.entries(h)) {
|
|
57
|
+
if (value !== undefined)
|
|
58
|
+
headers[name] = value;
|
|
59
|
+
}
|
|
60
|
+
return headers;
|
|
61
|
+
};
|
|
62
|
+
const res = await (fetchFn ?? fetch)(getStartInstanceUrl(instanceId), {
|
|
63
|
+
...options,
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
66
|
+
body: JSON.stringify(generationRequest),
|
|
67
|
+
});
|
|
68
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
69
|
+
const data = body ? JSON.parse(body) : {};
|
|
70
|
+
return { data, status: res.status, headers: res.headers };
|
|
71
|
+
};
|
|
72
|
+
export const getStopInstanceUrl = (instanceId) => {
|
|
73
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/stop`;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* @summary Stop instance
|
|
77
|
+
*/
|
|
78
|
+
export const stopInstance = async (instanceId, generationRequest, headers, options, fetchFn) => {
|
|
79
|
+
const getHeaders = (h) => {
|
|
80
|
+
if (!h)
|
|
81
|
+
return {};
|
|
82
|
+
if (h instanceof Headers)
|
|
83
|
+
return Object.fromEntries(h.entries());
|
|
84
|
+
if (Symbol.iterator in h) {
|
|
85
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
86
|
+
}
|
|
87
|
+
const headers = {};
|
|
88
|
+
for (const [name, value] of Object.entries(h)) {
|
|
89
|
+
if (value !== undefined)
|
|
90
|
+
headers[name] = value;
|
|
91
|
+
}
|
|
92
|
+
return headers;
|
|
93
|
+
};
|
|
94
|
+
const res = await (fetchFn ?? fetch)(getStopInstanceUrl(instanceId), {
|
|
95
|
+
...options,
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
98
|
+
body: JSON.stringify(generationRequest),
|
|
99
|
+
});
|
|
100
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
101
|
+
const data = body ? JSON.parse(body) : {};
|
|
102
|
+
return { data, status: res.status, headers: res.headers };
|
|
103
|
+
};
|
|
104
|
+
export const getRebootInstanceUrl = (instanceId) => {
|
|
105
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/reboot`;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* @summary Reboot instance
|
|
109
|
+
*/
|
|
110
|
+
export const rebootInstance = async (instanceId, generationRequest, headers, options, fetchFn) => {
|
|
111
|
+
const getHeaders = (h) => {
|
|
112
|
+
if (!h)
|
|
113
|
+
return {};
|
|
114
|
+
if (h instanceof Headers)
|
|
115
|
+
return Object.fromEntries(h.entries());
|
|
116
|
+
if (Symbol.iterator in h) {
|
|
117
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
118
|
+
}
|
|
119
|
+
const headers = {};
|
|
120
|
+
for (const [name, value] of Object.entries(h)) {
|
|
121
|
+
if (value !== undefined)
|
|
122
|
+
headers[name] = value;
|
|
123
|
+
}
|
|
124
|
+
return headers;
|
|
125
|
+
};
|
|
126
|
+
const res = await (fetchFn ?? fetch)(getRebootInstanceUrl(instanceId), {
|
|
127
|
+
...options,
|
|
128
|
+
method: "POST",
|
|
129
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
130
|
+
body: JSON.stringify(generationRequest),
|
|
131
|
+
});
|
|
132
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
133
|
+
const data = body ? JSON.parse(body) : {};
|
|
134
|
+
return { data, status: res.status, headers: res.headers };
|
|
135
|
+
};
|
|
136
|
+
export const getListInstanceReinstallImagesUrl = (instanceId, params) => {
|
|
137
|
+
const normalizedParams = new URLSearchParams();
|
|
138
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
139
|
+
if (value !== undefined) {
|
|
140
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const stringifiedParams = normalizedParams.toString();
|
|
144
|
+
return stringifiedParams.length > 0
|
|
145
|
+
? `/api/v1/instances/${encodeURIComponent(String(instanceId))}/reinstall-images?${stringifiedParams}`
|
|
146
|
+
: `/api/v1/instances/${encodeURIComponent(String(instanceId))}/reinstall-images`;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* @summary List instance reinstall images
|
|
150
|
+
*/
|
|
151
|
+
export const listInstanceReinstallImages = async (instanceId, params, options, fetchFn) => {
|
|
152
|
+
const res = await (fetchFn ?? fetch)(getListInstanceReinstallImagesUrl(instanceId, params), {
|
|
153
|
+
...options,
|
|
154
|
+
method: "GET",
|
|
155
|
+
});
|
|
156
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
157
|
+
const data = body ? JSON.parse(body) : {};
|
|
158
|
+
return { data, status: res.status, headers: res.headers };
|
|
159
|
+
};
|
|
160
|
+
export const getReinstallInstanceUrl = (instanceId) => {
|
|
161
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/reinstall`;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* @summary Reinstall instance
|
|
165
|
+
*/
|
|
166
|
+
export const reinstallInstance = async (instanceId, reinstallRequest, headers, options, fetchFn) => {
|
|
167
|
+
const getHeaders = (h) => {
|
|
168
|
+
if (!h)
|
|
169
|
+
return {};
|
|
170
|
+
if (h instanceof Headers)
|
|
171
|
+
return Object.fromEntries(h.entries());
|
|
172
|
+
if (Symbol.iterator in h) {
|
|
173
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
174
|
+
}
|
|
175
|
+
const headers = {};
|
|
176
|
+
for (const [name, value] of Object.entries(h)) {
|
|
177
|
+
if (value !== undefined)
|
|
178
|
+
headers[name] = value;
|
|
179
|
+
}
|
|
180
|
+
return headers;
|
|
181
|
+
};
|
|
182
|
+
const res = await (fetchFn ?? fetch)(getReinstallInstanceUrl(instanceId), {
|
|
183
|
+
...options,
|
|
184
|
+
method: "POST",
|
|
185
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
186
|
+
body: JSON.stringify(reinstallRequest),
|
|
187
|
+
});
|
|
188
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
189
|
+
const data = body ? JSON.parse(body) : {};
|
|
190
|
+
return { data, status: res.status, headers: res.headers };
|
|
191
|
+
};
|
|
192
|
+
export const getSetInstancePasswordUrl = (instanceId) => {
|
|
193
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/password`;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* @summary Set instance password
|
|
197
|
+
*/
|
|
198
|
+
export const setInstancePassword = async (instanceId, passwordRequest, headers, options, fetchFn) => {
|
|
199
|
+
const getHeaders = (h) => {
|
|
200
|
+
if (!h)
|
|
201
|
+
return {};
|
|
202
|
+
if (h instanceof Headers)
|
|
203
|
+
return Object.fromEntries(h.entries());
|
|
204
|
+
if (Symbol.iterator in h) {
|
|
205
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
206
|
+
}
|
|
207
|
+
const headers = {};
|
|
208
|
+
for (const [name, value] of Object.entries(h)) {
|
|
209
|
+
if (value !== undefined)
|
|
210
|
+
headers[name] = value;
|
|
211
|
+
}
|
|
212
|
+
return headers;
|
|
213
|
+
};
|
|
214
|
+
const res = await (fetchFn ?? fetch)(getSetInstancePasswordUrl(instanceId), {
|
|
215
|
+
...options,
|
|
216
|
+
method: "POST",
|
|
217
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
218
|
+
body: JSON.stringify(passwordRequest),
|
|
219
|
+
});
|
|
220
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
221
|
+
const data = body ? JSON.parse(body) : {};
|
|
222
|
+
return { data, status: res.status, headers: res.headers };
|
|
223
|
+
};
|
|
224
|
+
export const getCreateInstanceConsoleUrl = (instanceId) => {
|
|
225
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/console`;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* @summary Create instance console
|
|
229
|
+
*/
|
|
230
|
+
export const createInstanceConsole = async (instanceId, generationRequest, headers, options, fetchFn) => {
|
|
231
|
+
const getHeaders = (h) => {
|
|
232
|
+
if (!h)
|
|
233
|
+
return {};
|
|
234
|
+
if (h instanceof Headers)
|
|
235
|
+
return Object.fromEntries(h.entries());
|
|
236
|
+
if (Symbol.iterator in h) {
|
|
237
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
238
|
+
}
|
|
239
|
+
const headers = {};
|
|
240
|
+
for (const [name, value] of Object.entries(h)) {
|
|
241
|
+
if (value !== undefined)
|
|
242
|
+
headers[name] = value;
|
|
243
|
+
}
|
|
244
|
+
return headers;
|
|
245
|
+
};
|
|
246
|
+
const res = await (fetchFn ?? fetch)(getCreateInstanceConsoleUrl(instanceId), {
|
|
247
|
+
...options,
|
|
248
|
+
method: "POST",
|
|
249
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
250
|
+
body: JSON.stringify(generationRequest),
|
|
251
|
+
});
|
|
252
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
253
|
+
const data = body ? JSON.parse(body) : {};
|
|
254
|
+
return { data, status: res.status, headers: res.headers };
|
|
255
|
+
};
|
|
256
|
+
export const getListInstanceMetricsUrl = (instanceId, params) => {
|
|
257
|
+
const normalizedParams = new URLSearchParams();
|
|
258
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
259
|
+
if (value !== undefined) {
|
|
260
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
const stringifiedParams = normalizedParams.toString();
|
|
264
|
+
return stringifiedParams.length > 0
|
|
265
|
+
? `/api/v1/instances/${encodeURIComponent(String(instanceId))}/metrics?${stringifiedParams}`
|
|
266
|
+
: `/api/v1/instances/${encodeURIComponent(String(instanceId))}/metrics`;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* @summary List instance metrics
|
|
270
|
+
*/
|
|
271
|
+
export const listInstanceMetrics = async (instanceId, params, options, fetchFn) => {
|
|
272
|
+
const res = await (fetchFn ?? fetch)(getListInstanceMetricsUrl(instanceId, params), {
|
|
273
|
+
...options,
|
|
274
|
+
method: "GET",
|
|
275
|
+
});
|
|
276
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
277
|
+
const data = body ? JSON.parse(body) : {};
|
|
278
|
+
return { data, status: res.status, headers: res.headers };
|
|
279
|
+
};
|
|
280
|
+
export const getGetInstanceTrafficUrl = (instanceId) => {
|
|
281
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/traffic`;
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* @summary Get instance traffic
|
|
285
|
+
*/
|
|
286
|
+
export const getInstanceTraffic = async (instanceId, options, fetchFn) => {
|
|
287
|
+
const res = await (fetchFn ?? fetch)(getGetInstanceTrafficUrl(instanceId), {
|
|
288
|
+
...options,
|
|
289
|
+
method: "GET",
|
|
290
|
+
});
|
|
291
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
292
|
+
const data = body ? JSON.parse(body) : {};
|
|
293
|
+
return { data, status: res.status, headers: res.headers };
|
|
294
|
+
};
|
|
295
|
+
export const getListInstanceFirewallRulesUrl = (instanceId, params) => {
|
|
296
|
+
const normalizedParams = new URLSearchParams();
|
|
297
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
298
|
+
if (value !== undefined) {
|
|
299
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
const stringifiedParams = normalizedParams.toString();
|
|
303
|
+
return stringifiedParams.length > 0
|
|
304
|
+
? `/api/v1/instances/${encodeURIComponent(String(instanceId))}/firewall-rules?${stringifiedParams}`
|
|
305
|
+
: `/api/v1/instances/${encodeURIComponent(String(instanceId))}/firewall-rules`;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* @summary List instance firewall rules
|
|
309
|
+
*/
|
|
310
|
+
export const listInstanceFirewallRules = async (instanceId, params, options, fetchFn) => {
|
|
311
|
+
const res = await (fetchFn ?? fetch)(getListInstanceFirewallRulesUrl(instanceId, params), {
|
|
312
|
+
...options,
|
|
313
|
+
method: "GET",
|
|
314
|
+
});
|
|
315
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
316
|
+
const data = body ? JSON.parse(body) : {};
|
|
317
|
+
return { data, status: res.status, headers: res.headers };
|
|
318
|
+
};
|
|
319
|
+
export const getCreateInstanceFirewallRuleUrl = (instanceId) => {
|
|
320
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/firewall-rules`;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* @summary Create instance firewall rule
|
|
324
|
+
*/
|
|
325
|
+
export const createInstanceFirewallRule = async (instanceId, firewallWriteRequest, headers, options, fetchFn) => {
|
|
326
|
+
const getHeaders = (h) => {
|
|
327
|
+
if (!h)
|
|
328
|
+
return {};
|
|
329
|
+
if (h instanceof Headers)
|
|
330
|
+
return Object.fromEntries(h.entries());
|
|
331
|
+
if (Symbol.iterator in h) {
|
|
332
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
333
|
+
}
|
|
334
|
+
const headers = {};
|
|
335
|
+
for (const [name, value] of Object.entries(h)) {
|
|
336
|
+
if (value !== undefined)
|
|
337
|
+
headers[name] = value;
|
|
338
|
+
}
|
|
339
|
+
return headers;
|
|
340
|
+
};
|
|
341
|
+
const res = await (fetchFn ?? fetch)(getCreateInstanceFirewallRuleUrl(instanceId), {
|
|
342
|
+
...options,
|
|
343
|
+
method: "POST",
|
|
344
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
345
|
+
body: JSON.stringify(firewallWriteRequest),
|
|
346
|
+
});
|
|
347
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
348
|
+
const data = body ? JSON.parse(body) : {};
|
|
349
|
+
return { data, status: res.status, headers: res.headers };
|
|
350
|
+
};
|
|
351
|
+
export const getUpdateInstanceFirewallRuleUrl = (instanceId, ruleId) => {
|
|
352
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/firewall-rules/${encodeURIComponent(String(ruleId))}`;
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* @summary Update instance firewall rule
|
|
356
|
+
*/
|
|
357
|
+
export const updateInstanceFirewallRule = async (instanceId, ruleId, firewallWriteRequest, headers, options, fetchFn) => {
|
|
358
|
+
const getHeaders = (h) => {
|
|
359
|
+
if (!h)
|
|
360
|
+
return {};
|
|
361
|
+
if (h instanceof Headers)
|
|
362
|
+
return Object.fromEntries(h.entries());
|
|
363
|
+
if (Symbol.iterator in h) {
|
|
364
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
365
|
+
}
|
|
366
|
+
const headers = {};
|
|
367
|
+
for (const [name, value] of Object.entries(h)) {
|
|
368
|
+
if (value !== undefined)
|
|
369
|
+
headers[name] = value;
|
|
370
|
+
}
|
|
371
|
+
return headers;
|
|
372
|
+
};
|
|
373
|
+
const res = await (fetchFn ?? fetch)(getUpdateInstanceFirewallRuleUrl(instanceId, ruleId), {
|
|
374
|
+
...options,
|
|
375
|
+
method: "PATCH",
|
|
376
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
377
|
+
body: JSON.stringify(firewallWriteRequest),
|
|
378
|
+
});
|
|
379
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
380
|
+
const data = body ? JSON.parse(body) : {};
|
|
381
|
+
return { data, status: res.status, headers: res.headers };
|
|
382
|
+
};
|
|
383
|
+
export const getDeleteInstanceFirewallRuleUrl = (instanceId, ruleId) => {
|
|
384
|
+
return `/api/v1/instances/${encodeURIComponent(String(instanceId))}/firewall-rules/${encodeURIComponent(String(ruleId))}`;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* @summary Delete instance firewall rule
|
|
388
|
+
*/
|
|
389
|
+
export const deleteInstanceFirewallRule = async (instanceId, ruleId, generationRequest, headers, options, fetchFn) => {
|
|
390
|
+
const getHeaders = (h) => {
|
|
391
|
+
if (!h)
|
|
392
|
+
return {};
|
|
393
|
+
if (h instanceof Headers)
|
|
394
|
+
return Object.fromEntries(h.entries());
|
|
395
|
+
if (Symbol.iterator in h) {
|
|
396
|
+
return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
397
|
+
}
|
|
398
|
+
const headers = {};
|
|
399
|
+
for (const [name, value] of Object.entries(h)) {
|
|
400
|
+
if (value !== undefined)
|
|
401
|
+
headers[name] = value;
|
|
402
|
+
}
|
|
403
|
+
return headers;
|
|
404
|
+
};
|
|
405
|
+
const res = await (fetchFn ?? fetch)(getDeleteInstanceFirewallRuleUrl(instanceId, ruleId), {
|
|
406
|
+
...options,
|
|
407
|
+
method: "DELETE",
|
|
408
|
+
headers: { "Content-Type": "application/json", ...headers, ...getHeaders(options?.headers) },
|
|
409
|
+
body: JSON.stringify(generationRequest),
|
|
410
|
+
});
|
|
411
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
412
|
+
const data = body ? JSON.parse(body) : {};
|
|
413
|
+
return { data, status: res.status, headers: res.headers };
|
|
414
|
+
};
|
|
415
|
+
export const getListInstanceOperationsUrl = (instanceId, params) => {
|
|
416
|
+
const normalizedParams = new URLSearchParams();
|
|
417
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
418
|
+
if (value !== undefined) {
|
|
419
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
const stringifiedParams = normalizedParams.toString();
|
|
423
|
+
return stringifiedParams.length > 0
|
|
424
|
+
? `/api/v1/instances/${encodeURIComponent(String(instanceId))}/operation-logs?${stringifiedParams}`
|
|
425
|
+
: `/api/v1/instances/${encodeURIComponent(String(instanceId))}/operation-logs`;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* @summary List instance operations
|
|
429
|
+
*/
|
|
430
|
+
export const listInstanceOperations = async (instanceId, params, options, fetchFn) => {
|
|
431
|
+
const res = await (fetchFn ?? fetch)(getListInstanceOperationsUrl(instanceId, params), {
|
|
432
|
+
...options,
|
|
433
|
+
method: "GET",
|
|
434
|
+
});
|
|
435
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
436
|
+
const data = body ? JSON.parse(body) : {};
|
|
437
|
+
return { data, status: res.status, headers: res.headers };
|
|
438
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const ErrorCode = {
|
|
2
|
+
TOKEN_INVALID: "TOKEN_INVALID",
|
|
3
|
+
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
4
|
+
INVALID_INPUT: "INVALID_INPUT",
|
|
5
|
+
NOT_FOUND: "NOT_FOUND",
|
|
6
|
+
CONFLICT: "CONFLICT",
|
|
7
|
+
DEPENDENCY_UNAVAILABLE: "DEPENDENCY_UNAVAILABLE",
|
|
8
|
+
};
|
|
9
|
+
export const OperationType = {
|
|
10
|
+
start: "start",
|
|
11
|
+
stop: "stop",
|
|
12
|
+
reboot: "reboot",
|
|
13
|
+
reinstall: "reinstall",
|
|
14
|
+
reset_password: "reset_password",
|
|
15
|
+
console: "console",
|
|
16
|
+
firewall_create: "firewall_create",
|
|
17
|
+
firewall_update: "firewall_update",
|
|
18
|
+
firewall_delete: "firewall_delete",
|
|
19
|
+
};
|
|
20
|
+
export const OperationState = {
|
|
21
|
+
running: "running",
|
|
22
|
+
needs_attention: "needs_attention",
|
|
23
|
+
succeeded: "succeeded",
|
|
24
|
+
failed: "failed",
|
|
25
|
+
};
|
|
26
|
+
export const LastOperationType = {
|
|
27
|
+
start: "start",
|
|
28
|
+
stop: "stop",
|
|
29
|
+
reboot: "reboot",
|
|
30
|
+
reinstall: "reinstall",
|
|
31
|
+
reset_password: "reset_password",
|
|
32
|
+
console: "console",
|
|
33
|
+
firewall_create: "firewall_create",
|
|
34
|
+
firewall_update: "firewall_update",
|
|
35
|
+
firewall_delete: "firewall_delete",
|
|
36
|
+
};
|
|
37
|
+
export const LastOperationResult = {
|
|
38
|
+
succeeded: "succeeded",
|
|
39
|
+
failed: "failed",
|
|
40
|
+
};
|
|
41
|
+
export const CapabilitiesValue = {
|
|
42
|
+
purchase: false,
|
|
43
|
+
renewal: false,
|
|
44
|
+
upgrade_order: false,
|
|
45
|
+
refund: false,
|
|
46
|
+
};
|
|
47
|
+
export const FirewallWriteRequestProtocol = {
|
|
48
|
+
tcp: "tcp",
|
|
49
|
+
udp: "udp",
|
|
50
|
+
tcp_udp: "tcp_udp",
|
|
51
|
+
icmp: "icmp",
|
|
52
|
+
};
|
|
53
|
+
export const FirewallRuleProtocol = {
|
|
54
|
+
tcp: "tcp",
|
|
55
|
+
udp: "udp",
|
|
56
|
+
tcp_udp: "tcp_udp",
|
|
57
|
+
icmp: "icmp",
|
|
58
|
+
};
|
|
59
|
+
export const MetricSeriesMetric = {
|
|
60
|
+
cpu: "cpu",
|
|
61
|
+
memory_used: "memory_used",
|
|
62
|
+
network_in: "network_in",
|
|
63
|
+
network_out: "network_out",
|
|
64
|
+
disk_read_iops: "disk_read_iops",
|
|
65
|
+
disk_write_iops: "disk_write_iops",
|
|
66
|
+
};
|
|
67
|
+
export const MetricSeriesAvailability = {
|
|
68
|
+
unavailable: "unavailable",
|
|
69
|
+
partial: "partial",
|
|
70
|
+
};
|
|
71
|
+
export const MetricsPeriod = {
|
|
72
|
+
"1h": "1h",
|
|
73
|
+
"6h": "6h",
|
|
74
|
+
"24h": "24h",
|
|
75
|
+
"7d": "7d",
|
|
76
|
+
};
|
|
77
|
+
export const TrafficAvailability = {
|
|
78
|
+
unavailable: "unavailable",
|
|
79
|
+
partial: "partial",
|
|
80
|
+
};
|
|
81
|
+
export const InstanceStatus = {
|
|
82
|
+
binding_pending: "binding_pending",
|
|
83
|
+
managed: "managed",
|
|
84
|
+
};
|
|
85
|
+
export const InstancePowerState = {
|
|
86
|
+
running: "running",
|
|
87
|
+
stopped: "stopped",
|
|
88
|
+
starting: "starting",
|
|
89
|
+
stopping: "stopping",
|
|
90
|
+
restarting: "restarting",
|
|
91
|
+
unknown: "unknown",
|
|
92
|
+
};
|
|
93
|
+
export const PeriodParameter = {
|
|
94
|
+
"1h": "1h",
|
|
95
|
+
"6h": "6h",
|
|
96
|
+
"24h": "24h",
|
|
97
|
+
"7d": "7d",
|
|
98
|
+
};
|