Skip to content

Commit 00be3b3

Browse files
authored
Merge branch 'main' into v1.6109.0
2 parents c68c3ae + 0972b37 commit 00be3b3

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

packages/clients/src/api/applesilicon/v1alpha1/marshalling.gen.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
} from '../../../bridge'
99
import type { DefaultValues } from '../../../bridge'
1010
import type {
11+
Commitment,
12+
CommitmentTypeValue,
1113
ConnectivityDiagnostic,
1214
ConnectivityDiagnosticServerHealth,
1315
CreateServerRequest,
@@ -161,6 +163,19 @@ export const unmarshalServerType = (data: unknown): ServerType => {
161163
} as ServerType
162164
}
163165

166+
const unmarshalCommitment = (data: unknown): Commitment => {
167+
if (!isJSONObject(data)) {
168+
throw new TypeError(
169+
`Unmarshalling the type 'Commitment' failed as data isn't a dictionary.`,
170+
)
171+
}
172+
173+
return {
174+
cancelled: data.cancelled,
175+
type: data.type,
176+
} as Commitment
177+
}
178+
164179
export const unmarshalServer = (data: unknown): Server => {
165180
if (!isJSONObject(data)) {
166181
throw new TypeError(
@@ -169,6 +184,9 @@ export const unmarshalServer = (data: unknown): Server => {
169184
}
170185

171186
return {
187+
commitment: data.commitment
188+
? unmarshalCommitment(data.commitment)
189+
: undefined,
172190
createdAt: unmarshalDate(data.created_at),
173191
deletableAt: unmarshalDate(data.deletable_at),
174192
deletionScheduled: data.deletion_scheduled,
@@ -326,6 +344,7 @@ export const marshalCreateServerRequest = (
326344
request: CreateServerRequest,
327345
defaults: DefaultValues,
328346
): Record<string, unknown> => ({
347+
commitment_type: request.commitmentType,
329348
enable_vpc: request.enableVpc,
330349
name: request.name || randomName('as'),
331350
os_id: request.osId,
@@ -362,10 +381,21 @@ export const marshalStartConnectivityDiagnosticRequest = (
362381
server_id: request.serverId,
363382
})
364383

384+
const marshalCommitmentTypeValue = (
385+
request: CommitmentTypeValue,
386+
defaults: DefaultValues,
387+
): Record<string, unknown> => ({
388+
commitment_type: request.commitmentType,
389+
})
390+
365391
export const marshalUpdateServerRequest = (
366392
request: UpdateServerRequest,
367393
defaults: DefaultValues,
368394
): Record<string, unknown> => ({
395+
commitment_type:
396+
request.commitmentType !== undefined
397+
? marshalCommitmentTypeValue(request.commitmentType, defaults)
398+
: undefined,
369399
enable_vpc: request.enableVpc,
370400
name: request.name,
371401
schedule_deletion: request.scheduleDeletion,

packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
import type { Zone as ScwZone } from '../../../bridge'
44

5+
export type CommitmentType = 'duration_24h' | 'renewed_monthly' | 'none'
6+
57
export type ConnectivityDiagnosticActionType =
68
| 'reboot_server'
79
| 'reinstall_server'
@@ -98,6 +100,11 @@ export interface ServerTypeNetwork {
98100
publicBandwidthBps: number
99101
}
100102

103+
export interface Commitment {
104+
type: CommitmentType
105+
cancelled: boolean
106+
}
107+
101108
export interface ConnectivityDiagnosticServerHealth {
102109
lastCheckinDate?: Date
103110
isServerAlive: boolean
@@ -204,6 +211,12 @@ export interface Server {
204211
* server.
205212
*/
206213
vpcStatus: ServerPrivateNetworkStatus
214+
/** Commitment scheme applied to this server. */
215+
commitment?: Commitment
216+
}
217+
218+
export interface CommitmentTypeValue {
219+
commitmentType: CommitmentType
207220
}
208221

209222
export interface ConnectivityDiagnostic {
@@ -235,6 +248,12 @@ export type CreateServerRequest = {
235248
* configured through the Apple Silicon - Private Networks API.
236249
*/
237250
enableVpc: boolean
251+
/**
252+
* Activate commitment for this server. If not specified, there is a 24h
253+
* commitment due to Apple licensing. It can be updated with the Update Server
254+
* request. Available commitment depends on server type.
255+
*/
256+
commitmentType?: CommitmentType
238257
}
239258

240259
export type DeleteServerRequest = {
@@ -444,4 +463,9 @@ export type UpdateServerRequest = {
444463
scheduleDeletion?: boolean
445464
/** Activate or deactivate Private Network support for this server. */
446465
enableVpc?: boolean
466+
/**
467+
* Change commitment. Use 'none' to automatically cancel a renewing
468+
* commitment.
469+
*/
470+
commitmentType?: CommitmentTypeValue
447471
}

0 commit comments

Comments
 (0)