@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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hetzner Cloud ISOs API
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { HCloudClient } from "@/client/index";
|
|
7
|
+
import type { ListISOsParams, ListISOsResponse, GetISOResponse } from "@/apis/isos/types";
|
|
8
|
+
import { validate } from "@/validation/index";
|
|
9
|
+
import { listISOsResponseSchema, getISOResponseSchema } from "@/apis/isos/schemas";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* ISOs API client
|
|
13
|
+
*/
|
|
14
|
+
export class ISOsClient {
|
|
15
|
+
constructor(private readonly client: HCloudClient) {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns all available ISO objects.
|
|
19
|
+
*
|
|
20
|
+
* @param params - Query parameters for filtering and pagination
|
|
21
|
+
* @returns Promise resolving to list of ISOs with pagination metadata
|
|
22
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-list-isos
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
27
|
+
*
|
|
28
|
+
* // List all ISOs
|
|
29
|
+
* const result = await client.isos.list();
|
|
30
|
+
*
|
|
31
|
+
* // List ISOs with filters
|
|
32
|
+
* const isos = await client.isos.list({
|
|
33
|
+
* name: 'debian',
|
|
34
|
+
* sort: ['name:asc'],
|
|
35
|
+
* page: 1,
|
|
36
|
+
* per_page: 50
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
async list(params?: ListISOsParams): Promise<ListISOsResponse> {
|
|
41
|
+
const queryParams: Record<string, string | number | string[] | undefined> = {};
|
|
42
|
+
|
|
43
|
+
if (params?.name) {
|
|
44
|
+
queryParams.name = params.name;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (params?.sort) {
|
|
48
|
+
queryParams.sort = Array.isArray(params.sort) ? params.sort : [params.sort];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (params?.page !== undefined) {
|
|
52
|
+
queryParams.page = params.page;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (params?.per_page !== undefined) {
|
|
56
|
+
queryParams.per_page = params.per_page;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const response = await this.client.get<unknown>("/isos", queryParams);
|
|
60
|
+
|
|
61
|
+
return validate(listISOsResponseSchema, response, {
|
|
62
|
+
context: "List ISOs response",
|
|
63
|
+
detailed: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns a specific ISO object.
|
|
69
|
+
*
|
|
70
|
+
* @param id - ID of the ISO
|
|
71
|
+
* @returns Promise resolving to the ISO
|
|
72
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-get-an-iso
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const client = new HCloudClient({ token: 'your-token' });
|
|
77
|
+
*
|
|
78
|
+
* // Get an ISO by ID
|
|
79
|
+
* const iso = await client.isos.get(12345);
|
|
80
|
+
* console.log(iso.iso.name);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
async get(id: number): Promise<GetISOResponse> {
|
|
84
|
+
const response = await this.client.get<unknown>(`/isos/${id}`);
|
|
85
|
+
|
|
86
|
+
return validate(getISOResponseSchema, response, {
|
|
87
|
+
context: "Get ISO response",
|
|
88
|
+
detailed: true,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for Hetzner Cloud ISOs API
|
|
3
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-list-isos
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { paginationMetaSchema } from "@/apis/common/schemas";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ISO type schema
|
|
11
|
+
*/
|
|
12
|
+
export const isoTypeSchema = z.enum(["public", "private"]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* ISO schema
|
|
16
|
+
*/
|
|
17
|
+
export const isoSchema = z.object({
|
|
18
|
+
id: z.number(),
|
|
19
|
+
name: z.string(),
|
|
20
|
+
description: z.string(),
|
|
21
|
+
type: isoTypeSchema,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* List ISOs response schema
|
|
26
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-list-isos
|
|
27
|
+
*/
|
|
28
|
+
export const listISOsResponseSchema = z.object({
|
|
29
|
+
isos: z.array(isoSchema),
|
|
30
|
+
meta: z
|
|
31
|
+
.object({
|
|
32
|
+
pagination: paginationMetaSchema,
|
|
33
|
+
})
|
|
34
|
+
.optional(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get ISO response schema
|
|
39
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-get-an-iso
|
|
40
|
+
*/
|
|
41
|
+
export const getISOResponseSchema = z.object({
|
|
42
|
+
iso: isoSchema,
|
|
43
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Hetzner Cloud ISOs API
|
|
3
|
+
* Types are inferred from Zod schemas
|
|
4
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// biome-ignore assist/source/organizeImports: we need to import the schemas first
|
|
8
|
+
import {
|
|
9
|
+
listISOsResponseSchema,
|
|
10
|
+
getISOResponseSchema,
|
|
11
|
+
isoSchema,
|
|
12
|
+
isoTypeSchema,
|
|
13
|
+
} from "@/apis/isos/schemas";
|
|
14
|
+
import type { z } from "zod";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ISO type
|
|
18
|
+
*/
|
|
19
|
+
export type ISOType = z.infer<typeof isoTypeSchema>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hetzner Cloud ISO
|
|
23
|
+
*/
|
|
24
|
+
export type ISO = z.infer<typeof isoSchema>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* List ISOs query parameters
|
|
28
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-list-isos
|
|
29
|
+
*/
|
|
30
|
+
export interface ListISOsParams {
|
|
31
|
+
/**
|
|
32
|
+
* Can be used multiple times. Choices: id, id:asc, id:desc, name, name:asc, name:desc
|
|
33
|
+
* @see https://docs.hetzner.cloud/reference/cloud#sorting
|
|
34
|
+
*/
|
|
35
|
+
sort?: string | string[];
|
|
36
|
+
/**
|
|
37
|
+
* Can be used to filter ISOs by their name. The response will only contain the ISO matching the specified name.
|
|
38
|
+
*/
|
|
39
|
+
name?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Page number to return. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
42
|
+
*/
|
|
43
|
+
page?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum number of entries returned per page. For more information, see [Pagination](https://docs.hetzner.cloud/reference/cloud#pagination).
|
|
46
|
+
*/
|
|
47
|
+
per_page?: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* List ISOs response
|
|
52
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-list-isos
|
|
53
|
+
*/
|
|
54
|
+
export type ListISOsResponse = z.infer<typeof listISOsResponseSchema>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get ISO response
|
|
58
|
+
* @see https://docs.hetzner.cloud/reference/cloud#isos-get-an-iso
|
|
59
|
+
*/
|
|
60
|
+
export type GetISOResponse = z.infer<typeof getISOResponseSchema>;
|