Skip to content

Commit e58ff8f

Browse files
authored
Merge branch 'main' into v1.5524.0
2 parents 18cd643 + cf904b0 commit e58ff8f

File tree

7 files changed

+147
-12
lines changed

7 files changed

+147
-12
lines changed

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ const unmarshalServerInstall = (data: unknown): ServerInstall => {
488488
return {
489489
hostname: data.hostname,
490490
osId: data.os_id,
491+
partitioningSchema: data.partitioning_schema
492+
? unmarshalSchema(data.partitioning_schema)
493+
: undefined,
491494
serviceUrl: data.service_url,
492495
serviceUser: data.service_user,
493496
sshKeyIds: data.ssh_key_ids,
@@ -759,12 +762,86 @@ export const marshalAddOptionServerRequest = (
759762
expires_at: request.expiresAt,
760763
})
761764

765+
const marshalSchemaPartition = (
766+
request: SchemaPartition,
767+
defaults: DefaultValues,
768+
): Record<string, unknown> => ({
769+
label: request.label,
770+
number: request.number,
771+
size: request.size,
772+
})
773+
774+
const marshalSchemaPool = (
775+
request: SchemaPool,
776+
defaults: DefaultValues,
777+
): Record<string, unknown> => ({
778+
devices: request.devices,
779+
filesystem_options: request.filesystemOptions,
780+
name: request.name,
781+
options: request.options,
782+
type: request.type,
783+
})
784+
785+
const marshalSchemaDisk = (
786+
request: SchemaDisk,
787+
defaults: DefaultValues,
788+
): Record<string, unknown> => ({
789+
device: request.device,
790+
partitions: request.partitions.map(elt =>
791+
marshalSchemaPartition(elt, defaults),
792+
),
793+
})
794+
795+
const marshalSchemaFilesystem = (
796+
request: SchemaFilesystem,
797+
defaults: DefaultValues,
798+
): Record<string, unknown> => ({
799+
device: request.device,
800+
format: request.format,
801+
mountpoint: request.mountpoint,
802+
})
803+
804+
const marshalSchemaRAID = (
805+
request: SchemaRAID,
806+
defaults: DefaultValues,
807+
): Record<string, unknown> => ({
808+
devices: request.devices,
809+
level: request.level,
810+
name: request.name,
811+
})
812+
813+
const marshalSchemaZFS = (
814+
request: SchemaZFS,
815+
defaults: DefaultValues,
816+
): Record<string, unknown> => ({
817+
pools: request.pools.map(elt => marshalSchemaPool(elt, defaults)),
818+
})
819+
820+
export const marshalSchema = (
821+
request: Schema,
822+
defaults: DefaultValues,
823+
): Record<string, unknown> => ({
824+
disks: request.disks.map(elt => marshalSchemaDisk(elt, defaults)),
825+
filesystems: request.filesystems.map(elt =>
826+
marshalSchemaFilesystem(elt, defaults),
827+
),
828+
raids: request.raids.map(elt => marshalSchemaRAID(elt, defaults)),
829+
zfs:
830+
request.zfs !== undefined
831+
? marshalSchemaZFS(request.zfs, defaults)
832+
: undefined,
833+
})
834+
762835
const marshalCreateServerRequestInstall = (
763836
request: CreateServerRequestInstall,
764837
defaults: DefaultValues,
765838
): Record<string, unknown> => ({
766839
hostname: request.hostname,
767840
os_id: request.osId,
841+
partitioning_schema:
842+
request.partitioningSchema !== undefined
843+
? marshalSchema(request.partitioningSchema, defaults)
844+
: undefined,
768845
password: request.password,
769846
service_password: request.servicePassword,
770847
service_user: request.serviceUser,
@@ -805,6 +882,10 @@ export const marshalInstallServerRequest = (
805882
): Record<string, unknown> => ({
806883
hostname: request.hostname,
807884
os_id: request.osId,
885+
partitioning_schema:
886+
request.partitioningSchema !== undefined
887+
? marshalSchema(request.partitioningSchema, defaults)
888+
: undefined,
808889
password: request.password,
809890
service_password: request.servicePassword,
810891
service_user: request.serviceUser,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export type SchemaFilesystemFormat =
3333
| 'ext4'
3434
| 'swap'
3535
| 'zfs'
36+
| 'xfs'
37+
3638

3739
export type SchemaPartitionLabel =
3840
| 'unknown_partition_label'
@@ -304,6 +306,8 @@ export interface ServerInstall {
304306
serviceUser: string
305307
/** Address of the installed service. */
306308
serviceUrl: string
309+
/** Partitioning schema. */
310+
partitioningSchema?: Schema
307311
}
308312

309313
export interface ServerOption {
@@ -376,6 +380,8 @@ export interface CreateServerRequestInstall {
376380
serviceUser?: string
377381
/** Password used for the service to install. */
378382
servicePassword?: string
383+
/** Partitioning schema. */
384+
partitioningSchema?: Schema
379385
}
380386

381387
export interface OS {
@@ -747,6 +753,8 @@ export type InstallServerRequest = {
747753
serviceUser?: string
748754
/** Password used for the service to install. */
749755
servicePassword?: string
756+
/** Partitioning schema. */
757+
partitioningSchema?: Schema
750758
}
751759

752760
export type ListOSRequest = {

packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export const CreateSSHKeyRequest = {
5656
}
5757

5858
export const CreateUserRequestMember = {
59+
email: {
60+
ignoreEmpty: true,
61+
},
5962
password: {
6063
ignoreEmpty: true,
6164
maxLength: 72,

packages/clients/src/api/instance/v1/api.gen.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,14 @@ export class API extends ParentAPI {
458458
* and release the hypervisor slot. `stop_in_place`: Stop the Instance, but
459459
* keep the slot on the hypervisor. `reboot`: Stop the instance and restart
460460
* it. `backup`: Create an image with all the volumes of an Instance.
461-
* `terminate`: Delete the Instance along with all attached volumes.
462-
* `enable_routed_ip`: Migrate the Instance to the new network stack.
461+
* `terminate`: Delete the Instance along with its attached volumes, except
462+
* for SBS volumes. `enable_routed_ip`: Migrate the Instance to the new
463+
* network stack.
463464
*
464-
* Keep in mind that terminating an Instance will result in the deletion of
465-
* all attached volumes, including local and block storage. If you want to
466-
* preserve your local volumes, you should use the `archive` action instead of
467-
* `terminate`. Similarly, if you want to keep your block storage volumes, you
468-
* must first detach them before issuing the `terminate` command. For more
469-
* information, read the [Volumes](#path-volumes-list-volumes) documentation.
465+
* Keep in mind that `terminate` an Instance will result in the deletion of
466+
* `l_ssd`, `b_ssd` and `scratch` volumes types, `sbs_volume` volumes type
467+
* will only be detached. If you want to preserve your volumes, you should
468+
* detach them before the Instance deletion or `terminate` action.
470469
*
471470
* @param request - The request {@link ServerActionRequest}
472471
* @returns A Promise of ServerActionResponse

packages/clients/src/scw/__tests__/custom-marshalling.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import {
44
marshalScwFile,
55
marshalTimeSeries,
66
marshalTimeSeriesPoint,
7+
unmarshalDecimal,
78
unmarshalMoney,
89
unmarshalScwFile,
910
unmarshalServiceInfo,
1011
unmarshalTimeSeries,
1112
unmarshalTimeSeriesPoint,
1213
} from '../custom-marshalling'
14+
import { Decimal } from '../custom-types'
1315

1416
describe('unmarshalMoney', () => {
1517
it('returns the proper object', () => {
@@ -123,6 +125,29 @@ describe('unmarshalTimeSeries', () => {
123125
})
124126
})
125127

128+
describe('unmarshalDecimal', () => {
129+
it('returns the proper object', () => {
130+
const decimal = unmarshalDecimal({
131+
value: '0.01',
132+
})
133+
expect(decimal).toBeInstanceOf(Decimal)
134+
expect(decimal?.toString()).toStrictEqual('0.01')
135+
})
136+
137+
it('throws for invalid input', () => {
138+
expect(unmarshalDecimal(null)).toBeNull()
139+
expect(() => {
140+
unmarshalDecimal({})
141+
}).toThrow()
142+
expect(() => {
143+
unmarshalDecimal({ value: null })
144+
}).toThrow()
145+
expect(() => {
146+
unmarshalDecimal({ value: 0.02 })
147+
}).toThrow()
148+
})
149+
})
150+
126151
describe('marshalScwFile', () => {
127152
it('returns a the proper object', () =>
128153
expect(

packages/clients/src/scw/custom-marshalling.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,28 @@ export const unmarshalTimeSeries = (data: unknown) => {
115115
* @internal
116116
*/
117117
export const unmarshalDecimal = (data: unknown) => {
118-
if (!(typeof data === 'string')) {
118+
if (!(typeof data === 'object')) {
119119
throw new TypeError(
120-
`Unmarshalling the type 'Decimal' failed as data isn't a string.`,
120+
`Unmarshalling the type 'Decimal' failed as data isn't an object.`,
121+
)
122+
}
123+
if (data === null) {
124+
return null
125+
}
126+
127+
if (!('value' in data)) {
128+
throw new TypeError(
129+
`Unmarshalling the type 'Decimal' failed as data object does not have a 'value' key.`,
121130
)
122131
}
123132

124-
return new Decimal(data)
133+
if (!(typeof data.value === 'string')) {
134+
throw new TypeError(
135+
`Unmarshalling the type 'Decimal' failed as 'value' is not a string.`,
136+
)
137+
}
138+
139+
return new Decimal(data.value)
125140
}
126141

127142
/**
@@ -189,4 +204,6 @@ export const marshalTimeSeries = (
189204
*
190205
* @internal
191206
*/
192-
export const marshalDecimal = (obj: Decimal): string => obj.toString()
207+
export const marshalDecimal = (obj: Decimal): { value: string } => ({
208+
value: obj.toString(),
209+
})

packages/clients/src/scw/custom-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@ export class Decimal {
7979
}
8080

8181
public toString = (): string => this.str
82+
83+
public marshal = (): object => ({ value: this.str })
8284
}

0 commit comments

Comments
 (0)