@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,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hetzner Cloud Certificates API
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { HCloudClient } from "../../client/index";
|
|
7
|
+
import type {
|
|
8
|
+
ListCertificatesParams,
|
|
9
|
+
ListCertificatesResponse,
|
|
10
|
+
CreateCertificateParams,
|
|
11
|
+
CreateCertificateResponse,
|
|
12
|
+
GetCertificateResponse,
|
|
13
|
+
UpdateCertificateParams,
|
|
14
|
+
UpdateCertificateResponse,
|
|
15
|
+
DeleteCertificateResponse,
|
|
16
|
+
ListCertificateActionsParams,
|
|
17
|
+
ListCertificateActionsResponse,
|
|
18
|
+
GetCertificateActionResponse,
|
|
19
|
+
RetryCertificateIssuanceResponse,
|
|
20
|
+
} from "../../apis/certificates/types";
|
|
21
|
+
import { validate } from "../../validation/index";
|
|
22
|
+
import {
|
|
23
|
+
listCertificatesResponseSchema,
|
|
24
|
+
createCertificateRequestSchema,
|
|
25
|
+
createCertificateResponseSchema,
|
|
26
|
+
getCertificateResponseSchema,
|
|
27
|
+
updateCertificateRequestSchema,
|
|
28
|
+
updateCertificateResponseSchema,
|
|
29
|
+
deleteCertificateResponseSchema,
|
|
30
|
+
listCertificateActionsResponseSchema,
|
|
31
|
+
getCertificateActionResponseSchema,
|
|
32
|
+
retryCertificateIssuanceResponseSchema,
|
|
33
|
+
} from "../../apis/certificates/schemas";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Certificates API client
|
|
37
|
+
*/
|
|
38
|
+
export class CertificatesClient {
|
|
39
|
+
constructor(private readonly client: HCloudClient) {}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns all Certificate objects.
|
|
43
|
+
*
|
|
44
|
+
* @param params - Query parameters for filtering and pagination
|
|
45
|
+
* @returns Promise resolving to list of certificates with pagination metadata
|
|
46
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-certificates
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
51
|
+
*
|
|
52
|
+
* // List all certificates
|
|
53
|
+
* const result = await client.certificates.list();
|
|
54
|
+
*
|
|
55
|
+
* // List certificates with filters
|
|
56
|
+
* const managedCerts = await client.certificates.list({
|
|
57
|
+
* type: ['managed'],
|
|
58
|
+
* label_selector: 'environment=production',
|
|
59
|
+
* sort: ['name:asc'],
|
|
60
|
+
* page: 1,
|
|
61
|
+
* per_page: 50
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
async list(params?: ListCertificatesParams): Promise<ListCertificatesResponse> {
|
|
66
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
67
|
+
|
|
68
|
+
if (params?.name) {
|
|
69
|
+
queryParams.name = params.name;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (params?.label_selector) {
|
|
73
|
+
queryParams.label_selector = params.label_selector;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (params?.sort) {
|
|
77
|
+
queryParams.sort = Array.isArray(params.sort) ? params.sort : [params.sort];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (params?.type) {
|
|
81
|
+
queryParams.type = Array.isArray(params.type) ? params.type : [params.type];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (params?.page !== undefined) {
|
|
85
|
+
queryParams.page = params.page;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (params?.per_page !== undefined) {
|
|
89
|
+
queryParams.per_page = params.per_page;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const response = await this.client.get<unknown>("/certificates", queryParams);
|
|
93
|
+
|
|
94
|
+
return validate(listCertificatesResponseSchema, response, {
|
|
95
|
+
context: "List certificates response",
|
|
96
|
+
detailed: true,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new Certificate.
|
|
102
|
+
*
|
|
103
|
+
* @param params - Parameters for creating the certificate
|
|
104
|
+
* @returns Promise resolving to the created certificate with action
|
|
105
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-create-a-certificate
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
110
|
+
*
|
|
111
|
+
* // Create an uploaded certificate
|
|
112
|
+
* const result = await client.certificates.create({
|
|
113
|
+
* name: 'my-certificate',
|
|
114
|
+
* type: 'uploaded',
|
|
115
|
+
* certificate: '-----BEGIN CERTIFICATE-----...',
|
|
116
|
+
* private_key: '-----BEGIN PRIVATE KEY-----...'
|
|
117
|
+
* });
|
|
118
|
+
*
|
|
119
|
+
* // Create a managed certificate
|
|
120
|
+
* const result = await client.certificates.create({
|
|
121
|
+
* name: 'my-managed-cert',
|
|
122
|
+
* type: 'managed',
|
|
123
|
+
* domain_names: ['example.com', 'www.example.com']
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
async create(params: CreateCertificateParams): Promise<CreateCertificateResponse> {
|
|
128
|
+
const validatedParams = validate(createCertificateRequestSchema, params, {
|
|
129
|
+
context: "Create certificate request",
|
|
130
|
+
detailed: true,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const response = await this.client.post<unknown>("/certificates", validatedParams);
|
|
134
|
+
|
|
135
|
+
return validate(createCertificateResponseSchema, response, {
|
|
136
|
+
context: "Create certificate response",
|
|
137
|
+
detailed: true,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Returns a specific Certificate object.
|
|
143
|
+
*
|
|
144
|
+
* @param id - ID of the Certificate
|
|
145
|
+
* @returns Promise resolving to the certificate
|
|
146
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-get-a-certificate
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
151
|
+
*
|
|
152
|
+
* const certificate = await client.certificates.get(12345);
|
|
153
|
+
* console.log(certificate.certificate.name);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
async get(id: number): Promise<GetCertificateResponse> {
|
|
157
|
+
const response = await this.client.get<unknown>(`/certificates/${id}`);
|
|
158
|
+
|
|
159
|
+
return validate(getCertificateResponseSchema, response, {
|
|
160
|
+
context: "Get certificate response",
|
|
161
|
+
detailed: true,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Updates a Certificate.
|
|
167
|
+
*
|
|
168
|
+
* You can update a Certificate's name and labels.
|
|
169
|
+
*
|
|
170
|
+
* @param id - ID of the Certificate
|
|
171
|
+
* @param params - Parameters to update (name and/or labels)
|
|
172
|
+
* @returns Promise resolving to the updated certificate
|
|
173
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-update-a-certificate
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
178
|
+
*
|
|
179
|
+
* const updated = await client.certificates.update(12345, {
|
|
180
|
+
* name: 'new-certificate-name',
|
|
181
|
+
* labels: { environment: 'production' }
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
async update(id: number, params: UpdateCertificateParams): Promise<UpdateCertificateResponse> {
|
|
186
|
+
const validatedParams = validate(updateCertificateRequestSchema, params, {
|
|
187
|
+
context: "Update certificate request",
|
|
188
|
+
detailed: true,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const response = await this.client.put<unknown>(`/certificates/${id}`, validatedParams);
|
|
192
|
+
|
|
193
|
+
return validate(updateCertificateResponseSchema, response, {
|
|
194
|
+
context: "Update certificate response",
|
|
195
|
+
detailed: true,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Deletes a Certificate.
|
|
201
|
+
*
|
|
202
|
+
* @param id - ID of the Certificate
|
|
203
|
+
* @returns Promise resolving to the delete action
|
|
204
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-delete-a-certificate
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
209
|
+
*
|
|
210
|
+
* const result = await client.certificates.delete(12345);
|
|
211
|
+
* console.log(`Delete action ID: ${result.action.id}`);
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
async delete(id: number): Promise<DeleteCertificateResponse> {
|
|
215
|
+
const response = await this.client.delete<unknown>(`/certificates/${id}`);
|
|
216
|
+
|
|
217
|
+
return validate(deleteCertificateResponseSchema, response, {
|
|
218
|
+
context: "Delete certificate response",
|
|
219
|
+
detailed: true,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Returns all Action objects for a Certificate.
|
|
225
|
+
*
|
|
226
|
+
* @param id - ID of the Certificate
|
|
227
|
+
* @param params - Query parameters for filtering and pagination
|
|
228
|
+
* @returns Promise resolving to list of actions with pagination metadata
|
|
229
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-actions-for-a-certificate
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
234
|
+
*
|
|
235
|
+
* const actions = await client.certificates.listActions(12345, {
|
|
236
|
+
* status: ['running'],
|
|
237
|
+
* sort: ['started:desc']
|
|
238
|
+
* });
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
async listActions(
|
|
242
|
+
id: number,
|
|
243
|
+
params?: ListCertificateActionsParams,
|
|
244
|
+
): Promise<ListCertificateActionsResponse> {
|
|
245
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
246
|
+
|
|
247
|
+
if (params?.id !== undefined) {
|
|
248
|
+
const ids = Array.isArray(params.id) ? params.id : [params.id];
|
|
249
|
+
queryParams.id = ids.map(String);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (params?.status) {
|
|
253
|
+
queryParams.status = Array.isArray(params.status) ? params.status : [params.status];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (params?.sort) {
|
|
257
|
+
queryParams.sort = Array.isArray(params.sort) ? params.sort : [params.sort];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (params?.page !== undefined) {
|
|
261
|
+
queryParams.page = params.page;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (params?.per_page !== undefined) {
|
|
265
|
+
queryParams.per_page = params.per_page;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const response = await this.client.get<unknown>(`/certificates/${id}/actions`, queryParams);
|
|
269
|
+
|
|
270
|
+
return validate(listCertificateActionsResponseSchema, response, {
|
|
271
|
+
context: "List certificate actions response",
|
|
272
|
+
detailed: true,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Returns a specific Action object for a Certificate.
|
|
278
|
+
*
|
|
279
|
+
* @param id - ID of the Certificate
|
|
280
|
+
* @param actionId - ID of the Action
|
|
281
|
+
* @returns Promise resolving to the action
|
|
282
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-get-an-action-for-a-certificate
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
287
|
+
*
|
|
288
|
+
* const action = await client.certificates.getAction(12345, 67890);
|
|
289
|
+
* console.log(action.action.command);
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
async getAction(id: number, actionId: number): Promise<GetCertificateActionResponse> {
|
|
293
|
+
const response = await this.client.get<unknown>(`/certificates/${id}/actions/${actionId}`);
|
|
294
|
+
|
|
295
|
+
return validate(getCertificateActionResponseSchema, response, {
|
|
296
|
+
context: "Get certificate action response",
|
|
297
|
+
detailed: true,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Retries the issuance or renewal of a managed Certificate.
|
|
303
|
+
*
|
|
304
|
+
* Only works for managed Certificates in state `verification_process`.
|
|
305
|
+
*
|
|
306
|
+
* @param id - ID of the Certificate
|
|
307
|
+
* @returns Promise resolving to the retry action
|
|
308
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-retry-issuance-or-renewal
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
313
|
+
*
|
|
314
|
+
* const result = await client.certificates.retryIssuance(12345);
|
|
315
|
+
* console.log(`Retry action ID: ${result.action.id}`);
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
async retryIssuance(id: number): Promise<RetryCertificateIssuanceResponse> {
|
|
319
|
+
const response = await this.client.post<unknown>(`/certificates/${id}/actions/retry`, {});
|
|
320
|
+
|
|
321
|
+
return validate(retryCertificateIssuanceResponseSchema, response, {
|
|
322
|
+
context: "Retry certificate issuance response",
|
|
323
|
+
detailed: true,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for Hetzner Cloud Certificates API
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates
|
|
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
|
+
* Certificate status schema
|
|
12
|
+
*/
|
|
13
|
+
export const certificateStatusSchema = z.enum(["ready", "verification_process", "pending_deletion"]);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Certificate type schema
|
|
17
|
+
*/
|
|
18
|
+
export const certificateTypeSchema = z.enum(["uploaded", "managed"]);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Certificate schema
|
|
22
|
+
*/
|
|
23
|
+
export const certificateSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
id: z.number(),
|
|
26
|
+
name: z.string(),
|
|
27
|
+
labels: z.record(z.string(), z.string()),
|
|
28
|
+
type: certificateTypeSchema,
|
|
29
|
+
certificate: z.string().nullable(),
|
|
30
|
+
created: z.string(),
|
|
31
|
+
not_valid_before: z.string(),
|
|
32
|
+
not_valid_after: z.string(),
|
|
33
|
+
domain_names: z.array(z.string()),
|
|
34
|
+
fingerprint: z.string().nullable(),
|
|
35
|
+
status: certificateStatusSchema.optional(),
|
|
36
|
+
used_by: z
|
|
37
|
+
.array(
|
|
38
|
+
z.object({
|
|
39
|
+
id: z.number(),
|
|
40
|
+
type: z.string(),
|
|
41
|
+
}),
|
|
42
|
+
)
|
|
43
|
+
.optional(),
|
|
44
|
+
})
|
|
45
|
+
.passthrough();
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* List Certificates response schema
|
|
49
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-certificates
|
|
50
|
+
*/
|
|
51
|
+
export const listCertificatesResponseSchema = z.object({
|
|
52
|
+
certificates: z.array(certificateSchema),
|
|
53
|
+
meta: z
|
|
54
|
+
.object({
|
|
55
|
+
pagination: paginationMetaSchema,
|
|
56
|
+
})
|
|
57
|
+
.optional(),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Create Certificate request schema
|
|
62
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-create-a-certificate
|
|
63
|
+
*/
|
|
64
|
+
export const createCertificateRequestSchema = z.object({
|
|
65
|
+
name: z.string().min(1),
|
|
66
|
+
type: certificateTypeSchema.optional(),
|
|
67
|
+
certificate: z.string().optional(),
|
|
68
|
+
private_key: z.string().optional(),
|
|
69
|
+
domain_names: z.array(z.string()).optional(),
|
|
70
|
+
labels: z.record(z.string(), z.string()).optional(),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create Certificate response schema
|
|
75
|
+
*/
|
|
76
|
+
export const createCertificateResponseSchema = z.object({
|
|
77
|
+
certificate: certificateSchema,
|
|
78
|
+
action: actionSchema.nullable(),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get Certificate response schema
|
|
83
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-get-a-certificate
|
|
84
|
+
*/
|
|
85
|
+
export const getCertificateResponseSchema = z.object({
|
|
86
|
+
certificate: certificateSchema,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Update Certificate request schema
|
|
91
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-update-a-certificate
|
|
92
|
+
*/
|
|
93
|
+
export const updateCertificateRequestSchema = z.object({
|
|
94
|
+
name: z.string().min(1).optional(),
|
|
95
|
+
labels: z.record(z.string(), z.string()).optional(),
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Update Certificate response schema
|
|
100
|
+
*/
|
|
101
|
+
export const updateCertificateResponseSchema = z.object({
|
|
102
|
+
certificate: certificateSchema,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Delete Certificate response schema
|
|
107
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-delete-a-certificate
|
|
108
|
+
*/
|
|
109
|
+
export const deleteCertificateResponseSchema = z.object({
|
|
110
|
+
action: actionSchema,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* List Certificate Actions response schema
|
|
115
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-actions-for-a-certificate
|
|
116
|
+
*/
|
|
117
|
+
export const listCertificateActionsResponseSchema = z.object({
|
|
118
|
+
actions: z.array(actionSchema),
|
|
119
|
+
meta: z
|
|
120
|
+
.object({
|
|
121
|
+
pagination: paginationMetaSchema,
|
|
122
|
+
})
|
|
123
|
+
.optional(),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Get Certificate Action response schema
|
|
128
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-get-an-action-for-a-certificate
|
|
129
|
+
*/
|
|
130
|
+
export const getCertificateActionResponseSchema = z.object({
|
|
131
|
+
action: actionSchema,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Retry Certificate Issuance/Renewal response schema
|
|
136
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-retry-issuance-or-renewal
|
|
137
|
+
*/
|
|
138
|
+
export const retryCertificateIssuanceResponseSchema = z.object({
|
|
139
|
+
action: actionSchema,
|
|
140
|
+
});
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Hetzner Cloud Certificates API
|
|
3
|
+
* Types are inferred from Zod schemas
|
|
4
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// biome-ignore assist/source/organizeImports: we need to import the schemas first
|
|
8
|
+
import {
|
|
9
|
+
certificateStatusSchema,
|
|
10
|
+
certificateTypeSchema,
|
|
11
|
+
listCertificatesResponseSchema,
|
|
12
|
+
createCertificateRequestSchema,
|
|
13
|
+
createCertificateResponseSchema,
|
|
14
|
+
getCertificateResponseSchema,
|
|
15
|
+
updateCertificateRequestSchema,
|
|
16
|
+
updateCertificateResponseSchema,
|
|
17
|
+
deleteCertificateResponseSchema,
|
|
18
|
+
listCertificateActionsResponseSchema,
|
|
19
|
+
getCertificateActionResponseSchema,
|
|
20
|
+
retryCertificateIssuanceResponseSchema,
|
|
21
|
+
certificateSchema,
|
|
22
|
+
} from "../../apis/certificates/schemas";
|
|
23
|
+
import { actionSchema } from "../../apis/actions/schemas";
|
|
24
|
+
import type { z } from "zod";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Certificate status values
|
|
28
|
+
*/
|
|
29
|
+
export type CertificateStatus = z.infer<typeof certificateStatusSchema>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Certificate type values
|
|
33
|
+
*/
|
|
34
|
+
export type CertificateType = z.infer<typeof certificateTypeSchema>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Hetzner Cloud Certificate
|
|
38
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-certificates
|
|
39
|
+
*/
|
|
40
|
+
export type Certificate = z.infer<typeof certificateSchema>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Pagination metadata
|
|
44
|
+
* @see https://docs.hetzner.cloud/reference/cloud#pagination
|
|
45
|
+
* Re-exported from servers module for consistency
|
|
46
|
+
*/
|
|
47
|
+
export type { PaginationMeta } from "../../apis/servers/types";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Action information
|
|
51
|
+
* Re-exported from servers module for consistency
|
|
52
|
+
*/
|
|
53
|
+
export type Action = z.infer<typeof actionSchema>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* List Certificates query parameters
|
|
57
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-certificates
|
|
58
|
+
*/
|
|
59
|
+
export interface ListCertificatesParams {
|
|
60
|
+
/**
|
|
61
|
+
* Can be used to filter Certificates by their name. The response will only contain the Certificate matching the specified name.
|
|
62
|
+
*/
|
|
63
|
+
name?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Can be used to filter Certificates by labels. The response will only contain Certificates matching the label selector.
|
|
66
|
+
* @see https://docs.hetzner.cloud/reference/cloud#label-selector
|
|
67
|
+
*/
|
|
68
|
+
label_selector?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Can be used multiple times. Choices: id, id:asc, id:desc, name, name:asc, name:desc, created, created:asc, created:desc
|
|
71
|
+
* @see https://docs.hetzner.cloud/reference/cloud#sorting
|
|
72
|
+
*/
|
|
73
|
+
sort?: string | string[];
|
|
74
|
+
/**
|
|
75
|
+
* Can be used multiple times. The response will only contain Certificates matching the specified type.
|
|
76
|
+
* Choices: uploaded, managed
|
|
77
|
+
*/
|
|
78
|
+
type?: CertificateType | CertificateType[];
|
|
79
|
+
/**
|
|
80
|
+
* Page number to return. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
81
|
+
*/
|
|
82
|
+
page?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Maximum number of entries returned per page. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
85
|
+
*/
|
|
86
|
+
per_page?: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* List Certificates response
|
|
91
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-certificates
|
|
92
|
+
*/
|
|
93
|
+
export type ListCertificatesResponse = z.infer<typeof listCertificatesResponseSchema>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Create Certificate request parameters
|
|
97
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-create-a-certificate
|
|
98
|
+
*/
|
|
99
|
+
export type CreateCertificateParams = z.infer<typeof createCertificateRequestSchema>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Create Certificate response
|
|
103
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-create-a-certificate
|
|
104
|
+
*/
|
|
105
|
+
export type CreateCertificateResponse = z.infer<typeof createCertificateResponseSchema>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get Certificate response
|
|
109
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-get-a-certificate
|
|
110
|
+
*/
|
|
111
|
+
export type GetCertificateResponse = z.infer<typeof getCertificateResponseSchema>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Update Certificate request parameters
|
|
115
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-update-a-certificate
|
|
116
|
+
*/
|
|
117
|
+
export type UpdateCertificateParams = z.infer<typeof updateCertificateRequestSchema>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Update Certificate response
|
|
121
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-update-a-certificate
|
|
122
|
+
*/
|
|
123
|
+
export type UpdateCertificateResponse = z.infer<typeof updateCertificateResponseSchema>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Delete Certificate response
|
|
127
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-delete-a-certificate
|
|
128
|
+
*/
|
|
129
|
+
export type DeleteCertificateResponse = z.infer<typeof deleteCertificateResponseSchema>;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* List Certificate Actions query parameters
|
|
133
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-actions-for-a-certificate
|
|
134
|
+
*/
|
|
135
|
+
export interface ListCertificateActionsParams {
|
|
136
|
+
/**
|
|
137
|
+
* Can be used multiple times. The response will only contain Actions matching the specified IDs.
|
|
138
|
+
*/
|
|
139
|
+
id?: number | number[];
|
|
140
|
+
/**
|
|
141
|
+
* Can be used multiple times. The response will only contain Actions matching the specified status.
|
|
142
|
+
* Choices: running, success, error
|
|
143
|
+
*/
|
|
144
|
+
status?: "running" | "success" | "error" | Array<"running" | "success" | "error">;
|
|
145
|
+
/**
|
|
146
|
+
* 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
|
|
147
|
+
* @see https://docs.hetzner.cloud/reference/cloud#sorting
|
|
148
|
+
*/
|
|
149
|
+
sort?: string | string[];
|
|
150
|
+
/**
|
|
151
|
+
* Page number to return. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
152
|
+
*/
|
|
153
|
+
page?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Maximum number of entries returned per page. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
156
|
+
*/
|
|
157
|
+
per_page?: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* List Certificate Actions response
|
|
162
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-list-actions-for-a-certificate
|
|
163
|
+
*/
|
|
164
|
+
export type ListCertificateActionsResponse = z.infer<typeof listCertificateActionsResponseSchema>;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get Certificate Action response
|
|
168
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-get-an-action-for-a-certificate
|
|
169
|
+
*/
|
|
170
|
+
export type GetCertificateActionResponse = z.infer<typeof getCertificateActionResponseSchema>;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Retry Certificate Issuance/Renewal response
|
|
174
|
+
* @see https://docs.hetzner.cloud/reference/cloud#certificates-retry-issuance-or-renewal
|
|
175
|
+
*/
|
|
176
|
+
export type RetryCertificateIssuanceResponse = z.infer<typeof retryCertificateIssuanceResponseSchema>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common Zod schemas shared across multiple API modules
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#pagination
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pagination metadata schema
|
|
10
|
+
* @see https://docs.hetzner.cloud/reference/cloud#pagination
|
|
11
|
+
*/
|
|
12
|
+
export const paginationMetaSchema = z.object({
|
|
13
|
+
page: z.number(),
|
|
14
|
+
per_page: z.number(),
|
|
15
|
+
previous_page: z.number().nullable(),
|
|
16
|
+
next_page: z.number().nullable(),
|
|
17
|
+
last_page: z.number(),
|
|
18
|
+
total_entries: z.number(),
|
|
19
|
+
});
|