From 19553dc4994f87e665679464fdf596a805ab3535 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Fri, 2 Aug 2024 15:27:44 +0000 Subject: [PATCH] feat: update generated APIs --- packages/clients/src/api/k8s/v1/api.gen.ts | 42 +++++++++++++ packages/clients/src/api/k8s/v1/index.gen.ts | 5 ++ .../clients/src/api/k8s/v1/marshalling.gen.ts | 62 +++++++++++++++++++ packages/clients/src/api/k8s/v1/types.gen.ts | 53 ++++++++++++++++ 4 files changed, 162 insertions(+) diff --git a/packages/clients/src/api/k8s/v1/api.gen.ts b/packages/clients/src/api/k8s/v1/api.gen.ts index 89baa6281..e7285dbfd 100644 --- a/packages/clients/src/api/k8s/v1/api.gen.ts +++ b/packages/clients/src/api/k8s/v1/api.gen.ts @@ -23,6 +23,7 @@ import { marshalUpgradePoolRequest, unmarshalCluster, unmarshalExternalNode, + unmarshalExternalNodeAuth, unmarshalListClusterAvailableTypesResponse, unmarshalListClusterAvailableVersionsResponse, unmarshalListClusterTypesResponse, @@ -31,10 +32,12 @@ import { unmarshalListPoolsResponse, unmarshalListVersionsResponse, unmarshalNode, + unmarshalNodeMetadata, unmarshalPool, unmarshalVersion, } from './marshalling.gen' import type { + AuthExternalNodeRequest, Cluster, CreateClusterRequest, CreateExternalNodeRequest, @@ -43,8 +46,10 @@ import type { DeleteNodeRequest, DeletePoolRequest, ExternalNode, + ExternalNodeAuth, GetClusterKubeConfigRequest, GetClusterRequest, + GetNodeMetadataRequest, GetNodeRequest, GetPoolRequest, GetVersionRequest, @@ -64,6 +69,7 @@ import type { ListVersionsResponse, MigrateClusterToRoutedIPsRequest, Node, + NodeMetadata, Pool, RebootNodeRequest, ReplaceNodeRequest, @@ -487,6 +493,42 @@ export class API extends ParentAPI { unmarshalPool, ) + /** + * Fetch node metadata. Rerieve metadata to instantiate a Kapsule/Kosmos node. + * This method is not intended to be called by end users but rather + * programmatically by the node-installer. + * + * @param request - The request {@link GetNodeMetadataRequest} + * @returns A Promise of NodeMetadata + */ + getNodeMetadata = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/k8s/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/nodes/metadata`, + }, + unmarshalNodeMetadata, + ) + + /** + * Authenticate Kosmos external node. Creates a newer Kosmos node and returns + * its token. This method is not intended to be called by end users but rather + * programmatically by the node-installer. + * + * @param request - The request {@link AuthExternalNodeRequest} + * @returns A Promise of ExternalNodeAuth + */ + authExternalNode = (request: Readonly) => + this.client.fetch( + { + body: '{}', + headers: jsonContentHeaders, + method: 'POST', + path: `/k8s/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/pools/${validatePathParam('poolId', request.poolId)}/external-nodes/auth`, + }, + unmarshalExternalNodeAuth, + ) + /** * Create a Kosmos node. Retrieve metadata for a Kosmos node. This method is * not intended to be called by end users but rather programmatically by the diff --git a/packages/clients/src/api/k8s/v1/index.gen.ts b/packages/clients/src/api/k8s/v1/index.gen.ts index aea48b8be..864f930e2 100644 --- a/packages/clients/src/api/k8s/v1/index.gen.ts +++ b/packages/clients/src/api/k8s/v1/index.gen.ts @@ -3,6 +3,7 @@ export { API } from './api.gen' export * from './content.gen' export type { + AuthExternalNodeRequest, AutoscalerEstimator, AutoscalerExpander, CNI, @@ -27,9 +28,11 @@ export type { DeleteNodeRequest, DeletePoolRequest, ExternalNode, + ExternalNodeAuth, ExternalNodeCoreV1Taint, GetClusterKubeConfigRequest, GetClusterRequest, + GetNodeMetadataRequest, GetNodeRequest, GetPoolRequest, GetVersionRequest, @@ -54,6 +57,8 @@ export type { MaintenanceWindowDayOfTheWeek, MigrateClusterToRoutedIPsRequest, Node, + NodeMetadata, + NodeMetadataCoreV1Taint, NodeStatus, Pool, PoolStatus, diff --git a/packages/clients/src/api/k8s/v1/marshalling.gen.ts b/packages/clients/src/api/k8s/v1/marshalling.gen.ts index 7e3c940c3..8af92cdb0 100644 --- a/packages/clients/src/api/k8s/v1/marshalling.gen.ts +++ b/packages/clients/src/api/k8s/v1/marshalling.gen.ts @@ -23,6 +23,7 @@ import type { CreatePoolRequest, CreatePoolRequestUpgradePolicy, ExternalNode, + ExternalNodeAuth, ExternalNodeCoreV1Taint, ListClusterAvailableTypesResponse, ListClusterAvailableVersionsResponse, @@ -33,6 +34,8 @@ import type { ListVersionsResponse, MaintenanceWindow, Node, + NodeMetadata, + NodeMetadataCoreV1Taint, Pool, PoolUpgradePolicy, SetClusterTypeRequest, @@ -219,6 +222,7 @@ export const unmarshalCluster = (data: unknown): Cluster => { projectId: data.project_id, region: data.region, routedIpEnabled: data.routed_ip_enabled, + sbsCsiEnabled: data.sbs_csi_enabled, status: data.status, tags: data.tags, type: data.type, @@ -295,6 +299,19 @@ export const unmarshalExternalNode = (data: unknown): ExternalNode => { } as ExternalNode } +export const unmarshalExternalNodeAuth = (data: unknown): ExternalNodeAuth => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ExternalNodeAuth' failed as data isn't a dictionary.`, + ) + } + + return { + apiUrl: data.api_url, + nodeToken: data.node_token, + } as ExternalNodeAuth +} + const unmarshalClusterType = (data: unknown): ClusterType => { if (!isJSONObject(data)) { throw new TypeError( @@ -307,6 +324,7 @@ const unmarshalClusterType = (data: unknown): ClusterType => { availability: data.availability, commitmentDelay: data.commitment_delay, dedicated: data.dedicated, + maxEtcdSize: data.max_etcd_size, maxNodes: data.max_nodes, memory: data.memory, name: data.name, @@ -424,6 +442,50 @@ export const unmarshalListVersionsResponse = ( } as ListVersionsResponse } +const unmarshalNodeMetadataCoreV1Taint = ( + data: unknown, +): NodeMetadataCoreV1Taint => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'NodeMetadataCoreV1Taint' failed as data isn't a dictionary.`, + ) + } + + return { + effect: data.effect, + key: data.key, + value: data.value, + } as NodeMetadataCoreV1Taint +} + +export const unmarshalNodeMetadata = (data: unknown): NodeMetadata => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'NodeMetadata' failed as data isn't a dictionary.`, + ) + } + + return { + clusterCa: data.cluster_ca, + clusterUrl: data.cluster_url, + credentialProviderConfig: data.credential_provider_config, + externalIp: data.external_ip, + fullIsolation: data.full_isolation, + hasGpu: data.has_gpu, + id: data.id, + kapsuleIfaceMac: data.kapsule_iface_mac, + kubeletConfig: data.kubelet_config, + name: data.name, + nodeLabels: data.node_labels, + nodeTaints: unmarshalArrayOfObject( + data.node_taints, + unmarshalNodeMetadataCoreV1Taint, + ), + poolVersion: data.pool_version, + privateNetworkMode: data.private_network_mode, + } as NodeMetadata +} + const marshalMaintenanceWindow = ( request: MaintenanceWindow, defaults: DefaultValues, diff --git a/packages/clients/src/api/k8s/v1/types.gen.ts b/packages/clients/src/api/k8s/v1/types.gen.ts index 2a1105519..554c1b0bc 100644 --- a/packages/clients/src/api/k8s/v1/types.gen.ts +++ b/packages/clients/src/api/k8s/v1/types.gen.ts @@ -466,6 +466,8 @@ export interface ClusterType { * note that audit logs are sent to Cockpit. */ auditLogsSupported: boolean + /** Maximum amount of data that can be stored in etcd for the offer. */ + maxEtcdSize: number } export interface Version { @@ -547,6 +549,11 @@ export interface Cluster { * cluster. */ routedIpEnabled?: boolean + /** + * @deprecated Defines whether the SBS-enabled CSI starting from v0.3 is + * installed on the cluster. + */ + sbsCsiEnabled?: boolean } export interface Node { @@ -585,6 +592,12 @@ export interface Node { updatedAt?: Date } +export interface NodeMetadataCoreV1Taint { + key: string + value: string + effect: string +} + export interface UpdateClusterRequestAutoUpgrade { /** Defines whether auto upgrade is enabled for the cluster. */ enable?: boolean @@ -676,6 +689,16 @@ export interface UpdatePoolRequestUpgradePolicy { maxSurge?: number } +export type AuthExternalNodeRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region + /** Pool the node will be attached to. */ + poolId: string +} + export type CreateClusterRequest = { /** * Region to target. If none is passed will use default region from the @@ -885,6 +908,11 @@ export interface ExternalNode { nodeTaints: ExternalNodeCoreV1Taint[] } +export interface ExternalNodeAuth { + nodeToken: string + apiUrl: string +} + export type GetClusterKubeConfigRequest = { /** * Region to target. If none is passed will use default region from the @@ -907,6 +935,14 @@ export type GetClusterRequest = { clusterId: string } +export type GetNodeMetadataRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region +} + export type GetNodeRequest = { /** * Region to target. If none is passed will use default region from the @@ -1111,6 +1147,23 @@ export type MigrateClusterToRoutedIPsRequest = { clusterId: string } +export interface NodeMetadata { + id: string + name: string + clusterUrl: string + clusterCa: string + credentialProviderConfig: string + poolVersion: string + kubeletConfig: string + nodeLabels: Record + nodeTaints: NodeMetadataCoreV1Taint[] + privateNetworkMode: string + kapsuleIfaceMac: string + fullIsolation: boolean + hasGpu: boolean + externalIp: string +} + export type RebootNodeRequest = { /** * Region to target. If none is passed will use default region from the