import * as API from "@distilled.cloud/core/api"; // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-hetzner/specs/cloud.spec.json). Do not edit. import * as S from "@distilled.cloud/core/schema-lite"; import * as __L from "@distilled.cloud/core/schema-lite"; import { UnknownHetznerError } from "../errors.ts"; import { paginatePageNumber } from "../pagination.ts"; import { HetznerProtocol, type HetznerOpError, type HetznerOpContext } from "../protocol.ts"; import * as Retry from "../retry.ts"; import * as T from "../traits.ts"; // Schema table, filled on first reach (see __S at the end). const __s: any[] = []; export type { HetznerOpError, HetznerOpContext }; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type CreateSshKeyRequestLabelsMap = { [key: string]: string | undefined }; export interface CreateSshKeyRequest { /** Name of the SSH key. */ name: string; /** Public key. */ public_key: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels?: CreateSshKeyRequestLabelsMap; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type CreateSshKeyResponseSshKeyLabelsMap = { [key: string]: string | undefined }; export interface CreateSshKeyResponseSshKey { /** ID of the [SSH Key](#tag/ssh-keys). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** MD5 fingerprint of the SSH public key. */ fingerprint: string; /** Public key. */ public_key: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: CreateSshKeyResponseSshKeyLabelsMap; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; } export interface CreateSshKeyResponse { ssh_key: CreateSshKeyResponseSshKey; } export interface DeleteSshKeyRequest { /** ID of the SSH Key. */ id: number; } export interface DeleteSshKeyResponse {} export interface GetSshKeyRequest { /** ID of the SSH Key. */ id: number; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type GetSshKeyResponseSshKeyLabelsMap = { [key: string]: string | undefined }; export interface GetSshKeyResponseSshKey { /** ID of the [SSH Key](#tag/ssh-keys). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** MD5 fingerprint of the SSH public key. */ fingerprint: string; /** Public key. */ public_key: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: GetSshKeyResponseSshKeyLabelsMap; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; } export interface GetSshKeyResponse { ssh_key: GetSshKeyResponseSshKey; } export type ListSshKeysRequestSortItem = | "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc"; export type ListSshKeysRequestSortList = Array; export interface ListSshKeysRequest { /** Sort resources by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListSshKeysRequestSortList; /** Filter resources by their name. The response will only contain the resources matching exactly the specified name. */ name?: string; /** May be used to filter SSH keys by their fingerprint. The response will only contain the SSH key matching the specified fingerprint. */ fingerprint?: string; /** Filter resources by labels. The response will only contain resources matching the label selector. For more information, see "[Label Selector](#description/label-selector)". */ label_selector?: string; /** Page number to return. For more information, see "[Pagination](#description/pagination)". */ page?: number; /** Maximum number of entries returned per page. For more information, see "[Pagination](#description/pagination)". */ per_page?: number; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type ListSshKeysResponseSshKeysItemLabelsMap = { [key: string]: string | undefined }; export interface ListSshKeysResponseSshKeysItem { /** ID of the [SSH Key](#tag/ssh-keys). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** MD5 fingerprint of the SSH public key. */ fingerprint: string; /** Public key. */ public_key: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: ListSshKeysResponseSshKeysItemLabelsMap; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; } export type ListSshKeysResponseSshKeysList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListSshKeysResponseMetaPagination { /** Current page number. */ page: number; /** Maximum number of entries returned per page. */ per_page: number; /** Page number of the previous page. Can be null if the current page is the first one. */ previous_page: number | null; /** Page number of the next page. Can be null if the current page is the last one. */ next_page: number | null; /** Page number of the last page available. Can be null if the current page is the last one. */ last_page: number | null; /** Total number of entries that exist for this query. Can be null if unknown. */ total_entries: number | null; } export interface ListSshKeysResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListSshKeysResponseMetaPagination; } export interface ListSshKeysResponse { ssh_keys: ListSshKeysResponseSshKeysList; meta: ListSshKeysResponseMeta; } /** User-defined labels (`key/value` pairs) for the Resource. Note that the set of [Labels](#description/labels) provided in the request will overwrite the existing one. For more information, see "[Labels](#description/labels)". */ export type UpdateSshKeyRequestLabelsMap = { [key: string]: string | undefined }; export interface UpdateSshKeyRequest { /** ID of the SSH Key. */ id: number; /** New name Name to set. */ name?: string; /** User-defined labels (`key/value` pairs) for the Resource. Note that the set of [Labels](#description/labels) provided in the request will overwrite the existing one. For more information, see "[Labels](#description/labels)". */ labels?: UpdateSshKeyRequestLabelsMap; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type UpdateSshKeyResponseSshKeyLabelsMap = { [key: string]: string | undefined }; export interface UpdateSshKeyResponseSshKey { /** ID of the [SSH Key](#tag/ssh-keys). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** MD5 fingerprint of the SSH public key. */ fingerprint: string; /** Public key. */ public_key: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: UpdateSshKeyResponseSshKeyLabelsMap; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; } export interface UpdateSshKeyResponse { ssh_key: UpdateSshKeyResponseSshKey; } export type CreateSshKeyError = HetznerOpError; /** Create an SSH key Creates a new SSH key with the given `name` and `public_key`. Once an SSH key is created, it can be used in other calls such as creating Servers. */ export const createSshKey: API.OperationMethod< CreateSshKeyRequest, CreateSshKeyResponse, CreateSshKeyError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(0, __c0, 0) as any as S.Schema, output: __S(16, __c2, 0) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type DeleteSshKeyError = HetznerOpError; /** Delete an SSH key Deletes an SSH key. It cannot be used anymore. */ export const deleteSshKey: API.OperationMethod< DeleteSshKeyRequest, DeleteSshKeyResponse, DeleteSshKeyError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(24, __c3, 0) as any as S.Schema, output: __S(25, __c3, 1) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type GetSshKeyError = HetznerOpError; /** Get a SSH key Returns a specific SSH key object. */ export const getSshKey: API.OperationMethod< GetSshKeyRequest, GetSshKeyResponse, GetSshKeyError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(32, __c4, 0) as any as S.Schema, output: __S(16, __c2, 0) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type ListSshKeysError = HetznerOpError; /** List SSH keys Returns all SSH key objects. */ export const listSshKeys: API.PaginatedOperationMethod< ListSshKeysRequest, ListSshKeysResponse, ListSshKeysError, HetznerOpContext, ListSshKeysResponseSshKeysItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(41, __c5, 1) as any as S.Schema, output: __S(45, __c5, 5) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "meta.pagination.next_page", items: "ssh_keys", pageSize: "per_page", } as const, }), paginatePageNumber, ) as any; export type UpdateSshKeyError = HetznerOpError; /** Update an SSH key Updates an SSH key. You can update an SSH key name and an SSH key labels. */ export const updateSshKey: API.OperationMethod< UpdateSshKeyRequest, UpdateSshKeyResponse, UpdateSshKeyError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(48, __c6, 0) as any as S.Schema, output: __S(16, __c2, 0) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); // Schema builders: each runs one schema initializer, on that schema's first use. function __c0(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ name: S.String, public_key: S.String, labels: S.optional(__S(8, __c1, 0)), }).pipe(T.Http({ method: "POST", uri: "/ssh_keys", code: 200 })), ).annotate({ identifier: "CreateSshKeyRequest" }); } } function __c1(j: number): any { switch (j) { case 0: return S.Record(S.String, S.String); case 1: return S.suspend(() => S.Struct({ id: S.Number, name: S.String, fingerprint: S.String, public_key: S.String, labels: __S(8, __c1, 0), created: S.String, }), ).annotate({ identifier: "CreateSshKeyResponseSshKey" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ ssh_key: __S(9, __c1, 1), }), ).annotate({ identifier: "CreateSshKeyResponse" }); } } function __c3(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "DELETE", uri: "/ssh_keys/{id}", code: 200 })), ).annotate({ identifier: "DeleteSshKeyRequest" }); case 1: return S.suspend(() => S.Struct({})).annotate({ identifier: "DeleteSshKeyResponse" }); } } function __c4(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "GET", uri: "/ssh_keys/{id}", code: 200 })), ).annotate({ identifier: "GetSshKeyRequest" }); } } function __c5(j: number): any { switch (j) { case 0: return S.Array(S.String); case 1: return S.suspend(() => S.Struct({ sort: S.optional(__S(40, __c5, 0).pipe(T.Query())), name: S.optional(S.String.pipe(T.Query())), fingerprint: S.optional(S.String.pipe(T.Query())), label_selector: S.optional(S.String.pipe(T.Query())), page: S.optional(S.Number.pipe(T.Query())), per_page: S.optional(S.Number.pipe(T.Query())), }).pipe(T.Http({ method: "GET", uri: "/ssh_keys", code: 200 })), ).annotate({ identifier: "ListSshKeysRequest" }); case 2: return S.Array(__S(9, __c1, 1)); case 3: return S.suspend(() => S.Struct({ page: S.Number, per_page: S.Number, previous_page: S.NullOr(S.Number), next_page: S.NullOr(S.Number), last_page: S.NullOr(S.Number), total_entries: S.NullOr(S.Number), }), ).annotate({ identifier: "ListSshKeysResponseMetaPagination" }); case 4: return S.suspend(() => S.Struct({ pagination: __S(43, __c5, 3), }), ).annotate({ identifier: "ListSshKeysResponseMeta" }); case 5: return S.suspend(() => S.Struct({ ssh_keys: __S(42, __c5, 2), meta: __S(44, __c5, 4), }), ).annotate({ identifier: "ListSshKeysResponse" }); } } function __c6(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), name: S.optional(S.String), labels: S.optional(__S(8, __c1, 0)), }).pipe(T.Http({ method: "PUT", uri: "/ssh_keys/{id}", code: 200 })), ).annotate({ identifier: "UpdateSshKeyRequest" }); } } // Schema table: entry i is schema j of builder f, made on first reach. function __S(i: number, f: (j: number) => unknown, j: number): any { return (__s[i] ??= __L.at(f, j)); }