@scaleway/sdk 2.50.0 → 2.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/api/applesilicon/v1alpha1/marshalling.gen.cjs +1 -0
  2. package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +1 -0
  3. package/dist/api/applesilicon/v1alpha1/types.gen.d.ts +8 -0
  4. package/dist/api/baremetal/v1/index.gen.d.ts +1 -1
  5. package/dist/api/baremetal/v1/marshalling.gen.cjs +15 -1
  6. package/dist/api/baremetal/v1/marshalling.gen.js +15 -1
  7. package/dist/api/baremetal/v1/types.gen.d.ts +12 -3
  8. package/dist/api/block/v1alpha1/api.gen.cjs +3 -0
  9. package/dist/api/block/v1alpha1/api.gen.js +3 -0
  10. package/dist/api/container/v1beta1/index.gen.d.ts +1 -1
  11. package/dist/api/container/v1beta1/marshalling.gen.cjs +21 -0
  12. package/dist/api/container/v1beta1/marshalling.gen.js +21 -0
  13. package/dist/api/container/v1beta1/types.gen.d.ts +30 -2
  14. package/dist/api/container/v1beta1/validation-rules.gen.cjs +2 -0
  15. package/dist/api/container/v1beta1/validation-rules.gen.d.ts +1 -0
  16. package/dist/api/container/v1beta1/validation-rules.gen.js +2 -0
  17. package/dist/api/edge_services/v1alpha1/api.gen.cjs +27 -2
  18. package/dist/api/edge_services/v1alpha1/api.gen.d.ts +10 -3
  19. package/dist/api/edge_services/v1alpha1/api.gen.js +28 -3
  20. package/dist/api/edge_services/v1alpha1/index.gen.d.ts +1 -1
  21. package/dist/api/edge_services/v1alpha1/marshalling.gen.cjs +31 -0
  22. package/dist/api/edge_services/v1alpha1/marshalling.gen.d.ts +3 -1
  23. package/dist/api/edge_services/v1alpha1/marshalling.gen.js +31 -0
  24. package/dist/api/edge_services/v1alpha1/types.gen.d.ts +47 -9
  25. package/dist/api/iam/v1alpha1/api.gen.cjs +11 -0
  26. package/dist/api/iam/v1alpha1/api.gen.d.ts +2 -1
  27. package/dist/api/iam/v1alpha1/api.gen.js +12 -1
  28. package/dist/api/iam/v1alpha1/index.gen.d.ts +1 -1
  29. package/dist/api/iam/v1alpha1/marshalling.gen.cjs +6 -0
  30. package/dist/api/iam/v1alpha1/marshalling.gen.d.ts +2 -1
  31. package/dist/api/iam/v1alpha1/marshalling.gen.js +6 -0
  32. package/dist/api/iam/v1alpha1/types.gen.d.ts +25 -18
  33. package/dist/api/iam/v1alpha1/validation-rules.gen.cjs +7 -0
  34. package/dist/api/iam/v1alpha1/validation-rules.gen.d.ts +6 -0
  35. package/dist/api/iam/v1alpha1/validation-rules.gen.js +8 -1
  36. package/dist/api/index.gen.d.ts +2 -1
  37. package/dist/api/inference/v1beta1/validation-rules.gen.cjs +1 -1
  38. package/dist/api/inference/v1beta1/validation-rules.gen.js +1 -1
  39. package/dist/api/instance/v1/api.gen.cjs +0 -37
  40. package/dist/api/instance/v1/api.gen.d.ts +1 -21
  41. package/dist/api/instance/v1/api.gen.js +1 -38
  42. package/dist/api/instance/v1/index.gen.d.ts +1 -1
  43. package/dist/api/instance/v1/marshalling.gen.cjs +1 -28
  44. package/dist/api/instance/v1/marshalling.gen.d.ts +1 -3
  45. package/dist/api/instance/v1/marshalling.gen.js +1 -28
  46. package/dist/api/instance/v1/types.gen.d.ts +9 -53
  47. package/dist/api/instance/v1/types.private.gen.d.ts +1 -3
  48. package/dist/api/jobs/v1alpha1/api.gen.cjs +13 -0
  49. package/dist/api/jobs/v1alpha1/api.gen.d.ts +8 -1
  50. package/dist/api/jobs/v1alpha1/api.gen.js +14 -1
  51. package/dist/api/jobs/v1alpha1/index.gen.d.ts +1 -1
  52. package/dist/api/jobs/v1alpha1/marshalling.gen.cjs +11 -0
  53. package/dist/api/jobs/v1alpha1/marshalling.gen.d.ts +2 -1
  54. package/dist/api/jobs/v1alpha1/marshalling.gen.js +11 -0
  55. package/dist/api/jobs/v1alpha1/types.gen.d.ts +10 -0
  56. package/dist/api/jobs/v1alpha1/validation-rules.gen.cjs +2 -2
  57. package/dist/api/jobs/v1alpha1/validation-rules.gen.js +2 -2
  58. package/dist/api/k8s/v1/api.gen.cjs +0 -16
  59. package/dist/api/k8s/v1/api.gen.d.ts +1 -9
  60. package/dist/api/k8s/v1/api.gen.js +0 -16
  61. package/dist/api/k8s/v1/index.gen.d.ts +1 -1
  62. package/dist/api/k8s/v1/types.gen.d.ts +0 -9
  63. package/dist/api/k8s/v1/validation-rules.gen.cjs +8 -16
  64. package/dist/api/k8s/v1/validation-rules.gen.d.ts +0 -8
  65. package/dist/api/k8s/v1/validation-rules.gen.js +8 -16
  66. package/dist/api/mongodb/index.gen.cjs +4 -0
  67. package/dist/api/mongodb/index.gen.d.ts +5 -0
  68. package/dist/api/mongodb/index.gen.js +4 -0
  69. package/dist/api/mongodb/v1alpha1/api.gen.cjs +393 -0
  70. package/dist/api/mongodb/v1alpha1/api.gen.d.ts +203 -0
  71. package/dist/api/mongodb/v1alpha1/api.gen.js +393 -0
  72. package/dist/api/mongodb/v1alpha1/content.gen.cjs +16 -0
  73. package/dist/api/mongodb/v1alpha1/content.gen.d.ts +5 -0
  74. package/dist/api/mongodb/v1alpha1/content.gen.js +16 -0
  75. package/dist/api/mongodb/v1alpha1/index.gen.cjs +9 -0
  76. package/dist/api/mongodb/v1alpha1/index.gen.d.ts +4 -0
  77. package/dist/api/mongodb/v1alpha1/index.gen.js +9 -0
  78. package/dist/api/mongodb/v1alpha1/marshalling.gen.cjs +327 -0
  79. package/dist/api/mongodb/v1alpha1/marshalling.gen.d.ts +19 -0
  80. package/dist/api/mongodb/v1alpha1/marshalling.gen.js +327 -0
  81. package/dist/api/mongodb/v1alpha1/types.gen.d.ts +461 -0
  82. package/dist/api/mongodb/v1alpha1/validation-rules.gen.cjs +147 -0
  83. package/dist/api/mongodb/v1alpha1/validation-rules.gen.d.ts +134 -0
  84. package/dist/api/mongodb/v1alpha1/validation-rules.gen.js +147 -0
  85. package/dist/api/webhosting/v1alpha1/types.gen.d.ts +1 -1
  86. package/dist/index.cjs +16 -14
  87. package/dist/index.js +16 -14
  88. package/dist/scw/constants.cjs +1 -1
  89. package/dist/scw/constants.d.ts +2 -2
  90. package/dist/scw/constants.js +1 -1
  91. package/package.json +2 -2
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const randomName = require("@scaleway/random-name");
4
+ const json = require("../../../helpers/json.cjs");
5
+ const marshalling = require("../../../helpers/marshalling.cjs");
6
+ require("../../../vendor/base64/index.cjs");
7
+ const unmarshalEndpointPrivateNetworkDetails = (data) => {
8
+ if (!json.isJSONObject(data)) {
9
+ throw new TypeError(
10
+ `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`
11
+ );
12
+ }
13
+ return {
14
+ privateNetworkId: data.private_network_id
15
+ };
16
+ };
17
+ const unmarshalEndpointPublicDetails = (data) => {
18
+ if (!json.isJSONObject(data)) {
19
+ throw new TypeError(
20
+ `Unmarshalling the type 'EndpointPublicDetails' failed as data isn't a dictionary.`
21
+ );
22
+ }
23
+ return {};
24
+ };
25
+ const unmarshalEndpoint = (data) => {
26
+ if (!json.isJSONObject(data)) {
27
+ throw new TypeError(
28
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
29
+ );
30
+ }
31
+ return {
32
+ dnsRecords: data.dns_records,
33
+ id: data.id,
34
+ ips: data.ips,
35
+ port: data.port,
36
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
37
+ public: data.public ? unmarshalEndpointPublicDetails(data.public) : void 0
38
+ };
39
+ };
40
+ const unmarshalInstanceSetting = (data) => {
41
+ if (!json.isJSONObject(data)) {
42
+ throw new TypeError(
43
+ `Unmarshalling the type 'InstanceSetting' failed as data isn't a dictionary.`
44
+ );
45
+ }
46
+ return {
47
+ name: data.name,
48
+ value: data.value
49
+ };
50
+ };
51
+ const unmarshalVolume = (data) => {
52
+ if (!json.isJSONObject(data)) {
53
+ throw new TypeError(
54
+ `Unmarshalling the type 'Volume' failed as data isn't a dictionary.`
55
+ );
56
+ }
57
+ return {
58
+ size: data.size,
59
+ type: data.type
60
+ };
61
+ };
62
+ const unmarshalInstance = (data) => {
63
+ if (!json.isJSONObject(data)) {
64
+ throw new TypeError(
65
+ `Unmarshalling the type 'Instance' failed as data isn't a dictionary.`
66
+ );
67
+ }
68
+ return {
69
+ createdAt: marshalling.unmarshalDate(data.created_at),
70
+ endpoints: marshalling.unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
71
+ id: data.id,
72
+ name: data.name,
73
+ nodeNumber: data.node_number,
74
+ nodeType: data.node_type,
75
+ projectId: data.project_id,
76
+ region: data.region,
77
+ settings: marshalling.unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting),
78
+ status: data.status,
79
+ tags: data.tags,
80
+ version: data.version,
81
+ volume: data.volume ? unmarshalVolume(data.volume) : void 0
82
+ };
83
+ };
84
+ const unmarshalSnapshotVolumeType = (data) => {
85
+ if (!json.isJSONObject(data)) {
86
+ throw new TypeError(
87
+ `Unmarshalling the type 'SnapshotVolumeType' failed as data isn't a dictionary.`
88
+ );
89
+ }
90
+ return {
91
+ type: data.type
92
+ };
93
+ };
94
+ const unmarshalSnapshot = (data) => {
95
+ if (!json.isJSONObject(data)) {
96
+ throw new TypeError(
97
+ `Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`
98
+ );
99
+ }
100
+ return {
101
+ createdAt: marshalling.unmarshalDate(data.created_at),
102
+ expiresAt: marshalling.unmarshalDate(data.expires_at),
103
+ id: data.id,
104
+ instanceId: data.instance_id,
105
+ instanceName: data.instance_name,
106
+ name: data.name,
107
+ nodeType: data.node_type,
108
+ region: data.region,
109
+ size: data.size,
110
+ status: data.status,
111
+ updatedAt: marshalling.unmarshalDate(data.updated_at),
112
+ volumeType: data.volume_type ? unmarshalSnapshotVolumeType(data.volume_type) : void 0
113
+ };
114
+ };
115
+ const unmarshalUser = (data) => {
116
+ if (!json.isJSONObject(data)) {
117
+ throw new TypeError(
118
+ `Unmarshalling the type 'User' failed as data isn't a dictionary.`
119
+ );
120
+ }
121
+ return {
122
+ name: data.name
123
+ };
124
+ };
125
+ const unmarshalListInstancesResponse = (data) => {
126
+ if (!json.isJSONObject(data)) {
127
+ throw new TypeError(
128
+ `Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary.`
129
+ );
130
+ }
131
+ return {
132
+ instances: marshalling.unmarshalArrayOfObject(data.instances, unmarshalInstance),
133
+ totalCount: data.total_count
134
+ };
135
+ };
136
+ const unmarshalNodeTypeVolumeType = (data) => {
137
+ if (!json.isJSONObject(data)) {
138
+ throw new TypeError(
139
+ `Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary.`
140
+ );
141
+ }
142
+ return {
143
+ chunkSize: data.chunk_size,
144
+ description: data.description,
145
+ maxSize: data.max_size,
146
+ minSize: data.min_size,
147
+ type: data.type
148
+ };
149
+ };
150
+ const unmarshalNodeType = (data) => {
151
+ if (!json.isJSONObject(data)) {
152
+ throw new TypeError(
153
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
154
+ );
155
+ }
156
+ return {
157
+ availableVolumeTypes: marshalling.unmarshalArrayOfObject(
158
+ data.available_volume_types,
159
+ unmarshalNodeTypeVolumeType
160
+ ),
161
+ beta: data.beta,
162
+ description: data.description,
163
+ disabled: data.disabled,
164
+ instanceRange: data.instance_range,
165
+ memory: data.memory,
166
+ name: data.name,
167
+ stockStatus: data.stock_status,
168
+ vcpus: data.vcpus
169
+ };
170
+ };
171
+ const unmarshalListNodeTypesResponse = (data) => {
172
+ if (!json.isJSONObject(data)) {
173
+ throw new TypeError(
174
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
175
+ );
176
+ }
177
+ return {
178
+ nodeTypes: marshalling.unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
179
+ totalCount: data.total_count
180
+ };
181
+ };
182
+ const unmarshalListSnapshotsResponse = (data) => {
183
+ if (!json.isJSONObject(data)) {
184
+ throw new TypeError(
185
+ `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`
186
+ );
187
+ }
188
+ return {
189
+ snapshots: marshalling.unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
190
+ totalCount: data.total_count
191
+ };
192
+ };
193
+ const unmarshalListUsersResponse = (data) => {
194
+ if (!json.isJSONObject(data)) {
195
+ throw new TypeError(
196
+ `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
197
+ );
198
+ }
199
+ return {
200
+ totalCount: data.total_count,
201
+ users: marshalling.unmarshalArrayOfObject(data.users, unmarshalUser)
202
+ };
203
+ };
204
+ const unmarshalSetting = (data) => {
205
+ if (!json.isJSONObject(data)) {
206
+ throw new TypeError(
207
+ `Unmarshalling the type 'Setting' failed as data isn't a dictionary.`
208
+ );
209
+ }
210
+ return {
211
+ defaultValue: data.default_value,
212
+ description: data.description,
213
+ floatMax: data.float_max,
214
+ floatMin: data.float_min,
215
+ hotConfigurable: data.hot_configurable,
216
+ intMax: data.int_max,
217
+ intMin: data.int_min,
218
+ name: data.name,
219
+ propertyType: data.property_type,
220
+ stringConstraint: data.string_constraint,
221
+ unit: data.unit
222
+ };
223
+ };
224
+ const unmarshalVersion = (data) => {
225
+ if (!json.isJSONObject(data)) {
226
+ throw new TypeError(
227
+ `Unmarshalling the type 'Version' failed as data isn't a dictionary.`
228
+ );
229
+ }
230
+ return {
231
+ availableSettings: marshalling.unmarshalArrayOfObject(
232
+ data.available_settings,
233
+ unmarshalSetting
234
+ ),
235
+ endOfLifeAt: marshalling.unmarshalDate(data.end_of_life_at),
236
+ version: data.version
237
+ };
238
+ };
239
+ const unmarshalListVersionsResponse = (data) => {
240
+ if (!json.isJSONObject(data)) {
241
+ throw new TypeError(
242
+ `Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`
243
+ );
244
+ }
245
+ return {
246
+ totalCount: data.total_count,
247
+ versions: marshalling.unmarshalArrayOfObject(data.versions, unmarshalVersion)
248
+ };
249
+ };
250
+ const marshalEndpointSpecPrivateNetworkDetails = (request, defaults) => ({
251
+ private_network_id: request.privateNetworkId
252
+ });
253
+ const marshalEndpointSpecPublicDetails = (request, defaults) => ({});
254
+ const marshalCreateInstanceRequestVolumeDetails = (request, defaults) => ({
255
+ volume_size: request.volumeSize,
256
+ volume_type: request.volumeType
257
+ });
258
+ const marshalEndpointSpec = (request, defaults) => ({
259
+ ...marshalling.resolveOneOf([
260
+ {
261
+ param: "public",
262
+ value: request.public !== void 0 ? marshalEndpointSpecPublicDetails(request.public) : void 0
263
+ },
264
+ {
265
+ param: "private_network",
266
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkDetails(
267
+ request.privateNetwork
268
+ ) : void 0
269
+ }
270
+ ])
271
+ });
272
+ const marshalCreateInstanceRequest = (request, defaults) => ({
273
+ endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
274
+ name: request.name || randomName("mgdb"),
275
+ node_number: request.nodeNumber,
276
+ node_type: request.nodeType,
277
+ password: request.password,
278
+ project_id: request.projectId ?? defaults.defaultProjectId,
279
+ tags: request.tags,
280
+ user_name: request.userName,
281
+ version: request.version,
282
+ volume: request.volume !== void 0 ? marshalCreateInstanceRequestVolumeDetails(request.volume) : void 0
283
+ });
284
+ const marshalCreateSnapshotRequest = (request, defaults) => ({
285
+ expires_at: request.expiresAt,
286
+ name: request.name
287
+ });
288
+ const marshalRestoreSnapshotRequestVolumeDetails = (request, defaults) => ({
289
+ volume_type: request.volumeType
290
+ });
291
+ const marshalRestoreSnapshotRequest = (request, defaults) => ({
292
+ instance_name: request.instanceName,
293
+ node_number: request.nodeNumber,
294
+ node_type: request.nodeType,
295
+ volume: marshalRestoreSnapshotRequestVolumeDetails(request.volume)
296
+ });
297
+ const marshalUpdateInstanceRequest = (request, defaults) => ({
298
+ name: request.name,
299
+ tags: request.tags
300
+ });
301
+ const marshalUpdateSnapshotRequest = (request, defaults) => ({
302
+ expires_at: request.expiresAt,
303
+ name: request.name
304
+ });
305
+ const marshalUpdateUserRequest = (request, defaults) => ({
306
+ password: request.password
307
+ });
308
+ const marshalUpgradeInstanceRequest = (request, defaults) => ({
309
+ ...marshalling.resolveOneOf([{ param: "volume_size", value: request.volumeSize }])
310
+ });
311
+ exports.marshalCreateInstanceRequest = marshalCreateInstanceRequest;
312
+ exports.marshalCreateSnapshotRequest = marshalCreateSnapshotRequest;
313
+ exports.marshalRestoreSnapshotRequest = marshalRestoreSnapshotRequest;
314
+ exports.marshalUpdateInstanceRequest = marshalUpdateInstanceRequest;
315
+ exports.marshalUpdateSnapshotRequest = marshalUpdateSnapshotRequest;
316
+ exports.marshalUpdateUserRequest = marshalUpdateUserRequest;
317
+ exports.marshalUpgradeInstanceRequest = marshalUpgradeInstanceRequest;
318
+ exports.unmarshalInstance = unmarshalInstance;
319
+ exports.unmarshalInstanceSetting = unmarshalInstanceSetting;
320
+ exports.unmarshalListInstancesResponse = unmarshalListInstancesResponse;
321
+ exports.unmarshalListNodeTypesResponse = unmarshalListNodeTypesResponse;
322
+ exports.unmarshalListSnapshotsResponse = unmarshalListSnapshotsResponse;
323
+ exports.unmarshalListUsersResponse = unmarshalListUsersResponse;
324
+ exports.unmarshalListVersionsResponse = unmarshalListVersionsResponse;
325
+ exports.unmarshalSnapshot = unmarshalSnapshot;
326
+ exports.unmarshalUser = unmarshalUser;
327
+ exports.unmarshalVolume = unmarshalVolume;
@@ -0,0 +1,19 @@
1
+ import type { DefaultValues } from '../../../bridge';
2
+ import type { CreateInstanceRequest, CreateSnapshotRequest, Instance, InstanceSetting, ListInstancesResponse, ListNodeTypesResponse, ListSnapshotsResponse, ListUsersResponse, ListVersionsResponse, RestoreSnapshotRequest, Snapshot, UpdateInstanceRequest, UpdateSnapshotRequest, UpdateUserRequest, UpgradeInstanceRequest, User, Volume } from './types.gen';
3
+ export declare const unmarshalInstanceSetting: (data: unknown) => InstanceSetting;
4
+ export declare const unmarshalVolume: (data: unknown) => Volume;
5
+ export declare const unmarshalInstance: (data: unknown) => Instance;
6
+ export declare const unmarshalSnapshot: (data: unknown) => Snapshot;
7
+ export declare const unmarshalUser: (data: unknown) => User;
8
+ export declare const unmarshalListInstancesResponse: (data: unknown) => ListInstancesResponse;
9
+ export declare const unmarshalListNodeTypesResponse: (data: unknown) => ListNodeTypesResponse;
10
+ export declare const unmarshalListSnapshotsResponse: (data: unknown) => ListSnapshotsResponse;
11
+ export declare const unmarshalListUsersResponse: (data: unknown) => ListUsersResponse;
12
+ export declare const unmarshalListVersionsResponse: (data: unknown) => ListVersionsResponse;
13
+ export declare const marshalCreateInstanceRequest: (request: CreateInstanceRequest, defaults: DefaultValues) => Record<string, unknown>;
14
+ export declare const marshalCreateSnapshotRequest: (request: CreateSnapshotRequest, defaults: DefaultValues) => Record<string, unknown>;
15
+ export declare const marshalRestoreSnapshotRequest: (request: RestoreSnapshotRequest, defaults: DefaultValues) => Record<string, unknown>;
16
+ export declare const marshalUpdateInstanceRequest: (request: UpdateInstanceRequest, defaults: DefaultValues) => Record<string, unknown>;
17
+ export declare const marshalUpdateSnapshotRequest: (request: UpdateSnapshotRequest, defaults: DefaultValues) => Record<string, unknown>;
18
+ export declare const marshalUpdateUserRequest: (request: UpdateUserRequest, defaults: DefaultValues) => Record<string, unknown>;
19
+ export declare const marshalUpgradeInstanceRequest: (request: UpgradeInstanceRequest, defaults: DefaultValues) => Record<string, unknown>;
@@ -0,0 +1,327 @@
1
+ import randomName from "@scaleway/random-name";
2
+ import { isJSONObject } from "../../../helpers/json.js";
3
+ import { unmarshalDate, unmarshalArrayOfObject, resolveOneOf } from "../../../helpers/marshalling.js";
4
+ import "../../../vendor/base64/index.js";
5
+ const unmarshalEndpointPrivateNetworkDetails = (data) => {
6
+ if (!isJSONObject(data)) {
7
+ throw new TypeError(
8
+ `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`
9
+ );
10
+ }
11
+ return {
12
+ privateNetworkId: data.private_network_id
13
+ };
14
+ };
15
+ const unmarshalEndpointPublicDetails = (data) => {
16
+ if (!isJSONObject(data)) {
17
+ throw new TypeError(
18
+ `Unmarshalling the type 'EndpointPublicDetails' failed as data isn't a dictionary.`
19
+ );
20
+ }
21
+ return {};
22
+ };
23
+ const unmarshalEndpoint = (data) => {
24
+ if (!isJSONObject(data)) {
25
+ throw new TypeError(
26
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
27
+ );
28
+ }
29
+ return {
30
+ dnsRecords: data.dns_records,
31
+ id: data.id,
32
+ ips: data.ips,
33
+ port: data.port,
34
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
35
+ public: data.public ? unmarshalEndpointPublicDetails(data.public) : void 0
36
+ };
37
+ };
38
+ const unmarshalInstanceSetting = (data) => {
39
+ if (!isJSONObject(data)) {
40
+ throw new TypeError(
41
+ `Unmarshalling the type 'InstanceSetting' failed as data isn't a dictionary.`
42
+ );
43
+ }
44
+ return {
45
+ name: data.name,
46
+ value: data.value
47
+ };
48
+ };
49
+ const unmarshalVolume = (data) => {
50
+ if (!isJSONObject(data)) {
51
+ throw new TypeError(
52
+ `Unmarshalling the type 'Volume' failed as data isn't a dictionary.`
53
+ );
54
+ }
55
+ return {
56
+ size: data.size,
57
+ type: data.type
58
+ };
59
+ };
60
+ const unmarshalInstance = (data) => {
61
+ if (!isJSONObject(data)) {
62
+ throw new TypeError(
63
+ `Unmarshalling the type 'Instance' failed as data isn't a dictionary.`
64
+ );
65
+ }
66
+ return {
67
+ createdAt: unmarshalDate(data.created_at),
68
+ endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
69
+ id: data.id,
70
+ name: data.name,
71
+ nodeNumber: data.node_number,
72
+ nodeType: data.node_type,
73
+ projectId: data.project_id,
74
+ region: data.region,
75
+ settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting),
76
+ status: data.status,
77
+ tags: data.tags,
78
+ version: data.version,
79
+ volume: data.volume ? unmarshalVolume(data.volume) : void 0
80
+ };
81
+ };
82
+ const unmarshalSnapshotVolumeType = (data) => {
83
+ if (!isJSONObject(data)) {
84
+ throw new TypeError(
85
+ `Unmarshalling the type 'SnapshotVolumeType' failed as data isn't a dictionary.`
86
+ );
87
+ }
88
+ return {
89
+ type: data.type
90
+ };
91
+ };
92
+ const unmarshalSnapshot = (data) => {
93
+ if (!isJSONObject(data)) {
94
+ throw new TypeError(
95
+ `Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`
96
+ );
97
+ }
98
+ return {
99
+ createdAt: unmarshalDate(data.created_at),
100
+ expiresAt: unmarshalDate(data.expires_at),
101
+ id: data.id,
102
+ instanceId: data.instance_id,
103
+ instanceName: data.instance_name,
104
+ name: data.name,
105
+ nodeType: data.node_type,
106
+ region: data.region,
107
+ size: data.size,
108
+ status: data.status,
109
+ updatedAt: unmarshalDate(data.updated_at),
110
+ volumeType: data.volume_type ? unmarshalSnapshotVolumeType(data.volume_type) : void 0
111
+ };
112
+ };
113
+ const unmarshalUser = (data) => {
114
+ if (!isJSONObject(data)) {
115
+ throw new TypeError(
116
+ `Unmarshalling the type 'User' failed as data isn't a dictionary.`
117
+ );
118
+ }
119
+ return {
120
+ name: data.name
121
+ };
122
+ };
123
+ const unmarshalListInstancesResponse = (data) => {
124
+ if (!isJSONObject(data)) {
125
+ throw new TypeError(
126
+ `Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary.`
127
+ );
128
+ }
129
+ return {
130
+ instances: unmarshalArrayOfObject(data.instances, unmarshalInstance),
131
+ totalCount: data.total_count
132
+ };
133
+ };
134
+ const unmarshalNodeTypeVolumeType = (data) => {
135
+ if (!isJSONObject(data)) {
136
+ throw new TypeError(
137
+ `Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary.`
138
+ );
139
+ }
140
+ return {
141
+ chunkSize: data.chunk_size,
142
+ description: data.description,
143
+ maxSize: data.max_size,
144
+ minSize: data.min_size,
145
+ type: data.type
146
+ };
147
+ };
148
+ const unmarshalNodeType = (data) => {
149
+ if (!isJSONObject(data)) {
150
+ throw new TypeError(
151
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
152
+ );
153
+ }
154
+ return {
155
+ availableVolumeTypes: unmarshalArrayOfObject(
156
+ data.available_volume_types,
157
+ unmarshalNodeTypeVolumeType
158
+ ),
159
+ beta: data.beta,
160
+ description: data.description,
161
+ disabled: data.disabled,
162
+ instanceRange: data.instance_range,
163
+ memory: data.memory,
164
+ name: data.name,
165
+ stockStatus: data.stock_status,
166
+ vcpus: data.vcpus
167
+ };
168
+ };
169
+ const unmarshalListNodeTypesResponse = (data) => {
170
+ if (!isJSONObject(data)) {
171
+ throw new TypeError(
172
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
173
+ );
174
+ }
175
+ return {
176
+ nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
177
+ totalCount: data.total_count
178
+ };
179
+ };
180
+ const unmarshalListSnapshotsResponse = (data) => {
181
+ if (!isJSONObject(data)) {
182
+ throw new TypeError(
183
+ `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`
184
+ );
185
+ }
186
+ return {
187
+ snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
188
+ totalCount: data.total_count
189
+ };
190
+ };
191
+ const unmarshalListUsersResponse = (data) => {
192
+ if (!isJSONObject(data)) {
193
+ throw new TypeError(
194
+ `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
195
+ );
196
+ }
197
+ return {
198
+ totalCount: data.total_count,
199
+ users: unmarshalArrayOfObject(data.users, unmarshalUser)
200
+ };
201
+ };
202
+ const unmarshalSetting = (data) => {
203
+ if (!isJSONObject(data)) {
204
+ throw new TypeError(
205
+ `Unmarshalling the type 'Setting' failed as data isn't a dictionary.`
206
+ );
207
+ }
208
+ return {
209
+ defaultValue: data.default_value,
210
+ description: data.description,
211
+ floatMax: data.float_max,
212
+ floatMin: data.float_min,
213
+ hotConfigurable: data.hot_configurable,
214
+ intMax: data.int_max,
215
+ intMin: data.int_min,
216
+ name: data.name,
217
+ propertyType: data.property_type,
218
+ stringConstraint: data.string_constraint,
219
+ unit: data.unit
220
+ };
221
+ };
222
+ const unmarshalVersion = (data) => {
223
+ if (!isJSONObject(data)) {
224
+ throw new TypeError(
225
+ `Unmarshalling the type 'Version' failed as data isn't a dictionary.`
226
+ );
227
+ }
228
+ return {
229
+ availableSettings: unmarshalArrayOfObject(
230
+ data.available_settings,
231
+ unmarshalSetting
232
+ ),
233
+ endOfLifeAt: unmarshalDate(data.end_of_life_at),
234
+ version: data.version
235
+ };
236
+ };
237
+ const unmarshalListVersionsResponse = (data) => {
238
+ if (!isJSONObject(data)) {
239
+ throw new TypeError(
240
+ `Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`
241
+ );
242
+ }
243
+ return {
244
+ totalCount: data.total_count,
245
+ versions: unmarshalArrayOfObject(data.versions, unmarshalVersion)
246
+ };
247
+ };
248
+ const marshalEndpointSpecPrivateNetworkDetails = (request, defaults) => ({
249
+ private_network_id: request.privateNetworkId
250
+ });
251
+ const marshalEndpointSpecPublicDetails = (request, defaults) => ({});
252
+ const marshalCreateInstanceRequestVolumeDetails = (request, defaults) => ({
253
+ volume_size: request.volumeSize,
254
+ volume_type: request.volumeType
255
+ });
256
+ const marshalEndpointSpec = (request, defaults) => ({
257
+ ...resolveOneOf([
258
+ {
259
+ param: "public",
260
+ value: request.public !== void 0 ? marshalEndpointSpecPublicDetails(request.public) : void 0
261
+ },
262
+ {
263
+ param: "private_network",
264
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkDetails(
265
+ request.privateNetwork
266
+ ) : void 0
267
+ }
268
+ ])
269
+ });
270
+ const marshalCreateInstanceRequest = (request, defaults) => ({
271
+ endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
272
+ name: request.name || randomName("mgdb"),
273
+ node_number: request.nodeNumber,
274
+ node_type: request.nodeType,
275
+ password: request.password,
276
+ project_id: request.projectId ?? defaults.defaultProjectId,
277
+ tags: request.tags,
278
+ user_name: request.userName,
279
+ version: request.version,
280
+ volume: request.volume !== void 0 ? marshalCreateInstanceRequestVolumeDetails(request.volume) : void 0
281
+ });
282
+ const marshalCreateSnapshotRequest = (request, defaults) => ({
283
+ expires_at: request.expiresAt,
284
+ name: request.name
285
+ });
286
+ const marshalRestoreSnapshotRequestVolumeDetails = (request, defaults) => ({
287
+ volume_type: request.volumeType
288
+ });
289
+ const marshalRestoreSnapshotRequest = (request, defaults) => ({
290
+ instance_name: request.instanceName,
291
+ node_number: request.nodeNumber,
292
+ node_type: request.nodeType,
293
+ volume: marshalRestoreSnapshotRequestVolumeDetails(request.volume)
294
+ });
295
+ const marshalUpdateInstanceRequest = (request, defaults) => ({
296
+ name: request.name,
297
+ tags: request.tags
298
+ });
299
+ const marshalUpdateSnapshotRequest = (request, defaults) => ({
300
+ expires_at: request.expiresAt,
301
+ name: request.name
302
+ });
303
+ const marshalUpdateUserRequest = (request, defaults) => ({
304
+ password: request.password
305
+ });
306
+ const marshalUpgradeInstanceRequest = (request, defaults) => ({
307
+ ...resolveOneOf([{ param: "volume_size", value: request.volumeSize }])
308
+ });
309
+ export {
310
+ marshalCreateInstanceRequest,
311
+ marshalCreateSnapshotRequest,
312
+ marshalRestoreSnapshotRequest,
313
+ marshalUpdateInstanceRequest,
314
+ marshalUpdateSnapshotRequest,
315
+ marshalUpdateUserRequest,
316
+ marshalUpgradeInstanceRequest,
317
+ unmarshalInstance,
318
+ unmarshalInstanceSetting,
319
+ unmarshalListInstancesResponse,
320
+ unmarshalListNodeTypesResponse,
321
+ unmarshalListSnapshotsResponse,
322
+ unmarshalListUsersResponse,
323
+ unmarshalListVersionsResponse,
324
+ unmarshalSnapshot,
325
+ unmarshalUser,
326
+ unmarshalVolume
327
+ };