diff --git a/packages/clients/src/api/applesilicon/v1alpha1/index.gen.ts b/packages/clients/src/api/applesilicon/v1alpha1/index.gen.ts index da05d6767..2fef6a0c1 100644 --- a/packages/clients/src/api/applesilicon/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/applesilicon/v1alpha1/index.gen.ts @@ -3,6 +3,9 @@ export { API, PrivateNetworkAPI } from './api.gen' export * from './content.gen' export type { + Commitment, + CommitmentType, + CommitmentTypeValue, ConnectivityDiagnostic, ConnectivityDiagnosticActionType, ConnectivityDiagnosticDiagnosticStatus, diff --git a/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts index 9f48b6b2d..eaafde944 100644 --- a/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts @@ -8,6 +8,8 @@ import { } from '../../../bridge' import type { DefaultValues } from '../../../bridge' import type { + Commitment, + CommitmentTypeValue, ConnectivityDiagnostic, ConnectivityDiagnosticServerHealth, CreateServerRequest, @@ -161,6 +163,19 @@ export const unmarshalServerType = (data: unknown): ServerType => { } as ServerType } +const unmarshalCommitment = (data: unknown): Commitment => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Commitment' failed as data isn't a dictionary.`, + ) + } + + return { + cancelled: data.cancelled, + type: data.type, + } as Commitment +} + export const unmarshalServer = (data: unknown): Server => { if (!isJSONObject(data)) { throw new TypeError( @@ -169,6 +184,9 @@ export const unmarshalServer = (data: unknown): Server => { } return { + commitment: data.commitment + ? unmarshalCommitment(data.commitment) + : undefined, createdAt: unmarshalDate(data.created_at), deletableAt: unmarshalDate(data.deletable_at), deletionScheduled: data.deletion_scheduled, @@ -326,6 +344,7 @@ export const marshalCreateServerRequest = ( request: CreateServerRequest, defaults: DefaultValues, ): Record => ({ + commitment_type: request.commitmentType, enable_vpc: request.enableVpc, name: request.name || randomName('as'), os_id: request.osId, @@ -362,10 +381,21 @@ export const marshalStartConnectivityDiagnosticRequest = ( server_id: request.serverId, }) +const marshalCommitmentTypeValue = ( + request: CommitmentTypeValue, + defaults: DefaultValues, +): Record => ({ + commitment_type: request.commitmentType, +}) + export const marshalUpdateServerRequest = ( request: UpdateServerRequest, defaults: DefaultValues, ): Record => ({ + commitment_type: + request.commitmentType !== undefined + ? marshalCommitmentTypeValue(request.commitmentType, defaults) + : undefined, enable_vpc: request.enableVpc, name: request.name, schedule_deletion: request.scheduleDeletion, diff --git a/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts b/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts index 5f6e276a3..b627c54bc 100644 --- a/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts @@ -2,6 +2,8 @@ // If you have any remark or suggestion do not hesitate to open an issue. import type { Zone as ScwZone } from '../../../bridge' +export type CommitmentType = 'duration_24h' | 'renewed_monthly' | 'none' + export type ConnectivityDiagnosticActionType = | 'reboot_server' | 'reinstall_server' @@ -98,6 +100,11 @@ export interface ServerTypeNetwork { publicBandwidthBps: number } +export interface Commitment { + type: CommitmentType + cancelled: boolean +} + export interface ConnectivityDiagnosticServerHealth { lastCheckinDate?: Date isServerAlive: boolean @@ -204,6 +211,12 @@ export interface Server { * server. */ vpcStatus: ServerPrivateNetworkStatus + /** Commitment scheme applied to this server. */ + commitment?: Commitment +} + +export interface CommitmentTypeValue { + commitmentType: CommitmentType } export interface ConnectivityDiagnostic { @@ -235,6 +248,12 @@ export type CreateServerRequest = { * configured through the Apple Silicon - Private Networks API. */ enableVpc: boolean + /** + * Activate commitment for this server. If not specified, there is a 24h + * commitment due to Apple licensing. It can be updated with the Update Server + * request. Available commitment depends on server type. + */ + commitmentType?: CommitmentType } export type DeleteServerRequest = { @@ -444,4 +463,9 @@ export type UpdateServerRequest = { scheduleDeletion?: boolean /** Activate or deactivate Private Network support for this server. */ enableVpc?: boolean + /** + * Change commitment. Use 'none' to automatically cancel a renewing + * commitment. + */ + commitmentType?: CommitmentTypeValue }