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 }; export interface GetCertificatesActionRequest { /** ID of the Action. */ id: number; } /** Status of the Action. */ export type GetCertificatesActionResponseActionStatus = "running" | "success" | "error"; export interface GetCertificatesActionResponseActionResourcesItem { /** ID of the Resource. */ id: number; /** Type of the Resource. */ type: string; } /** Resources the Action relates to. */ export type GetCertificatesActionResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export interface GetCertificatesActionResponseActionError { /** Fixed error code for machines. */ code: string; /** Error message for humans. */ message: string; } export interface GetCertificatesActionResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: GetCertificatesActionResponseActionStatus; /** Point in time when the Action was started (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ started: string; /** Point in time when the Action was finished (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). Only set if the Action is finished otherwise null. */ finished: string | null; /** Progress of the Action in percent. */ progress: number; /** Resources the Action relates to. */ resources: GetCertificatesActionResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: GetCertificatesActionResponseActionError | null; } export interface GetCertificatesActionResponse { action: GetCertificatesActionResponseAction; } export type ListCertificateActionsRequestSortItem = | "id" | "id:asc" | "id:desc" | "command" | "command:asc" | "command:desc" | "status" | "status:asc" | "status:desc" | "started" | "started:asc" | "started:desc" | "finished" | "finished:asc" | "finished:desc"; export type ListCertificateActionsRequestSortList = Array< ListCertificateActionsRequestSortItem | (string & {}) >; /** Status of the Action. */ export type ListCertificateActionsRequestStatusItem = "running" | "success" | "error"; export type ListCertificateActionsRequestStatusList = Array< ListCertificateActionsRequestStatusItem | (string & {}) >; export interface ListCertificateActionsRequest { /** ID of the Certificate. */ id: number; /** Sort actions by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListCertificateActionsRequestSortList; /** Filter the actions by status. May be used multiple times. The response will only contain actions matching the specified statuses. */ status?: ListCertificateActionsRequestStatusList; /** 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; } /** Status of the Action. */ export type ListCertificateActionsResponseActionsItemStatus = "running" | "success" | "error"; export type ListCertificateActionsResponseActionsItemResourcesItem = GetCertificatesActionResponseActionResourcesItem; /** Resources the Action relates to. */ export type ListCertificateActionsResponseActionsItemResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ListCertificateActionsResponseActionsItemError = GetCertificatesActionResponseActionError; export interface ListCertificateActionsResponseActionsItem { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ListCertificateActionsResponseActionsItemStatus; /** Point in time when the Action was started (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ started: string; /** Point in time when the Action was finished (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). Only set if the Action is finished otherwise null. */ finished: string | null; /** Progress of the Action in percent. */ progress: number; /** Resources the Action relates to. */ resources: ListCertificateActionsResponseActionsItemResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: GetCertificatesActionResponseActionError | null; } export type ListCertificateActionsResponseActionsList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListCertificateActionsResponseMetaPagination { /** 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 ListCertificateActionsResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListCertificateActionsResponseMetaPagination; } export interface ListCertificateActionsResponse { actions: ListCertificateActionsResponseActionsList; meta: ListCertificateActionsResponseMeta; } export type ListCertificatesActionsRequestIdList = Array; export type ListCertificatesActionsRequestSortItem = | "id" | "id:asc" | "id:desc" | "command" | "command:asc" | "command:desc" | "status" | "status:asc" | "status:desc" | "started" | "started:asc" | "started:desc" | "finished" | "finished:asc" | "finished:desc"; export type ListCertificatesActionsRequestSortList = Array< ListCertificatesActionsRequestSortItem | (string & {}) >; /** Status of the Action. */ export type ListCertificatesActionsRequestStatusItem = "running" | "success" | "error"; export type ListCertificatesActionsRequestStatusList = Array< ListCertificatesActionsRequestStatusItem | (string & {}) >; export interface ListCertificatesActionsRequest { /** Filter the actions by ID. May be used multiple times. The response will only contain actions matching the specified IDs. */ id?: ListCertificatesActionsRequestIdList; /** Sort actions by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListCertificatesActionsRequestSortList; /** Filter the actions by status. May be used multiple times. The response will only contain actions matching the specified statuses. */ status?: ListCertificatesActionsRequestStatusList; /** 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; } /** Status of the Action. */ export type ListCertificatesActionsResponseActionsItemStatus = "running" | "success" | "error"; export type ListCertificatesActionsResponseActionsItemResourcesItem = GetCertificatesActionResponseActionResourcesItem; /** Resources the Action relates to. */ export type ListCertificatesActionsResponseActionsItemResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ListCertificatesActionsResponseActionsItemError = GetCertificatesActionResponseActionError; export interface ListCertificatesActionsResponseActionsItem { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ListCertificatesActionsResponseActionsItemStatus; /** Point in time when the Action was started (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ started: string; /** Point in time when the Action was finished (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). Only set if the Action is finished otherwise null. */ finished: string | null; /** Progress of the Action in percent. */ progress: number; /** Resources the Action relates to. */ resources: ListCertificatesActionsResponseActionsItemResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: GetCertificatesActionResponseActionError | null; } export type ListCertificatesActionsResponseActionsList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export type ListCertificatesActionsResponseMetaPagination = ListCertificateActionsResponseMetaPagination; export type ListCertificatesActionsResponseMeta = ListCertificateActionsResponseMeta; export interface ListCertificatesActionsResponse { actions: ListCertificatesActionsResponseActionsList; meta: ListCertificateActionsResponseMeta; } export interface RetryCertificateRequest { /** ID of the Certificate. */ id: number; } /** Status of the Action. */ export type RetryCertificateResponseActionStatus = "running" | "success" | "error"; export type RetryCertificateResponseActionResourcesItem = GetCertificatesActionResponseActionResourcesItem; /** Resources the Action relates to. */ export type RetryCertificateResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type RetryCertificateResponseActionError = GetCertificatesActionResponseActionError; export interface RetryCertificateResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: RetryCertificateResponseActionStatus; /** Point in time when the Action was started (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ started: string; /** Point in time when the Action was finished (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). Only set if the Action is finished otherwise null. */ finished: string | null; /** Progress of the Action in percent. */ progress: number; /** Resources the Action relates to. */ resources: RetryCertificateResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: GetCertificatesActionResponseActionError | null; } export interface RetryCertificateResponse { action: RetryCertificateResponseAction; } export type GetCertificatesActionError = HetznerOpError; /** Get an Action Returns a specific Action object. */ export const getCertificatesAction: API.OperationMethod< GetCertificatesActionRequest, GetCertificatesActionResponse, GetCertificatesActionError, 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 ListCertificateActionsError = HetznerOpError; /** List Actions for a Certificate Returns all Action objects for a Certificate. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter. Only type `managed` Certificates can have Actions. For type `uploaded` Certificates the `actions` key will always contain an empty array. */ export const listCertificateActions: API.PaginatedOperationMethod< ListCertificateActionsRequest, ListCertificateActionsResponse, ListCertificateActionsError, HetznerOpContext, ListCertificateActionsResponseActionsItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(24, __c3, 0) as any as S.Schema, output: __S(36, __c4, 4) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "meta.pagination.next_page", items: "actions", pageSize: "per_page", } as const, }), paginatePageNumber, ) as any; export type ListCertificatesActionsError = HetznerOpError; /** List Actions Returns all Action objects. You can `sort` the results by using the sort URI parameter, and filter them with the `status` and `id` parameter. */ export const listCertificatesActions: API.PaginatedOperationMethod< ListCertificatesActionsRequest, ListCertificatesActionsResponse, ListCertificatesActionsError, HetznerOpContext, ListCertificatesActionsResponseActionsItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(41, __c5, 1) as any as S.Schema, output: __S(36, __c4, 4) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "meta.pagination.next_page", items: "actions", pageSize: "per_page", } as const, }), paginatePageNumber, ) as any; export type RetryCertificateError = HetznerOpError; /** Retry Issuance or Renewal Retry a failed Certificate issuance or renewal. Only applicable if the type of the Certificate is `managed` and the issuance or renewal status is `failed`. #### Operation specific errors */ export const retryCertificate: API.OperationMethod< RetryCertificateRequest, RetryCertificateResponse, RetryCertificateError, 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({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "GET", uri: "/certificates/actions/{id}", code: 200 })), ).annotate({ identifier: "GetCertificatesActionRequest" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number, type: S.String, }), ).annotate({ identifier: "GetCertificatesActionResponseActionResourcesItem" }); case 1: return S.Array(__S(8, __c1, 0)); case 2: return S.suspend(() => S.Struct({ code: S.String, message: S.String, }), ).annotate({ identifier: "GetCertificatesActionResponseActionError" }); case 3: return S.suspend(() => S.Struct({ id: S.Number, command: S.String, status: S.String, started: S.String, finished: S.NullOr(S.String), progress: S.Number, resources: __S(9, __c1, 1), error: S.NullOr(__S(10, __c1, 2)), }), ).annotate({ identifier: "GetCertificatesActionResponseAction" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ action: __S(11, __c1, 3), }), ).annotate({ identifier: "GetCertificatesActionResponse" }); } } function __c3(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), sort: S.optional(__S(32, __c4, 0).pipe(T.Query())), status: S.optional(__S(32, __c4, 0).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: "/certificates/{id}/actions", code: 200 })), ).annotate({ identifier: "ListCertificateActionsRequest" }); } } function __c4(j: number): any { switch (j) { case 0: return S.Array(S.String); case 1: return S.Array(__S(11, __c1, 3)); case 2: 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: "ListCertificateActionsResponseMetaPagination" }); case 3: return S.suspend(() => S.Struct({ pagination: __S(34, __c4, 2), }), ).annotate({ identifier: "ListCertificateActionsResponseMeta" }); case 4: return S.suspend(() => S.Struct({ actions: __S(33, __c4, 1), meta: __S(35, __c4, 3), }), ).annotate({ identifier: "ListCertificateActionsResponse" }); } } function __c5(j: number): any { switch (j) { case 0: return S.Array(S.Number); case 1: return S.suspend(() => S.Struct({ id: S.optional(__S(40, __c5, 0).pipe(T.Query())), sort: S.optional(__S(32, __c4, 0).pipe(T.Query())), status: S.optional(__S(32, __c4, 0).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: "/certificates/actions", code: 200 })), ).annotate({ identifier: "ListCertificatesActionsRequest" }); } } function __c6(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "POST", uri: "/certificates/{id}/actions/retry", code: 200 })), ).annotate({ identifier: "RetryCertificateRequest" }); } } // 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)); }