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 GetIsoRequest { /** ID of the ISO. */ id: number; } /** Type of the ISO. */ export type GetIsoResponseIsoType = "public" | "private"; /** Describes if, when and how the resource is deprecated. If this field is set to `null` the resource is not deprecated. If a value is set, it is considered deprecated. */ export interface GetIsoResponseIsoDeprecation { /** Date of the deprecated resource removal. Once this date is reached, the resource will not be returned by resource type "list" endpoint, and the resource can not be used to create new resources. For example, if this is an image, you can not create new servers with this image after the mentioned date. */ unavailable_after: string; /** Date of the deprecation announcement. */ announced: string; } /** CPU architecture compatible with the ISO. Null indicates no restriction on the architecture (wildcard). */ export type GetIsoResponseIsoArchitecture = "x86" | "arm"; export interface GetIsoResponseIso { /** ID of the [ISO](#tag/isos). */ id: number; /** Unique identifier of the ISO. Only set for public ISOs. */ name: string | null; /** Description of the ISO. */ description: string; /** Type of the ISO. */ type: GetIsoResponseIsoType | null; /** Describes if, when and how the resource is deprecated. If this field is set to `null` the resource is not deprecated. If a value is set, it is considered deprecated. */ deprecation: GetIsoResponseIsoDeprecation | null; /** CPU architecture compatible with the ISO. Null indicates no restriction on the architecture (wildcard). */ architecture: GetIsoResponseIsoArchitecture | null; } export interface GetIsoResponse { iso: GetIsoResponseIso; } /** CPU architecture of the Resource. */ export type ListIsosRequestArchitecture = "x86" | "arm"; export interface ListIsosRequest { /** Filter resources by their name. The response will only contain the resources matching exactly the specified name. */ name?: string; /** Filter resources by cpu architecture. The response will only contain the resources with the specified cpu architecture. */ architecture?: ListIsosRequestArchitecture | (string & {}); /** Include Images with wildcard architecture (architecture is null). Architecture filter must be specified. */ include_architecture_wildcard?: boolean; /** 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; } /** Type of the ISO. */ export type ListIsosResponseIsosItemType = "public" | "private"; /** Describes if, when and how the resource is deprecated. If this field is set to `null` the resource is not deprecated. If a value is set, it is considered deprecated. */ export type ListIsosResponseIsosItemDeprecation = GetIsoResponseIsoDeprecation; /** CPU architecture compatible with the ISO. Null indicates no restriction on the architecture (wildcard). */ export type ListIsosResponseIsosItemArchitecture = "x86" | "arm"; export interface ListIsosResponseIsosItem { /** ID of the [ISO](#tag/isos). */ id: number; /** Unique identifier of the ISO. Only set for public ISOs. */ name: string | null; /** Description of the ISO. */ description: string; /** Type of the ISO. */ type: ListIsosResponseIsosItemType | null; /** Describes if, when and how the resource is deprecated. If this field is set to `null` the resource is not deprecated. If a value is set, it is considered deprecated. */ deprecation: GetIsoResponseIsoDeprecation | null; /** CPU architecture compatible with the ISO. Null indicates no restriction on the architecture (wildcard). */ architecture: ListIsosResponseIsosItemArchitecture | null; } export type ListIsosResponseIsosList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListIsosResponseMetaPagination { /** 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 ListIsosResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListIsosResponseMetaPagination; } export interface ListIsosResponse { isos: ListIsosResponseIsosList; meta: ListIsosResponseMeta; } export type GetIsoError = HetznerOpError; /** Get an ISO Returns a specific ISO object. */ export const getIso: API.OperationMethod< GetIsoRequest, GetIsoResponse, GetIsoError, 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 ListIsosError = HetznerOpError; /** List ISOs Returns all available ISO objects. */ export const listIsos: API.PaginatedOperationMethod< ListIsosRequest, ListIsosResponse, ListIsosError, HetznerOpContext, ListIsosResponseIsosItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(16, __c2, 0) as any as S.Schema, output: __S(20, __c2, 4) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "meta.pagination.next_page", items: "isos", 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()), }).pipe(T.Http({ method: "GET", uri: "/isos/{id}", code: 200 })), ).annotate({ identifier: "GetIsoRequest" }); case 1: return S.suspend(() => S.Struct({ iso: __S(9, __c1, 1), }), ).annotate({ identifier: "GetIsoResponse" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ unavailable_after: S.String, announced: S.String, }), ).annotate({ identifier: "GetIsoResponseIsoDeprecation" }); case 1: return S.suspend(() => S.Struct({ id: S.Number, name: S.NullOr(S.String), description: S.String, type: S.NullOr(S.String), deprecation: S.NullOr(__S(8, __c1, 0)), architecture: S.NullOr(S.String), }), ).annotate({ identifier: "GetIsoResponseIso" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ name: S.optional(S.String.pipe(T.Query())), architecture: S.optional(S.String.pipe(T.Query())), include_architecture_wildcard: S.optional(S.Boolean.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: "/isos", code: 200 })), ).annotate({ identifier: "ListIsosRequest" }); case 1: return S.Array(__S(9, __c1, 1)); 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: "ListIsosResponseMetaPagination" }); case 3: return S.suspend(() => S.Struct({ pagination: __S(18, __c2, 2), }), ).annotate({ identifier: "ListIsosResponseMeta" }); case 4: return S.suspend(() => S.Struct({ isos: __S(17, __c2, 1), meta: __S(19, __c2, 3), }), ).annotate({ identifier: "ListIsosResponse" }); } } // 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)); }