Skip to content

Commit c68cc53

Browse files
authored
feat(apple_silicon): add os selection fields (#1252)
1 parent 06b151b commit c68cc53

File tree

3 files changed

+58
-14
lines changed

3 files changed

+58
-14
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { WaitForOptions, Zone } from '../../../bridge'
1111
import { SERVER_TRANSIENT_STATUSES } from './content.gen'
1212
import {
1313
marshalCreateServerRequest,
14+
marshalReinstallServerRequest,
1415
marshalUpdateServerRequest,
1516
unmarshalListOSResponse,
1617
unmarshalListServerTypesResponse,
@@ -277,7 +278,9 @@ export class API extends ParentAPI {
277278
reinstallServer = (request: Readonly<ReinstallServerRequest>) =>
278279
this.client.fetch<Server>(
279280
{
280-
body: '{}',
281+
body: JSON.stringify(
282+
marshalReinstallServerRequest(request, this.client.settings),
283+
),
281284
headers: jsonContentHeaders,
282285
method: 'POST',
283286
path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reinstall`,

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
ListServerTypesResponse,
1414
ListServersResponse,
1515
OS,
16+
ReinstallServerRequest,
1617
Server,
1718
ServerType,
1819
ServerTypeCPU,
@@ -30,10 +31,14 @@ export const unmarshalOS = (data: unknown): OS => {
3031

3132
return {
3233
compatibleServerTypes: data.compatible_server_types,
34+
family: data.family,
3335
id: data.id,
3436
imageUrl: data.image_url,
37+
isBeta: data.is_beta,
3538
label: data.label,
3639
name: data.name,
40+
version: data.version,
41+
xcodeVersion: data.xcode_version,
3742
} as OS
3843
}
3944

@@ -85,6 +90,7 @@ export const unmarshalServerType = (data: unknown): ServerType => {
8590

8691
return {
8792
cpu: data.cpu ? unmarshalServerTypeCPU(data.cpu) : undefined,
93+
defaultOs: data.default_os ? unmarshalOS(data.default_os) : undefined,
8894
disk: data.disk ? unmarshalServerTypeDisk(data.disk) : undefined,
8995
memory: data.memory ? unmarshalServerTypeMemory(data.memory) : undefined,
9096
minimumLeaseDuration: data.minimum_lease_duration,
@@ -107,6 +113,7 @@ export const unmarshalServer = (data: unknown): Server => {
107113
ip: data.ip,
108114
name: data.name,
109115
organizationId: data.organization_id,
116+
os: data.os ? unmarshalOS(data.os) : undefined,
110117
projectId: data.project_id,
111118
status: data.status,
112119
type: data.type,
@@ -163,10 +170,18 @@ export const marshalCreateServerRequest = (
163170
defaults: DefaultValues,
164171
): Record<string, unknown> => ({
165172
name: request.name || randomName('as'),
173+
os_id: request.osId,
166174
project_id: request.projectId ?? defaults.defaultProjectId,
167175
type: request.type,
168176
})
169177

178+
export const marshalReinstallServerRequest = (
179+
request: ReinstallServerRequest,
180+
defaults: DefaultValues,
181+
): Record<string, unknown> => ({
182+
os_id: request.osId,
183+
})
184+
170185
export const marshalUpdateServerRequest = (
171186
request: UpdateServerRequest,
172187
defaults: DefaultValues,

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

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ export type ServerTypeStock =
2222
| 'low_stock'
2323
| 'high_stock'
2424

25+
export interface OS {
26+
/** Unique ID of the OS. */
27+
id: string
28+
/** OS name. */
29+
name: string
30+
/** OS name as it should be displayed. */
31+
label: string
32+
/** URL of the image. */
33+
imageUrl: string
34+
/** The OS family to which this OS belongs, eg. 13 or 14. */
35+
family: string
36+
/** Describes if the OS is in beta. */
37+
isBeta: boolean
38+
/** The OS version number, eg. Sonoma has version number 14.3. */
39+
version: string
40+
/** The current xcode version for this OS. */
41+
xcodeVersion: string
42+
/** List of compatible server types. */
43+
compatibleServerTypes: string[]
44+
}
45+
2546
export interface ServerTypeCPU {
2647
name: string
2748
coreCount: number
@@ -37,19 +58,6 @@ export interface ServerTypeMemory {
3758
type: string
3859
}
3960

40-
export interface OS {
41-
/** Unique ID of the OS. */
42-
id: string
43-
/** OS name. */
44-
name: string
45-
/** OS name as it should be displayed. */
46-
label: string
47-
/** URL of the image. */
48-
imageUrl: string
49-
/** List of compatible server types. */
50-
compatibleServerTypes: string[]
51-
}
52-
5361
export interface ServerType {
5462
/** CPU description. */
5563
cpu?: ServerTypeCPU
@@ -63,6 +71,8 @@ export interface ServerType {
6371
stock: ServerTypeStock
6472
/** Minimum duration of the lease in seconds (example. 3.4s). */
6573
minimumLeaseDuration?: string
74+
/** The default OS for this server type. */
75+
defaultOs?: OS
6676
}
6777

6878
export interface Server {
@@ -80,6 +90,11 @@ export interface Server {
8090
ip: string
8191
/** URL of the VNC. */
8292
vncUrl: string
93+
/**
94+
* Initially installed OS, this does not necessarily reflect the current OS
95+
* version.
96+
*/
97+
os?: OS
8398
/** Current status of the server. */
8499
status: ServerStatus
85100
/** Date on which the server was created. */
@@ -101,6 +116,12 @@ export type CreateServerRequest = {
101116
projectId?: string
102117
/** Create a server of the given type. */
103118
type: string
119+
/**
120+
* Create a server & install the given os_id, when no os_id provided the
121+
* default OS for this server type is chosen. Requesting a non-default OS will
122+
* induce an extended delivery time.
123+
*/
124+
osId?: string
104125
}
105126

106127
export type DeleteServerRequest = {
@@ -204,6 +225,11 @@ export type ReinstallServerRequest = {
204225
zone?: Zone
205226
/** UUID of the server you want to reinstall. */
206227
serverId: string
228+
/**
229+
* Reinstall the server with the target OS, when no os_id provided the default
230+
* OS for the server type is used.
231+
*/
232+
osId?: string
207233
}
208234

209235
export type UpdateServerRequest = {

0 commit comments

Comments
 (0)