From 47bcfcc2e82ee5f44f1cee02ce753b9255349733 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 25 Apr 2024 14:14:57 +0000 Subject: [PATCH] feat: update generated APIs --- .../src/api/applesilicon/v1alpha1/api.gen.ts | 5 +- .../applesilicon/v1alpha1/marshalling.gen.ts | 15 ++++++ .../api/applesilicon/v1alpha1/types.gen.ts | 52 ++++++++++++++----- 3 files changed, 58 insertions(+), 14 deletions(-) diff --git a/packages/clients/src/api/applesilicon/v1alpha1/api.gen.ts b/packages/clients/src/api/applesilicon/v1alpha1/api.gen.ts index da3ae380b..995540c2b 100644 --- a/packages/clients/src/api/applesilicon/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/applesilicon/v1alpha1/api.gen.ts @@ -11,6 +11,7 @@ import type { WaitForOptions, Zone } from '../../../bridge' import { SERVER_TRANSIENT_STATUSES } from './content.gen' import { marshalCreateServerRequest, + marshalReinstallServerRequest, marshalUpdateServerRequest, unmarshalListOSResponse, unmarshalListServerTypesResponse, @@ -277,7 +278,9 @@ export class API extends ParentAPI { reinstallServer = (request: Readonly) => this.client.fetch( { - body: '{}', + body: JSON.stringify( + marshalReinstallServerRequest(request, this.client.settings), + ), headers: jsonContentHeaders, method: 'POST', path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reinstall`, diff --git a/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts index ae5e7c656..270cc4835 100644 --- a/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts @@ -13,6 +13,7 @@ import type { ListServerTypesResponse, ListServersResponse, OS, + ReinstallServerRequest, Server, ServerType, ServerTypeCPU, @@ -30,10 +31,14 @@ export const unmarshalOS = (data: unknown): OS => { return { compatibleServerTypes: data.compatible_server_types, + family: data.family, id: data.id, imageUrl: data.image_url, + isBeta: data.is_beta, label: data.label, name: data.name, + version: data.version, + xcodeVersion: data.xcode_version, } as OS } @@ -85,6 +90,7 @@ export const unmarshalServerType = (data: unknown): ServerType => { return { cpu: data.cpu ? unmarshalServerTypeCPU(data.cpu) : undefined, + defaultOs: data.default_os ? unmarshalOS(data.default_os) : undefined, disk: data.disk ? unmarshalServerTypeDisk(data.disk) : undefined, memory: data.memory ? unmarshalServerTypeMemory(data.memory) : undefined, minimumLeaseDuration: data.minimum_lease_duration, @@ -107,6 +113,7 @@ export const unmarshalServer = (data: unknown): Server => { ip: data.ip, name: data.name, organizationId: data.organization_id, + os: data.os ? unmarshalOS(data.os) : undefined, projectId: data.project_id, status: data.status, type: data.type, @@ -163,10 +170,18 @@ export const marshalCreateServerRequest = ( defaults: DefaultValues, ): Record => ({ name: request.name || randomName('as'), + os_id: request.osId, project_id: request.projectId ?? defaults.defaultProjectId, type: request.type, }) +export const marshalReinstallServerRequest = ( + request: ReinstallServerRequest, + defaults: DefaultValues, +): Record => ({ + os_id: request.osId, +}) + export const marshalUpdateServerRequest = ( request: UpdateServerRequest, defaults: DefaultValues, diff --git a/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts b/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts index 79d7ac633..5c64e566a 100644 --- a/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts @@ -22,6 +22,27 @@ export type ServerTypeStock = | 'low_stock' | 'high_stock' +export interface OS { + /** Unique ID of the OS. */ + id: string + /** OS name. */ + name: string + /** OS name as it should be displayed. */ + label: string + /** URL of the image. */ + imageUrl: string + /** The OS family to which this OS belongs, eg. 13 or 14. */ + family: string + /** Describes if the OS is in beta. */ + isBeta: boolean + /** The OS version number, eg. Sonoma has version number 14.3. */ + version: string + /** The current xcode version for this OS. */ + xcodeVersion: string + /** List of compatible server types. */ + compatibleServerTypes: string[] +} + export interface ServerTypeCPU { name: string coreCount: number @@ -37,19 +58,6 @@ export interface ServerTypeMemory { type: string } -export interface OS { - /** Unique ID of the OS. */ - id: string - /** OS name. */ - name: string - /** OS name as it should be displayed. */ - label: string - /** URL of the image. */ - imageUrl: string - /** List of compatible server types. */ - compatibleServerTypes: string[] -} - export interface ServerType { /** CPU description. */ cpu?: ServerTypeCPU @@ -63,6 +71,8 @@ export interface ServerType { stock: ServerTypeStock /** Minimum duration of the lease in seconds (example. 3.4s). */ minimumLeaseDuration?: string + /** The default OS for this server type. */ + defaultOs?: OS } export interface Server { @@ -80,6 +90,11 @@ export interface Server { ip: string /** URL of the VNC. */ vncUrl: string + /** + * Initially installed OS, this does not necessarily reflect the current OS + * version. + */ + os?: OS /** Current status of the server. */ status: ServerStatus /** Date on which the server was created. */ @@ -101,6 +116,12 @@ export type CreateServerRequest = { projectId?: string /** Create a server of the given type. */ type: string + /** + * Create a server & install the given os_id, when no os_id provided the + * default OS for this server type is chosen. Requesting a non-default OS will + * induce an extended delivery time. + */ + osId?: string } export type DeleteServerRequest = { @@ -204,6 +225,11 @@ export type ReinstallServerRequest = { zone?: Zone /** UUID of the server you want to reinstall. */ serverId: string + /** + * Reinstall the server with the target OS, when no os_id provided the default + * OS for the server type is used. + */ + osId?: string } export type UpdateServerRequest = {