@nilovonjs/hcloud-js 1.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/README.md +90 -0
- package/package.json +70 -0
- package/src/apis/actions/index.ts +113 -0
- package/src/apis/actions/schemas.ts +59 -0
- package/src/apis/actions/types.ts +77 -0
- package/src/apis/certificates/index.ts +326 -0
- package/src/apis/certificates/schemas.ts +140 -0
- package/src/apis/certificates/types.ts +176 -0
- package/src/apis/common/schemas.ts +19 -0
- package/src/apis/dns/index.ts +961 -0
- package/src/apis/dns/schemas.ts +437 -0
- package/src/apis/dns/types.ts +397 -0
- package/src/apis/firewalls/index.ts +469 -0
- package/src/apis/firewalls/schemas.ts +274 -0
- package/src/apis/firewalls/types.ts +205 -0
- package/src/apis/floating-ips/index.ts +466 -0
- package/src/apis/floating-ips/schemas.ts +203 -0
- package/src/apis/floating-ips/types.ts +207 -0
- package/src/apis/images/index.ts +195 -0
- package/src/apis/images/schemas.ts +113 -0
- package/src/apis/images/types.ts +124 -0
- package/src/apis/isos/index.ts +91 -0
- package/src/apis/isos/schemas.ts +43 -0
- package/src/apis/isos/types.ts +60 -0
- package/src/apis/load-balancers/index.ts +892 -0
- package/src/apis/load-balancers/schemas.ts +561 -0
- package/src/apis/load-balancers/types.ts +361 -0
- package/src/apis/locations/index.ts +176 -0
- package/src/apis/locations/schemas.ts +83 -0
- package/src/apis/locations/types.ts +113 -0
- package/src/apis/networks/index.ts +544 -0
- package/src/apis/networks/schemas.ts +279 -0
- package/src/apis/networks/types.ts +243 -0
- package/src/apis/placement-groups/index.ts +212 -0
- package/src/apis/placement-groups/schemas.ts +90 -0
- package/src/apis/placement-groups/types.ts +99 -0
- package/src/apis/pricing/index.ts +42 -0
- package/src/apis/pricing/schemas.ts +93 -0
- package/src/apis/pricing/types.ts +71 -0
- package/src/apis/primary-ips/index.ts +467 -0
- package/src/apis/primary-ips/schemas.ts +221 -0
- package/src/apis/primary-ips/types.ts +221 -0
- package/src/apis/server-types/index.ts +93 -0
- package/src/apis/server-types/schemas.ts +29 -0
- package/src/apis/server-types/types.ts +43 -0
- package/src/apis/servers/index.ts +378 -0
- package/src/apis/servers/schemas.ts +771 -0
- package/src/apis/servers/types.ts +538 -0
- package/src/apis/ssh-keys/index.ts +204 -0
- package/src/apis/ssh-keys/schemas.ts +84 -0
- package/src/apis/ssh-keys/types.ts +106 -0
- package/src/apis/volumes/index.ts +452 -0
- package/src/apis/volumes/schemas.ts +195 -0
- package/src/apis/volumes/types.ts +197 -0
- package/src/auth/index.ts +26 -0
- package/src/base/index.ts +10 -0
- package/src/client/index.ts +388 -0
- package/src/config/index.ts +34 -0
- package/src/errors/index.ts +38 -0
- package/src/index.ts +799 -0
- package/src/types/index.ts +37 -0
- package/src/validation/index.ts +109 -0
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hetzner Cloud Load Balancers API
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { HCloudClient } from "@/client/index";
|
|
7
|
+
import type {
|
|
8
|
+
ListLoadBalancersParams,
|
|
9
|
+
ListLoadBalancersResponse,
|
|
10
|
+
CreateLoadBalancerParams,
|
|
11
|
+
CreateLoadBalancerResponse,
|
|
12
|
+
GetLoadBalancerResponse,
|
|
13
|
+
UpdateLoadBalancerParams,
|
|
14
|
+
UpdateLoadBalancerResponse,
|
|
15
|
+
DeleteLoadBalancerResponse,
|
|
16
|
+
ListLoadBalancerActionsParams,
|
|
17
|
+
ListLoadBalancerActionsResponse,
|
|
18
|
+
GetLoadBalancerActionResponse,
|
|
19
|
+
AddLoadBalancerServiceParams,
|
|
20
|
+
AddLoadBalancerServiceResponse,
|
|
21
|
+
UpdateLoadBalancerServiceParams,
|
|
22
|
+
UpdateLoadBalancerServiceResponse,
|
|
23
|
+
DeleteLoadBalancerServiceResponse,
|
|
24
|
+
AddLoadBalancerTargetParams,
|
|
25
|
+
AddLoadBalancerTargetResponse,
|
|
26
|
+
RemoveLoadBalancerTargetParams,
|
|
27
|
+
RemoveLoadBalancerTargetResponse,
|
|
28
|
+
ChangeLoadBalancerAlgorithmParams,
|
|
29
|
+
ChangeLoadBalancerAlgorithmResponse,
|
|
30
|
+
ChangeLoadBalancerReverseDNSParams,
|
|
31
|
+
ChangeLoadBalancerReverseDNSResponse,
|
|
32
|
+
ChangeLoadBalancerProtectionParams,
|
|
33
|
+
ChangeLoadBalancerProtectionResponse,
|
|
34
|
+
ChangeLoadBalancerTypeParams,
|
|
35
|
+
ChangeLoadBalancerTypeResponse,
|
|
36
|
+
AttachLoadBalancerToNetworkParams,
|
|
37
|
+
AttachLoadBalancerToNetworkResponse,
|
|
38
|
+
DetachLoadBalancerFromNetworkResponse,
|
|
39
|
+
EnableLoadBalancerPublicInterfaceResponse,
|
|
40
|
+
DisableLoadBalancerPublicInterfaceResponse,
|
|
41
|
+
GetLoadBalancerMetricsParams,
|
|
42
|
+
GetLoadBalancerMetricsResponse,
|
|
43
|
+
} from "@/apis/load-balancers/types";
|
|
44
|
+
import { validate } from "@/validation/index";
|
|
45
|
+
import {
|
|
46
|
+
listLoadBalancersResponseSchema,
|
|
47
|
+
createLoadBalancerRequestSchema,
|
|
48
|
+
createLoadBalancerResponseSchema,
|
|
49
|
+
getLoadBalancerResponseSchema,
|
|
50
|
+
updateLoadBalancerRequestSchema,
|
|
51
|
+
updateLoadBalancerResponseSchema,
|
|
52
|
+
deleteLoadBalancerResponseSchema,
|
|
53
|
+
listLoadBalancerActionsResponseSchema,
|
|
54
|
+
getLoadBalancerActionResponseSchema,
|
|
55
|
+
addLoadBalancerServiceRequestSchema,
|
|
56
|
+
addLoadBalancerServiceResponseSchema,
|
|
57
|
+
updateLoadBalancerServiceRequestSchema,
|
|
58
|
+
updateLoadBalancerServiceResponseSchema,
|
|
59
|
+
deleteLoadBalancerServiceRequestSchema,
|
|
60
|
+
deleteLoadBalancerServiceResponseSchema,
|
|
61
|
+
addLoadBalancerTargetRequestSchema,
|
|
62
|
+
addLoadBalancerTargetResponseSchema,
|
|
63
|
+
removeLoadBalancerTargetRequestSchema,
|
|
64
|
+
removeLoadBalancerTargetResponseSchema,
|
|
65
|
+
changeLoadBalancerAlgorithmRequestSchema,
|
|
66
|
+
changeLoadBalancerAlgorithmResponseSchema,
|
|
67
|
+
changeLoadBalancerReverseDNSRequestSchema,
|
|
68
|
+
changeLoadBalancerReverseDNSResponseSchema,
|
|
69
|
+
changeLoadBalancerProtectionRequestSchema,
|
|
70
|
+
changeLoadBalancerProtectionResponseSchema,
|
|
71
|
+
changeLoadBalancerTypeRequestSchema,
|
|
72
|
+
changeLoadBalancerTypeResponseSchema,
|
|
73
|
+
attachLoadBalancerToNetworkRequestSchema,
|
|
74
|
+
attachLoadBalancerToNetworkResponseSchema,
|
|
75
|
+
detachLoadBalancerFromNetworkRequestSchema,
|
|
76
|
+
detachLoadBalancerFromNetworkResponseSchema,
|
|
77
|
+
enableLoadBalancerPublicInterfaceRequestSchema,
|
|
78
|
+
enableLoadBalancerPublicInterfaceResponseSchema,
|
|
79
|
+
disableLoadBalancerPublicInterfaceRequestSchema,
|
|
80
|
+
disableLoadBalancerPublicInterfaceResponseSchema,
|
|
81
|
+
getLoadBalancerMetricsRequestSchema,
|
|
82
|
+
getLoadBalancerMetricsResponseSchema,
|
|
83
|
+
} from "@/apis/load-balancers/schemas";
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Load Balancers API client
|
|
87
|
+
*/
|
|
88
|
+
export class LoadBalancersClient {
|
|
89
|
+
constructor(private readonly client: HCloudClient) {}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns all Load Balancer objects.
|
|
93
|
+
*
|
|
94
|
+
* @param params - Query parameters for filtering and pagination
|
|
95
|
+
* @returns Promise resolving to list of load balancers with pagination metadata
|
|
96
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-list-load-balancers
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
101
|
+
*
|
|
102
|
+
* // List all load balancers
|
|
103
|
+
* const result = await client.loadBalancers.list();
|
|
104
|
+
*
|
|
105
|
+
* // List load balancers with filters
|
|
106
|
+
* const loadBalancers = await client.loadBalancers.list({
|
|
107
|
+
* name: 'my-lb',
|
|
108
|
+
* label_selector: 'environment=production',
|
|
109
|
+
* sort: ['name:asc'],
|
|
110
|
+
* page: 1,
|
|
111
|
+
* per_page: 50
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
async list(params?: ListLoadBalancersParams): Promise<ListLoadBalancersResponse> {
|
|
116
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
117
|
+
|
|
118
|
+
if (params?.name) {
|
|
119
|
+
queryParams.name = params.name;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (params?.label_selector) {
|
|
123
|
+
queryParams.label_selector = params.label_selector;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (params?.sort) {
|
|
127
|
+
queryParams.sort = Array.isArray(params.sort) ? params.sort : [params.sort];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (params?.page !== undefined) {
|
|
131
|
+
queryParams.page = params.page;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (params?.per_page !== undefined) {
|
|
135
|
+
queryParams.per_page = params.per_page;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const response = await this.client.get<unknown>("/load_balancers", queryParams);
|
|
139
|
+
|
|
140
|
+
return validate(listLoadBalancersResponseSchema, response, {
|
|
141
|
+
context: "List load balancers response",
|
|
142
|
+
detailed: true,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Creates a new Load Balancer.
|
|
148
|
+
*
|
|
149
|
+
* @param params - Parameters for creating the load balancer
|
|
150
|
+
* @returns Promise resolving to the created load balancer and action
|
|
151
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-create-a-load-balancer
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
156
|
+
*
|
|
157
|
+
* // Create a load balancer
|
|
158
|
+
* const lb = await client.loadBalancers.create({
|
|
159
|
+
* name: 'my-lb',
|
|
160
|
+
* load_balancer_type: 'lb11',
|
|
161
|
+
* location: 'nbg1',
|
|
162
|
+
* algorithm: { type: 'round_robin' },
|
|
163
|
+
* services: [{
|
|
164
|
+
* protocol: 'http',
|
|
165
|
+
* listen_port: 80,
|
|
166
|
+
* destination_port: 80,
|
|
167
|
+
* proxyprotocol: false,
|
|
168
|
+
* health_check: {
|
|
169
|
+
* protocol: 'http',
|
|
170
|
+
* port: 80,
|
|
171
|
+
* interval: 15,
|
|
172
|
+
* timeout: 10,
|
|
173
|
+
* retries: 3,
|
|
174
|
+
* http: {
|
|
175
|
+
* domain: null,
|
|
176
|
+
* path: '/',
|
|
177
|
+
* response: null,
|
|
178
|
+
* status_codes: null
|
|
179
|
+
* }
|
|
180
|
+
* }
|
|
181
|
+
* }]
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
async create(params: CreateLoadBalancerParams): Promise<CreateLoadBalancerResponse> {
|
|
186
|
+
const validatedParams = validate(createLoadBalancerRequestSchema, params, {
|
|
187
|
+
context: "Create load balancer request",
|
|
188
|
+
detailed: true,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const response = await this.client.post<unknown>("/load_balancers", validatedParams);
|
|
192
|
+
|
|
193
|
+
return validate(createLoadBalancerResponseSchema, response, {
|
|
194
|
+
context: "Create load balancer response",
|
|
195
|
+
detailed: true,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Returns a specific Load Balancer object.
|
|
201
|
+
*
|
|
202
|
+
* @param id - ID of the Load Balancer
|
|
203
|
+
* @returns Promise resolving to the load balancer
|
|
204
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-get-a-load-balancer
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
209
|
+
*
|
|
210
|
+
* // Get a load balancer by ID
|
|
211
|
+
* const lb = await client.loadBalancers.get(12345);
|
|
212
|
+
* console.log(lb.load_balancer.name);
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
async get(id: number): Promise<GetLoadBalancerResponse> {
|
|
216
|
+
const response = await this.client.get<unknown>(`/load_balancers/${id}`);
|
|
217
|
+
|
|
218
|
+
return validate(getLoadBalancerResponseSchema, response, {
|
|
219
|
+
context: "Get load balancer response",
|
|
220
|
+
detailed: true,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Updates the Load Balancer.
|
|
226
|
+
*
|
|
227
|
+
* You can update a Load Balancer's name and labels.
|
|
228
|
+
*
|
|
229
|
+
* @param id - ID of the Load Balancer
|
|
230
|
+
* @param params - Parameters to update (name and/or labels)
|
|
231
|
+
* @returns Promise resolving to the updated load balancer
|
|
232
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-update-a-load-balancer
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
237
|
+
*
|
|
238
|
+
* // Update load balancer name
|
|
239
|
+
* const updated = await client.loadBalancers.update(12345, {
|
|
240
|
+
* name: 'new-lb-name'
|
|
241
|
+
* });
|
|
242
|
+
*
|
|
243
|
+
* // Update labels
|
|
244
|
+
* const updated = await client.loadBalancers.update(12345, {
|
|
245
|
+
* labels: { environment: 'production', team: 'backend' }
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
async update(
|
|
250
|
+
id: number,
|
|
251
|
+
params: UpdateLoadBalancerParams,
|
|
252
|
+
): Promise<UpdateLoadBalancerResponse> {
|
|
253
|
+
const validatedParams = validate(updateLoadBalancerRequestSchema, params, {
|
|
254
|
+
context: "Update load balancer request",
|
|
255
|
+
detailed: true,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const response = await this.client.put<unknown>(`/load_balancers/${id}`, validatedParams);
|
|
259
|
+
|
|
260
|
+
return validate(updateLoadBalancerResponseSchema, response, {
|
|
261
|
+
context: "Update load balancer response",
|
|
262
|
+
detailed: true,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Deletes a Load Balancer.
|
|
268
|
+
*
|
|
269
|
+
* @param id - ID of the Load Balancer
|
|
270
|
+
* @returns Promise resolving to the delete action
|
|
271
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-delete-a-load-balancer
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
276
|
+
*
|
|
277
|
+
* // Delete a load balancer
|
|
278
|
+
* const result = await client.loadBalancers.delete(12345);
|
|
279
|
+
* if (result.action) {
|
|
280
|
+
* console.log(`Delete action ID: ${result.action.id}`);
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
async delete(id: number): Promise<DeleteLoadBalancerResponse> {
|
|
285
|
+
const response = await this.client.delete<unknown>(`/load_balancers/${id}`);
|
|
286
|
+
|
|
287
|
+
return validate(deleteLoadBalancerResponseSchema, response, {
|
|
288
|
+
context: "Delete load balancer response",
|
|
289
|
+
detailed: true,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Returns all Action objects for a Load Balancer.
|
|
295
|
+
*
|
|
296
|
+
* @param id - ID of the Load Balancer
|
|
297
|
+
* @param params - Query parameters for filtering and pagination
|
|
298
|
+
* @returns Promise resolving to list of actions with pagination metadata
|
|
299
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-list-actions-for-a-load-balancer
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
304
|
+
*
|
|
305
|
+
* // List all actions for a load balancer
|
|
306
|
+
* const actions = await client.loadBalancers.listActions(12345);
|
|
307
|
+
*
|
|
308
|
+
* // List actions with filters
|
|
309
|
+
* const runningActions = await client.loadBalancers.listActions(12345, {
|
|
310
|
+
* status: ['running'],
|
|
311
|
+
* sort: ['started:desc']
|
|
312
|
+
* });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
async listActions(
|
|
316
|
+
id: number,
|
|
317
|
+
params?: ListLoadBalancerActionsParams,
|
|
318
|
+
): Promise<ListLoadBalancerActionsResponse> {
|
|
319
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
320
|
+
|
|
321
|
+
if (params?.sort) {
|
|
322
|
+
queryParams.sort = Array.isArray(params.sort) ? params.sort : [params.sort];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (params?.status) {
|
|
326
|
+
queryParams.status = Array.isArray(params.status) ? params.status : [params.status];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (params?.page !== undefined) {
|
|
330
|
+
queryParams.page = params.page;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (params?.per_page !== undefined) {
|
|
334
|
+
queryParams.per_page = params.per_page;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const response = await this.client.get<unknown>(`/load_balancers/${id}/actions`, queryParams);
|
|
338
|
+
|
|
339
|
+
return validate(listLoadBalancerActionsResponseSchema, response, {
|
|
340
|
+
context: "List load balancer actions response",
|
|
341
|
+
detailed: true,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Returns a specific Action object for a Load Balancer.
|
|
347
|
+
*
|
|
348
|
+
* @param id - ID of the Load Balancer
|
|
349
|
+
* @param actionId - ID of the Action
|
|
350
|
+
* @returns Promise resolving to the action
|
|
351
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-get-an-action-for-a-load-balancer
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
356
|
+
*
|
|
357
|
+
* // Get an action by ID
|
|
358
|
+
* const action = await client.loadBalancers.getAction(12345, 67890);
|
|
359
|
+
* console.log(action.action.command);
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
async getAction(id: number, actionId: number): Promise<GetLoadBalancerActionResponse> {
|
|
363
|
+
const response = await this.client.get<unknown>(`/load_balancers/${id}/actions/${actionId}`);
|
|
364
|
+
|
|
365
|
+
return validate(getLoadBalancerActionResponseSchema, response, {
|
|
366
|
+
context: "Get load balancer action response",
|
|
367
|
+
detailed: true,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Adds a service to a Load Balancer.
|
|
373
|
+
*
|
|
374
|
+
* @param id - ID of the Load Balancer
|
|
375
|
+
* @param params - Service configuration
|
|
376
|
+
* @returns Promise resolving to the action
|
|
377
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-add-service
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```typescript
|
|
381
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
382
|
+
*
|
|
383
|
+
* const result = await client.loadBalancers.addService(12345, {
|
|
384
|
+
* protocol: 'http',
|
|
385
|
+
* listen_port: 80,
|
|
386
|
+
* destination_port: 80,
|
|
387
|
+
* proxyprotocol: false,
|
|
388
|
+
* health_check: {
|
|
389
|
+
* protocol: 'http',
|
|
390
|
+
* port: 80,
|
|
391
|
+
* interval: 15,
|
|
392
|
+
* timeout: 10,
|
|
393
|
+
* retries: 3,
|
|
394
|
+
* http: {
|
|
395
|
+
* domain: null,
|
|
396
|
+
* path: '/',
|
|
397
|
+
* response: null,
|
|
398
|
+
* status_codes: null
|
|
399
|
+
* }
|
|
400
|
+
* }
|
|
401
|
+
* });
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
async addService(
|
|
405
|
+
id: number,
|
|
406
|
+
params: AddLoadBalancerServiceParams,
|
|
407
|
+
): Promise<AddLoadBalancerServiceResponse> {
|
|
408
|
+
const validatedParams = validate(addLoadBalancerServiceRequestSchema, params, {
|
|
409
|
+
context: "Add load balancer service request",
|
|
410
|
+
detailed: true,
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
const response = await this.client.post<unknown>(
|
|
414
|
+
`/load_balancers/${id}/actions/add_service`,
|
|
415
|
+
validatedParams,
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
return validate(addLoadBalancerServiceResponseSchema, response, {
|
|
419
|
+
context: "Add load balancer service response",
|
|
420
|
+
detailed: true,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Updates a service for a Load Balancer.
|
|
426
|
+
*
|
|
427
|
+
* @param id - ID of the Load Balancer
|
|
428
|
+
* @param listenPort - Listen port of the service to update
|
|
429
|
+
* @param params - Service configuration updates
|
|
430
|
+
* @returns Promise resolving to the action
|
|
431
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-update-service
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```typescript
|
|
435
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
436
|
+
*
|
|
437
|
+
* const result = await client.loadBalancers.updateService(12345, 80, {
|
|
438
|
+
* destination_port: 8080,
|
|
439
|
+
* http: {
|
|
440
|
+
* sticky_sessions: true,
|
|
441
|
+
* cookie_name: 'session'
|
|
442
|
+
* }
|
|
443
|
+
* });
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
async updateService(
|
|
447
|
+
id: number,
|
|
448
|
+
listenPort: number,
|
|
449
|
+
params: UpdateLoadBalancerServiceParams,
|
|
450
|
+
): Promise<UpdateLoadBalancerServiceResponse> {
|
|
451
|
+
const validatedParams = validate(updateLoadBalancerServiceRequestSchema, params, {
|
|
452
|
+
context: "Update load balancer service request",
|
|
453
|
+
detailed: true,
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
const response = await this.client.put<unknown>(
|
|
457
|
+
`/load_balancers/${id}/actions/update_service`,
|
|
458
|
+
{ listen_port: listenPort, ...validatedParams },
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
return validate(updateLoadBalancerServiceResponseSchema, response, {
|
|
462
|
+
context: "Update load balancer service response",
|
|
463
|
+
detailed: true,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Deletes a service from a Load Balancer.
|
|
469
|
+
*
|
|
470
|
+
* @param id - ID of the Load Balancer
|
|
471
|
+
* @param listenPort - Listen port of the service to delete
|
|
472
|
+
* @returns Promise resolving to the action
|
|
473
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-delete-service
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
478
|
+
*
|
|
479
|
+
* const result = await client.loadBalancers.deleteService(12345, 80);
|
|
480
|
+
* console.log(`Action ID: ${result.action.id}`);
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
async deleteService(
|
|
484
|
+
id: number,
|
|
485
|
+
listenPort: number,
|
|
486
|
+
): Promise<DeleteLoadBalancerServiceResponse> {
|
|
487
|
+
const response = await this.client.post<unknown>(
|
|
488
|
+
`/load_balancers/${id}/actions/delete_service`,
|
|
489
|
+
{ listen_port: listenPort },
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
return validate(deleteLoadBalancerServiceResponseSchema, response, {
|
|
493
|
+
context: "Delete load balancer service response",
|
|
494
|
+
detailed: true,
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Adds a target to a Load Balancer.
|
|
500
|
+
*
|
|
501
|
+
* @param id - ID of the Load Balancer
|
|
502
|
+
* @param params - Target configuration
|
|
503
|
+
* @returns Promise resolving to the action
|
|
504
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-add-target
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
509
|
+
*
|
|
510
|
+
* // Add a server target
|
|
511
|
+
* const result = await client.loadBalancers.addTarget(12345, {
|
|
512
|
+
* type: 'server',
|
|
513
|
+
* server: { id: 67890 }
|
|
514
|
+
* });
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
async addTarget(
|
|
518
|
+
id: number,
|
|
519
|
+
params: AddLoadBalancerTargetParams,
|
|
520
|
+
): Promise<AddLoadBalancerTargetResponse> {
|
|
521
|
+
const validatedParams = validate(addLoadBalancerTargetRequestSchema, params, {
|
|
522
|
+
context: "Add load balancer target request",
|
|
523
|
+
detailed: true,
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
const response = await this.client.post<unknown>(
|
|
527
|
+
`/load_balancers/${id}/actions/add_target`,
|
|
528
|
+
validatedParams,
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
return validate(addLoadBalancerTargetResponseSchema, response, {
|
|
532
|
+
context: "Add load balancer target response",
|
|
533
|
+
detailed: true,
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Removes a target from a Load Balancer.
|
|
539
|
+
*
|
|
540
|
+
* @param id - ID of the Load Balancer
|
|
541
|
+
* @param params - Target to remove
|
|
542
|
+
* @returns Promise resolving to the action
|
|
543
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-remove-target
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```typescript
|
|
547
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
548
|
+
*
|
|
549
|
+
* const result = await client.loadBalancers.removeTarget(12345, {
|
|
550
|
+
* type: 'server',
|
|
551
|
+
* server: { id: 67890 }
|
|
552
|
+
* });
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
async removeTarget(
|
|
556
|
+
id: number,
|
|
557
|
+
params: RemoveLoadBalancerTargetParams,
|
|
558
|
+
): Promise<RemoveLoadBalancerTargetResponse> {
|
|
559
|
+
const validatedParams = validate(removeLoadBalancerTargetRequestSchema, params, {
|
|
560
|
+
context: "Remove load balancer target request",
|
|
561
|
+
detailed: true,
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
const response = await this.client.post<unknown>(
|
|
565
|
+
`/load_balancers/${id}/actions/remove_target`,
|
|
566
|
+
validatedParams,
|
|
567
|
+
);
|
|
568
|
+
|
|
569
|
+
return validate(removeLoadBalancerTargetResponseSchema, response, {
|
|
570
|
+
context: "Remove load balancer target response",
|
|
571
|
+
detailed: true,
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Changes the algorithm of a Load Balancer.
|
|
577
|
+
*
|
|
578
|
+
* @param id - ID of the Load Balancer
|
|
579
|
+
* @param params - Algorithm configuration
|
|
580
|
+
* @returns Promise resolving to the action
|
|
581
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-algorithm
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```typescript
|
|
585
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
586
|
+
*
|
|
587
|
+
* const result = await client.loadBalancers.changeAlgorithm(12345, {
|
|
588
|
+
* type: 'least_connections'
|
|
589
|
+
* });
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
async changeAlgorithm(
|
|
593
|
+
id: number,
|
|
594
|
+
params: ChangeLoadBalancerAlgorithmParams,
|
|
595
|
+
): Promise<ChangeLoadBalancerAlgorithmResponse> {
|
|
596
|
+
const validatedParams = validate(changeLoadBalancerAlgorithmRequestSchema, params, {
|
|
597
|
+
context: "Change load balancer algorithm request",
|
|
598
|
+
detailed: true,
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
const response = await this.client.post<unknown>(
|
|
602
|
+
`/load_balancers/${id}/actions/change_algorithm`,
|
|
603
|
+
validatedParams,
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
return validate(changeLoadBalancerAlgorithmResponseSchema, response, {
|
|
607
|
+
context: "Change load balancer algorithm response",
|
|
608
|
+
detailed: true,
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Changes the reverse DNS entry for a Load Balancer.
|
|
614
|
+
*
|
|
615
|
+
* @param id - ID of the Load Balancer
|
|
616
|
+
* @param params - Reverse DNS configuration
|
|
617
|
+
* @returns Promise resolving to the action
|
|
618
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-reverse-dns-entry-for-this-load-balancer
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```typescript
|
|
622
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
623
|
+
*
|
|
624
|
+
* const result = await client.loadBalancers.changeReverseDNS(12345, {
|
|
625
|
+
* ip: '1.2.3.4',
|
|
626
|
+
* dns_ptr: 'lb.example.com'
|
|
627
|
+
* });
|
|
628
|
+
* ```
|
|
629
|
+
*/
|
|
630
|
+
async changeReverseDNS(
|
|
631
|
+
id: number,
|
|
632
|
+
params: ChangeLoadBalancerReverseDNSParams,
|
|
633
|
+
): Promise<ChangeLoadBalancerReverseDNSResponse> {
|
|
634
|
+
const validatedParams = validate(changeLoadBalancerReverseDNSRequestSchema, params, {
|
|
635
|
+
context: "Change load balancer reverse DNS request",
|
|
636
|
+
detailed: true,
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
const response = await this.client.post<unknown>(
|
|
640
|
+
`/load_balancers/${id}/actions/change_dns_ptr`,
|
|
641
|
+
validatedParams,
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
return validate(changeLoadBalancerReverseDNSResponseSchema, response, {
|
|
645
|
+
context: "Change load balancer reverse DNS response",
|
|
646
|
+
detailed: true,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Changes the Protection configuration of a Load Balancer.
|
|
652
|
+
*
|
|
653
|
+
* @param id - ID of the Load Balancer
|
|
654
|
+
* @param params - Protection configuration
|
|
655
|
+
* @returns Promise resolving to the action
|
|
656
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-load-balancer-protection
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```typescript
|
|
660
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
661
|
+
*
|
|
662
|
+
* const result = await client.loadBalancers.changeProtection(12345, {
|
|
663
|
+
* delete: true
|
|
664
|
+
* });
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
667
|
+
async changeProtection(
|
|
668
|
+
id: number,
|
|
669
|
+
params: ChangeLoadBalancerProtectionParams,
|
|
670
|
+
): Promise<ChangeLoadBalancerProtectionResponse> {
|
|
671
|
+
const validatedParams = validate(changeLoadBalancerProtectionRequestSchema, params, {
|
|
672
|
+
context: "Change load balancer protection request",
|
|
673
|
+
detailed: true,
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
const response = await this.client.post<unknown>(
|
|
677
|
+
`/load_balancers/${id}/actions/change_protection`,
|
|
678
|
+
validatedParams,
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
return validate(changeLoadBalancerProtectionResponseSchema, response, {
|
|
682
|
+
context: "Change load balancer protection response",
|
|
683
|
+
detailed: true,
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Changes the type of a Load Balancer.
|
|
689
|
+
*
|
|
690
|
+
* @param id - ID of the Load Balancer
|
|
691
|
+
* @param params - New load balancer type
|
|
692
|
+
* @returns Promise resolving to the action
|
|
693
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-the-type-of-a-load-balancer
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* ```typescript
|
|
697
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
698
|
+
*
|
|
699
|
+
* const result = await client.loadBalancers.changeType(12345, {
|
|
700
|
+
* load_balancer_type: 'lb21'
|
|
701
|
+
* });
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
async changeType(
|
|
705
|
+
id: number,
|
|
706
|
+
params: ChangeLoadBalancerTypeParams,
|
|
707
|
+
): Promise<ChangeLoadBalancerTypeResponse> {
|
|
708
|
+
const validatedParams = validate(changeLoadBalancerTypeRequestSchema, params, {
|
|
709
|
+
context: "Change load balancer type request",
|
|
710
|
+
detailed: true,
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
const response = await this.client.post<unknown>(
|
|
714
|
+
`/load_balancers/${id}/actions/change_type`,
|
|
715
|
+
validatedParams,
|
|
716
|
+
);
|
|
717
|
+
|
|
718
|
+
return validate(changeLoadBalancerTypeResponseSchema, response, {
|
|
719
|
+
context: "Change load balancer type response",
|
|
720
|
+
detailed: true,
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Attaches a Load Balancer to a Network.
|
|
726
|
+
*
|
|
727
|
+
* @param id - ID of the Load Balancer
|
|
728
|
+
* @param params - Network configuration
|
|
729
|
+
* @returns Promise resolving to the action
|
|
730
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-attach-a-load-balancer-to-a-network
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
735
|
+
*
|
|
736
|
+
* const result = await client.loadBalancers.attachToNetwork(12345, {
|
|
737
|
+
* network: 67890
|
|
738
|
+
* });
|
|
739
|
+
* ```
|
|
740
|
+
*/
|
|
741
|
+
async attachToNetwork(
|
|
742
|
+
id: number,
|
|
743
|
+
params: AttachLoadBalancerToNetworkParams,
|
|
744
|
+
): Promise<AttachLoadBalancerToNetworkResponse> {
|
|
745
|
+
const validatedParams = validate(attachLoadBalancerToNetworkRequestSchema, params, {
|
|
746
|
+
context: "Attach load balancer to network request",
|
|
747
|
+
detailed: true,
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
const response = await this.client.post<unknown>(
|
|
751
|
+
`/load_balancers/${id}/actions/attach_to_network`,
|
|
752
|
+
validatedParams,
|
|
753
|
+
);
|
|
754
|
+
|
|
755
|
+
return validate(attachLoadBalancerToNetworkResponseSchema, response, {
|
|
756
|
+
context: "Attach load balancer to network response",
|
|
757
|
+
detailed: true,
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Detaches a Load Balancer from a Network.
|
|
763
|
+
*
|
|
764
|
+
* @param id - ID of the Load Balancer
|
|
765
|
+
* @param networkId - ID of the Network
|
|
766
|
+
* @returns Promise resolving to the action
|
|
767
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-detach-a-load-balancer-from-a-network
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```typescript
|
|
771
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
772
|
+
*
|
|
773
|
+
* const result = await client.loadBalancers.detachFromNetwork(12345, 67890);
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
async detachFromNetwork(
|
|
777
|
+
id: number,
|
|
778
|
+
networkId: number,
|
|
779
|
+
): Promise<DetachLoadBalancerFromNetworkResponse> {
|
|
780
|
+
const response = await this.client.post<unknown>(
|
|
781
|
+
`/load_balancers/${id}/actions/detach_from_network`,
|
|
782
|
+
{ network: networkId },
|
|
783
|
+
);
|
|
784
|
+
|
|
785
|
+
return validate(detachLoadBalancerFromNetworkResponseSchema, response, {
|
|
786
|
+
context: "Detach load balancer from network response",
|
|
787
|
+
detailed: true,
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Enables the public interface of a Load Balancer.
|
|
793
|
+
*
|
|
794
|
+
* @param id - ID of the Load Balancer
|
|
795
|
+
* @returns Promise resolving to the action
|
|
796
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-enable-the-public-interface-of-a-load-balancer
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* ```typescript
|
|
800
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
801
|
+
*
|
|
802
|
+
* const result = await client.loadBalancers.enablePublicInterface(12345);
|
|
803
|
+
* ```
|
|
804
|
+
*/
|
|
805
|
+
async enablePublicInterface(
|
|
806
|
+
id: number,
|
|
807
|
+
): Promise<EnableLoadBalancerPublicInterfaceResponse> {
|
|
808
|
+
const response = await this.client.post<unknown>(
|
|
809
|
+
`/load_balancers/${id}/actions/enable_public_interface`,
|
|
810
|
+
{},
|
|
811
|
+
);
|
|
812
|
+
|
|
813
|
+
return validate(enableLoadBalancerPublicInterfaceResponseSchema, response, {
|
|
814
|
+
context: "Enable load balancer public interface response",
|
|
815
|
+
detailed: true,
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Disables the public interface of a Load Balancer.
|
|
821
|
+
*
|
|
822
|
+
* @param id - ID of the Load Balancer
|
|
823
|
+
* @returns Promise resolving to the action
|
|
824
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-disable-the-public-interface-of-a-load-balancer
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* ```typescript
|
|
828
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
829
|
+
*
|
|
830
|
+
* const result = await client.loadBalancers.disablePublicInterface(12345);
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
async disablePublicInterface(
|
|
834
|
+
id: number,
|
|
835
|
+
): Promise<DisableLoadBalancerPublicInterfaceResponse> {
|
|
836
|
+
const response = await this.client.post<unknown>(
|
|
837
|
+
`/load_balancers/${id}/actions/disable_public_interface`,
|
|
838
|
+
{},
|
|
839
|
+
);
|
|
840
|
+
|
|
841
|
+
return validate(disableLoadBalancerPublicInterfaceResponseSchema, response, {
|
|
842
|
+
context: "Disable load balancer public interface response",
|
|
843
|
+
detailed: true,
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Gets metrics for a Load Balancer.
|
|
849
|
+
*
|
|
850
|
+
* @param id - ID of the Load Balancer
|
|
851
|
+
* @param params - Metrics query parameters
|
|
852
|
+
* @returns Promise resolving to the metrics
|
|
853
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-get-metrics-for-a-load-balancer
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```typescript
|
|
857
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
858
|
+
*
|
|
859
|
+
* const metrics = await client.loadBalancers.getMetrics(12345, {
|
|
860
|
+
* type: ['connections_per_second'],
|
|
861
|
+
* start: '2024-01-01T00:00:00Z',
|
|
862
|
+
* end: '2024-01-01T01:00:00Z',
|
|
863
|
+
* step: 60
|
|
864
|
+
* });
|
|
865
|
+
* ```
|
|
866
|
+
*/
|
|
867
|
+
async getMetrics(
|
|
868
|
+
id: number,
|
|
869
|
+
params: GetLoadBalancerMetricsParams,
|
|
870
|
+
): Promise<GetLoadBalancerMetricsResponse> {
|
|
871
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
872
|
+
|
|
873
|
+
if (params.type) {
|
|
874
|
+
const types = Array.isArray(params.type) ? params.type : [params.type];
|
|
875
|
+
queryParams.type = types;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
queryParams.start = params.start;
|
|
879
|
+
queryParams.end = params.end;
|
|
880
|
+
|
|
881
|
+
if (params.step !== undefined) {
|
|
882
|
+
queryParams.step = params.step;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
const response = await this.client.get<unknown>(`/load_balancers/${id}/metrics`, queryParams);
|
|
886
|
+
|
|
887
|
+
return validate(getLoadBalancerMetricsResponseSchema, response, {
|
|
888
|
+
context: "Get load balancer metrics response",
|
|
889
|
+
detailed: true,
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
}
|