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 AttachVolumeRequest { /** ID of the Volume. */ id: number; /** ID of the Server the Volume will be attached to. */ server: number; /** Auto-mount the Volume after attaching it. */ automount?: boolean; } /** Status of the Action. */ export type AttachVolumeResponseActionStatus = "running" | "success" | "error"; export interface AttachVolumeResponseActionResourcesItem { /** ID of the Resource. */ id: number; /** Type of the Resource. */ type: string; } /** Resources the Action relates to. */ export type AttachVolumeResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export interface AttachVolumeResponseActionError { /** Fixed error code for machines. */ code: string; /** Error message for humans. */ message: string; } export interface AttachVolumeResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: AttachVolumeResponseActionStatus; /** 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: AttachVolumeResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: AttachVolumeResponseActionError | null; } export interface AttachVolumeResponse { action: AttachVolumeResponseAction; } export interface ChangeVolumeProtectionRequest { /** ID of the Volume. */ id: number; /** If true, prevents the Volume from being deleted. */ delete?: boolean; } /** Status of the Action. */ export type ChangeVolumeProtectionResponseActionStatus = "running" | "success" | "error"; export type ChangeVolumeProtectionResponseActionResourcesItem = AttachVolumeResponseActionResourcesItem; /** Resources the Action relates to. */ export type ChangeVolumeProtectionResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ChangeVolumeProtectionResponseActionError = AttachVolumeResponseActionError; export interface ChangeVolumeProtectionResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ChangeVolumeProtectionResponseActionStatus; /** 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: ChangeVolumeProtectionResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: AttachVolumeResponseActionError | null; } export interface ChangeVolumeProtectionResponse { action: ChangeVolumeProtectionResponseAction; } export interface DetachVolumeRequest { /** ID of the Volume. */ id: number; } /** Status of the Action. */ export type DetachVolumeResponseActionStatus = "running" | "success" | "error"; export type DetachVolumeResponseActionResourcesItem = AttachVolumeResponseActionResourcesItem; /** Resources the Action relates to. */ export type DetachVolumeResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type DetachVolumeResponseActionError = AttachVolumeResponseActionError; export interface DetachVolumeResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: DetachVolumeResponseActionStatus; /** 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: DetachVolumeResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: AttachVolumeResponseActionError | null; } export interface DetachVolumeResponse { action: DetachVolumeResponseAction; } export interface GetVolumesActionRequest { /** ID of the Action. */ id: number; } /** Status of the Action. */ export type GetVolumesActionResponseActionStatus = "running" | "success" | "error"; export type GetVolumesActionResponseActionResourcesItem = AttachVolumeResponseActionResourcesItem; /** Resources the Action relates to. */ export type GetVolumesActionResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type GetVolumesActionResponseActionError = AttachVolumeResponseActionError; export interface GetVolumesActionResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: GetVolumesActionResponseActionStatus; /** 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: GetVolumesActionResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: AttachVolumeResponseActionError | null; } export interface GetVolumesActionResponse { action: GetVolumesActionResponseAction; } export type ListVolumeActionsRequestSortItem = | "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 ListVolumeActionsRequestSortList = Array< ListVolumeActionsRequestSortItem | (string & {}) >; /** Status of the Action. */ export type ListVolumeActionsRequestStatusItem = "running" | "success" | "error"; export type ListVolumeActionsRequestStatusList = Array< ListVolumeActionsRequestStatusItem | (string & {}) >; export interface ListVolumeActionsRequest { /** ID of the Volume. */ id: number; /** Sort actions by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListVolumeActionsRequestSortList; /** Filter the actions by status. May be used multiple times. The response will only contain actions matching the specified statuses. */ status?: ListVolumeActionsRequestStatusList; /** 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 ListVolumeActionsResponseActionsItemStatus = "running" | "success" | "error"; export type ListVolumeActionsResponseActionsItemResourcesItem = AttachVolumeResponseActionResourcesItem; /** Resources the Action relates to. */ export type ListVolumeActionsResponseActionsItemResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ListVolumeActionsResponseActionsItemError = AttachVolumeResponseActionError; export interface ListVolumeActionsResponseActionsItem { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ListVolumeActionsResponseActionsItemStatus; /** 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: ListVolumeActionsResponseActionsItemResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: AttachVolumeResponseActionError | null; } export type ListVolumeActionsResponseActionsList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListVolumeActionsResponseMetaPagination { /** 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 ListVolumeActionsResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListVolumeActionsResponseMetaPagination; } export interface ListVolumeActionsResponse { actions: ListVolumeActionsResponseActionsList; meta: ListVolumeActionsResponseMeta; } export type ListVolumesActionsRequestIdList = Array; export type ListVolumesActionsRequestSortItem = | "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 ListVolumesActionsRequestSortList = Array< ListVolumesActionsRequestSortItem | (string & {}) >; /** Status of the Action. */ export type ListVolumesActionsRequestStatusItem = "running" | "success" | "error"; export type ListVolumesActionsRequestStatusList = Array< ListVolumesActionsRequestStatusItem | (string & {}) >; export interface ListVolumesActionsRequest { /** Filter the actions by ID. May be used multiple times. The response will only contain actions matching the specified IDs. */ id?: ListVolumesActionsRequestIdList; /** Sort actions by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListVolumesActionsRequestSortList; /** Filter the actions by status. May be used multiple times. The response will only contain actions matching the specified statuses. */ status?: ListVolumesActionsRequestStatusList; /** 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 ListVolumesActionsResponseActionsItemStatus = "running" | "success" | "error"; export type ListVolumesActionsResponseActionsItemResourcesItem = AttachVolumeResponseActionResourcesItem; /** Resources the Action relates to. */ export type ListVolumesActionsResponseActionsItemResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ListVolumesActionsResponseActionsItemError = AttachVolumeResponseActionError; export interface ListVolumesActionsResponseActionsItem { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ListVolumesActionsResponseActionsItemStatus; /** 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: ListVolumesActionsResponseActionsItemResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: AttachVolumeResponseActionError | null; } export type ListVolumesActionsResponseActionsList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export type ListVolumesActionsResponseMetaPagination = ListVolumeActionsResponseMetaPagination; export type ListVolumesActionsResponseMeta = ListVolumeActionsResponseMeta; export interface ListVolumesActionsResponse { actions: ListVolumesActionsResponseActionsList; meta: ListVolumeActionsResponseMeta; } export interface ResizeVolumeRequest { /** ID of the Volume. */ id: number; /** New Volume size in GB (must be greater than current size). */ size: number; } /** Status of the Action. */ export type ResizeVolumeResponseActionStatus = "running" | "success" | "error"; export type ResizeVolumeResponseActionResourcesItem = AttachVolumeResponseActionResourcesItem; /** Resources the Action relates to. */ export type ResizeVolumeResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type ResizeVolumeResponseActionError = AttachVolumeResponseActionError; export interface ResizeVolumeResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: ResizeVolumeResponseActionStatus; /** 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: ResizeVolumeResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: AttachVolumeResponseActionError | null; } export interface ResizeVolumeResponse { action: ResizeVolumeResponseAction; } export type AttachVolumeError = HetznerOpError; /** Attach Volume to a Server Attaches a Volume to a Server. Works only if the Server is in the same Location as the Volume. */ export const attachVolume: API.OperationMethod< AttachVolumeRequest, AttachVolumeResponse, AttachVolumeError, 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 ChangeVolumeProtectionError = HetznerOpError; /** Change Volume Protection Changes the protection configuration of a Volume. */ export const changeVolumeProtection: API.OperationMethod< ChangeVolumeProtectionRequest, ChangeVolumeProtectionResponse, ChangeVolumeProtectionError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(24, __c3, 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 DetachVolumeError = HetznerOpError; /** Detach Volume Detaches a Volume from the Server it's attached to. You may attach it to a Server again at a later time. */ export const detachVolume: API.OperationMethod< DetachVolumeRequest, DetachVolumeResponse, DetachVolumeError, 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 GetVolumesActionError = HetznerOpError; /** Get an Action Returns a specific Action object. */ export const getVolumesAction: API.OperationMethod< GetVolumesActionRequest, GetVolumesActionResponse, GetVolumesActionError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(40, __c5, 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 ListVolumeActionsError = HetznerOpError; /** List Actions for a Volume Returns all Action objects for a Volume. You can `sort` the results by using the sort URI parameter, and filter them with the `status` parameter. */ export const listVolumeActions: API.PaginatedOperationMethod< ListVolumeActionsRequest, ListVolumeActionsResponse, ListVolumeActionsError, HetznerOpContext, ListVolumeActionsResponseActionsItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(48, __c6, 0) as any as S.Schema, output: __S(60, __c7, 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 ListVolumesActionsError = 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 listVolumesActions: API.PaginatedOperationMethod< ListVolumesActionsRequest, ListVolumesActionsResponse, ListVolumesActionsError, HetznerOpContext, ListVolumesActionsResponseActionsItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(65, __c8, 1) as any as S.Schema, output: __S(60, __c7, 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 ResizeVolumeError = HetznerOpError; /** Resize Volume Changes the size of a Volume. Note that downsizing a Volume is not possible. */ export const resizeVolume: API.OperationMethod< ResizeVolumeRequest, ResizeVolumeResponse, ResizeVolumeError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(72, __c9, 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()), server: S.Number, automount: S.optional(S.Boolean), }).pipe(T.Http({ method: "POST", uri: "/volumes/{id}/actions/attach", code: 200 })), ).annotate({ identifier: "AttachVolumeRequest" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number, type: S.String, }), ).annotate({ identifier: "AttachVolumeResponseActionResourcesItem" }); case 1: return S.Array(__S(8, __c1, 0)); case 2: return S.suspend(() => S.Struct({ code: S.String, message: S.String, }), ).annotate({ identifier: "AttachVolumeResponseActionError" }); 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: "AttachVolumeResponseAction" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ action: __S(11, __c1, 3), }), ).annotate({ identifier: "AttachVolumeResponse" }); } } function __c3(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: "/volumes/{id}/actions/change_protection", code: 200 }), ), ).annotate({ identifier: "ChangeVolumeProtectionRequest" }); } } function __c4(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "POST", uri: "/volumes/{id}/actions/detach", code: 200 })), ).annotate({ identifier: "DetachVolumeRequest" }); } } function __c5(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "GET", uri: "/volumes/actions/{id}", code: 200 })), ).annotate({ identifier: "GetVolumesActionRequest" }); } } function __c6(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), sort: S.optional(__S(56, __c7, 0).pipe(T.Query())), status: S.optional(__S(56, __c7, 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: "/volumes/{id}/actions", code: 200 })), ).annotate({ identifier: "ListVolumeActionsRequest" }); } } function __c7(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: "ListVolumeActionsResponseMetaPagination" }); case 3: return S.suspend(() => S.Struct({ pagination: __S(58, __c7, 2), }), ).annotate({ identifier: "ListVolumeActionsResponseMeta" }); case 4: return S.suspend(() => S.Struct({ actions: __S(57, __c7, 1), meta: __S(59, __c7, 3), }), ).annotate({ identifier: "ListVolumeActionsResponse" }); } } function __c8(j: number): any { switch (j) { case 0: return S.Array(S.Number); case 1: return S.suspend(() => S.Struct({ id: S.optional(__S(64, __c8, 0).pipe(T.Query())), sort: S.optional(__S(56, __c7, 0).pipe(T.Query())), status: S.optional(__S(56, __c7, 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: "/volumes/actions", code: 200 })), ).annotate({ identifier: "ListVolumesActionsRequest" }); } } function __c9(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), size: S.Number, }).pipe(T.Http({ method: "POST", uri: "/volumes/{id}/actions/resize", code: 200 })), ).annotate({ identifier: "ResizeVolumeRequest" }); } } // 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)); }