From a12f720b732a441380d5d10221cc9c23d9703fc7 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 3 Jul 2025 14:27:04 +0000 Subject: [PATCH] feat: update generated APIs --- .../applesilicon/src/v1alpha1/api.gen.ts | 23 ++++++++++ .../applesilicon/src/v1alpha1/index.gen.ts | 3 ++ .../src/v1alpha1/marshalling.gen.ts | 45 ++++++++++++++++++ .../applesilicon/src/v1alpha1/types.gen.ts | 46 +++++++++++++++++++ 4 files changed, 117 insertions(+) diff --git a/packages_generated/applesilicon/src/v1alpha1/api.gen.ts b/packages_generated/applesilicon/src/v1alpha1/api.gen.ts index 5ec4eafdb..7dce387f7 100644 --- a/packages_generated/applesilicon/src/v1alpha1/api.gen.ts +++ b/packages_generated/applesilicon/src/v1alpha1/api.gen.ts @@ -14,12 +14,14 @@ import { SERVER_TRANSIENT_STATUSES as SERVER_TRANSIENT_STATUSES_APPLESILICON, } from './content.gen' import { + marshalBatchCreateServersRequest, marshalCreateServerRequest, marshalPrivateNetworkApiAddServerPrivateNetworkRequest, marshalPrivateNetworkApiSetServerPrivateNetworksRequest, marshalReinstallServerRequest, marshalStartConnectivityDiagnosticRequest, marshalUpdateServerRequest, + unmarshalBatchCreateServersResponse, unmarshalConnectivityDiagnostic, unmarshalListOSResponse, unmarshalListServerPrivateNetworksResponse, @@ -33,6 +35,8 @@ import { unmarshalStartConnectivityDiagnosticResponse, } from './marshalling.gen' import type { + BatchCreateServersRequest, + BatchCreateServersResponse, ConnectivityDiagnostic, CreateServerRequest, DeleteServerRequest, @@ -131,6 +135,25 @@ export class API extends ParentAPI { unmarshalServer, ) + /** + * Create multiple servers atomically. Create multiple servers in the targeted zone specifying their configurations. If the request cannot entirely be fullfilled, no servers are created. + * + * @param request - The request {@link BatchCreateServersRequest} + * @returns A Promise of BatchCreateServersResponse + */ + batchCreateServers = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalBatchCreateServersRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/batch-create-servers`, + }, + unmarshalBatchCreateServersResponse, + ) + protected pageOfListServers = (request: Readonly = {}) => this.client.fetch( { diff --git a/packages_generated/applesilicon/src/v1alpha1/index.gen.ts b/packages_generated/applesilicon/src/v1alpha1/index.gen.ts index 9bf295e69..93d1ce2a9 100644 --- a/packages_generated/applesilicon/src/v1alpha1/index.gen.ts +++ b/packages_generated/applesilicon/src/v1alpha1/index.gen.ts @@ -7,6 +7,9 @@ export { export * from './content.gen' export * from './marshalling.gen' export type { + BatchCreateServersRequest, + BatchCreateServersRequestBatchInnerCreateServerRequest, + BatchCreateServersResponse, Commitment, CommitmentType, CommitmentTypeValue, diff --git a/packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts b/packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts index e74060ebc..bf163fdfe 100644 --- a/packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts +++ b/packages_generated/applesilicon/src/v1alpha1/marshalling.gen.ts @@ -8,6 +8,9 @@ import { } from '@scaleway/sdk-client' import type { DefaultValues } from '@scaleway/sdk-client' import type { + BatchCreateServersRequest, + BatchCreateServersRequestBatchInnerCreateServerRequest, + BatchCreateServersResponse, Commitment, CommitmentTypeValue, ConnectivityDiagnostic, @@ -211,6 +214,20 @@ export const unmarshalServerType = (data: unknown): ServerType => { } as ServerType } +export const unmarshalBatchCreateServersResponse = ( + data: unknown, +): BatchCreateServersResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'BatchCreateServersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + servers: unmarshalArrayOfObject(data.servers, unmarshalServer), + } as BatchCreateServersResponse +} + const unmarshalConnectivityDiagnosticServerHealth = ( data: unknown, ): ConnectivityDiagnosticServerHealth => { @@ -342,6 +359,34 @@ export const unmarshalStartConnectivityDiagnosticResponse = ( } as StartConnectivityDiagnosticResponse } +const marshalBatchCreateServersRequestBatchInnerCreateServerRequest = ( + request: BatchCreateServersRequestBatchInnerCreateServerRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, +}) + +export const marshalBatchCreateServersRequest = ( + request: BatchCreateServersRequest, + defaults: DefaultValues, +): Record => ({ + commitment_type: request.commitmentType, + enable_vpc: request.enableVpc, + os_id: request.osId, + project_id: request.projectId ?? defaults.defaultProjectId, + public_bandwidth_bps: request.publicBandwidthBps, + requests: + request.requests !== undefined + ? request.requests.map(elt => + marshalBatchCreateServersRequestBatchInnerCreateServerRequest( + elt, + defaults, + ), + ) + : undefined, + type: request.type, +}) + export const marshalCreateServerRequest = ( request: CreateServerRequest, defaults: DefaultValues, diff --git a/packages_generated/applesilicon/src/v1alpha1/types.gen.ts b/packages_generated/applesilicon/src/v1alpha1/types.gen.ts index 2c2c5e08b..be29aa3fd 100644 --- a/packages_generated/applesilicon/src/v1alpha1/types.gen.ts +++ b/packages_generated/applesilicon/src/v1alpha1/types.gen.ts @@ -124,6 +124,10 @@ export interface ServerTypeNetwork { supportedBandwidth: number[] } +export interface BatchCreateServersRequestBatchInnerCreateServerRequest { + name: string +} + export interface Server { /** * UUID of the server. @@ -302,6 +306,48 @@ export interface CommitmentTypeValue { commitmentType: CommitmentType } +export type BatchCreateServersRequest = { + /** + * Zone to target. If none is passed will use default zone from the config. + */ + zone?: ScwZone + /** + * Create servers in the given project ID. + */ + projectId?: string + /** + * Create servers of the given type. + */ + type: string + /** + * Create servers & 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 + /** + * Activate the Private Network feature for these servers. This feature is configured through the Apple Silicon - Private Networks API. + */ + enableVpc: boolean + /** + * Activate commitment for these servers. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. + */ + commitmentType?: CommitmentType + /** + * Public bandwidth to configure for these servers. This defaults to the minimum bandwidth for the corresponding server type. For compatible server types, the bandwidth can be increased which incurs additional costs. + */ + publicBandwidthBps: number + /** + * List of servers to create. + */ + requests?: BatchCreateServersRequestBatchInnerCreateServerRequest[] +} + +export interface BatchCreateServersResponse { + /** + * List of created servers. + */ + servers: Server[] +} + export interface ConnectivityDiagnostic { id: string status: ConnectivityDiagnosticDiagnosticStatus