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
5 changes: 4 additions & 1 deletion packages/clients/src/api/applesilicon/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { WaitForOptions, Zone } from '../../../bridge'
import { SERVER_TRANSIENT_STATUSES } from './content.gen'
import {
marshalCreateServerRequest,
marshalReinstallServerRequest,
marshalUpdateServerRequest,
unmarshalListOSResponse,
unmarshalListServerTypesResponse,
Expand Down Expand Up @@ -277,7 +278,9 @@ export class API extends ParentAPI {
reinstallServer = (request: Readonly<ReinstallServerRequest>) =>
this.client.fetch<Server>(
{
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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
ListServerTypesResponse,
ListServersResponse,
OS,
ReinstallServerRequest,
Server,
ServerType,
ServerTypeCPU,
Expand All @@ -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
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -163,10 +170,18 @@ export const marshalCreateServerRequest = (
defaults: DefaultValues,
): Record<string, unknown> => ({
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<string, unknown> => ({
os_id: request.osId,
})

export const marshalUpdateServerRequest = (
request: UpdateServerRequest,
defaults: DefaultValues,
Expand Down
52 changes: 39 additions & 13 deletions packages/clients/src/api/applesilicon/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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. */
Expand All @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down