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 ChangeImageProtectionRequest { /** ID of the Image. */ id: number; /** If true, prevents the snapshot from being deleted. */ delete?: boolean; } /** Status of the Action. */ export type ChangeImageProtectionResponseActionStatus = "running" | "success" | "error"; export interface ChangeImageProtectionResponseActionResourcesItem { /** ID of the Resource. */ id: number; /** Type of the Resource. */ type: string; } /** Resources the Action relates to. */ export type ChangeImageProtectionResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export interface ChangeImageProtectionResponseActionError { /** Fixed error code for machines. */ code: string; /** Error message for humans. */ message: string; } export interface ChangeImageProtectionResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ChangeImageProtectionResponseActionStatus; /** 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: ChangeImageProtectionResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: ChangeImageProtectionResponseActionError | null; } export interface ChangeImageProtectionResponse { action: ChangeImageProtectionResponseAction; } export interface GetImagesActionRequest { /** ID of the Action. */ id: number; } /** Status of the Action. */ export type GetImagesActionResponseActionStatus = "running" | "success" | "error"; export type GetImagesActionResponseActionResourcesItem = ChangeImageProtectionResponseActionResourcesItem; /** Resources the Action relates to. */ export type GetImagesActionResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type GetImagesActionResponseActionError = ChangeImageProtectionResponseActionError; export interface GetImagesActionResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: GetImagesActionResponseActionStatus; /** 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: GetImagesActionResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: ChangeImageProtectionResponseActionError | null; } export interface GetImagesActionResponse { action: GetImagesActionResponseAction; } export type ListImageActionsRequestSortItem = | "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 ListImageActionsRequestSortList = Array< ListImageActionsRequestSortItem | (string & {}) >; /** Status of the Action. */ export type ListImageActionsRequestStatusItem = "running" | "success" | "error"; export type ListImageActionsRequestStatusList = Array< ListImageActionsRequestStatusItem | (string & {}) >; export interface ListImageActionsRequest { /** ID of the Image. */ id: number; /** Sort actions by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListImageActionsRequestSortList; /** Filter the actions by status. May be used multiple times. The response will only contain actions matching the specified statuses. */ status?: ListImageActionsRequestStatusList; /** 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 ListImageActionsResponseActionsItemStatus = "running" | "success" | "error"; export type ListImageActionsResponseActionsItemResourcesItem = ChangeImageProtectionResponseActionResourcesItem; /** Resources the Action relates to. */ export type ListImageActionsResponseActionsItemResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ListImageActionsResponseActionsItemError = ChangeImageProtectionResponseActionError; export interface ListImageActionsResponseActionsItem { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ListImageActionsResponseActionsItemStatus; /** 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: ListImageActionsResponseActionsItemResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: ChangeImageProtectionResponseActionError | null; } export type ListImageActionsResponseActionsList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListImageActionsResponseMetaPagination { /** 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 ListImageActionsResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListImageActionsResponseMetaPagination; } export interface ListImageActionsResponse { actions: ListImageActionsResponseActionsList; meta: ListImageActionsResponseMeta; } export type ListImagesActionsRequestIdList = Array; export type ListImagesActionsRequestSortItem = | "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 ListImagesActionsRequestSortList = Array< ListImagesActionsRequestSortItem | (string & {}) >; /** Status of the Action. */ export type ListImagesActionsRequestStatusItem = "running" | "success" | "error"; export type ListImagesActionsRequestStatusList = Array< ListImagesActionsRequestStatusItem | (string & {}) >; export interface ListImagesActionsRequest { /** Filter the actions by ID. May be used multiple times. The response will only contain actions matching the specified IDs. */ id?: ListImagesActionsRequestIdList; /** Sort actions by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListImagesActionsRequestSortList; /** Filter the actions by status. May be used multiple times. The response will only contain actions matching the specified statuses. */ status?: ListImagesActionsRequestStatusList; /** 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 ListImagesActionsResponseActionsItemStatus = "running" | "success" | "error"; export type ListImagesActionsResponseActionsItemResourcesItem = ChangeImageProtectionResponseActionResourcesItem; /** Resources the Action relates to. */ export type ListImagesActionsResponseActionsItemResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ListImagesActionsResponseActionsItemError = ChangeImageProtectionResponseActionError; export interface ListImagesActionsResponseActionsItem { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ListImagesActionsResponseActionsItemStatus; /** 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: ListImagesActionsResponseActionsItemResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: ChangeImageProtectionResponseActionError | null; } export type ListImagesActionsResponseActionsList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export type ListImagesActionsResponseMetaPagination = ListImageActionsResponseMetaPagination; export type ListImagesActionsResponseMeta = ListImageActionsResponseMeta; export interface ListImagesActionsResponse { actions: ListImagesActionsResponseActionsList; meta: ListImageActionsResponseMeta; } export type ChangeImageProtectionError = HetznerOpError; /** Change Image Protection Changes the protection configuration of the Image. Can only be used on snapshots. */ export const changeImageProtection: API.OperationMethod< ChangeImageProtectionRequest, ChangeImageProtectionResponse, ChangeImageProtectionError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(0, __c0, 0) as any as S.Schema, output: __S(8, __c1, 0) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type GetImagesActionError = HetznerOpError; /** Get an Action Returns a specific Action object. */ export const getImagesAction: API.OperationMethod< GetImagesActionRequest, GetImagesActionResponse, GetImagesActionError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(24, __c3, 0) as any as S.Schema, output: __S(8, __c1, 0) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type ListImageActionsError = HetznerOpError; /** List Actions for an Image Returns all Action objects for an Image. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter. */ export const listImageActions: API.PaginatedOperationMethod< ListImageActionsRequest, ListImageActionsResponse, ListImageActionsError, HetznerOpContext, ListImageActionsResponseActionsItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(32, __c4, 0) as any as S.Schema, output: __S(44, __c5, 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 ListImagesActionsError = 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 listImagesActions: API.PaginatedOperationMethod< ListImagesActionsRequest, ListImagesActionsResponse, ListImagesActionsError, HetznerOpContext, ListImagesActionsResponseActionsItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(49, __c6, 1) as any as S.Schema, output: __S(44, __c5, 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; // 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()), delete: S.optional(S.Boolean), }).pipe( T.Http({ method: "POST", uri: "/images/{id}/actions/change_protection", code: 200 }), ), ).annotate({ identifier: "ChangeImageProtectionRequest" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ action: __S(19, __c2, 3), }), ).annotate({ identifier: "ChangeImageProtectionResponse" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number, type: S.String, }), ).annotate({ identifier: "ChangeImageProtectionResponseActionResourcesItem" }); case 1: return S.Array(__S(16, __c2, 0)); case 2: return S.suspend(() => S.Struct({ code: S.String, message: S.String, }), ).annotate({ identifier: "ChangeImageProtectionResponseActionError" }); 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(17, __c2, 1), error: S.NullOr(__S(18, __c2, 2)), }), ).annotate({ identifier: "ChangeImageProtectionResponseAction" }); } } function __c3(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "GET", uri: "/images/actions/{id}", code: 200 })), ).annotate({ identifier: "GetImagesActionRequest" }); } } function __c4(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), sort: S.optional(__S(40, __c5, 0).pipe(T.Query())), status: S.optional(__S(40, __c5, 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: "/images/{id}/actions", code: 200 })), ).annotate({ identifier: "ListImageActionsRequest" }); } } function __c5(j: number): any { switch (j) { case 0: return S.Array(S.String); case 1: return S.Array(__S(19, __c2, 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: "ListImageActionsResponseMetaPagination" }); case 3: return S.suspend(() => S.Struct({ pagination: __S(42, __c5, 2), }), ).annotate({ identifier: "ListImageActionsResponseMeta" }); case 4: return S.suspend(() => S.Struct({ actions: __S(41, __c5, 1), meta: __S(43, __c5, 3), }), ).annotate({ identifier: "ListImageActionsResponse" }); } } function __c6(j: number): any { switch (j) { case 0: return S.Array(S.Number); case 1: return S.suspend(() => S.Struct({ id: S.optional(__S(48, __c6, 0).pipe(T.Query())), sort: S.optional(__S(40, __c5, 0).pipe(T.Query())), status: S.optional(__S(40, __c5, 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: "/images/actions", code: 200 })), ).annotate({ identifier: "ListImagesActionsRequest" }); } } // 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)); }