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 GetServerTypeRequest { /** ID of the Server Type. */ id: number; } /** Hourly price in this [Location](#tag/locations). */ export interface GetServerTypeResponseServerTypePricesItemPriceHourly { /** Price without VAT. */ net: string; /** Price with VAT added. */ gross: string; } /** Monthly price in this [Location](#tag/locations). */ export type GetServerTypeResponseServerTypePricesItemPriceMonthly = GetServerTypeResponseServerTypePricesItemPriceHourly; /** Additional traffic price per TB in this [Location](#tag/locations). */ export type GetServerTypeResponseServerTypePricesItemPricePerTbTraffic = GetServerTypeResponseServerTypePricesItemPriceHourly; export interface GetServerTypeResponseServerTypePricesItem { /** Name of the [Location](#tag/locations) the price is for. */ location: string; /** Hourly price in this [Location](#tag/locations). */ price_hourly: GetServerTypeResponseServerTypePricesItemPriceHourly; /** Monthly price in this [Location](#tag/locations). */ price_monthly: GetServerTypeResponseServerTypePricesItemPriceHourly; /** Free traffic per month in bytes in this [Location](#tag/locations). */ included_traffic: number; /** Additional traffic price per TB in this [Location](#tag/locations). */ price_per_tb_traffic: GetServerTypeResponseServerTypePricesItemPriceHourly; } /** Price per [Location](#tag/locations). */ export type GetServerTypeResponseServerTypePricesList = Array; /** Type of Server boot drive. Local has higher speed. Network has better availability. */ export type GetServerTypeResponseServerTypeStorageType = "local" | "network"; /** Type of cpu. */ export type GetServerTypeResponseServerTypeCpuType = "shared" | "dedicated"; /** CPU architecture of the Server Type. */ export type GetServerTypeResponseServerTypeArchitecture = "x86" | "arm"; /** This field is deprecated. Use the `deprecation` object in the `locations` field instead (`.locations[].deprecation`). */ export interface GetServerTypeResponseServerTypeDeprecation { /** 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; } /** 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 GetServerTypeResponseServerTypeLocationsItemDeprecation = GetServerTypeResponseServerTypeDeprecation; /** A [Location](#tag/locations) (containing only id and name) and Server Type specific metadata. */ export interface GetServerTypeResponseServerTypeLocationsItem { /** ID of the [Location](#tag/locations). */ id: number; /** Name of the [Location](#tag/locations). */ name: string; /** 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: GetServerTypeResponseServerTypeDeprecation | null; /** Whether the [Server Type](#tag/server-types) is recommended in this [Location](#tag/locations). */ recommended: boolean; /** Whether the [Server Type](#tag/server-types) is temporarily unavailable in this [Location](#tag/locations). */ available: boolean; } /** Supported [Location](#tag/locations) and per [Location](#tag/locations) details for the [Server Type](#tag/server-types). A [Server Type](#tag/server-types) is: - only supported in the [Location](#tag/locations) that are listed. - deprecated in the [Location](#tag/locations) when the `deprecation` property is set. - permanently unavailable in the [Location](#tag/locations) when the `deprecation.unavailable_after` date is in the past. - temporarily unavailable in the [Location](#tag/locations) when the `deprecation.available` is false. */ export type GetServerTypeResponseServerTypeLocationsList = Array; export interface GetServerTypeResponseServerType { /** ID of the Server type. */ id: number; /** Unique identifier of the Server type. */ name: string; /** Description of the Server type. */ description: string; /** Number of cpu cores a Server of this type will have. */ cores: number; /** Memory a Server of this type will have in GB. */ memory: number; /** Disk size a Server of this type will have in GB. */ disk: number; /** This field is deprecated. Use the deprecation object instead. */ deprecated: boolean; /** Price per [Location](#tag/locations). */ prices: GetServerTypeResponseServerTypePricesList; /** Type of Server boot drive. Local has higher speed. Network has better availability. */ storage_type: GetServerTypeResponseServerTypeStorageType; /** Type of cpu. */ cpu_type: GetServerTypeResponseServerTypeCpuType; /** Category of Server Type. */ category?: string; /** CPU architecture of the Server Type. */ architecture: GetServerTypeResponseServerTypeArchitecture; /** This field is deprecated. Use the `deprecation` object in the `locations` field instead (`.locations[].deprecation`). */ deprecation?: GetServerTypeResponseServerTypeDeprecation | null; /** Supported [Location](#tag/locations) and per [Location](#tag/locations) details for the [Server Type](#tag/server-types). A [Server Type](#tag/server-types) is: - only supported in the [Location](#tag/locations) that are listed. - deprecated in the [Location](#tag/locations) when the `deprecation` property is set. - permanently unavailable in the [Location](#tag/locations) when the `deprecation.unavailable_after` date is in the past. - temporarily unavailable in the [Location](#tag/locations) when the `deprecation.available` is false. */ locations: GetServerTypeResponseServerTypeLocationsList; } export interface GetServerTypeResponse { server_type: GetServerTypeResponseServerType; } export interface ListServerTypesRequest { /** Filter resources by their name. The response will only contain the resources matching exactly the specified name. */ name?: 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; } /** Hourly price in this [Location](#tag/locations). */ export type ListServerTypesResponseServerTypesItemPricesItemPriceHourly = GetServerTypeResponseServerTypePricesItemPriceHourly; /** Monthly price in this [Location](#tag/locations). */ export type ListServerTypesResponseServerTypesItemPricesItemPriceMonthly = GetServerTypeResponseServerTypePricesItemPriceHourly; /** Additional traffic price per TB in this [Location](#tag/locations). */ export type ListServerTypesResponseServerTypesItemPricesItemPricePerTbTraffic = GetServerTypeResponseServerTypePricesItemPriceHourly; export type ListServerTypesResponseServerTypesItemPricesItem = GetServerTypeResponseServerTypePricesItem; /** Price per [Location](#tag/locations). */ export type ListServerTypesResponseServerTypesItemPricesList = Array; /** Type of Server boot drive. Local has higher speed. Network has better availability. */ export type ListServerTypesResponseServerTypesItemStorageType = "local" | "network"; /** Type of cpu. */ export type ListServerTypesResponseServerTypesItemCpuType = "shared" | "dedicated"; /** CPU architecture of the Server Type. */ export type ListServerTypesResponseServerTypesItemArchitecture = "x86" | "arm"; /** This field is deprecated. Use the `deprecation` object in the `locations` field instead (`.locations[].deprecation`). */ export type ListServerTypesResponseServerTypesItemDeprecation = GetServerTypeResponseServerTypeDeprecation; /** 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 ListServerTypesResponseServerTypesItemLocationsItemDeprecation = GetServerTypeResponseServerTypeDeprecation; /** A [Location](#tag/locations) (containing only id and name) and Server Type specific metadata. */ export type ListServerTypesResponseServerTypesItemLocationsItem = GetServerTypeResponseServerTypeLocationsItem; /** Supported [Location](#tag/locations) and per [Location](#tag/locations) details for the [Server Type](#tag/server-types). A [Server Type](#tag/server-types) is: - only supported in the [Location](#tag/locations) that are listed. - deprecated in the [Location](#tag/locations) when the `deprecation` property is set. - permanently unavailable in the [Location](#tag/locations) when the `deprecation.unavailable_after` date is in the past. - temporarily unavailable in the [Location](#tag/locations) when the `deprecation.available` is false. */ export type ListServerTypesResponseServerTypesItemLocationsList = Array; export interface ListServerTypesResponseServerTypesItem { /** ID of the Server type. */ id: number; /** Unique identifier of the Server type. */ name: string; /** Description of the Server type. */ description: string; /** Number of cpu cores a Server of this type will have. */ cores: number; /** Memory a Server of this type will have in GB. */ memory: number; /** Disk size a Server of this type will have in GB. */ disk: number; /** This field is deprecated. Use the deprecation object instead. */ deprecated: boolean; /** Price per [Location](#tag/locations). */ prices: ListServerTypesResponseServerTypesItemPricesList; /** Type of Server boot drive. Local has higher speed. Network has better availability. */ storage_type: ListServerTypesResponseServerTypesItemStorageType; /** Type of cpu. */ cpu_type: ListServerTypesResponseServerTypesItemCpuType; /** Category of Server Type. */ category?: string; /** CPU architecture of the Server Type. */ architecture: ListServerTypesResponseServerTypesItemArchitecture; /** This field is deprecated. Use the `deprecation` object in the `locations` field instead (`.locations[].deprecation`). */ deprecation?: GetServerTypeResponseServerTypeDeprecation | null; /** Supported [Location](#tag/locations) and per [Location](#tag/locations) details for the [Server Type](#tag/server-types). A [Server Type](#tag/server-types) is: - only supported in the [Location](#tag/locations) that are listed. - deprecated in the [Location](#tag/locations) when the `deprecation` property is set. - permanently unavailable in the [Location](#tag/locations) when the `deprecation.unavailable_after` date is in the past. - temporarily unavailable in the [Location](#tag/locations) when the `deprecation.available` is false. */ locations: ListServerTypesResponseServerTypesItemLocationsList; } export type ListServerTypesResponseServerTypesList = Array; /** See "[Pagination](#description/pagination)" for more information. */ export interface ListServerTypesResponseMetaPagination { /** 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 ListServerTypesResponseMeta { /** See "[Pagination](#description/pagination)" for more information. */ pagination: ListServerTypesResponseMetaPagination; } export interface ListServerTypesResponse { server_types: ListServerTypesResponseServerTypesList; meta: ListServerTypesResponseMeta; } export type GetServerTypeError = HetznerOpError; /** Get a Server Type Gets a specific Server type object. */ export const getServerType: API.OperationMethod< GetServerTypeRequest, GetServerTypeResponse, GetServerTypeError, 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 ListServerTypesError = HetznerOpError; /** List Server Types Gets all Server type objects. */ export const listServerTypes: API.PaginatedOperationMethod< ListServerTypesRequest, ListServerTypesResponse, ListServerTypesError, HetznerOpContext, ListServerTypesResponseServerTypesItem > = /*@__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: "server_types", 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: "/server_types/{id}", code: 200 })), ).annotate({ identifier: "GetServerTypeRequest" }); case 1: return S.suspend(() => S.Struct({ server_type: __S(14, __c1, 6), }), ).annotate({ identifier: "GetServerTypeResponse" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ net: S.String, gross: S.String, }), ).annotate({ identifier: "GetServerTypeResponseServerTypePricesItemPriceHourly" }); case 1: return S.suspend(() => S.Struct({ location: S.String, price_hourly: __S(8, __c1, 0), price_monthly: __S(8, __c1, 0), included_traffic: S.Number, price_per_tb_traffic: __S(8, __c1, 0), }), ).annotate({ identifier: "GetServerTypeResponseServerTypePricesItem" }); case 2: return S.Array(__S(9, __c1, 1)); case 3: return S.suspend(() => S.Struct({ unavailable_after: S.String, announced: S.String, }), ).annotate({ identifier: "GetServerTypeResponseServerTypeDeprecation" }); case 4: return S.suspend(() => S.Struct({ id: S.Number, name: S.String, deprecation: S.NullOr(__S(11, __c1, 3)), recommended: S.Boolean, available: S.Boolean, }), ).annotate({ identifier: "GetServerTypeResponseServerTypeLocationsItem" }); case 5: return S.Array(__S(12, __c1, 4)); case 6: return S.suspend(() => S.Struct({ id: S.Number, name: S.String, description: S.String, cores: S.Number, memory: S.Number, disk: S.Number, deprecated: S.Boolean, prices: __S(10, __c1, 2), storage_type: S.String, cpu_type: S.String, category: S.optional(S.String), architecture: S.String, deprecation: S.optional(S.NullOr(__S(11, __c1, 3))), locations: __S(13, __c1, 5), }), ).annotate({ identifier: "GetServerTypeResponseServerType" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ name: 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: "/server_types", code: 200 })), ).annotate({ identifier: "ListServerTypesRequest" }); case 1: return S.Array(__S(14, __c1, 6)); 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: "ListServerTypesResponseMetaPagination" }); case 3: return S.suspend(() => S.Struct({ pagination: __S(18, __c2, 2), }), ).annotate({ identifier: "ListServerTypesResponseMeta" }); case 4: return S.suspend(() => S.Struct({ server_types: __S(17, __c2, 1), meta: __S(19, __c2, 3), }), ).annotate({ identifier: "ListServerTypesResponse" }); } } // 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)); }