Skip to content

Commit f3cf9c5

Browse files
authored
feat(k8s): list cluster types (#700)
1 parent 0a754f8 commit f3cf9c5

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

packages/clients/src/api/k8s/v1/api.gen.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
unmarshalCluster,
2626
unmarshalExternalNode,
2727
unmarshalListClusterAvailableVersionsResponse,
28+
unmarshalListClusterTypesResponse,
2829
unmarshalListClustersResponse,
2930
unmarshalListNodesResponse,
3031
unmarshalListPoolsResponse,
@@ -48,6 +49,8 @@ import type {
4849
GetVersionRequest,
4950
ListClusterAvailableVersionsRequest,
5051
ListClusterAvailableVersionsResponse,
52+
ListClusterTypesRequest,
53+
ListClusterTypesResponse,
5154
ListClustersRequest,
5255
ListClustersResponse,
5356
ListNodesRequest,
@@ -733,4 +736,35 @@ export class API extends ParentAPI {
733736
},
734737
unmarshalVersion,
735738
)
739+
740+
protected pageOfListClusterTypes = (
741+
request: Readonly<ListClusterTypesRequest> = {},
742+
) =>
743+
this.client.fetch<ListClusterTypesResponse>(
744+
{
745+
method: 'GET',
746+
path: `/k8s/v1/regions/${validatePathParam(
747+
'region',
748+
request.region ?? this.client.settings.defaultRegion,
749+
)}/cluster-types`,
750+
urlParams: urlParams(
751+
['page', request.page],
752+
[
753+
'page_size',
754+
request.pageSize ?? this.client.settings.defaultPageSize,
755+
],
756+
),
757+
},
758+
unmarshalListClusterTypesResponse,
759+
)
760+
761+
/**
762+
* List cluster types. List available cluster types and their technical
763+
* details.
764+
*
765+
* @param request - The request {@link ListClusterTypesRequest}
766+
* @returns A Promise of ListClusterTypesResponse
767+
*/
768+
listClusterTypes = (request: Readonly<ListClusterTypesRequest> = {}) =>
769+
enrichForPagination('clusterTypes', this.pageOfListClusterTypes, request)
736770
}

packages/clients/src/api/k8s/v1/index.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export type {
1111
ClusterAutoscalerConfig,
1212
ClusterOpenIDConnectConfig,
1313
ClusterStatus,
14+
ClusterType,
15+
ClusterTypeAvailability,
1416
CreateClusterRequest,
1517
CreateClusterRequestAutoUpgrade,
1618
CreateClusterRequestAutoscalerConfig,
@@ -31,6 +33,8 @@ export type {
3133
Ingress,
3234
ListClusterAvailableVersionsRequest,
3335
ListClusterAvailableVersionsResponse,
36+
ListClusterTypesRequest,
37+
ListClusterTypesResponse,
3438
ListClustersRequest,
3539
ListClustersRequestOrderBy,
3640
ListClustersResponse,

packages/clients/src/api/k8s/v1/marshalling.gen.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
ClusterAutoUpgrade,
1414
ClusterAutoscalerConfig,
1515
ClusterOpenIDConnectConfig,
16+
ClusterType,
1617
CreateClusterRequest,
1718
CreateClusterRequestAutoUpgrade,
1819
CreateClusterRequestAutoscalerConfig,
@@ -23,6 +24,7 @@ import type {
2324
CreatePoolRequestUpgradePolicy,
2425
ExternalNode,
2526
ListClusterAvailableVersionsResponse,
27+
ListClusterTypesResponse,
2628
ListClustersResponse,
2729
ListNodesResponse,
2830
ListPoolsResponse,
@@ -163,6 +165,16 @@ export const unmarshalCluster = (data: unknown) => {
163165
} as Cluster
164166
}
165167

168+
const unmarshalClusterType = (data: unknown) => {
169+
if (!isJSONObject(data)) {
170+
throw new TypeError(
171+
`Unmarshalling the type 'ClusterType' failed as data isn't a dictionary.`,
172+
)
173+
}
174+
175+
return { availability: data.availability, name: data.name } as ClusterType
176+
}
177+
166178
export const unmarshalNode = (data: unknown) => {
167179
if (!isJSONObject(data)) {
168180
throw new TypeError(
@@ -275,6 +287,22 @@ export const unmarshalListClusterAvailableVersionsResponse = (
275287
} as ListClusterAvailableVersionsResponse
276288
}
277289

290+
export const unmarshalListClusterTypesResponse = (data: unknown) => {
291+
if (!isJSONObject(data)) {
292+
throw new TypeError(
293+
`Unmarshalling the type 'ListClusterTypesResponse' failed as data isn't a dictionary.`,
294+
)
295+
}
296+
297+
return {
298+
clusterTypes: unmarshalArrayOfObject(
299+
data.cluster_types,
300+
unmarshalClusterType,
301+
),
302+
totalCount: data.total_count,
303+
} as ListClusterTypesResponse
304+
}
305+
278306
export const unmarshalListClustersResponse = (data: unknown) => {
279307
if (!isJSONObject(data)) {
280308
throw new TypeError(

packages/clients/src/api/k8s/v1/types.gen.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export type ClusterStatus =
3030
| 'locked'
3131
| 'pool_required'
3232

33+
export type ClusterTypeAvailability = 'available' | 'scarce' | 'shortage'
34+
3335
export type Ingress =
3436
| 'unknown_ingress'
3537
| 'none'
@@ -256,6 +258,14 @@ export interface ClusterOpenIDConnectConfig {
256258
requiredClaim: string[]
257259
}
258260

261+
/** Cluster type. */
262+
export interface ClusterType {
263+
/** Cluster type name. */
264+
name: string
265+
/** Cluster type availability. */
266+
availability: ClusterTypeAvailability
267+
}
268+
259269
/** Create cluster request. auto upgrade. */
260270
export interface CreateClusterRequestAutoUpgrade {
261271
/** Defines whether auto upgrade is enabled for the cluster. */
@@ -433,6 +443,14 @@ export interface ListClusterAvailableVersionsResponse {
433443
versions: Version[]
434444
}
435445

446+
/** List cluster types response. */
447+
export interface ListClusterTypesResponse {
448+
/** Total number of cluster-types. */
449+
totalCount: number
450+
/** Paginated returned cluster-types. */
451+
clusterTypes: ClusterType[]
452+
}
453+
436454
/** List clusters response. */
437455
export interface ListClustersResponse {
438456
/** Total number of clusters. */
@@ -1184,3 +1202,15 @@ export type GetVersionRequest = {
11841202
/** Requested version name. */
11851203
versionName: string
11861204
}
1205+
1206+
export type ListClusterTypesRequest = {
1207+
/**
1208+
* Region to target. If none is passed will use default region from the
1209+
* config.
1210+
*/
1211+
region?: Region
1212+
/** Page number, from the paginated results, to return for cluster-types. */
1213+
page?: number
1214+
/** Maximum number of clusters per page. */
1215+
pageSize?: number
1216+
}

packages/clients/src/api/k8s/v1/validation-rules.gen.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ export const CreatePoolRequest = {
4141
},
4242
}
4343

44+
export const ListClusterTypesRequest = {
45+
page: {
46+
greaterThan: 0,
47+
},
48+
pageSize: {
49+
greaterThan: 0,
50+
lessThanOrEqual: 100,
51+
},
52+
}
53+
4454
export const ListClustersRequest = {
4555
name: {
4656
minLength: 1,

0 commit comments

Comments
 (0)