Skip to content

Commit b5be58f

Browse files
authored
Merge branch 'main' into v1.5540.0
2 parents 04ccb2f + 0ab8ab3 commit b5be58f

File tree

8 files changed

+148
-76
lines changed

8 files changed

+148
-76
lines changed

packages/clients/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [2.49.0](https://github.com/scaleway/scaleway-sdk-js/compare/@scaleway/[email protected]...@scaleway/[email protected]) (2024-10-04)
7+
8+
### Features
9+
10+
- **iam:** make sur e-mail optional in CreateUser ([#1456](https://github.com/scaleway/scaleway-sdk-js/issues/1456)) ([f37723e](https://github.com/scaleway/scaleway-sdk-js/commit/f37723ecc2c88d4823eaa3d2670ddea5b4ff5346))
11+
12+
### Bug Fixes
13+
14+
- **edge_services:** fix plan endpoints ([#1450](https://github.com/scaleway/scaleway-sdk-js/issues/1450)) ([9e3bd41](https://github.com/scaleway/scaleway-sdk-js/commit/9e3bd41bf53288e760ae209d462e3a85a22181eb))
15+
- **scw:** decimal json representation ([#1460](https://github.com/scaleway/scaleway-sdk-js/issues/1460)) ([6829c46](https://github.com/scaleway/scaleway-sdk-js/commit/6829c46bdc362b02fe974ca7dd18267c7c0dbd9b))
16+
617
## [2.48.0](https://github.com/scaleway/scaleway-sdk-js/compare/@scaleway/[email protected]...@scaleway/[email protected]) (2024-09-30)
718

819
### Features

packages/clients/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scaleway/sdk",
3-
"version": "2.48.0",
3+
"version": "2.49.0",
44
"license": "Apache-2.0",
55
"description": "Scaleway SDK.",
66
"keywords": [

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

Lines changed: 81 additions & 70 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,
@@ -870,76 +951,6 @@ export const marshalUpdateSettingRequest = (
870951
enabled: request.enabled,
871952
})
872953

873-
const marshalSchemaPartition = (
874-
request: SchemaPartition,
875-
defaults: DefaultValues,
876-
): Record<string, unknown> => ({
877-
label: request.label,
878-
number: request.number,
879-
size: request.size,
880-
})
881-
882-
const marshalSchemaPool = (
883-
request: SchemaPool,
884-
defaults: DefaultValues,
885-
): Record<string, unknown> => ({
886-
devices: request.devices,
887-
filesystem_options: request.filesystemOptions,
888-
name: request.name,
889-
options: request.options,
890-
type: request.type,
891-
})
892-
893-
const marshalSchemaDisk = (
894-
request: SchemaDisk,
895-
defaults: DefaultValues,
896-
): Record<string, unknown> => ({
897-
device: request.device,
898-
partitions: request.partitions.map(elt =>
899-
marshalSchemaPartition(elt, defaults),
900-
),
901-
})
902-
903-
const marshalSchemaFilesystem = (
904-
request: SchemaFilesystem,
905-
defaults: DefaultValues,
906-
): Record<string, unknown> => ({
907-
device: request.device,
908-
format: request.format,
909-
mountpoint: request.mountpoint,
910-
})
911-
912-
const marshalSchemaRAID = (
913-
request: SchemaRAID,
914-
defaults: DefaultValues,
915-
): Record<string, unknown> => ({
916-
devices: request.devices,
917-
level: request.level,
918-
name: request.name,
919-
})
920-
921-
const marshalSchemaZFS = (
922-
request: SchemaZFS,
923-
defaults: DefaultValues,
924-
): Record<string, unknown> => ({
925-
pools: request.pools.map(elt => marshalSchemaPool(elt, defaults)),
926-
})
927-
928-
export const marshalSchema = (
929-
request: Schema,
930-
defaults: DefaultValues,
931-
): Record<string, unknown> => ({
932-
disks: request.disks.map(elt => marshalSchemaDisk(elt, defaults)),
933-
filesystems: request.filesystems.map(elt =>
934-
marshalSchemaFilesystem(elt, defaults),
935-
),
936-
raids: request.raids.map(elt => marshalSchemaRAID(elt, defaults)),
937-
zfs:
938-
request.zfs !== undefined
939-
? marshalSchemaZFS(request.zfs, defaults)
940-
: undefined,
941-
})
942-
943954
export const marshalValidatePartitioningSchemaRequest = (
944955
request: ValidatePartitioningSchemaRequest,
945956
defaults: DefaultValues,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ export interface ServerInstall {
305305
serviceUser: string
306306
/** Address of the installed service. */
307307
serviceUrl: string
308+
/** Partitioning schema. */
309+
partitioningSchema?: Schema
308310
}
309311

310312
export interface ServerOption {
@@ -377,6 +379,8 @@ export interface CreateServerRequestInstall {
377379
serviceUser?: string
378380
/** Password used for the service to install. */
379381
servicePassword?: string
382+
/** Partitioning schema. */
383+
partitioningSchema?: Schema
380384
}
381385

382386
export interface OS {
@@ -748,6 +752,8 @@ export type InstallServerRequest = {
748752
serviceUser?: string
749753
/** Password used for the service to install. */
750754
servicePassword?: string
755+
/** Partitioning schema. */
756+
partitioningSchema?: Schema
751757
}
752758

753759
export type ListOSRequest = {

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(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const version = 'v2.48.0'
1+
export const version = 'v2.49.0'
22

33
export const userAgent = `scaleway-sdk-js/${version}`

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)