@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,437 @@
1
+ /**
2
+ * Zod schemas for Hetzner Cloud DNS (Zones) API
3
+ * @see https://docs.hetzner.cloud/reference/cloud#dns
4
+ */
5
+
6
+ import { z } from "zod";
7
+ import { actionSchema, actionResourceSchema } from "../../apis/actions/schemas";
8
+ import { paginationMetaSchema } from "../../apis/common/schemas";
9
+
10
+ /**
11
+ * Zone status schema
12
+ */
13
+ export const zoneStatusSchema = z.enum(["verified", "pending", "unknown"]);
14
+
15
+ /**
16
+ * Zone protection schema
17
+ */
18
+ export const zoneProtectionSchema = z.object({
19
+ delete: z.boolean(),
20
+ });
21
+
22
+ /**
23
+ * Zone schema
24
+ */
25
+ export const zoneSchema = z
26
+ .object({
27
+ id: z.string(),
28
+ name: z.string(),
29
+ ttl: z.number(),
30
+ nameservers: z.array(z.string()),
31
+ status: zoneStatusSchema,
32
+ created: z.string(),
33
+ modified: z.string(),
34
+ verified: z.string().nullable(),
35
+ records_count: z.number(),
36
+ is_secondary_dns: z.boolean(),
37
+ txt_verification: z
38
+ .object({
39
+ name: z.string(),
40
+ record: z.string(),
41
+ })
42
+ .nullable(),
43
+ protected: z.boolean().optional(),
44
+ labels: z.record(z.string(), z.string()),
45
+ blocking: z.array(actionResourceSchema).optional(),
46
+ })
47
+ .passthrough();
48
+
49
+ /**
50
+ * RRSet record schema
51
+ */
52
+ export const rrsetRecordSchema = z.object({
53
+ value: z.string(),
54
+ comment: z.string().nullable(),
55
+ });
56
+
57
+ /**
58
+ * RRSet protection schema
59
+ */
60
+ export const rrsetProtectionSchema = z.object({
61
+ delete: z.boolean(),
62
+ });
63
+
64
+ /**
65
+ * RRSet schema
66
+ */
67
+ export const rrsetSchema = z
68
+ .object({
69
+ type: z.string(),
70
+ id: z.string(),
71
+ name: z.string(),
72
+ zone_id: z.string(),
73
+ created: z.string(),
74
+ modified: z.string(),
75
+ ttl: z.number().nullable(),
76
+ records: z.array(rrsetRecordSchema),
77
+ protected: z.boolean().optional(),
78
+ labels: z.record(z.string(), z.string()),
79
+ blocking: z.array(actionResourceSchema).optional(),
80
+ })
81
+ .passthrough();
82
+
83
+ /**
84
+ * List Zones response schema
85
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-list-zones
86
+ */
87
+ export const listZonesResponseSchema = z.object({
88
+ zones: z.array(zoneSchema),
89
+ meta: z
90
+ .object({
91
+ pagination: paginationMetaSchema,
92
+ })
93
+ .optional(),
94
+ });
95
+
96
+ /**
97
+ * Create Zone request schema
98
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-create-a-zone
99
+ */
100
+ export const createZoneRequestSchema = z.object({
101
+ name: z.string(),
102
+ ttl: z.number().optional(),
103
+ labels: z.record(z.string(), z.string()).optional(),
104
+ });
105
+
106
+ /**
107
+ * Create Zone response schema
108
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-create-a-zone
109
+ */
110
+ export const createZoneResponseSchema = z.object({
111
+ zone: zoneSchema,
112
+ action: actionSchema.optional(),
113
+ });
114
+
115
+ /**
116
+ * Get Zone response schema
117
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-get-a-zone
118
+ */
119
+ export const getZoneResponseSchema = z.object({
120
+ zone: zoneSchema,
121
+ });
122
+
123
+ /**
124
+ * Update Zone request schema
125
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-update-a-zone
126
+ */
127
+ export const updateZoneRequestSchema = z.object({
128
+ ttl: z.number().optional(),
129
+ labels: z.record(z.string(), z.string()).optional(),
130
+ });
131
+
132
+ /**
133
+ * Update Zone response schema
134
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-update-a-zone
135
+ */
136
+ export const updateZoneResponseSchema = z.object({
137
+ zone: zoneSchema,
138
+ });
139
+
140
+ /**
141
+ * Delete Zone response schema
142
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-delete-a-zone
143
+ */
144
+ export const deleteZoneResponseSchema = z.object({});
145
+
146
+ /**
147
+ * Export Zone response schema
148
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-export-a-zone-file
149
+ */
150
+ export const exportZoneResponseSchema = z.object({
151
+ zone_file: z.string(),
152
+ });
153
+
154
+ /**
155
+ * List Zone Actions response schema
156
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-list-actions-for-a-zone
157
+ */
158
+ export const listZoneActionsResponseSchema = z.object({
159
+ actions: z.array(actionSchema),
160
+ meta: z
161
+ .object({
162
+ pagination: paginationMetaSchema,
163
+ })
164
+ .optional(),
165
+ });
166
+
167
+ /**
168
+ * Get Zone Action response schema
169
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-get-an-action-for-a-zone
170
+ */
171
+ export const getZoneActionResponseSchema = z.object({
172
+ action: actionSchema,
173
+ });
174
+
175
+ /**
176
+ * Change Zone Primary Nameservers request schema
177
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-change-a-zones-primary-nameservers
178
+ */
179
+ export const changeZonePrimaryNameserversRequestSchema = z.object({
180
+ nameservers: z.array(z.string()),
181
+ });
182
+
183
+ /**
184
+ * Change Zone Primary Nameservers response schema
185
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-change-a-zones-primary-nameservers
186
+ */
187
+ export const changeZonePrimaryNameserversResponseSchema = z.object({
188
+ action: actionSchema,
189
+ });
190
+
191
+ /**
192
+ * Change Zone Protection request schema
193
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-change-a-zones-protection
194
+ */
195
+ export const changeZoneProtectionRequestSchema = z.object({
196
+ delete: z.boolean(),
197
+ });
198
+
199
+ /**
200
+ * Change Zone Protection response schema
201
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-change-a-zones-protection
202
+ */
203
+ export const changeZoneProtectionResponseSchema = z.object({
204
+ action: actionSchema,
205
+ });
206
+
207
+ /**
208
+ * Change Zone Default TTL request schema
209
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-change-a-zones-default-ttl
210
+ */
211
+ export const changeZoneDefaultTTLRequestSchema = z.object({
212
+ ttl: z.number(),
213
+ });
214
+
215
+ /**
216
+ * Change Zone Default TTL response schema
217
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-change-a-zones-default-ttl
218
+ */
219
+ export const changeZoneDefaultTTLResponseSchema = z.object({
220
+ action: actionSchema,
221
+ });
222
+
223
+ /**
224
+ * Import Zone file request schema
225
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-import-a-zone-file
226
+ */
227
+ export const importZoneFileRequestSchema = z.object({
228
+ zone_file: z.string(),
229
+ });
230
+
231
+ /**
232
+ * Import Zone file response schema
233
+ * @see https://docs.hetzner.cloud/reference/cloud#zones-import-a-zone-file
234
+ */
235
+ export const importZoneFileResponseSchema = z.object({
236
+ zone: zoneSchema,
237
+ action: actionSchema,
238
+ });
239
+
240
+ /**
241
+ * List RRSets response schema
242
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-list-rrsets
243
+ */
244
+ export const listRRSetsResponseSchema = z.object({
245
+ rrsets: z.array(rrsetSchema),
246
+ meta: z
247
+ .object({
248
+ pagination: paginationMetaSchema,
249
+ })
250
+ .optional(),
251
+ });
252
+
253
+ /**
254
+ * Get RRSet response schema
255
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-get-an-rrset
256
+ */
257
+ export const getRRSetResponseSchema = z.object({
258
+ rrset: rrsetSchema,
259
+ });
260
+
261
+ /**
262
+ * Create RRSet request schema
263
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-create-an-rrset
264
+ */
265
+ export const createRRSetRequestSchema = z.object({
266
+ name: z.string(),
267
+ type: z.string(),
268
+ ttl: z.number().optional(),
269
+ records: z.array(
270
+ z.object({
271
+ value: z.string(),
272
+ comment: z.string().nullable().optional(),
273
+ }),
274
+ ),
275
+ labels: z.record(z.string(), z.string()).optional(),
276
+ });
277
+
278
+ /**
279
+ * Create RRSet response schema
280
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-create-an-rrset
281
+ */
282
+ export const createRRSetResponseSchema = z.object({
283
+ rrset: rrsetSchema,
284
+ action: actionSchema.optional(),
285
+ });
286
+
287
+ /**
288
+ * Update RRSet request schema
289
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-update-an-rrset
290
+ */
291
+ export const updateRRSetRequestSchema = z.object({
292
+ ttl: z.number().nullable().optional(),
293
+ records: z
294
+ .array(
295
+ z.object({
296
+ value: z.string(),
297
+ comment: z.string().nullable().optional(),
298
+ }),
299
+ )
300
+ .optional(),
301
+ labels: z.record(z.string(), z.string()).optional(),
302
+ });
303
+
304
+ /**
305
+ * Update RRSet response schema
306
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-update-an-rrset
307
+ */
308
+ export const updateRRSetResponseSchema = z.object({
309
+ rrset: rrsetSchema,
310
+ action: actionSchema.optional(),
311
+ });
312
+
313
+ /**
314
+ * Delete RRSet response schema
315
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-delete-an-rrset
316
+ */
317
+ export const deleteRRSetResponseSchema = z.object({
318
+ action: actionSchema.optional(),
319
+ });
320
+
321
+ /**
322
+ * Change RRSet Protection request schema
323
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-change-an-rrsets-protection
324
+ */
325
+ export const changeRRSetProtectionRequestSchema = z.object({
326
+ delete: z.boolean(),
327
+ });
328
+
329
+ /**
330
+ * Change RRSet Protection response schema
331
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-change-an-rrsets-protection
332
+ */
333
+ export const changeRRSetProtectionResponseSchema = z.object({
334
+ action: actionSchema,
335
+ });
336
+
337
+ /**
338
+ * Change RRSet TTL request schema
339
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-change-an-rrsets-ttl
340
+ */
341
+ export const changeRRSetTTLRequestSchema = z.object({
342
+ ttl: z.number().nullable(),
343
+ });
344
+
345
+ /**
346
+ * Change RRSet TTL response schema
347
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-change-an-rrsets-ttl
348
+ */
349
+ export const changeRRSetTTLResponseSchema = z.object({
350
+ action: actionSchema,
351
+ });
352
+
353
+ /**
354
+ * Set RRSet Records request schema
355
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-set-records-of-an-rrset
356
+ */
357
+ export const setRRSetRecordsRequestSchema = z.object({
358
+ records: z.array(
359
+ z.object({
360
+ value: z.string(),
361
+ comment: z.string().nullable().optional(),
362
+ }),
363
+ ),
364
+ ttl: z.number().nullable().optional(),
365
+ });
366
+
367
+ /**
368
+ * Set RRSet Records response schema
369
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-set-records-of-an-rrset
370
+ */
371
+ export const setRRSetRecordsResponseSchema = z.object({
372
+ action: actionSchema,
373
+ });
374
+
375
+ /**
376
+ * Add RRSet Records request schema
377
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-add-records-to-an-rrset
378
+ */
379
+ export const addRRSetRecordsRequestSchema = z.object({
380
+ records: z.array(
381
+ z.object({
382
+ value: z.string(),
383
+ comment: z.string().nullable().optional(),
384
+ }),
385
+ ),
386
+ ttl: z.number().nullable().optional(),
387
+ });
388
+
389
+ /**
390
+ * Add RRSet Records response schema
391
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-add-records-to-an-rrset
392
+ */
393
+ export const addRRSetRecordsResponseSchema = z.object({
394
+ action: actionSchema,
395
+ });
396
+
397
+ /**
398
+ * Remove RRSet Records request schema
399
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-remove-records-from-an-rrset
400
+ */
401
+ export const removeRRSetRecordsRequestSchema = z.object({
402
+ records: z.array(
403
+ z.object({
404
+ value: z.string(),
405
+ comment: z.string().nullable().optional(),
406
+ }),
407
+ ),
408
+ });
409
+
410
+ /**
411
+ * Remove RRSet Records response schema
412
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-remove-records-from-an-rrset
413
+ */
414
+ export const removeRRSetRecordsResponseSchema = z.object({
415
+ action: actionSchema,
416
+ });
417
+
418
+ /**
419
+ * Update RRSet Records request schema
420
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-update-records-of-an-rrset
421
+ */
422
+ export const updateRRSetRecordsRequestSchema = z.object({
423
+ records: z.array(
424
+ z.object({
425
+ value: z.string(),
426
+ comment: z.string().nullable().optional(),
427
+ }),
428
+ ),
429
+ });
430
+
431
+ /**
432
+ * Update RRSet Records response schema
433
+ * @see https://docs.hetzner.cloud/reference/cloud#rrsets-update-records-of-an-rrset
434
+ */
435
+ export const updateRRSetRecordsResponseSchema = z.object({
436
+ action: actionSchema,
437
+ });