@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,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Hetzner Cloud Load Balancers API
|
|
3
|
+
* Types are inferred from Zod schemas
|
|
4
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// biome-ignore assist/source/organizeImports: we need to import the schemas first
|
|
8
|
+
import {
|
|
9
|
+
listLoadBalancersResponseSchema,
|
|
10
|
+
createLoadBalancerRequestSchema,
|
|
11
|
+
createLoadBalancerResponseSchema,
|
|
12
|
+
getLoadBalancerResponseSchema,
|
|
13
|
+
updateLoadBalancerRequestSchema,
|
|
14
|
+
updateLoadBalancerResponseSchema,
|
|
15
|
+
deleteLoadBalancerResponseSchema,
|
|
16
|
+
listLoadBalancerActionsResponseSchema,
|
|
17
|
+
getLoadBalancerActionResponseSchema,
|
|
18
|
+
addLoadBalancerServiceRequestSchema,
|
|
19
|
+
addLoadBalancerServiceResponseSchema,
|
|
20
|
+
updateLoadBalancerServiceRequestSchema,
|
|
21
|
+
updateLoadBalancerServiceResponseSchema,
|
|
22
|
+
deleteLoadBalancerServiceRequestSchema,
|
|
23
|
+
deleteLoadBalancerServiceResponseSchema,
|
|
24
|
+
addLoadBalancerTargetRequestSchema,
|
|
25
|
+
addLoadBalancerTargetResponseSchema,
|
|
26
|
+
removeLoadBalancerTargetRequestSchema,
|
|
27
|
+
removeLoadBalancerTargetResponseSchema,
|
|
28
|
+
changeLoadBalancerAlgorithmRequestSchema,
|
|
29
|
+
changeLoadBalancerAlgorithmResponseSchema,
|
|
30
|
+
changeLoadBalancerReverseDNSRequestSchema,
|
|
31
|
+
changeLoadBalancerReverseDNSResponseSchema,
|
|
32
|
+
changeLoadBalancerProtectionRequestSchema,
|
|
33
|
+
changeLoadBalancerProtectionResponseSchema,
|
|
34
|
+
changeLoadBalancerTypeRequestSchema,
|
|
35
|
+
changeLoadBalancerTypeResponseSchema,
|
|
36
|
+
attachLoadBalancerToNetworkRequestSchema,
|
|
37
|
+
attachLoadBalancerToNetworkResponseSchema,
|
|
38
|
+
detachLoadBalancerFromNetworkRequestSchema,
|
|
39
|
+
detachLoadBalancerFromNetworkResponseSchema,
|
|
40
|
+
enableLoadBalancerPublicInterfaceRequestSchema,
|
|
41
|
+
enableLoadBalancerPublicInterfaceResponseSchema,
|
|
42
|
+
disableLoadBalancerPublicInterfaceRequestSchema,
|
|
43
|
+
disableLoadBalancerPublicInterfaceResponseSchema,
|
|
44
|
+
getLoadBalancerMetricsRequestSchema,
|
|
45
|
+
getLoadBalancerMetricsResponseSchema,
|
|
46
|
+
loadBalancerSchema,
|
|
47
|
+
loadBalancerAlgorithmTypeSchema,
|
|
48
|
+
loadBalancerServiceProtocolSchema,
|
|
49
|
+
loadBalancerTargetTypeSchema,
|
|
50
|
+
loadBalancerServiceHealthCheckProtocolSchema,
|
|
51
|
+
} from "@/apis/load-balancers/schemas";
|
|
52
|
+
import type { z } from "zod";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Load Balancer algorithm type
|
|
56
|
+
*/
|
|
57
|
+
export type LoadBalancerAlgorithmType = z.infer<typeof loadBalancerAlgorithmTypeSchema>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Load Balancer service protocol
|
|
61
|
+
*/
|
|
62
|
+
export type LoadBalancerServiceProtocol = z.infer<typeof loadBalancerServiceProtocolSchema>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Load Balancer target type
|
|
66
|
+
*/
|
|
67
|
+
export type LoadBalancerTargetType = z.infer<typeof loadBalancerTargetTypeSchema>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Load Balancer service health check protocol
|
|
71
|
+
*/
|
|
72
|
+
export type LoadBalancerServiceHealthCheckProtocol = z.infer<
|
|
73
|
+
typeof loadBalancerServiceHealthCheckProtocolSchema
|
|
74
|
+
>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Load Balancer
|
|
78
|
+
*/
|
|
79
|
+
export type LoadBalancer = z.infer<typeof loadBalancerSchema>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* List Load Balancers query parameters
|
|
83
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-list-load-balancers
|
|
84
|
+
*/
|
|
85
|
+
export interface ListLoadBalancersParams {
|
|
86
|
+
/**
|
|
87
|
+
* Can be used to filter resources by their name. The response will only contain the resources matching the specified name.
|
|
88
|
+
*/
|
|
89
|
+
name?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Can be used multiple times. Choices: id, id:asc, id:desc, name, name:asc, name:desc, created, created:asc, created:desc
|
|
92
|
+
* @see https://docs.hetzner.cloud/reference/cloud#sorting
|
|
93
|
+
*/
|
|
94
|
+
sort?: string | string[];
|
|
95
|
+
/**
|
|
96
|
+
* Can be used to filter resources by labels. The response will only contain resources matching the label selector.
|
|
97
|
+
*/
|
|
98
|
+
label_selector?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Page number to return. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
101
|
+
*/
|
|
102
|
+
page?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Maximum number of entries returned per page. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
105
|
+
*/
|
|
106
|
+
per_page?: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* List Load Balancers response
|
|
111
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-list-load-balancers
|
|
112
|
+
*/
|
|
113
|
+
export type ListLoadBalancersResponse = z.infer<typeof listLoadBalancersResponseSchema>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create Load Balancer parameters
|
|
117
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-create-a-load-balancer
|
|
118
|
+
*/
|
|
119
|
+
export type CreateLoadBalancerParams = z.infer<typeof createLoadBalancerRequestSchema>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Create Load Balancer response
|
|
123
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-create-a-load-balancer
|
|
124
|
+
*/
|
|
125
|
+
export type CreateLoadBalancerResponse = z.infer<typeof createLoadBalancerResponseSchema>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get Load Balancer response
|
|
129
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-get-a-load-balancer
|
|
130
|
+
*/
|
|
131
|
+
export type GetLoadBalancerResponse = z.infer<typeof getLoadBalancerResponseSchema>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Update Load Balancer parameters
|
|
135
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-update-a-load-balancer
|
|
136
|
+
*/
|
|
137
|
+
export type UpdateLoadBalancerParams = z.infer<typeof updateLoadBalancerRequestSchema>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Update Load Balancer response
|
|
141
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-update-a-load-balancer
|
|
142
|
+
*/
|
|
143
|
+
export type UpdateLoadBalancerResponse = z.infer<typeof updateLoadBalancerResponseSchema>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Delete Load Balancer response
|
|
147
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-delete-a-load-balancer
|
|
148
|
+
*/
|
|
149
|
+
export type DeleteLoadBalancerResponse = z.infer<typeof deleteLoadBalancerResponseSchema>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* List Load Balancer Actions query parameters
|
|
153
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-list-actions-for-a-load-balancer
|
|
154
|
+
*/
|
|
155
|
+
export interface ListLoadBalancerActionsParams {
|
|
156
|
+
/**
|
|
157
|
+
* Can be used multiple times. Choices: id, id:asc, id:desc, command, command:asc, command:desc, status, status:asc, status:desc, progress, progress:asc, progress:desc, started, started:asc, started:desc, finished, finished:asc, finished:desc
|
|
158
|
+
* @see https://docs.hetzner.cloud/reference/cloud#sorting
|
|
159
|
+
*/
|
|
160
|
+
sort?: string | string[];
|
|
161
|
+
/**
|
|
162
|
+
* Can be used to filter Actions by status. The response will only contain Actions matching the status.
|
|
163
|
+
*/
|
|
164
|
+
status?: string | string[];
|
|
165
|
+
/**
|
|
166
|
+
* Page number to return. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
167
|
+
*/
|
|
168
|
+
page?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Maximum number of entries returned per page. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
171
|
+
*/
|
|
172
|
+
per_page?: number;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* List Load Balancer Actions response
|
|
177
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-list-actions-for-a-load-balancer
|
|
178
|
+
*/
|
|
179
|
+
export type ListLoadBalancerActionsResponse = z.infer<typeof listLoadBalancerActionsResponseSchema>;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get Load Balancer Action response
|
|
183
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-get-an-action-for-a-load-balancer
|
|
184
|
+
*/
|
|
185
|
+
export type GetLoadBalancerActionResponse = z.infer<typeof getLoadBalancerActionResponseSchema>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Add Load Balancer Service parameters
|
|
189
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-add-service
|
|
190
|
+
*/
|
|
191
|
+
export type AddLoadBalancerServiceParams = z.infer<typeof addLoadBalancerServiceRequestSchema>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Add Load Balancer Service response
|
|
195
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-add-service
|
|
196
|
+
*/
|
|
197
|
+
export type AddLoadBalancerServiceResponse = z.infer<typeof addLoadBalancerServiceResponseSchema>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Update Load Balancer Service parameters
|
|
201
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-update-service
|
|
202
|
+
*/
|
|
203
|
+
export type UpdateLoadBalancerServiceParams = z.infer<
|
|
204
|
+
typeof updateLoadBalancerServiceRequestSchema
|
|
205
|
+
>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Update Load Balancer Service response
|
|
209
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-update-service
|
|
210
|
+
*/
|
|
211
|
+
export type UpdateLoadBalancerServiceResponse = z.infer<
|
|
212
|
+
typeof updateLoadBalancerServiceResponseSchema
|
|
213
|
+
>;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Delete Load Balancer Service response
|
|
217
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-delete-service
|
|
218
|
+
*/
|
|
219
|
+
export type DeleteLoadBalancerServiceResponse = z.infer<
|
|
220
|
+
typeof deleteLoadBalancerServiceResponseSchema
|
|
221
|
+
>;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Add Load Balancer Target parameters
|
|
225
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-add-target
|
|
226
|
+
*/
|
|
227
|
+
export type AddLoadBalancerTargetParams = z.infer<typeof addLoadBalancerTargetRequestSchema>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Add Load Balancer Target response
|
|
231
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-add-target
|
|
232
|
+
*/
|
|
233
|
+
export type AddLoadBalancerTargetResponse = z.infer<typeof addLoadBalancerTargetResponseSchema>;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Remove Load Balancer Target parameters
|
|
237
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-remove-target
|
|
238
|
+
*/
|
|
239
|
+
export type RemoveLoadBalancerTargetParams = z.infer<
|
|
240
|
+
typeof removeLoadBalancerTargetRequestSchema
|
|
241
|
+
>;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Remove Load Balancer Target response
|
|
245
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-remove-target
|
|
246
|
+
*/
|
|
247
|
+
export type RemoveLoadBalancerTargetResponse = z.infer<
|
|
248
|
+
typeof removeLoadBalancerTargetResponseSchema
|
|
249
|
+
>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Change Load Balancer Algorithm parameters
|
|
253
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-algorithm
|
|
254
|
+
*/
|
|
255
|
+
export type ChangeLoadBalancerAlgorithmParams = z.infer<
|
|
256
|
+
typeof changeLoadBalancerAlgorithmRequestSchema
|
|
257
|
+
>;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Change Load Balancer Algorithm response
|
|
261
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-algorithm
|
|
262
|
+
*/
|
|
263
|
+
export type ChangeLoadBalancerAlgorithmResponse = z.infer<
|
|
264
|
+
typeof changeLoadBalancerAlgorithmResponseSchema
|
|
265
|
+
>;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Change Load Balancer reverse DNS parameters
|
|
269
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-reverse-dns-entry-for-this-load-balancer
|
|
270
|
+
*/
|
|
271
|
+
export type ChangeLoadBalancerReverseDNSParams = z.infer<
|
|
272
|
+
typeof changeLoadBalancerReverseDNSRequestSchema
|
|
273
|
+
>;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Change Load Balancer reverse DNS response
|
|
277
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-reverse-dns-entry-for-this-load-balancer
|
|
278
|
+
*/
|
|
279
|
+
export type ChangeLoadBalancerReverseDNSResponse = z.infer<
|
|
280
|
+
typeof changeLoadBalancerReverseDNSResponseSchema
|
|
281
|
+
>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Change Load Balancer Protection parameters
|
|
285
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-load-balancer-protection
|
|
286
|
+
*/
|
|
287
|
+
export type ChangeLoadBalancerProtectionParams = z.infer<
|
|
288
|
+
typeof changeLoadBalancerProtectionRequestSchema
|
|
289
|
+
>;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Change Load Balancer Protection response
|
|
293
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-load-balancer-protection
|
|
294
|
+
*/
|
|
295
|
+
export type ChangeLoadBalancerProtectionResponse = z.infer<
|
|
296
|
+
typeof changeLoadBalancerProtectionResponseSchema
|
|
297
|
+
>;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Change Load Balancer Type parameters
|
|
301
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-the-type-of-a-load-balancer
|
|
302
|
+
*/
|
|
303
|
+
export type ChangeLoadBalancerTypeParams = z.infer<typeof changeLoadBalancerTypeRequestSchema>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Change Load Balancer Type response
|
|
307
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-change-the-type-of-a-load-balancer
|
|
308
|
+
*/
|
|
309
|
+
export type ChangeLoadBalancerTypeResponse = z.infer<typeof changeLoadBalancerTypeResponseSchema>;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Attach Load Balancer to Network parameters
|
|
313
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-attach-a-load-balancer-to-a-network
|
|
314
|
+
*/
|
|
315
|
+
export type AttachLoadBalancerToNetworkParams = z.infer<
|
|
316
|
+
typeof attachLoadBalancerToNetworkRequestSchema
|
|
317
|
+
>;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Attach Load Balancer to Network response
|
|
321
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-attach-a-load-balancer-to-a-network
|
|
322
|
+
*/
|
|
323
|
+
export type AttachLoadBalancerToNetworkResponse = z.infer<
|
|
324
|
+
typeof attachLoadBalancerToNetworkResponseSchema
|
|
325
|
+
>;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Detach Load Balancer from Network response
|
|
329
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-detach-a-load-balancer-from-a-network
|
|
330
|
+
*/
|
|
331
|
+
export type DetachLoadBalancerFromNetworkResponse = z.infer<
|
|
332
|
+
typeof detachLoadBalancerFromNetworkResponseSchema
|
|
333
|
+
>;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Enable Load Balancer public interface response
|
|
337
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-enable-the-public-interface-of-a-load-balancer
|
|
338
|
+
*/
|
|
339
|
+
export type EnableLoadBalancerPublicInterfaceResponse = z.infer<
|
|
340
|
+
typeof enableLoadBalancerPublicInterfaceResponseSchema
|
|
341
|
+
>;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Disable Load Balancer public interface response
|
|
345
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-disable-the-public-interface-of-a-load-balancer
|
|
346
|
+
*/
|
|
347
|
+
export type DisableLoadBalancerPublicInterfaceResponse = z.infer<
|
|
348
|
+
typeof disableLoadBalancerPublicInterfaceResponseSchema
|
|
349
|
+
>;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Get Load Balancer Metrics parameters
|
|
353
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-get-metrics-for-a-load-balancer
|
|
354
|
+
*/
|
|
355
|
+
export type GetLoadBalancerMetricsParams = z.infer<typeof getLoadBalancerMetricsRequestSchema>;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Get Load Balancer Metrics response
|
|
359
|
+
* @see https://docs.hetzner.cloud/reference/cloud#load-balancers-get-metrics-for-a-load-balancer
|
|
360
|
+
*/
|
|
361
|
+
export type GetLoadBalancerMetricsResponse = z.infer<typeof getLoadBalancerMetricsResponseSchema>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hetzner Cloud Locations API
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#locations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { HCloudClient } from "@/client/index";
|
|
7
|
+
import type {
|
|
8
|
+
ListLocationsParams,
|
|
9
|
+
ListLocationsResponse,
|
|
10
|
+
GetLocationResponse,
|
|
11
|
+
ListDataCentersParams,
|
|
12
|
+
ListDataCentersResponse,
|
|
13
|
+
GetDataCenterResponse,
|
|
14
|
+
} from "@/apis/locations/types";
|
|
15
|
+
import { validate } from "@/validation/index";
|
|
16
|
+
import {
|
|
17
|
+
listLocationsResponseSchema,
|
|
18
|
+
getLocationResponseSchema,
|
|
19
|
+
listDataCentersResponseSchema,
|
|
20
|
+
getDataCenterResponseSchema,
|
|
21
|
+
} from "@/apis/locations/schemas";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Locations API client
|
|
25
|
+
*/
|
|
26
|
+
export class LocationsClient {
|
|
27
|
+
constructor(private readonly client: HCloudClient) {}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns all Location objects.
|
|
31
|
+
*
|
|
32
|
+
* @param params - Query parameters for filtering and pagination
|
|
33
|
+
* @returns Promise resolving to list of locations with pagination metadata
|
|
34
|
+
* @see https://docs.hetzner.cloud/reference/cloud#locations-list-locations
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
39
|
+
*
|
|
40
|
+
* // List all locations
|
|
41
|
+
* const result = await client.locations.list();
|
|
42
|
+
*
|
|
43
|
+
* // List locations with filters
|
|
44
|
+
* const locations = await client.locations.list({
|
|
45
|
+
* name: 'nbg1',
|
|
46
|
+
* sort: ['name:asc'],
|
|
47
|
+
* page: 1,
|
|
48
|
+
* per_page: 50
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
async list(params?: ListLocationsParams): Promise<ListLocationsResponse> {
|
|
53
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
54
|
+
|
|
55
|
+
if (params?.name) {
|
|
56
|
+
queryParams.name = params.name;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (params?.sort) {
|
|
60
|
+
queryParams.sort = Array.isArray(params.sort) ? params.sort : [params.sort];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (params?.page !== undefined) {
|
|
64
|
+
queryParams.page = params.page;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (params?.per_page !== undefined) {
|
|
68
|
+
queryParams.per_page = params.per_page;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const response = await this.client.get<unknown>("/locations", queryParams);
|
|
72
|
+
|
|
73
|
+
return validate(listLocationsResponseSchema, response, {
|
|
74
|
+
context: "List locations response",
|
|
75
|
+
detailed: true,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Returns a specific Location object.
|
|
81
|
+
*
|
|
82
|
+
* @param id - ID or name of the Location
|
|
83
|
+
* @returns Promise resolving to the location
|
|
84
|
+
* @see https://docs.hetzner.cloud/reference/cloud#locations-get-a-location
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
89
|
+
*
|
|
90
|
+
* // Get a location by ID or name
|
|
91
|
+
* const location = await client.locations.get('nbg1');
|
|
92
|
+
* console.log(location.location.name);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
async get(id: number | string): Promise<GetLocationResponse> {
|
|
96
|
+
const response = await this.client.get<unknown>(`/locations/${id}`);
|
|
97
|
+
|
|
98
|
+
return validate(getLocationResponseSchema, response, {
|
|
99
|
+
context: "Get location response",
|
|
100
|
+
detailed: true,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Returns all Datacenter objects.
|
|
106
|
+
*
|
|
107
|
+
* @param params - Query parameters for filtering and pagination
|
|
108
|
+
* @returns Promise resolving to list of datacenters with pagination metadata
|
|
109
|
+
* @see https://docs.hetzner.cloud/reference/cloud#data-centers-list-data-centers
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
114
|
+
*
|
|
115
|
+
* // List all datacenters
|
|
116
|
+
* const result = await client.locations.listDataCenters();
|
|
117
|
+
*
|
|
118
|
+
* // List datacenters with filters
|
|
119
|
+
* const datacenters = await client.locations.listDataCenters({
|
|
120
|
+
* name: 'nbg1-dc3',
|
|
121
|
+
* sort: ['name:asc']
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
async listDataCenters(params?: ListDataCentersParams): Promise<ListDataCentersResponse> {
|
|
126
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
127
|
+
|
|
128
|
+
if (params?.name) {
|
|
129
|
+
queryParams.name = params.name;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (params?.sort) {
|
|
133
|
+
queryParams.sort = Array.isArray(params.sort) ? params.sort : [params.sort];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (params?.page !== undefined) {
|
|
137
|
+
queryParams.page = params.page;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (params?.per_page !== undefined) {
|
|
141
|
+
queryParams.per_page = params.per_page;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const response = await this.client.get<unknown>("/datacenters", queryParams);
|
|
145
|
+
|
|
146
|
+
return validate(listDataCentersResponseSchema, response, {
|
|
147
|
+
context: "List datacenters response",
|
|
148
|
+
detailed: true,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns a specific Datacenter object.
|
|
154
|
+
*
|
|
155
|
+
* @param id - ID or name of the Datacenter
|
|
156
|
+
* @returns Promise resolving to the datacenter
|
|
157
|
+
* @see https://docs.hetzner.cloud/reference/cloud#data-centers-get-a-data-center
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
162
|
+
*
|
|
163
|
+
* // Get a datacenter by ID or name
|
|
164
|
+
* const datacenter = await client.locations.getDataCenter('nbg1-dc3');
|
|
165
|
+
* console.log(datacenter.datacenter.name);
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
async getDataCenter(id: number | string): Promise<GetDataCenterResponse> {
|
|
169
|
+
const response = await this.client.get<unknown>(`/datacenters/${id}`);
|
|
170
|
+
|
|
171
|
+
return validate(getDataCenterResponseSchema, response, {
|
|
172
|
+
context: "Get datacenter response",
|
|
173
|
+
detailed: true,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for Hetzner Cloud Locations API
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#locations
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { paginationMetaSchema } from "@/apis/common/schemas";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Location schema
|
|
11
|
+
*/
|
|
12
|
+
export const locationSchema = z.object({
|
|
13
|
+
id: z.number(),
|
|
14
|
+
name: z.string(),
|
|
15
|
+
description: z.string(),
|
|
16
|
+
country: z.string(),
|
|
17
|
+
city: z.string(),
|
|
18
|
+
latitude: z.number(),
|
|
19
|
+
longitude: z.number(),
|
|
20
|
+
network_zone: z.string(),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Datacenter server types schema
|
|
25
|
+
*/
|
|
26
|
+
export const datacenterServerTypesSchema = z.object({
|
|
27
|
+
supported: z.array(z.number()),
|
|
28
|
+
available: z.array(z.number()),
|
|
29
|
+
available_for_migration: z.array(z.number()),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Datacenter schema
|
|
34
|
+
*/
|
|
35
|
+
export const datacenterSchema = z.object({
|
|
36
|
+
id: z.number(),
|
|
37
|
+
name: z.string(),
|
|
38
|
+
description: z.string(),
|
|
39
|
+
location: locationSchema,
|
|
40
|
+
server_types: datacenterServerTypesSchema,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* List Locations response schema
|
|
45
|
+
* @see https://docs.hetzner.cloud/reference/cloud#locations-list-locations
|
|
46
|
+
*/
|
|
47
|
+
export const listLocationsResponseSchema = z.object({
|
|
48
|
+
locations: z.array(locationSchema),
|
|
49
|
+
meta: z
|
|
50
|
+
.object({
|
|
51
|
+
pagination: paginationMetaSchema,
|
|
52
|
+
})
|
|
53
|
+
.optional(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get Location response schema
|
|
58
|
+
* @see https://docs.hetzner.cloud/reference/cloud#locations-get-a-location
|
|
59
|
+
*/
|
|
60
|
+
export const getLocationResponseSchema = z.object({
|
|
61
|
+
location: locationSchema,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* List Data Centers response schema
|
|
66
|
+
* @see https://docs.hetzner.cloud/reference/cloud#data-centers-list-data-centers
|
|
67
|
+
*/
|
|
68
|
+
export const listDataCentersResponseSchema = z.object({
|
|
69
|
+
datacenters: z.array(datacenterSchema),
|
|
70
|
+
meta: z
|
|
71
|
+
.object({
|
|
72
|
+
pagination: paginationMetaSchema,
|
|
73
|
+
})
|
|
74
|
+
.optional(),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get Data Center response schema
|
|
79
|
+
* @see https://docs.hetzner.cloud/reference/cloud#data-centers-get-a-data-center
|
|
80
|
+
*/
|
|
81
|
+
export const getDataCenterResponseSchema = z.object({
|
|
82
|
+
datacenter: datacenterSchema,
|
|
83
|
+
});
|