@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.
Files changed (62) hide show
  1. package/README.md +90 -0
  2. package/package.json +70 -0
  3. package/src/apis/actions/index.ts +113 -0
  4. package/src/apis/actions/schemas.ts +59 -0
  5. package/src/apis/actions/types.ts +77 -0
  6. package/src/apis/certificates/index.ts +326 -0
  7. package/src/apis/certificates/schemas.ts +140 -0
  8. package/src/apis/certificates/types.ts +176 -0
  9. package/src/apis/common/schemas.ts +19 -0
  10. package/src/apis/dns/index.ts +961 -0
  11. package/src/apis/dns/schemas.ts +437 -0
  12. package/src/apis/dns/types.ts +397 -0
  13. package/src/apis/firewalls/index.ts +469 -0
  14. package/src/apis/firewalls/schemas.ts +274 -0
  15. package/src/apis/firewalls/types.ts +205 -0
  16. package/src/apis/floating-ips/index.ts +466 -0
  17. package/src/apis/floating-ips/schemas.ts +203 -0
  18. package/src/apis/floating-ips/types.ts +207 -0
  19. package/src/apis/images/index.ts +195 -0
  20. package/src/apis/images/schemas.ts +113 -0
  21. package/src/apis/images/types.ts +124 -0
  22. package/src/apis/isos/index.ts +91 -0
  23. package/src/apis/isos/schemas.ts +43 -0
  24. package/src/apis/isos/types.ts +60 -0
  25. package/src/apis/load-balancers/index.ts +892 -0
  26. package/src/apis/load-balancers/schemas.ts +561 -0
  27. package/src/apis/load-balancers/types.ts +361 -0
  28. package/src/apis/locations/index.ts +176 -0
  29. package/src/apis/locations/schemas.ts +83 -0
  30. package/src/apis/locations/types.ts +113 -0
  31. package/src/apis/networks/index.ts +544 -0
  32. package/src/apis/networks/schemas.ts +279 -0
  33. package/src/apis/networks/types.ts +243 -0
  34. package/src/apis/placement-groups/index.ts +212 -0
  35. package/src/apis/placement-groups/schemas.ts +90 -0
  36. package/src/apis/placement-groups/types.ts +99 -0
  37. package/src/apis/pricing/index.ts +42 -0
  38. package/src/apis/pricing/schemas.ts +93 -0
  39. package/src/apis/pricing/types.ts +71 -0
  40. package/src/apis/primary-ips/index.ts +467 -0
  41. package/src/apis/primary-ips/schemas.ts +221 -0
  42. package/src/apis/primary-ips/types.ts +221 -0
  43. package/src/apis/server-types/index.ts +93 -0
  44. package/src/apis/server-types/schemas.ts +29 -0
  45. package/src/apis/server-types/types.ts +43 -0
  46. package/src/apis/servers/index.ts +378 -0
  47. package/src/apis/servers/schemas.ts +771 -0
  48. package/src/apis/servers/types.ts +538 -0
  49. package/src/apis/ssh-keys/index.ts +204 -0
  50. package/src/apis/ssh-keys/schemas.ts +84 -0
  51. package/src/apis/ssh-keys/types.ts +106 -0
  52. package/src/apis/volumes/index.ts +452 -0
  53. package/src/apis/volumes/schemas.ts +195 -0
  54. package/src/apis/volumes/types.ts +197 -0
  55. package/src/auth/index.ts +26 -0
  56. package/src/base/index.ts +10 -0
  57. package/src/client/index.ts +388 -0
  58. package/src/config/index.ts +34 -0
  59. package/src/errors/index.ts +38 -0
  60. package/src/index.ts +799 -0
  61. package/src/types/index.ts +37 -0
  62. package/src/validation/index.ts +109 -0
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Zod schemas for Hetzner Cloud Networks API
3
+ * @see https://docs.hetzner.cloud/reference/cloud#networks
4
+ */
5
+
6
+ import { z } from "zod";
7
+ import { actionSchema, actionResourceSchema } from "@/apis/actions/schemas";
8
+ import { paginationMetaSchema } from "@/apis/common/schemas";
9
+ import { locationSchema } from "@/apis/servers/schemas";
10
+
11
+ /**
12
+ * Network route destination schema
13
+ */
14
+ export const networkRouteDestinationSchema = z.object({
15
+ ip: z.string(),
16
+ });
17
+
18
+ /**
19
+ * Network route gateway schema
20
+ */
21
+ export const networkRouteGatewaySchema = z.object({
22
+ ip: z.string(),
23
+ });
24
+
25
+ /**
26
+ * Network route schema
27
+ */
28
+ export const networkRouteSchema = z.object({
29
+ destination: networkRouteDestinationSchema,
30
+ gateway: networkRouteGatewaySchema,
31
+ });
32
+
33
+ /**
34
+ * Network subnet type schema
35
+ */
36
+ export const networkSubnetTypeSchema = z.enum(["cloud", "server", "vswitch"]);
37
+
38
+ /**
39
+ * Network subnet schema
40
+ */
41
+ export const networkSubnetSchema = z.object({
42
+ type: networkSubnetTypeSchema,
43
+ ip_range: z.string().nullable(),
44
+ network_zone: z.string(),
45
+ gateway: z.string().nullable(),
46
+ vswitch_id: z.number().nullable(),
47
+ });
48
+
49
+ /**
50
+ * Network protection schema
51
+ */
52
+ export const networkProtectionSchema = z.object({
53
+ delete: z.boolean(),
54
+ });
55
+
56
+ /**
57
+ * Network schema
58
+ */
59
+ export const networkSchema = z
60
+ .object({
61
+ id: z.number(),
62
+ name: z.string(),
63
+ ip_range: z.string(),
64
+ subnets: z.array(networkSubnetSchema),
65
+ routes: z.array(networkRouteSchema),
66
+ servers: z.array(z.number()),
67
+ load_balancers: z.array(z.number()).optional(),
68
+ protection: networkProtectionSchema,
69
+ labels: z.record(z.string(), z.string()),
70
+ created: z.string(),
71
+ expose_routes_to_vswitch: z.boolean().optional(),
72
+ blocking: z.array(actionResourceSchema).optional(),
73
+ })
74
+ .passthrough();
75
+
76
+ /**
77
+ * List Networks response schema
78
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-list-networks
79
+ */
80
+ export const listNetworksResponseSchema = z.object({
81
+ networks: z.array(networkSchema),
82
+ meta: z
83
+ .object({
84
+ pagination: paginationMetaSchema,
85
+ })
86
+ .optional(),
87
+ });
88
+
89
+ /**
90
+ * Create Network request schema
91
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-create-a-network
92
+ */
93
+ export const createNetworkRequestSchema = z.object({
94
+ name: z.string(),
95
+ ip_range: z.string(),
96
+ subnets: z
97
+ .array(
98
+ z.object({
99
+ type: networkSubnetTypeSchema,
100
+ network_zone: z.string(),
101
+ ip_range: z.string().optional(),
102
+ vswitch_id: z.number().optional(),
103
+ }),
104
+ )
105
+ .optional(),
106
+ routes: z
107
+ .array(
108
+ z.object({
109
+ destination: z.string(),
110
+ gateway: z.string(),
111
+ }),
112
+ )
113
+ .optional(),
114
+ labels: z.record(z.string(), z.string()).optional(),
115
+ expose_routes_to_vswitch: z.boolean().optional(),
116
+ });
117
+
118
+ /**
119
+ * Create Network response schema
120
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-create-a-network
121
+ */
122
+ export const createNetworkResponseSchema = z.object({
123
+ network: networkSchema,
124
+ action: actionSchema.optional(),
125
+ });
126
+
127
+ /**
128
+ * Get Network response schema
129
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-get-a-network
130
+ */
131
+ export const getNetworkResponseSchema = z.object({
132
+ network: networkSchema,
133
+ });
134
+
135
+ /**
136
+ * Update Network request schema
137
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-update-a-network
138
+ */
139
+ export const updateNetworkRequestSchema = z.object({
140
+ name: z.string().optional(),
141
+ labels: z.record(z.string(), z.string()).optional(),
142
+ expose_routes_to_vswitch: z.boolean().optional(),
143
+ });
144
+
145
+ /**
146
+ * Update Network response schema
147
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-update-a-network
148
+ */
149
+ export const updateNetworkResponseSchema = z.object({
150
+ network: networkSchema,
151
+ });
152
+
153
+ /**
154
+ * Delete Network response schema
155
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-network
156
+ */
157
+ export const deleteNetworkResponseSchema = z.object({});
158
+
159
+ /**
160
+ * List Network Actions response schema
161
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-list-actions-for-a-network
162
+ */
163
+ export const listNetworkActionsResponseSchema = z.object({
164
+ actions: z.array(actionSchema),
165
+ meta: z
166
+ .object({
167
+ pagination: paginationMetaSchema,
168
+ })
169
+ .optional(),
170
+ });
171
+
172
+ /**
173
+ * Get Network Action response schema
174
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-get-an-action-for-a-network
175
+ */
176
+ export const getNetworkActionResponseSchema = z.object({
177
+ action: actionSchema,
178
+ });
179
+
180
+ /**
181
+ * Add Network route request schema
182
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-route-to-a-network
183
+ */
184
+ export const addNetworkRouteRequestSchema = z.object({
185
+ destination: z.string(),
186
+ gateway: z.string(),
187
+ });
188
+
189
+ /**
190
+ * Add Network route response schema
191
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-route-to-a-network
192
+ */
193
+ export const addNetworkRouteResponseSchema = z.object({
194
+ action: actionSchema,
195
+ });
196
+
197
+ /**
198
+ * Delete Network route request schema
199
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-route-from-a-network
200
+ */
201
+ export const deleteNetworkRouteRequestSchema = z.object({
202
+ destination: z.string(),
203
+ gateway: z.string(),
204
+ });
205
+
206
+ /**
207
+ * Delete Network route response schema
208
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-route-from-a-network
209
+ */
210
+ export const deleteNetworkRouteResponseSchema = z.object({
211
+ action: actionSchema,
212
+ });
213
+
214
+ /**
215
+ * Add Network subnet request schema
216
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-subnet-to-a-network
217
+ */
218
+ export const addNetworkSubnetRequestSchema = z.object({
219
+ type: networkSubnetTypeSchema,
220
+ network_zone: z.string(),
221
+ ip_range: z.string().optional(),
222
+ vswitch_id: z.number().optional(),
223
+ });
224
+
225
+ /**
226
+ * Add Network subnet response schema
227
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-subnet-to-a-network
228
+ */
229
+ export const addNetworkSubnetResponseSchema = z.object({
230
+ action: actionSchema,
231
+ });
232
+
233
+ /**
234
+ * Delete Network subnet request schema
235
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-subnet-from-a-network
236
+ */
237
+ export const deleteNetworkSubnetRequestSchema = z.object({
238
+ ip_range: z.string(),
239
+ });
240
+
241
+ /**
242
+ * Delete Network subnet response schema
243
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-subnet-from-a-network
244
+ */
245
+ export const deleteNetworkSubnetResponseSchema = z.object({
246
+ action: actionSchema,
247
+ });
248
+
249
+ /**
250
+ * Change Network IP range request schema
251
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-ip-range-of-a-network
252
+ */
253
+ export const changeNetworkIpRangeRequestSchema = z.object({
254
+ ip_range: z.string(),
255
+ });
256
+
257
+ /**
258
+ * Change Network IP range response schema
259
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-ip-range-of-a-network
260
+ */
261
+ export const changeNetworkIpRangeResponseSchema = z.object({
262
+ action: actionSchema,
263
+ });
264
+
265
+ /**
266
+ * Change Network Protection request schema
267
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-network-protection
268
+ */
269
+ export const changeNetworkProtectionRequestSchema = z.object({
270
+ delete: z.boolean(),
271
+ });
272
+
273
+ /**
274
+ * Change Network Protection response schema
275
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-network-protection
276
+ */
277
+ export const changeNetworkProtectionResponseSchema = z.object({
278
+ action: actionSchema,
279
+ });
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Types for Hetzner Cloud Networks API
3
+ * Types are inferred from Zod schemas
4
+ * @see https://docs.hetzner.cloud/reference/cloud#networks
5
+ */
6
+
7
+ // biome-ignore assist/source/organizeImports: we need to import the schemas first
8
+ import {
9
+ listNetworksResponseSchema,
10
+ createNetworkRequestSchema,
11
+ createNetworkResponseSchema,
12
+ getNetworkResponseSchema,
13
+ updateNetworkRequestSchema,
14
+ updateNetworkResponseSchema,
15
+ deleteNetworkResponseSchema,
16
+ listNetworkActionsResponseSchema,
17
+ getNetworkActionResponseSchema,
18
+ addNetworkRouteRequestSchema,
19
+ addNetworkRouteResponseSchema,
20
+ deleteNetworkRouteRequestSchema,
21
+ deleteNetworkRouteResponseSchema,
22
+ addNetworkSubnetRequestSchema,
23
+ addNetworkSubnetResponseSchema,
24
+ deleteNetworkSubnetRequestSchema,
25
+ deleteNetworkSubnetResponseSchema,
26
+ changeNetworkIpRangeRequestSchema,
27
+ changeNetworkIpRangeResponseSchema,
28
+ changeNetworkProtectionRequestSchema,
29
+ changeNetworkProtectionResponseSchema,
30
+ networkSchema,
31
+ networkSubnetTypeSchema,
32
+ networkRouteSchema,
33
+ networkSubnetSchema,
34
+ networkProtectionSchema,
35
+ } from "@/apis/networks/schemas";
36
+ import type { z } from "zod";
37
+
38
+ /**
39
+ * Network subnet type
40
+ */
41
+ export type NetworkSubnetType = z.infer<typeof networkSubnetTypeSchema>;
42
+
43
+ /**
44
+ * Network route
45
+ */
46
+ export type NetworkRoute = z.infer<typeof networkRouteSchema>;
47
+
48
+ /**
49
+ * Network subnet
50
+ */
51
+ export type NetworkSubnet = z.infer<typeof networkSubnetSchema>;
52
+
53
+ /**
54
+ * Network protection
55
+ */
56
+ export type NetworkProtection = z.infer<typeof networkProtectionSchema>;
57
+
58
+ /**
59
+ * Network
60
+ */
61
+ export type Network = z.infer<typeof networkSchema>;
62
+
63
+ /**
64
+ * List Networks query parameters
65
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-list-networks
66
+ */
67
+ export interface ListNetworksParams {
68
+ /**
69
+ * Can be used to filter resources by their name. The response will only contain the resources matching the specified name.
70
+ */
71
+ name?: string;
72
+ /**
73
+ * Can be used multiple times. Choices: id, id:asc, id:desc, name, name:asc, name:desc, created, created:asc, created:desc
74
+ * @see https://docs.hetzner.cloud/reference/cloud#sorting
75
+ */
76
+ sort?: string | string[];
77
+ /**
78
+ * Can be used to filter resources by labels. The response will only contain resources matching the label selector.
79
+ */
80
+ label_selector?: string;
81
+ /**
82
+ * Page number to return. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
83
+ */
84
+ page?: number;
85
+ /**
86
+ * Maximum number of entries returned per page. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
87
+ */
88
+ per_page?: number;
89
+ }
90
+
91
+ /**
92
+ * List Networks response
93
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-list-networks
94
+ */
95
+ export type ListNetworksResponse = z.infer<typeof listNetworksResponseSchema>;
96
+
97
+ /**
98
+ * Create Network parameters
99
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-create-a-network
100
+ */
101
+ export type CreateNetworkParams = z.infer<typeof createNetworkRequestSchema>;
102
+
103
+ /**
104
+ * Create Network response
105
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-create-a-network
106
+ */
107
+ export type CreateNetworkResponse = z.infer<typeof createNetworkResponseSchema>;
108
+
109
+ /**
110
+ * Get Network response
111
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-get-a-network
112
+ */
113
+ export type GetNetworkResponse = z.infer<typeof getNetworkResponseSchema>;
114
+
115
+ /**
116
+ * Update Network parameters
117
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-update-a-network
118
+ */
119
+ export type UpdateNetworkParams = z.infer<typeof updateNetworkRequestSchema>;
120
+
121
+ /**
122
+ * Update Network response
123
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-update-a-network
124
+ */
125
+ export type UpdateNetworkResponse = z.infer<typeof updateNetworkResponseSchema>;
126
+
127
+ /**
128
+ * Delete Network response
129
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-network
130
+ */
131
+ export type DeleteNetworkResponse = z.infer<typeof deleteNetworkResponseSchema>;
132
+
133
+ /**
134
+ * List Network Actions query parameters
135
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-list-actions-for-a-network
136
+ */
137
+ export interface ListNetworkActionsParams {
138
+ /**
139
+ * 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
140
+ * @see https://docs.hetzner.cloud/reference/cloud#sorting
141
+ */
142
+ sort?: string | string[];
143
+ /**
144
+ * Can be used to filter Actions by status. The response will only contain Actions matching the status.
145
+ */
146
+ status?: string | string[];
147
+ /**
148
+ * Page number to return. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
149
+ */
150
+ page?: number;
151
+ /**
152
+ * Maximum number of entries returned per page. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
153
+ */
154
+ per_page?: number;
155
+ }
156
+
157
+ /**
158
+ * List Network Actions response
159
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-list-actions-for-a-network
160
+ */
161
+ export type ListNetworkActionsResponse = z.infer<typeof listNetworkActionsResponseSchema>;
162
+
163
+ /**
164
+ * Get Network Action response
165
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-get-an-action-for-a-network
166
+ */
167
+ export type GetNetworkActionResponse = z.infer<typeof getNetworkActionResponseSchema>;
168
+
169
+ /**
170
+ * Add Network route parameters
171
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-route-to-a-network
172
+ */
173
+ export type AddNetworkRouteParams = z.infer<typeof addNetworkRouteRequestSchema>;
174
+
175
+ /**
176
+ * Add Network route response
177
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-route-to-a-network
178
+ */
179
+ export type AddNetworkRouteResponse = z.infer<typeof addNetworkRouteResponseSchema>;
180
+
181
+ /**
182
+ * Delete Network route parameters
183
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-route-from-a-network
184
+ */
185
+ export type DeleteNetworkRouteParams = z.infer<typeof deleteNetworkRouteRequestSchema>;
186
+
187
+ /**
188
+ * Delete Network route response
189
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-route-from-a-network
190
+ */
191
+ export type DeleteNetworkRouteResponse = z.infer<typeof deleteNetworkRouteResponseSchema>;
192
+
193
+ /**
194
+ * Add Network subnet parameters
195
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-subnet-to-a-network
196
+ */
197
+ export type AddNetworkSubnetParams = z.infer<typeof addNetworkSubnetRequestSchema>;
198
+
199
+ /**
200
+ * Add Network subnet response
201
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-add-a-subnet-to-a-network
202
+ */
203
+ export type AddNetworkSubnetResponse = z.infer<typeof addNetworkSubnetResponseSchema>;
204
+
205
+ /**
206
+ * Delete Network subnet parameters
207
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-subnet-from-a-network
208
+ */
209
+ export type DeleteNetworkSubnetParams = z.infer<typeof deleteNetworkSubnetRequestSchema>;
210
+
211
+ /**
212
+ * Delete Network subnet response
213
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-delete-a-subnet-from-a-network
214
+ */
215
+ export type DeleteNetworkSubnetResponse = z.infer<typeof deleteNetworkSubnetResponseSchema>;
216
+
217
+ /**
218
+ * Change Network IP range parameters
219
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-ip-range-of-a-network
220
+ */
221
+ export type ChangeNetworkIpRangeParams = z.infer<typeof changeNetworkIpRangeRequestSchema>;
222
+
223
+ /**
224
+ * Change Network IP range response
225
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-ip-range-of-a-network
226
+ */
227
+ export type ChangeNetworkIpRangeResponse = z.infer<typeof changeNetworkIpRangeResponseSchema>;
228
+
229
+ /**
230
+ * Change Network Protection parameters
231
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-network-protection
232
+ */
233
+ export type ChangeNetworkProtectionParams = z.infer<
234
+ typeof changeNetworkProtectionRequestSchema
235
+ >;
236
+
237
+ /**
238
+ * Change Network Protection response
239
+ * @see https://docs.hetzner.cloud/reference/cloud#networks-change-network-protection
240
+ */
241
+ export type ChangeNetworkProtectionResponse = z.infer<
242
+ typeof changeNetworkProtectionResponseSchema
243
+ >;