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 { 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 GetActionRequest { /** ID of the Action. */ id: number; } /** Status of the Action. */ export type GetActionResponseActionStatus = "running" | "success" | "error"; export interface GetActionResponseActionResourcesItem { /** ID of the Resource. */ id: number; /** Type of the Resource. */ type: string; } /** Resources the Action relates to. */ export type GetActionResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export interface GetActionResponseActionError { /** Fixed error code for machines. */ code: string; /** Error message for humans. */ message: string; } export interface GetActionResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: GetActionResponseActionStatus; /** 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: GetActionResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: GetActionResponseActionError | null; } export interface GetActionResponse { action: GetActionResponseAction; } export type GetActionsRequestIdList = Array; export interface GetActionsRequest { /** Filter the actions by ID. May be used multiple times. The response will only contain actions matching the specified IDs. */ id: GetActionsRequestIdList; } /** Status of the Action. */ export type GetActionsResponseActionsItemStatus = "running" | "success" | "error"; export type GetActionsResponseActionsItemResourcesItem = GetActionResponseActionResourcesItem; /** Resources the Action relates to. */ export type GetActionsResponseActionsItemResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export type GetActionsResponseActionsItemError = GetActionResponseActionError; export interface GetActionsResponseActionsItem { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: GetActionsResponseActionsItemStatus; /** 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: GetActionsResponseActionsItemResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: GetActionResponseActionError | null; } export type GetActionsResponseActionsList = Array; export interface GetActionsResponse { actions: GetActionsResponseActionsList; } export type GetActionError = HetznerOpError; /** Get an Action Returns a specific Action object. */ export const getAction: API.OperationMethod< GetActionRequest, GetActionResponse, GetActionError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(0, __c0, 0) as any as S.Schema, output: __S(1, __c0, 1) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type GetActionsError = HetznerOpError; /** Get multiple Actions Returns multiple Action objects specified by the `id` parameter. **Note**: This endpoint previously allowed listing all actions in the project. This functionality was deprecated in July 2023 and removed on 30 January 2025. - Announcement: https://docs.hetzner.cloud/changelog#2023-07-20-actions-list-endpoint-is-deprecated - Removal: https://docs.hetzner.cloud/changelog#2025-01-30-listing-arbitrary-actions-in-the-actions-list-endpoint-is-removed */ export const getActions: API.OperationMethod< GetActionsRequest, GetActionsResponse, GetActionsError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(9, __c2, 1) as any as S.Schema, output: __S(11, __c2, 3) 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: "/actions/{id}", code: 200 })), ).annotate({ identifier: "GetActionRequest" }); case 1: return S.suspend(() => S.Struct({ action: __S(7, __c1, 3), }), ).annotate({ identifier: "GetActionResponse" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number, type: S.String, }), ).annotate({ identifier: "GetActionResponseActionResourcesItem" }); case 1: return S.Array(__S(4, __c1, 0)); case 2: return S.suspend(() => S.Struct({ code: S.String, message: S.String, }), ).annotate({ identifier: "GetActionResponseActionError" }); 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(5, __c1, 1), error: S.NullOr(__S(6, __c1, 2)), }), ).annotate({ identifier: "GetActionResponseAction" }); } } function __c2(j: number): any { switch (j) { case 0: return S.Array(S.Number); case 1: return S.suspend(() => S.Struct({ id: __S(8, __c2, 0).pipe(T.Query()), }).pipe(T.Http({ method: "GET", uri: "/actions", code: 200 })), ).annotate({ identifier: "GetActionsRequest" }); case 2: return S.Array(__S(7, __c1, 3)); case 3: return S.suspend(() => S.Struct({ actions: __S(10, __c2, 2), }), ).annotate({ identifier: "GetActionsResponse" }); } } // 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)); }