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 DeleteImageRequest { /** ID of the Image. */ id: number; } export interface DeleteImageResponse {} export interface GetImageRequest { /** ID of the Image. */ id: number; } /** Type of the Image. */ export type GetImageResponseImageType = "system" | "app" | "snapshot" | "backup"; /** Status of the Image. */ export type GetImageResponseImageStatus = "available" | "creating" | "unavailable"; /** Information about the Server the Image was created from. */ export interface GetImageResponseImageCreatedFrom { /** ID of the Server the Image was created from. */ id: number; /** Server name at the time the Image was created. */ name: string; } /** Flavor of operating system contained in the Image. */ export type GetImageResponseImageOsFlavor = | "ubuntu" | "centos" | "debian" | "fedora" | "rocky" | "alma" | "opensuse" | "unknown"; /** Protection configuration for the Resource. */ export interface GetImageResponseImageProtection { /** Prevent the Resource from being deleted. */ delete: boolean; } /** 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 GetImageResponseImageDeprecation { /** 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; } /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type GetImageResponseImageLabelsMap = { [key: string]: string | undefined }; /** CPU architecture compatible with the Image. */ export type GetImageResponseImageArchitecture = "x86" | "arm"; export interface GetImageResponseImage { /** ID of the [Image](#tag/images). */ id: number; /** Type of the Image. */ type: GetImageResponseImageType; /** Status of the Image. */ status: GetImageResponseImageStatus; /** Unique identifier of the Image. This value is only set for system Images. */ name: string | null; /** Description of the Image. */ description: string; /** Size of the Image file in our storage in GB. For snapshot Images this is the value relevant for calculating costs for the Image. */ image_size: number | null; /** Size of the disk contained in the Image in GB. */ disk_size: number; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; /** Information about the Server the Image was created from. */ created_from: GetImageResponseImageCreatedFrom | null; /** ID of Server the Image is bound to. Only set for Images of type `backup`. */ bound_to: number | null; /** Flavor of operating system contained in the Image. */ os_flavor: GetImageResponseImageOsFlavor; /** Operating system version. */ os_version: string | null; /** Indicates that rapid deploy of the Image is available. */ rapid_deploy?: boolean; /** Protection configuration for the Resource. */ protection: GetImageResponseImageProtection; /** **Deprecated:** This field is deprecated, use the deprecation object instead. Point in time when the Image is considered to be deprecated (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ deprecated: string | 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: GetImageResponseImageDeprecation | null; /** Point in time where the Image was deleted (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ deleted: string | null; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: GetImageResponseImageLabelsMap; /** CPU architecture compatible with the Image. */ architecture: GetImageResponseImageArchitecture; } export interface GetImageResponse { image?: GetImageResponseImage; } export type ListImagesRequestSortItem = | "id" | "id:asc" | "id:desc" | "name" | "name:asc" | "name:desc" | "created" | "created:asc" | "created:desc"; export type ListImagesRequestSortList = Array; /** Type of the Image. */ export type ListImagesRequestTypeItem = "system" | "app" | "snapshot" | "backup"; export type ListImagesRequestTypeList = Array; /** Status of the Image. */ export type ListImagesRequestStatusItem = "available" | "creating" | "unavailable"; export type ListImagesRequestStatusList = Array; export type ListImagesRequestBoundToList = Array; /** CPU architecture of the Resource. */ export type ListImagesRequestArchitecture = "x86" | "arm"; export interface ListImagesRequest { /** Sort resources by field and direction. May be used multiple times. For more information, see "[Sorting](#description/sorting)". */ sort?: ListImagesRequestSortList; /** Filter resources by type. May be used multiple times. The response will only contain the resources with the specified type. */ type?: ListImagesRequestTypeList; /** Filter resources by status. May be used multiple times. The response will only contain the resources with the specified status. */ status?: ListImagesRequestStatusList; /** Filter Images by their linked Server ID. May be used multiple times. Only available for Images of type `backup`. */ bound_to?: ListImagesRequestBoundToList; /** Include deprecated Images. */ include_deprecated?: boolean; /** 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 cpu architecture. The response will only contain the resources with the specified cpu architecture. */ architecture?: ListImagesRequestArchitecture | (string & {}); /** 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 Image. */ export type ListImagesResponseImagesItemType = "system" | "app" | "snapshot" | "backup"; /** Status of the Image. */ export type ListImagesResponseImagesItemStatus = "available" | "creating" | "unavailable"; /** Information about the Server the Image was created from. */ export type ListImagesResponseImagesItemCreatedFrom = GetImageResponseImageCreatedFrom; /** Flavor of operating system contained in the Image. */ export type ListImagesResponseImagesItemOsFlavor = | "ubuntu" | "centos" | "debian" | "fedora" | "rocky" | "alma" | "opensuse" | "unknown"; /** Protection configuration for the Resource. */ export type ListImagesResponseImagesItemProtection = GetImageResponseImageProtection; /** 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 ListImagesResponseImagesItemDeprecation = GetImageResponseImageDeprecation; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type ListImagesResponseImagesItemLabelsMap = { [key: string]: string | undefined }; /** CPU architecture compatible with the Image. */ export type ListImagesResponseImagesItemArchitecture = "x86" | "arm"; export interface ListImagesResponseImagesItem { /** ID of the [Image](#tag/images). */ id: number; /** Type of the Image. */ type: ListImagesResponseImagesItemType; /** Status of the Image. */ status: ListImagesResponseImagesItemStatus; /** Unique identifier of the Image. This value is only set for system Images. */ name: string | null; /** Description of the Image. */ description: string; /** Size of the Image file in our storage in GB. For snapshot Images this is the value relevant for calculating costs for the Image. */ image_size: number | null; /** Size of the disk contained in the Image in GB. */ disk_size: number; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; /** Information about the Server the Image was created from. */ created_from: GetImageResponseImageCreatedFrom | null; /** ID of Server the Image is bound to. Only set for Images of type `backup`. */ bound_to: number | null; /** Flavor of operating system contained in the Image. */ os_flavor: ListImagesResponseImagesItemOsFlavor; /** Operating system version. */ os_version: string | null; /** Indicates that rapid deploy of the Image is available. */ rapid_deploy?: boolean; /** Protection configuration for the Resource. */ protection: GetImageResponseImageProtection; /** **Deprecated:** This field is deprecated, use the deprecation object instead. Point in time when the Image is considered to be deprecated (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ deprecated: string | 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: GetImageResponseImageDeprecation | null; /** Point in time where the Image was deleted (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ deleted: string | null; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: ListImagesResponseImagesItemLabelsMap; /** CPU architecture compatible with the Image. */ architecture: ListImagesResponseImagesItemArchitecture; } export type ListImagesResponseImagesList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListImagesResponseMetaPagination { /** 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 ListImagesResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListImagesResponseMetaPagination; } export interface ListImagesResponse { images: ListImagesResponseImagesList; meta: ListImagesResponseMeta; } /** Destination Image type to convert to. */ export type UpdateImageRequestType = "snapshot"; /** 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 UpdateImageRequestLabelsMap = { [key: string]: string | undefined }; export interface UpdateImageRequest { /** ID of the Image. */ id: number; /** New description of Image. */ description?: string; /** Destination Image type to convert to. */ type?: UpdateImageRequestType | (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?: UpdateImageRequestLabelsMap; } /** Type of the Image. */ export type UpdateImageResponseImageType = "system" | "app" | "snapshot" | "backup"; /** Status of the Image. */ export type UpdateImageResponseImageStatus = "available" | "creating" | "unavailable"; /** Information about the Server the Image was created from. */ export type UpdateImageResponseImageCreatedFrom = GetImageResponseImageCreatedFrom; /** Flavor of operating system contained in the Image. */ export type UpdateImageResponseImageOsFlavor = | "ubuntu" | "centos" | "debian" | "fedora" | "rocky" | "alma" | "opensuse" | "unknown"; /** Protection configuration for the Resource. */ export type UpdateImageResponseImageProtection = GetImageResponseImageProtection; /** 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 UpdateImageResponseImageDeprecation = GetImageResponseImageDeprecation; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ export type UpdateImageResponseImageLabelsMap = { [key: string]: string | undefined }; /** CPU architecture compatible with the Image. */ export type UpdateImageResponseImageArchitecture = "x86" | "arm"; export interface UpdateImageResponseImage { /** ID of the [Image](#tag/images). */ id: number; /** Type of the Image. */ type: UpdateImageResponseImageType; /** Status of the Image. */ status: UpdateImageResponseImageStatus; /** Unique identifier of the Image. This value is only set for system Images. */ name: string | null; /** Description of the Image. */ description: string; /** Size of the Image file in our storage in GB. For snapshot Images this is the value relevant for calculating costs for the Image. */ image_size: number | null; /** Size of the disk contained in the Image in GB. */ disk_size: number; /** Point in time when the Resource was created (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ created: string; /** Information about the Server the Image was created from. */ created_from: GetImageResponseImageCreatedFrom | null; /** ID of Server the Image is bound to. Only set for Images of type `backup`. */ bound_to: number | null; /** Flavor of operating system contained in the Image. */ os_flavor: UpdateImageResponseImageOsFlavor; /** Operating system version. */ os_version: string | null; /** Indicates that rapid deploy of the Image is available. */ rapid_deploy?: boolean; /** Protection configuration for the Resource. */ protection: GetImageResponseImageProtection; /** **Deprecated:** This field is deprecated, use the deprecation object instead. Point in time when the Image is considered to be deprecated (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ deprecated: string | 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: GetImageResponseImageDeprecation | null; /** Point in time where the Image was deleted (in [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) format). */ deleted: string | null; /** User-defined labels (`key/value` pairs) for the Resource. For more information, see "[Labels](#description/labels)". */ labels: UpdateImageResponseImageLabelsMap; /** CPU architecture compatible with the Image. */ architecture: UpdateImageResponseImageArchitecture; } export interface UpdateImageResponse { image?: UpdateImageResponseImage; } export type DeleteImageError = HetznerOpError; /** Delete an Image Deletes an Image. Only Images of type `snapshot` and `backup` can be deleted. */ export const deleteImage: API.OperationMethod< DeleteImageRequest, DeleteImageResponse, DeleteImageError, 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 GetImageError = HetznerOpError; /** Get an Image Returns a specific Image object. */ export const getImage: API.OperationMethod< GetImageRequest, GetImageResponse, GetImageError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(8, __c1, 0) as any as S.Schema, output: __S(24, __c3, 0) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, })); export type ListImagesError = HetznerOpError; /** List Images Returns all Image objects. You can select specific Image types only and sort the results by using URI parameters. */ export const listImages: API.PaginatedOperationMethod< ListImagesRequest, ListImagesResponse, ListImagesError, HetznerOpContext, ListImagesResponseImagesItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: __S(34, __c4, 2) as any as S.Schema, output: __S(38, __c4, 6) as any as S.Schema, errors: [UnknownHetznerError], protocol: HetznerProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "meta.pagination.next_page", items: "images", pageSize: "per_page", } as const, }), paginatePageNumber, ) as any; export type UpdateImageError = HetznerOpError; /** Update an Image Updates the Image. You may change the description, convert a Backup Image to a Snapshot Image or change the Image labels. Only Images of type `snapshot` and `backup` can be updated. */ export const updateImage: API.OperationMethod< UpdateImageRequest, UpdateImageResponse, UpdateImageError, HetznerOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(40, __c5, 0) as any as S.Schema, output: __S(24, __c3, 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()), }).pipe(T.Http({ method: "DELETE", uri: "/images/{id}", code: 200 })), ).annotate({ identifier: "DeleteImageRequest" }); case 1: return S.suspend(() => S.Struct({})).annotate({ identifier: "DeleteImageResponse" }); } } function __c1(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/{id}", code: 200 })), ).annotate({ identifier: "GetImageRequest" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number, name: S.String, }), ).annotate({ identifier: "GetImageResponseImageCreatedFrom" }); case 1: return S.suspend(() => S.Struct({ delete: S.Boolean, }), ).annotate({ identifier: "GetImageResponseImageProtection" }); case 2: return S.suspend(() => S.Struct({ unavailable_after: S.String, announced: S.String, }), ).annotate({ identifier: "GetImageResponseImageDeprecation" }); case 3: return S.Record(S.String, S.String); case 4: return S.suspend(() => S.Struct({ id: S.Number, type: S.String, status: S.String, name: S.NullOr(S.String), description: S.String, image_size: S.NullOr(S.Number), disk_size: S.Number, created: S.String, created_from: S.NullOr(__S(16, __c2, 0)), bound_to: S.NullOr(S.Number), os_flavor: S.String, os_version: S.NullOr(S.String), rapid_deploy: S.optional(S.Boolean), protection: __S(17, __c2, 1), deprecated: S.NullOr(S.String), deprecation: S.NullOr(__S(18, __c2, 2)), deleted: S.NullOr(S.String), labels: __S(19, __c2, 3), architecture: S.String, }), ).annotate({ identifier: "GetImageResponseImage" }); } } function __c3(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ image: S.optional(__S(20, __c2, 4)), }), ).annotate({ identifier: "GetImageResponse" }); } } function __c4(j: number): any { switch (j) { case 0: return S.Array(S.String); case 1: return S.Array(S.String); case 2: return S.suspend(() => S.Struct({ sort: S.optional(__S(32, __c4, 0).pipe(T.Query())), type: S.optional(__S(32, __c4, 0).pipe(T.Query())), status: S.optional(__S(32, __c4, 0).pipe(T.Query())), bound_to: S.optional(__S(33, __c4, 1).pipe(T.Query())), include_deprecated: S.optional(S.Boolean.pipe(T.Query())), name: S.optional(S.String.pipe(T.Query())), label_selector: S.optional(S.String.pipe(T.Query())), architecture: S.optional(S.String.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", code: 200 })), ).annotate({ identifier: "ListImagesRequest" }); case 3: return S.Array(__S(20, __c2, 4)); case 4: 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: "ListImagesResponseMetaPagination" }); case 5: return S.suspend(() => S.Struct({ pagination: __S(36, __c4, 4), }), ).annotate({ identifier: "ListImagesResponseMeta" }); case 6: return S.suspend(() => S.Struct({ images: __S(35, __c4, 3), meta: __S(37, __c4, 5), }), ).annotate({ identifier: "ListImagesResponse" }); } } function __c5(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ id: S.Number.pipe(T.Label()), description: S.optional(S.String), type: S.optional(S.String), labels: S.optional(__S(19, __c2, 3)), }).pipe(T.Http({ method: "PUT", uri: "/images/{id}", code: 200 })), ).annotate({ identifier: "UpdateImageRequest" }); } } // 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)); }