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 }; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type CreatePlacementGroupRequestLabelsMap = { [key: string]: string | undefined }; /** Define the Placement Group Type. */ export type CreatePlacementGroupRequestType = "spread"; export interface CreatePlacementGroupRequest { /** Name of the Placement Group. */ name: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels?: CreatePlacementGroupRequestLabelsMap; /** Define the Placement Group Type. */ type: CreatePlacementGroupRequestType | (string & {}); } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type CreatePlacementGroupResponsePlacementGroupLabelsMap = { [key: string]: string | undefined; }; /** Type of Placement Group. */ export type CreatePlacementGroupResponsePlacementGroupType = "spread"; /** Array of IDs of Servers that are part of this Placement Group. */ export type CreatePlacementGroupResponsePlacementGroupServersList = Array; export interface CreatePlacementGroupResponsePlacementGroup { /** ID of the [Placement Group](#tag/placement-groups). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: CreatePlacementGroupResponsePlacementGroupLabelsMap; /** Type of Placement Group. */ type: CreatePlacementGroupResponsePlacementGroupType; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; /** Array of IDs of Servers that are part of this Placement Group. */ servers: CreatePlacementGroupResponsePlacementGroupServersList; } /** Status of the Action. */ export type CreatePlacementGroupResponseActionStatus = "running" | "success" | "error"; export interface CreatePlacementGroupResponseActionResourcesItem { /** ID of the Resource. */ id: number; /** Type of the Resource. */ type: string; } /** Resources the Action relates to. */ export type CreatePlacementGroupResponseActionResourcesList = Array; /** Error message for the Action if an error occurred, otherwise null. */ export interface CreatePlacementGroupResponseActionError { /** Fixed error code for machines. */ code: string; /** Error message for humans. */ message: string; } export interface CreatePlacementGroupResponseAction { /** ID of the [Action](#description/actions). */ id: number; /** Command executed in the Action. */ command: string; /** Status of the Action. */ status: CreatePlacementGroupResponseActionStatus; /** 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: CreatePlacementGroupResponseActionResourcesList; /** Error message for the Action if an error occurred, otherwise null. */ error: CreatePlacementGroupResponseActionError | null; } export interface CreatePlacementGroupResponse { placement_group: CreatePlacementGroupResponsePlacementGroup; action?: CreatePlacementGroupResponseAction | null; } export interface DeletePlacementGroupRequest { /** ID of the Placement Group. */ id: number; } export interface DeletePlacementGroupResponse {} export interface GetPlacementGroupRequest { /** ID of the Placement Group. */ id: number; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type GetPlacementGroupResponsePlacementGroupLabelsMap = { [key: string]: string | undefined; }; /** Type of Placement Group. */ export type GetPlacementGroupResponsePlacementGroupType = "spread"; /** Array of IDs of Servers that are part of this Placement Group. */ export type GetPlacementGroupResponsePlacementGroupServersList = Array; export interface GetPlacementGroupResponsePlacementGroup { /** ID of the [Placement Group](#tag/placement-groups). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: GetPlacementGroupResponsePlacementGroupLabelsMap; /** Type of Placement Group. */ type: GetPlacementGroupResponsePlacementGroupType; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; /** Array of IDs of Servers that are part of this Placement Group. */ servers: GetPlacementGroupResponsePlacementGroupServersList; } export interface GetPlacementGroupResponse { placement_group: GetPlacementGroupResponsePlacementGroup; } export type ListPlacementGroupsRequestSortItem = | "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc" | "created" | "created:asc" | "created:desc"; export type ListPlacementGroupsRequestSortList = Array< ListPlacementGroupsRequestSortItem | (string & {}) >; /** Type of Placement Group. */ export type ListPlacementGroupsRequestTypeItem = "spread"; export type ListPlacementGroupsRequestTypeList = Array< ListPlacementGroupsRequestTypeItem | (string & {}) >; export interface ListPlacementGroupsRequest { /** Sort resources by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListPlacementGroupsRequestSortList; /** Filter resources by their name. The response will only contain the resources matching exactly the specified name. */ name?: string; /** Filter resources by labels. The response will only contain resources matching the label selector. For more information, see "[Label Selector](#description/label-selector)". */ label_selector?: string; /** Filter resources by type. May be used multiple times. The response will only contain the resources with the specified type. */ type?: ListPlacementGroupsRequestTypeList; /** 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; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type ListPlacementGroupsResponsePlacementGroupsItemLabelsMap = { [key: string]: string | undefined; }; /** Type of Placement Group. */ export type ListPlacementGroupsResponsePlacementGroupsItemType = "spread"; /** Array of IDs of Servers that are part of this Placement Group. */ export type ListPlacementGroupsResponsePlacementGroupsItemServersList = Array; export interface ListPlacementGroupsResponsePlacementGroupsItem { /** ID of the [Placement Group](#tag/placement-groups). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: ListPlacementGroupsResponsePlacementGroupsItemLabelsMap; /** Type of Placement Group. */ type: ListPlacementGroupsResponsePlacementGroupsItemType; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; /** Array of IDs of Servers that are part of this Placement Group. */ servers: ListPlacementGroupsResponsePlacementGroupsItemServersList; } export type ListPlacementGroupsResponsePlacementGroupsList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListPlacementGroupsResponseMetaPagination { /** 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 ListPlacementGroupsResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListPlacementGroupsResponseMetaPagination; } export interface ListPlacementGroupsResponse { placement_groups: ListPlacementGroupsResponsePlacementGroupsList; meta: ListPlacementGroupsResponseMeta; } /** User-defined labels (`key/value` pairs) for the Resource. Note that the set of [Labels](#description/labels) provided in the request will overwrite the existing one. For more information, see "[Labels](#description/labels)". */ export type UpdatePlacementGroupRequestLabelsMap = { [key: string]: string | undefined }; export interface UpdatePlacementGroupRequest { /** ID of the Placement Group. */ id: number; /** New Placement Group name. */ name?: string; /** User-defined labels (`key/value` pairs) for the Resource. Note that the set of [Labels](#description/labels) provided in the request will overwrite the existing one. For more information, see "[Labels](#description/labels)". */ labels?: UpdatePlacementGroupRequestLabelsMap; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type UpdatePlacementGroupResponsePlacementGroupLabelsMap = { [key: string]: string | undefined; }; /** Type of Placement Group. */ export type UpdatePlacementGroupResponsePlacementGroupType = "spread"; /** Array of IDs of Servers that are part of this Placement Group. */ export type UpdatePlacementGroupResponsePlacementGroupServersList = Array; export interface UpdatePlacementGroupResponsePlacementGroup { /** ID of the [Placement Group](#tag/placement-groups). */ id: number; /** Name of the Resource. Must be unique per Project. */ name: string; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: UpdatePlacementGroupResponsePlacementGroupLabelsMap; /** Type of Placement Group. */ type: UpdatePlacementGroupResponsePlacementGroupType; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; /** Array of IDs of Servers that are part of this Placement Group. */ servers: UpdatePlacementGroupResponsePlacementGroupServersList; } export interface UpdatePlacementGroupResponse { placement_group: UpdatePlacementGroupResponsePlacementGroup; } export type CreatePlacementGroupError = HetznerOpError; /** Create a PlacementGroup Creates a new Placement Group. */ export const createPlacementGroup: API.OperationMethod< CreatePlacementGroupRequest, CreatePlacementGroupResponse, CreatePlacementGroupError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(0, __c0, 0) as any as S.Schema, output: __S(5, __c0, 5) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type DeletePlacementGroupError = HetznerOpError; /** Delete a PlacementGroup Deletes a Placement Group. */ export const deletePlacementGroup: API.OperationMethod< DeletePlacementGroupRequest, DeletePlacementGroupResponse, DeletePlacementGroupError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(16, __c2, 0) as any as S.Schema, output: __S(17, __c2, 1) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type GetPlacementGroupError = HetznerOpError; /** Get a PlacementGroup Gets a specific Placement Group object. */ export const getPlacementGroup: API.OperationMethod< GetPlacementGroupRequest, GetPlacementGroupResponse, GetPlacementGroupError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(24, __c3, 0) as any as S.Schema, output: __S(32, __c4, 0) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type ListPlacementGroupsError = HetznerOpError; /** List Placement Groups Returns all Placement Group objects. */ export const listPlacementGroups: API.PaginatedOperationMethod< ListPlacementGroupsRequest, ListPlacementGroupsResponse, ListPlacementGroupsError, HetznerOpContext, ListPlacementGroupsResponsePlacementGroupsItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(41, __c5, 1) as any as S.Schema, output: __S(45, __c5, 5) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "meta.pagination.next_page", items: "placement_groups", pageSize: "per_page", } as const, }), paginatePageNumber, ) as any; export type UpdatePlacementGroupError = HetznerOpError; /** Update a PlacementGroup Updates the Placement Group properties. Note: if the Placement Group object changes during the request, the response will be a "conflict" error. */ export const updatePlacementGroup: API.OperationMethod< UpdatePlacementGroupRequest, UpdatePlacementGroupResponse, UpdatePlacementGroupError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(48, __c6, 0) as any as S.Schema, output: __S(32, __c4, 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({ name: S.String, labels: S.optional(__S(8, __c1, 0)), type: S.String, }).pipe(T.Http({ method: "POST", uri: "/placement_groups", code: 200 })), ).annotate({ identifier: "CreatePlacementGroupRequest" }); case 1: return S.suspend(() => S.Struct({ id: S.Number, type: S.String, }), ).annotate({ identifier: "CreatePlacementGroupResponseActionResourcesItem" }); case 2: return S.Array(__S(1, __c0, 1)); case 3: return S.suspend(() => S.Struct({ code: S.String, message: S.String, }), ).annotate({ identifier: "CreatePlacementGroupResponseActionError" }); case 4: 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(2, __c0, 2), error: S.NullOr(__S(3, __c0, 3)), }), ).annotate({ identifier: "CreatePlacementGroupResponseAction" }); case 5: return S.suspend(() => S.Struct({ placement_group: __S(10, __c1, 2), action: S.optional(S.NullOr(__S(4, __c0, 4))), }), ).annotate({ identifier: "CreatePlacementGroupResponse" }); } } function __c1(j: number): any { switch (j) { case 0: return S.Record(S.String, S.String); case 1: return S.Array(S.Number); case 2: return S.suspend(() => S.Struct({ id: S.Number, name: S.String, labels: __S(8, __c1, 0), type: S.String, created: S.String, servers: __S(9, __c1, 1), }), ).annotate({ identifier: "CreatePlacementGroupResponsePlacementGroup" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), }).pipe(T.Http({ method: "DELETE", uri: "/placement_groups/{id}", code: 200 })), ).annotate({ identifier: "DeletePlacementGroupRequest" }); case 1: return S.suspend(() => S.Struct({})).annotate({ identifier: "DeletePlacementGroupResponse" }); } } 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: "/placement_groups/{id}", code: 200 })), ).annotate({ identifier: "GetPlacementGroupRequest" }); } } function __c4(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ placement_group: __S(10, __c1, 2), }), ).annotate({ identifier: "GetPlacementGroupResponse" }); } } function __c5(j: number): any { switch (j) { case 0: return S.Array(S.String); case 1: return S.suspend(() => S.Struct({ sort: S.optional(__S(40, __c5, 0).pipe(T.Query())), name: S.optional(S.String.pipe(T.Query())), label_selector: S.optional(S.String.pipe(T.Query())), type: 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: "/placement_groups", code: 200 })), ).annotate({ identifier: "ListPlacementGroupsRequest" }); case 2: return S.Array(__S(10, __c1, 2)); case 3: 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: "ListPlacementGroupsResponseMetaPagination" }); case 4: return S.suspend(() => S.Struct({ pagination: __S(43, __c5, 3), }), ).annotate({ identifier: "ListPlacementGroupsResponseMeta" }); case 5: return S.suspend(() => S.Struct({ placement_groups: __S(42, __c5, 2), meta: __S(44, __c5, 4), }), ).annotate({ identifier: "ListPlacementGroupsResponse" }); } } function __c6(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), name: S.optional(S.String), labels: S.optional(__S(8, __c1, 0)), }).pipe(T.Http({ method: "PUT", uri: "/placement_groups/{id}", code: 200 })), ).annotate({ identifier: "UpdatePlacementGroupRequest" }); } } // 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)); }