diff --git a/packages/clients/src/api/k8s/v1/api.gen.ts b/packages/clients/src/api/k8s/v1/api.gen.ts index d02a52ef2..d75e9fc4f 100644 --- a/packages/clients/src/api/k8s/v1/api.gen.ts +++ b/packages/clients/src/api/k8s/v1/api.gen.ts @@ -25,6 +25,7 @@ import { unmarshalCluster, unmarshalExternalNode, unmarshalListClusterAvailableVersionsResponse, + unmarshalListClusterTypesResponse, unmarshalListClustersResponse, unmarshalListNodesResponse, unmarshalListPoolsResponse, @@ -48,6 +49,8 @@ import type { GetVersionRequest, ListClusterAvailableVersionsRequest, ListClusterAvailableVersionsResponse, + ListClusterTypesRequest, + ListClusterTypesResponse, ListClustersRequest, ListClustersResponse, ListNodesRequest, @@ -733,4 +736,35 @@ export class API extends ParentAPI { }, unmarshalVersion, ) + + protected pageOfListClusterTypes = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/k8s/v1/regions/${validatePathParam( + 'region', + request.region ?? this.client.settings.defaultRegion, + )}/cluster-types`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListClusterTypesResponse, + ) + + /** + * List cluster types. List available cluster types and their technical + * details. + * + * @param request - The request {@link ListClusterTypesRequest} + * @returns A Promise of ListClusterTypesResponse + */ + listClusterTypes = (request: Readonly = {}) => + enrichForPagination('clusterTypes', this.pageOfListClusterTypes, request) } diff --git a/packages/clients/src/api/k8s/v1/index.gen.ts b/packages/clients/src/api/k8s/v1/index.gen.ts index b71213f13..13f0807bf 100644 --- a/packages/clients/src/api/k8s/v1/index.gen.ts +++ b/packages/clients/src/api/k8s/v1/index.gen.ts @@ -11,6 +11,8 @@ export type { ClusterAutoscalerConfig, ClusterOpenIDConnectConfig, ClusterStatus, + ClusterType, + ClusterTypeAvailability, CreateClusterRequest, CreateClusterRequestAutoUpgrade, CreateClusterRequestAutoscalerConfig, @@ -31,6 +33,8 @@ export type { Ingress, ListClusterAvailableVersionsRequest, ListClusterAvailableVersionsResponse, + ListClusterTypesRequest, + ListClusterTypesResponse, ListClustersRequest, ListClustersRequestOrderBy, ListClustersResponse, diff --git a/packages/clients/src/api/k8s/v1/marshalling.gen.ts b/packages/clients/src/api/k8s/v1/marshalling.gen.ts index 55d69ff3f..ba889dcd0 100644 --- a/packages/clients/src/api/k8s/v1/marshalling.gen.ts +++ b/packages/clients/src/api/k8s/v1/marshalling.gen.ts @@ -13,6 +13,7 @@ import type { ClusterAutoUpgrade, ClusterAutoscalerConfig, ClusterOpenIDConnectConfig, + ClusterType, CreateClusterRequest, CreateClusterRequestAutoUpgrade, CreateClusterRequestAutoscalerConfig, @@ -23,6 +24,7 @@ import type { CreatePoolRequestUpgradePolicy, ExternalNode, ListClusterAvailableVersionsResponse, + ListClusterTypesResponse, ListClustersResponse, ListNodesResponse, ListPoolsResponse, @@ -163,6 +165,16 @@ export const unmarshalCluster = (data: unknown) => { } as Cluster } +const unmarshalClusterType = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ClusterType' failed as data isn't a dictionary.`, + ) + } + + return { availability: data.availability, name: data.name } as ClusterType +} + export const unmarshalNode = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -275,6 +287,22 @@ export const unmarshalListClusterAvailableVersionsResponse = ( } as ListClusterAvailableVersionsResponse } +export const unmarshalListClusterTypesResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListClusterTypesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + clusterTypes: unmarshalArrayOfObject( + data.cluster_types, + unmarshalClusterType, + ), + totalCount: data.total_count, + } as ListClusterTypesResponse +} + export const unmarshalListClustersResponse = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( diff --git a/packages/clients/src/api/k8s/v1/types.gen.ts b/packages/clients/src/api/k8s/v1/types.gen.ts index 5609bba7e..f902f3199 100644 --- a/packages/clients/src/api/k8s/v1/types.gen.ts +++ b/packages/clients/src/api/k8s/v1/types.gen.ts @@ -30,6 +30,8 @@ export type ClusterStatus = | 'locked' | 'pool_required' +export type ClusterTypeAvailability = 'available' | 'scarce' | 'shortage' + export type Ingress = | 'unknown_ingress' | 'none' @@ -256,6 +258,14 @@ export interface ClusterOpenIDConnectConfig { requiredClaim: string[] } +/** Cluster type. */ +export interface ClusterType { + /** Cluster type name. */ + name: string + /** Cluster type availability. */ + availability: ClusterTypeAvailability +} + /** Create cluster request. auto upgrade. */ export interface CreateClusterRequestAutoUpgrade { /** Defines whether auto upgrade is enabled for the cluster. */ @@ -433,6 +443,14 @@ export interface ListClusterAvailableVersionsResponse { versions: Version[] } +/** List cluster types response. */ +export interface ListClusterTypesResponse { + /** Total number of cluster-types. */ + totalCount: number + /** Paginated returned cluster-types. */ + clusterTypes: ClusterType[] +} + /** List clusters response. */ export interface ListClustersResponse { /** Total number of clusters. */ @@ -1184,3 +1202,15 @@ export type GetVersionRequest = { /** Requested version name. */ versionName: string } + +export type ListClusterTypesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Page number, from the paginated results, to return for cluster-types. */ + page?: number + /** Maximum number of clusters per page. */ + pageSize?: number +} diff --git a/packages/clients/src/api/k8s/v1/validation-rules.gen.ts b/packages/clients/src/api/k8s/v1/validation-rules.gen.ts index cc00cf6aa..6596e74ed 100644 --- a/packages/clients/src/api/k8s/v1/validation-rules.gen.ts +++ b/packages/clients/src/api/k8s/v1/validation-rules.gen.ts @@ -41,6 +41,16 @@ export const CreatePoolRequest = { }, } +export const ListClusterTypesRequest = { + page: { + greaterThan: 0, + }, + pageSize: { + greaterThan: 0, + lessThanOrEqual: 100, + }, +} + export const ListClustersRequest = { name: { minLength: 1,