Skip to content

Commit 3258595

Browse files
authored
feat(baremetal): add OptionType and ExtraOptionVars (#1421)
1 parent ef55b9d commit 3258595

File tree

3 files changed

+225
-1
lines changed

3 files changed

+225
-1
lines changed

packages/clients/src/api/baremetal/v1/index.gen.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type {
66
AddOptionServerRequest,
77
BMCAccess,
88
CPU,
9+
CertificationOption,
910
CreateServerRequest,
1011
CreateServerRequestInstall,
1112
DeleteOptionServerRequest,
@@ -22,6 +23,7 @@ export type {
2223
IPReverseStatus,
2324
IPVersion,
2425
InstallServerRequest,
26+
LicenseOption,
2527
ListOSRequest,
2628
ListOSResponse,
2729
ListOffersRequest,
@@ -52,8 +54,11 @@ export type {
5254
PrivateNetworkApiDeleteServerPrivateNetworkRequest,
5355
PrivateNetworkApiListServerPrivateNetworksRequest,
5456
PrivateNetworkApiSetServerPrivateNetworksRequest,
57+
PrivateNetworkOption,
58+
PublicBandwidthOption,
5559
RaidController,
5660
RebootServerRequest,
61+
RemoteAccessOption,
5762
Server,
5863
ServerBootType,
5964
ServerEvent,

packages/clients/src/api/baremetal/v1/marshalling.gen.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import type {
1313
AddOptionServerRequest,
1414
BMCAccess,
1515
CPU,
16+
CertificationOption,
1617
CreateServerRequest,
1718
CreateServerRequestInstall,
1819
Disk,
1920
GetServerMetricsResponse,
2021
IP,
2122
InstallServerRequest,
23+
LicenseOption,
2224
ListOSResponse,
2325
ListOffersResponse,
2426
ListOptionsResponse,
@@ -35,8 +37,11 @@ import type {
3537
PersistentMemory,
3638
PrivateNetworkApiAddServerPrivateNetworkRequest,
3739
PrivateNetworkApiSetServerPrivateNetworksRequest,
40+
PrivateNetworkOption,
41+
PublicBandwidthOption,
3842
RaidController,
3943
RebootServerRequest,
44+
RemoteAccessOption,
4045
Server,
4146
ServerEvent,
4247
ServerInstall,
@@ -111,6 +116,62 @@ export const unmarshalOS = (data: unknown): OS => {
111116
} as OS
112117
}
113118

119+
const unmarshalCertificationOption = (data: unknown): CertificationOption => {
120+
if (!isJSONObject(data)) {
121+
throw new TypeError(
122+
`Unmarshalling the type 'CertificationOption' failed as data isn't a dictionary.`,
123+
)
124+
}
125+
126+
return {} as CertificationOption
127+
}
128+
129+
const unmarshalLicenseOption = (data: unknown): LicenseOption => {
130+
if (!isJSONObject(data)) {
131+
throw new TypeError(
132+
`Unmarshalling the type 'LicenseOption' failed as data isn't a dictionary.`,
133+
)
134+
}
135+
136+
return {
137+
osId: data.os_id,
138+
} as LicenseOption
139+
}
140+
141+
const unmarshalPrivateNetworkOption = (data: unknown): PrivateNetworkOption => {
142+
if (!isJSONObject(data)) {
143+
throw new TypeError(
144+
`Unmarshalling the type 'PrivateNetworkOption' failed as data isn't a dictionary.`,
145+
)
146+
}
147+
148+
return {} as PrivateNetworkOption
149+
}
150+
151+
const unmarshalPublicBandwidthOption = (
152+
data: unknown,
153+
): PublicBandwidthOption => {
154+
if (!isJSONObject(data)) {
155+
throw new TypeError(
156+
`Unmarshalling the type 'PublicBandwidthOption' failed as data isn't a dictionary.`,
157+
)
158+
}
159+
160+
return {
161+
bandwidthInBps: data.bandwidth_in_bps,
162+
} as PublicBandwidthOption
163+
}
164+
165+
const unmarshalRemoteAccessOption = (data: unknown): RemoteAccessOption => {
166+
if (!isJSONObject(data)) {
167+
throw new TypeError(
168+
`Unmarshalling the type 'RemoteAccessOption' failed as data isn't a dictionary.`,
169+
)
170+
}
171+
172+
return {} as RemoteAccessOption
173+
}
174+
114175
const unmarshalCPU = (data: unknown): CPU => {
115176
if (!isJSONObject(data)) {
116177
throw new TypeError(
@@ -163,12 +224,25 @@ const unmarshalOfferOptionOffer = (data: unknown): OfferOptionOffer => {
163224
}
164225

165226
return {
227+
certification: data.certification
228+
? unmarshalCertificationOption(data.certification)
229+
: undefined,
166230
enabled: data.enabled,
167231
id: data.id,
232+
license: data.license ? unmarshalLicenseOption(data.license) : undefined,
168233
manageable: data.manageable,
169234
name: data.name,
170235
osId: data.os_id,
171236
price: data.price ? unmarshalMoney(data.price) : undefined,
237+
privateNetwork: data.private_network
238+
? unmarshalPrivateNetworkOption(data.private_network)
239+
: undefined,
240+
publicBandwidth: data.public_bandwidth
241+
? unmarshalPublicBandwidthOption(data.public_bandwidth)
242+
: undefined,
243+
remoteAccess: data.remote_access
244+
? unmarshalRemoteAccessOption(data.remote_access)
245+
: undefined,
172246
subscriptionPeriod: data.subscription_period,
173247
} as OfferOptionOffer
174248
}
@@ -252,9 +326,22 @@ export const unmarshalOption = (data: unknown): Option => {
252326
}
253327

254328
return {
329+
certification: data.certification
330+
? unmarshalCertificationOption(data.certification)
331+
: undefined,
255332
id: data.id,
333+
license: data.license ? unmarshalLicenseOption(data.license) : undefined,
256334
manageable: data.manageable,
257335
name: data.name,
336+
privateNetwork: data.private_network
337+
? unmarshalPrivateNetworkOption(data.private_network)
338+
: undefined,
339+
publicBandwidth: data.public_bandwidth
340+
? unmarshalPublicBandwidthOption(data.public_bandwidth)
341+
: undefined,
342+
remoteAccess: data.remote_access
343+
? unmarshalRemoteAccessOption(data.remote_access)
344+
: undefined,
258345
} as Option
259346
}
260347

@@ -305,10 +392,23 @@ const unmarshalServerOption = (data: unknown): ServerOption => {
305392
}
306393

307394
return {
395+
certification: data.certification
396+
? unmarshalCertificationOption(data.certification)
397+
: undefined,
308398
expiresAt: unmarshalDate(data.expires_at),
309399
id: data.id,
400+
license: data.license ? unmarshalLicenseOption(data.license) : undefined,
310401
manageable: data.manageable,
311402
name: data.name,
403+
privateNetwork: data.private_network
404+
? unmarshalPrivateNetworkOption(data.private_network)
405+
: undefined,
406+
publicBandwidth: data.public_bandwidth
407+
? unmarshalPublicBandwidthOption(data.public_bandwidth)
408+
: undefined,
409+
remoteAccess: data.remote_access
410+
? unmarshalRemoteAccessOption(data.remote_access)
411+
: undefined,
312412
status: data.status,
313413
} as ServerOption
314414
}

packages/clients/src/api/baremetal/v1/types.gen.ts

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ export type ServerStatus =
7272

7373
export type SettingType = 'unknown' | 'smtp'
7474

75+
export interface CertificationOption {}
76+
77+
export interface LicenseOption {
78+
osId: string
79+
}
80+
81+
export interface PrivateNetworkOption {}
82+
83+
export interface PublicBandwidthOption {
84+
bandwidthInBps: number
85+
}
86+
87+
export interface RemoteAccessOption {}
88+
7589
export interface OSOSField {
7690
editable: boolean
7791
required: boolean
@@ -125,8 +139,43 @@ export interface OfferOptionOffer {
125139
price?: Money
126140
/** Boolean to know if option could be managed. */
127141
manageable: boolean
128-
/** ID of the OS linked to the option. */
142+
/** @deprecated Deprecated, use LicenseOptionVars.os_id instead. */
129143
osId?: string
144+
/**
145+
* License option, contains the ID of the OS linked to the option.
146+
*
147+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
148+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
149+
*/
150+
license?: LicenseOption
151+
/**
152+
* Public_bandwidth option, contains the bandwidth_in_bps.
153+
*
154+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
155+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
156+
*/
157+
publicBandwidth?: PublicBandwidthOption
158+
/**
159+
* Private_network option.
160+
*
161+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
162+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
163+
*/
164+
privateNetwork?: PrivateNetworkOption
165+
/**
166+
* Remote_access option.
167+
*
168+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
169+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
170+
*/
171+
remoteAccess?: RemoteAccessOption
172+
/**
173+
* Certification option.
174+
*
175+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
176+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
177+
*/
178+
certification?: CertificationOption
130179
}
131180

132181
export interface PersistentMemory {
@@ -192,6 +241,41 @@ export interface ServerOption {
192241
manageable: boolean
193242
/** Auto expiration date for compatible options. */
194243
expiresAt?: Date
244+
/**
245+
* License option, contains the ID of the OS linked to the option.
246+
*
247+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
248+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
249+
*/
250+
license?: LicenseOption
251+
/**
252+
* Public_bandwidth option, contains the bandwidth_in_bps.
253+
*
254+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
255+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
256+
*/
257+
publicBandwidth?: PublicBandwidthOption
258+
/**
259+
* Private_network option.
260+
*
261+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
262+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
263+
*/
264+
privateNetwork?: PrivateNetworkOption
265+
/**
266+
* Remote_access option.
267+
*
268+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
269+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
270+
*/
271+
remoteAccess?: RemoteAccessOption
272+
/**
273+
* Certification option.
274+
*
275+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
276+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
277+
*/
278+
certification?: CertificationOption
195279
}
196280

197281
export interface ServerRescueServer {
@@ -312,6 +396,41 @@ export interface Option {
312396
name: string
313397
/** Defines whether the option is manageable (could be added or removed). */
314398
manageable: boolean
399+
/**
400+
* License option, contains the ID of the OS linked to the option.
401+
*
402+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
403+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
404+
*/
405+
license?: LicenseOption
406+
/**
407+
* Public_bandwidth option, contains the bandwidth_in_bps.
408+
*
409+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
410+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
411+
*/
412+
publicBandwidth?: PublicBandwidthOption
413+
/**
414+
* Private_network option.
415+
*
416+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
417+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
418+
*/
419+
privateNetwork?: PrivateNetworkOption
420+
/**
421+
* Remote_access option.
422+
*
423+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
424+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
425+
*/
426+
remoteAccess?: RemoteAccessOption
427+
/**
428+
* Certification option.
429+
*
430+
* One-of ('option'): at most one of 'license', 'publicBandwidth',
431+
* 'privateNetwork', 'remoteAccess', 'certification' could be set.
432+
*/
433+
certification?: CertificationOption
315434
}
316435

317436
export interface ServerEvent {

0 commit comments

Comments
 (0)