@scaleway/sdk-mongodb 1.0.1
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.
- package/LICENSE +191 -0
- package/dist/index.gen.cjs +4 -0
- package/dist/index.gen.d.ts +5 -0
- package/dist/index.gen.js +4 -0
- package/dist/v1alpha1/api.gen.cjs +410 -0
- package/dist/v1alpha1/api.gen.d.ts +194 -0
- package/dist/v1alpha1/api.gen.js +410 -0
- package/dist/v1alpha1/content.gen.cjs +16 -0
- package/dist/v1alpha1/content.gen.d.ts +5 -0
- package/dist/v1alpha1/content.gen.js +16 -0
- package/dist/v1alpha1/index.gen.cjs +31 -0
- package/dist/v1alpha1/index.gen.d.ts +5 -0
- package/dist/v1alpha1/index.gen.js +31 -0
- package/dist/v1alpha1/marshalling.gen.cjs +361 -0
- package/dist/v1alpha1/marshalling.gen.d.ts +23 -0
- package/dist/v1alpha1/marshalling.gen.js +361 -0
- package/dist/v1alpha1/types.gen.d.ts +788 -0
- package/dist/v1alpha1/validation-rules.gen.cjs +175 -0
- package/dist/v1alpha1/validation-rules.gen.d.ts +159 -0
- package/dist/v1alpha1/validation-rules.gen.js +175 -0
- package/package.json +51 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import randomName from "@scaleway/random-name";
|
|
2
|
+
import { resolveOneOf, isJSONObject, unmarshalArrayOfObject, unmarshalDate } from "@scaleway/sdk-client";
|
|
3
|
+
const unmarshalEndpointPrivateNetworkDetails = (data) => {
|
|
4
|
+
if (!isJSONObject(data)) {
|
|
5
|
+
throw new TypeError(
|
|
6
|
+
`Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
privateNetworkId: data.private_network_id
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const unmarshalEndpointPublicDetails = (data) => {
|
|
14
|
+
if (!isJSONObject(data)) {
|
|
15
|
+
throw new TypeError(
|
|
16
|
+
`Unmarshalling the type 'EndpointPublicDetails' failed as data isn't a dictionary.`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return {};
|
|
20
|
+
};
|
|
21
|
+
const unmarshalEndpoint = (data) => {
|
|
22
|
+
if (!isJSONObject(data)) {
|
|
23
|
+
throw new TypeError(
|
|
24
|
+
`Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
dnsRecords: data.dns_records,
|
|
29
|
+
id: data.id,
|
|
30
|
+
ips: data.ips,
|
|
31
|
+
port: data.port,
|
|
32
|
+
privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
|
|
33
|
+
public: data.public ? unmarshalEndpointPublicDetails(data.public) : void 0
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const unmarshalInstanceSetting = (data) => {
|
|
37
|
+
if (!isJSONObject(data)) {
|
|
38
|
+
throw new TypeError(
|
|
39
|
+
`Unmarshalling the type 'InstanceSetting' failed as data isn't a dictionary.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
name: data.name,
|
|
44
|
+
value: data.value
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const unmarshalVolume = (data) => {
|
|
48
|
+
if (!isJSONObject(data)) {
|
|
49
|
+
throw new TypeError(
|
|
50
|
+
`Unmarshalling the type 'Volume' failed as data isn't a dictionary.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
size: data.size,
|
|
55
|
+
type: data.type
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const unmarshalInstance = (data) => {
|
|
59
|
+
if (!isJSONObject(data)) {
|
|
60
|
+
throw new TypeError(
|
|
61
|
+
`Unmarshalling the type 'Instance' failed as data isn't a dictionary.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
createdAt: unmarshalDate(data.created_at),
|
|
66
|
+
endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
|
|
67
|
+
id: data.id,
|
|
68
|
+
name: data.name,
|
|
69
|
+
nodeNumber: data.node_number,
|
|
70
|
+
nodeType: data.node_type,
|
|
71
|
+
projectId: data.project_id,
|
|
72
|
+
region: data.region,
|
|
73
|
+
settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting),
|
|
74
|
+
status: data.status,
|
|
75
|
+
tags: data.tags,
|
|
76
|
+
version: data.version,
|
|
77
|
+
volume: data.volume ? unmarshalVolume(data.volume) : void 0
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const unmarshalSnapshotVolumeType = (data) => {
|
|
81
|
+
if (!isJSONObject(data)) {
|
|
82
|
+
throw new TypeError(
|
|
83
|
+
`Unmarshalling the type 'SnapshotVolumeType' failed as data isn't a dictionary.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
type: data.type
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
const unmarshalSnapshot = (data) => {
|
|
91
|
+
if (!isJSONObject(data)) {
|
|
92
|
+
throw new TypeError(
|
|
93
|
+
`Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
createdAt: unmarshalDate(data.created_at),
|
|
98
|
+
expiresAt: unmarshalDate(data.expires_at),
|
|
99
|
+
id: data.id,
|
|
100
|
+
instanceId: data.instance_id,
|
|
101
|
+
instanceName: data.instance_name,
|
|
102
|
+
name: data.name,
|
|
103
|
+
nodeType: data.node_type,
|
|
104
|
+
region: data.region,
|
|
105
|
+
size: data.size,
|
|
106
|
+
status: data.status,
|
|
107
|
+
updatedAt: unmarshalDate(data.updated_at),
|
|
108
|
+
volumeType: data.volume_type ? unmarshalSnapshotVolumeType(data.volume_type) : void 0
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const unmarshalUserRole = (data) => {
|
|
112
|
+
if (!isJSONObject(data)) {
|
|
113
|
+
throw new TypeError(
|
|
114
|
+
`Unmarshalling the type 'UserRole' failed as data isn't a dictionary.`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
anyDatabase: data.any_database,
|
|
119
|
+
database: data.database,
|
|
120
|
+
role: data.role
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
const unmarshalUser = (data) => {
|
|
124
|
+
if (!isJSONObject(data)) {
|
|
125
|
+
throw new TypeError(
|
|
126
|
+
`Unmarshalling the type 'User' failed as data isn't a dictionary.`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
name: data.name,
|
|
131
|
+
roles: unmarshalArrayOfObject(data.roles, unmarshalUserRole)
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const unmarshalListInstancesResponse = (data) => {
|
|
135
|
+
if (!isJSONObject(data)) {
|
|
136
|
+
throw new TypeError(
|
|
137
|
+
`Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary.`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
instances: unmarshalArrayOfObject(data.instances, unmarshalInstance),
|
|
142
|
+
totalCount: data.total_count
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
const unmarshalNodeTypeVolumeType = (data) => {
|
|
146
|
+
if (!isJSONObject(data)) {
|
|
147
|
+
throw new TypeError(
|
|
148
|
+
`Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary.`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
chunkSize: data.chunk_size,
|
|
153
|
+
description: data.description,
|
|
154
|
+
maxSize: data.max_size,
|
|
155
|
+
minSize: data.min_size,
|
|
156
|
+
type: data.type
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const unmarshalNodeType = (data) => {
|
|
160
|
+
if (!isJSONObject(data)) {
|
|
161
|
+
throw new TypeError(
|
|
162
|
+
`Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
availableVolumeTypes: unmarshalArrayOfObject(
|
|
167
|
+
data.available_volume_types,
|
|
168
|
+
unmarshalNodeTypeVolumeType
|
|
169
|
+
),
|
|
170
|
+
beta: data.beta,
|
|
171
|
+
description: data.description,
|
|
172
|
+
disabled: data.disabled,
|
|
173
|
+
instanceRange: data.instance_range,
|
|
174
|
+
memory: data.memory,
|
|
175
|
+
name: data.name,
|
|
176
|
+
stockStatus: data.stock_status,
|
|
177
|
+
vcpus: data.vcpus
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
const unmarshalListNodeTypesResponse = (data) => {
|
|
181
|
+
if (!isJSONObject(data)) {
|
|
182
|
+
throw new TypeError(
|
|
183
|
+
`Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
|
|
188
|
+
totalCount: data.total_count
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const unmarshalListSnapshotsResponse = (data) => {
|
|
192
|
+
if (!isJSONObject(data)) {
|
|
193
|
+
throw new TypeError(
|
|
194
|
+
`Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
|
|
199
|
+
totalCount: data.total_count
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
const unmarshalListUsersResponse = (data) => {
|
|
203
|
+
if (!isJSONObject(data)) {
|
|
204
|
+
throw new TypeError(
|
|
205
|
+
`Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
totalCount: data.total_count,
|
|
210
|
+
users: unmarshalArrayOfObject(data.users, unmarshalUser)
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
const unmarshalSetting = (data) => {
|
|
214
|
+
if (!isJSONObject(data)) {
|
|
215
|
+
throw new TypeError(
|
|
216
|
+
`Unmarshalling the type 'Setting' failed as data isn't a dictionary.`
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
defaultValue: data.default_value,
|
|
221
|
+
description: data.description,
|
|
222
|
+
floatMax: data.float_max,
|
|
223
|
+
floatMin: data.float_min,
|
|
224
|
+
hotConfigurable: data.hot_configurable,
|
|
225
|
+
intMax: data.int_max,
|
|
226
|
+
intMin: data.int_min,
|
|
227
|
+
name: data.name,
|
|
228
|
+
propertyType: data.property_type,
|
|
229
|
+
stringConstraint: data.string_constraint,
|
|
230
|
+
unit: data.unit
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
const unmarshalVersion = (data) => {
|
|
234
|
+
if (!isJSONObject(data)) {
|
|
235
|
+
throw new TypeError(
|
|
236
|
+
`Unmarshalling the type 'Version' failed as data isn't a dictionary.`
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
availableSettings: unmarshalArrayOfObject(
|
|
241
|
+
data.available_settings,
|
|
242
|
+
unmarshalSetting
|
|
243
|
+
),
|
|
244
|
+
endOfLifeAt: unmarshalDate(data.end_of_life_at),
|
|
245
|
+
version: data.version
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
const unmarshalListVersionsResponse = (data) => {
|
|
249
|
+
if (!isJSONObject(data)) {
|
|
250
|
+
throw new TypeError(
|
|
251
|
+
`Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
totalCount: data.total_count,
|
|
256
|
+
versions: unmarshalArrayOfObject(data.versions, unmarshalVersion)
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
const marshalEndpointSpecPrivateNetworkDetails = (request, defaults) => ({
|
|
260
|
+
private_network_id: request.privateNetworkId
|
|
261
|
+
});
|
|
262
|
+
const marshalEndpointSpecPublicDetails = (request, defaults) => ({});
|
|
263
|
+
const marshalEndpointSpec = (request, defaults) => ({
|
|
264
|
+
...resolveOneOf([
|
|
265
|
+
{
|
|
266
|
+
param: "public",
|
|
267
|
+
value: request.public !== void 0 ? marshalEndpointSpecPublicDetails(request.public) : void 0
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
param: "private_network",
|
|
271
|
+
value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkDetails(
|
|
272
|
+
request.privateNetwork
|
|
273
|
+
) : void 0
|
|
274
|
+
}
|
|
275
|
+
])
|
|
276
|
+
});
|
|
277
|
+
const marshalCreateEndpointRequest = (request, defaults) => ({
|
|
278
|
+
endpoint: marshalEndpointSpec(request.endpoint),
|
|
279
|
+
instance_id: request.instanceId
|
|
280
|
+
});
|
|
281
|
+
const marshalCreateInstanceRequestVolumeDetails = (request, defaults) => ({
|
|
282
|
+
volume_size: request.volumeSize,
|
|
283
|
+
volume_type: request.volumeType
|
|
284
|
+
});
|
|
285
|
+
const marshalCreateInstanceRequest = (request, defaults) => ({
|
|
286
|
+
endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
|
|
287
|
+
name: request.name || randomName("mgdb"),
|
|
288
|
+
node_number: request.nodeNumber,
|
|
289
|
+
node_type: request.nodeType,
|
|
290
|
+
password: request.password,
|
|
291
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
292
|
+
tags: request.tags,
|
|
293
|
+
user_name: request.userName,
|
|
294
|
+
version: request.version,
|
|
295
|
+
volume: request.volume !== void 0 ? marshalCreateInstanceRequestVolumeDetails(request.volume) : void 0
|
|
296
|
+
});
|
|
297
|
+
const marshalCreateSnapshotRequest = (request, defaults) => ({
|
|
298
|
+
expires_at: request.expiresAt,
|
|
299
|
+
name: request.name
|
|
300
|
+
});
|
|
301
|
+
const marshalCreateUserRequest = (request, defaults) => ({
|
|
302
|
+
name: request.name,
|
|
303
|
+
password: request.password
|
|
304
|
+
});
|
|
305
|
+
const marshalRestoreSnapshotRequestVolumeDetails = (request, defaults) => ({
|
|
306
|
+
volume_type: request.volumeType
|
|
307
|
+
});
|
|
308
|
+
const marshalRestoreSnapshotRequest = (request, defaults) => ({
|
|
309
|
+
instance_name: request.instanceName,
|
|
310
|
+
node_number: request.nodeNumber,
|
|
311
|
+
node_type: request.nodeType,
|
|
312
|
+
volume: marshalRestoreSnapshotRequestVolumeDetails(request.volume)
|
|
313
|
+
});
|
|
314
|
+
const marshalUserRole = (request, defaults) => ({
|
|
315
|
+
role: request.role,
|
|
316
|
+
...resolveOneOf([
|
|
317
|
+
{ param: "database", value: request.database },
|
|
318
|
+
{ param: "any_database", value: request.anyDatabase }
|
|
319
|
+
])
|
|
320
|
+
});
|
|
321
|
+
const marshalSetUserRoleRequest = (request, defaults) => ({
|
|
322
|
+
roles: request.roles !== void 0 ? request.roles.map((elt) => marshalUserRole(elt)) : void 0,
|
|
323
|
+
user_name: request.userName
|
|
324
|
+
});
|
|
325
|
+
const marshalUpdateInstanceRequest = (request, defaults) => ({
|
|
326
|
+
name: request.name,
|
|
327
|
+
tags: request.tags
|
|
328
|
+
});
|
|
329
|
+
const marshalUpdateSnapshotRequest = (request, defaults) => ({
|
|
330
|
+
expires_at: request.expiresAt,
|
|
331
|
+
name: request.name
|
|
332
|
+
});
|
|
333
|
+
const marshalUpdateUserRequest = (request, defaults) => ({
|
|
334
|
+
password: request.password
|
|
335
|
+
});
|
|
336
|
+
const marshalUpgradeInstanceRequest = (request, defaults) => ({
|
|
337
|
+
...resolveOneOf([{ param: "volume_size", value: request.volumeSize }])
|
|
338
|
+
});
|
|
339
|
+
export {
|
|
340
|
+
marshalCreateEndpointRequest,
|
|
341
|
+
marshalCreateInstanceRequest,
|
|
342
|
+
marshalCreateSnapshotRequest,
|
|
343
|
+
marshalCreateUserRequest,
|
|
344
|
+
marshalRestoreSnapshotRequest,
|
|
345
|
+
marshalSetUserRoleRequest,
|
|
346
|
+
marshalUpdateInstanceRequest,
|
|
347
|
+
marshalUpdateSnapshotRequest,
|
|
348
|
+
marshalUpdateUserRequest,
|
|
349
|
+
marshalUpgradeInstanceRequest,
|
|
350
|
+
unmarshalEndpoint,
|
|
351
|
+
unmarshalInstance,
|
|
352
|
+
unmarshalInstanceSetting,
|
|
353
|
+
unmarshalListInstancesResponse,
|
|
354
|
+
unmarshalListNodeTypesResponse,
|
|
355
|
+
unmarshalListSnapshotsResponse,
|
|
356
|
+
unmarshalListUsersResponse,
|
|
357
|
+
unmarshalListVersionsResponse,
|
|
358
|
+
unmarshalSnapshot,
|
|
359
|
+
unmarshalUser,
|
|
360
|
+
unmarshalVolume
|
|
361
|
+
};
|