Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/clients/src/api/applesilicon/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
export { API, PrivateNetworkAPI } from './api.gen'
export * from './content.gen'
export type {
Commitment,
CommitmentType,
CommitmentTypeValue,
ConnectivityDiagnostic,
ConnectivityDiagnosticActionType,
ConnectivityDiagnosticDiagnosticStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
} from '../../../bridge'
import type { DefaultValues } from '../../../bridge'
import type {
Commitment,
CommitmentTypeValue,
ConnectivityDiagnostic,
ConnectivityDiagnosticServerHealth,
CreateServerRequest,
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -326,6 +344,7 @@ export const marshalCreateServerRequest = (
request: CreateServerRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
commitment_type: request.commitmentType,
enable_vpc: request.enableVpc,
name: request.name || randomName('as'),
os_id: request.osId,
Expand Down Expand Up @@ -362,10 +381,21 @@ export const marshalStartConnectivityDiagnosticRequest = (
server_id: request.serverId,
})

const marshalCommitmentTypeValue = (
request: CommitmentTypeValue,
defaults: DefaultValues,
): Record<string, unknown> => ({
commitment_type: request.commitmentType,
})

export const marshalUpdateServerRequest = (
request: UpdateServerRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
commitment_type:
request.commitmentType !== undefined
? marshalCommitmentTypeValue(request.commitmentType, defaults)
: undefined,
enable_vpc: request.enableVpc,
name: request.name,
schedule_deletion: request.scheduleDeletion,
Expand Down
24 changes: 24 additions & 0 deletions packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -98,6 +100,11 @@ export interface ServerTypeNetwork {
publicBandwidthBps: number
}

export interface Commitment {
type: CommitmentType
cancelled: boolean
}

export interface ConnectivityDiagnosticServerHealth {
lastCheckinDate?: Date
isServerAlive: boolean
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
}
Loading