@scaleway/sdk-mongodb 1.0.5 → 1.0.6

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.
@@ -0,0 +1,333 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const randomName = require("@scaleway/random-name");
4
+ const sdkClient = require("@scaleway/sdk-client");
5
+ const unmarshalEndpointPrivateNetworkDetails = (data) => {
6
+ if (!sdkClient.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 unmarshalEndpointPublicNetworkDetails = (data) => {
16
+ if (!sdkClient.isJSONObject(data)) {
17
+ throw new TypeError(
18
+ `Unmarshalling the type 'EndpointPublicNetworkDetails' failed as data isn't a dictionary.`
19
+ );
20
+ }
21
+ return {};
22
+ };
23
+ const unmarshalEndpoint = (data) => {
24
+ if (!sdkClient.isJSONObject(data)) {
25
+ throw new TypeError(
26
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
27
+ );
28
+ }
29
+ return {
30
+ dnsRecord: data.dns_record,
31
+ id: data.id,
32
+ port: data.port,
33
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
34
+ publicNetwork: data.public_network ? unmarshalEndpointPublicNetworkDetails(data.public_network) : void 0
35
+ };
36
+ };
37
+ const unmarshalInstanceSnapshotSchedule = (data) => {
38
+ if (!sdkClient.isJSONObject(data)) {
39
+ throw new TypeError(
40
+ `Unmarshalling the type 'InstanceSnapshotSchedule' failed as data isn't a dictionary.`
41
+ );
42
+ }
43
+ return {
44
+ enabled: data.enabled,
45
+ frequencyHours: data.frequency_hours,
46
+ lastRun: sdkClient.unmarshalDate(data.last_run),
47
+ nextUpdate: sdkClient.unmarshalDate(data.next_update),
48
+ retentionDays: data.retention_days
49
+ };
50
+ };
51
+ const unmarshalVolume = (data) => {
52
+ if (!sdkClient.isJSONObject(data)) {
53
+ throw new TypeError(
54
+ `Unmarshalling the type 'Volume' failed as data isn't a dictionary.`
55
+ );
56
+ }
57
+ return {
58
+ sizeBytes: data.size_bytes,
59
+ type: data.type
60
+ };
61
+ };
62
+ const unmarshalInstance = (data) => {
63
+ if (!sdkClient.isJSONObject(data)) {
64
+ throw new TypeError(
65
+ `Unmarshalling the type 'Instance' failed as data isn't a dictionary.`
66
+ );
67
+ }
68
+ return {
69
+ createdAt: sdkClient.unmarshalDate(data.created_at),
70
+ endpoints: sdkClient.unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
71
+ id: data.id,
72
+ name: data.name,
73
+ nodeAmount: data.node_amount,
74
+ nodeType: data.node_type,
75
+ organizationId: data.organization_id,
76
+ projectId: data.project_id,
77
+ region: data.region,
78
+ snapshotSchedule: data.snapshot_schedule ? unmarshalInstanceSnapshotSchedule(data.snapshot_schedule) : void 0,
79
+ status: data.status,
80
+ tags: data.tags,
81
+ version: data.version,
82
+ volume: data.volume ? unmarshalVolume(data.volume) : void 0
83
+ };
84
+ };
85
+ const unmarshalSnapshot = (data) => {
86
+ if (!sdkClient.isJSONObject(data)) {
87
+ throw new TypeError(
88
+ `Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`
89
+ );
90
+ }
91
+ return {
92
+ createdAt: sdkClient.unmarshalDate(data.created_at),
93
+ expiresAt: sdkClient.unmarshalDate(data.expires_at),
94
+ id: data.id,
95
+ instanceId: data.instance_id,
96
+ instanceName: data.instance_name,
97
+ name: data.name,
98
+ nodeType: data.node_type,
99
+ region: data.region,
100
+ sizeBytes: data.size_bytes,
101
+ status: data.status,
102
+ updatedAt: sdkClient.unmarshalDate(data.updated_at),
103
+ volumeType: data.volume_type
104
+ };
105
+ };
106
+ const unmarshalUserRole = (data) => {
107
+ if (!sdkClient.isJSONObject(data)) {
108
+ throw new TypeError(
109
+ `Unmarshalling the type 'UserRole' failed as data isn't a dictionary.`
110
+ );
111
+ }
112
+ return {
113
+ anyDatabase: data.any_database,
114
+ databaseName: data.database_name,
115
+ role: data.role
116
+ };
117
+ };
118
+ const unmarshalUser = (data) => {
119
+ if (!sdkClient.isJSONObject(data)) {
120
+ throw new TypeError(
121
+ `Unmarshalling the type 'User' failed as data isn't a dictionary.`
122
+ );
123
+ }
124
+ return {
125
+ name: data.name,
126
+ roles: sdkClient.unmarshalArrayOfObject(data.roles, unmarshalUserRole)
127
+ };
128
+ };
129
+ const unmarshalListInstancesResponse = (data) => {
130
+ if (!sdkClient.isJSONObject(data)) {
131
+ throw new TypeError(
132
+ `Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary.`
133
+ );
134
+ }
135
+ return {
136
+ instances: sdkClient.unmarshalArrayOfObject(data.instances, unmarshalInstance),
137
+ totalCount: data.total_count
138
+ };
139
+ };
140
+ const unmarshalNodeTypeVolumeType = (data) => {
141
+ if (!sdkClient.isJSONObject(data)) {
142
+ throw new TypeError(
143
+ `Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary.`
144
+ );
145
+ }
146
+ return {
147
+ chunkSizeBytes: data.chunk_size_bytes,
148
+ description: data.description,
149
+ maxSizeBytes: data.max_size_bytes,
150
+ minSizeBytes: data.min_size_bytes,
151
+ type: data.type
152
+ };
153
+ };
154
+ const unmarshalNodeType = (data) => {
155
+ if (!sdkClient.isJSONObject(data)) {
156
+ throw new TypeError(
157
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
158
+ );
159
+ }
160
+ return {
161
+ availableVolumeTypes: sdkClient.unmarshalArrayOfObject(
162
+ data.available_volume_types,
163
+ unmarshalNodeTypeVolumeType
164
+ ),
165
+ beta: data.beta,
166
+ description: data.description,
167
+ disabled: data.disabled,
168
+ instanceRange: data.instance_range,
169
+ memoryBytes: data.memory_bytes,
170
+ name: data.name,
171
+ stockStatus: data.stock_status,
172
+ vcpus: data.vcpus
173
+ };
174
+ };
175
+ const unmarshalListNodeTypesResponse = (data) => {
176
+ if (!sdkClient.isJSONObject(data)) {
177
+ throw new TypeError(
178
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
179
+ );
180
+ }
181
+ return {
182
+ nodeTypes: sdkClient.unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
183
+ totalCount: data.total_count
184
+ };
185
+ };
186
+ const unmarshalListSnapshotsResponse = (data) => {
187
+ if (!sdkClient.isJSONObject(data)) {
188
+ throw new TypeError(
189
+ `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`
190
+ );
191
+ }
192
+ return {
193
+ snapshots: sdkClient.unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
194
+ totalCount: data.total_count
195
+ };
196
+ };
197
+ const unmarshalListUsersResponse = (data) => {
198
+ if (!sdkClient.isJSONObject(data)) {
199
+ throw new TypeError(
200
+ `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
201
+ );
202
+ }
203
+ return {
204
+ totalCount: data.total_count,
205
+ users: sdkClient.unmarshalArrayOfObject(data.users, unmarshalUser)
206
+ };
207
+ };
208
+ const unmarshalVersion = (data) => {
209
+ if (!sdkClient.isJSONObject(data)) {
210
+ throw new TypeError(
211
+ `Unmarshalling the type 'Version' failed as data isn't a dictionary.`
212
+ );
213
+ }
214
+ return {
215
+ endOfLifeAt: sdkClient.unmarshalDate(data.end_of_life_at),
216
+ version: data.version
217
+ };
218
+ };
219
+ const unmarshalListVersionsResponse = (data) => {
220
+ if (!sdkClient.isJSONObject(data)) {
221
+ throw new TypeError(
222
+ `Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`
223
+ );
224
+ }
225
+ return {
226
+ totalCount: data.total_count,
227
+ versions: sdkClient.unmarshalArrayOfObject(data.versions, unmarshalVersion)
228
+ };
229
+ };
230
+ const marshalEndpointSpecPrivateNetworkDetails = (request, defaults) => ({
231
+ private_network_id: request.privateNetworkId
232
+ });
233
+ const marshalEndpointSpecPublicNetworkDetails = (request, defaults) => ({});
234
+ const marshalEndpointSpec = (request, defaults) => ({
235
+ ...sdkClient.resolveOneOf([
236
+ {
237
+ param: "public_network",
238
+ value: request.publicNetwork !== void 0 ? marshalEndpointSpecPublicNetworkDetails(
239
+ request.publicNetwork
240
+ ) : void 0
241
+ },
242
+ {
243
+ param: "private_network",
244
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkDetails(
245
+ request.privateNetwork
246
+ ) : void 0
247
+ }
248
+ ])
249
+ });
250
+ const marshalCreateEndpointRequest = (request, defaults) => ({
251
+ endpoint: marshalEndpointSpec(request.endpoint),
252
+ instance_id: request.instanceId
253
+ });
254
+ const marshalVolume = (request, defaults) => ({
255
+ size_bytes: request.sizeBytes,
256
+ type: request.type
257
+ });
258
+ const marshalCreateInstanceRequest = (request, defaults) => ({
259
+ endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
260
+ name: request.name || randomName("mgdb"),
261
+ node_amount: request.nodeAmount,
262
+ node_type: request.nodeType,
263
+ password: request.password,
264
+ project_id: request.projectId ?? defaults.defaultProjectId,
265
+ tags: request.tags,
266
+ user_name: request.userName,
267
+ version: request.version,
268
+ volume: request.volume !== void 0 ? marshalVolume(request.volume) : void 0
269
+ });
270
+ const marshalCreateSnapshotRequest = (request, defaults) => ({
271
+ expires_at: request.expiresAt,
272
+ instance_id: request.instanceId,
273
+ name: request.name
274
+ });
275
+ const marshalCreateUserRequest = (request, defaults) => ({
276
+ name: request.name,
277
+ password: request.password
278
+ });
279
+ const marshalRestoreSnapshotRequest = (request, defaults) => ({
280
+ instance_name: request.instanceName,
281
+ node_amount: request.nodeAmount,
282
+ node_type: request.nodeType,
283
+ volume_type: request.volumeType
284
+ });
285
+ const marshalUserRole = (request, defaults) => ({
286
+ role: request.role,
287
+ ...sdkClient.resolveOneOf([
288
+ { param: "database_name", value: request.databaseName },
289
+ { param: "any_database", value: request.anyDatabase }
290
+ ])
291
+ });
292
+ const marshalSetUserRoleRequest = (request, defaults) => ({
293
+ roles: request.roles !== void 0 ? request.roles.map((elt) => marshalUserRole(elt)) : void 0,
294
+ user_name: request.userName
295
+ });
296
+ const marshalUpdateInstanceRequest = (request, defaults) => ({
297
+ is_snapshot_schedule_enabled: request.isSnapshotScheduleEnabled,
298
+ name: request.name,
299
+ snapshot_schedule_frequency_hours: request.snapshotScheduleFrequencyHours,
300
+ snapshot_schedule_retention_days: request.snapshotScheduleRetentionDays,
301
+ tags: request.tags
302
+ });
303
+ const marshalUpdateSnapshotRequest = (request, defaults) => ({
304
+ expires_at: request.expiresAt,
305
+ name: request.name
306
+ });
307
+ const marshalUpdateUserRequest = (request, defaults) => ({
308
+ password: request.password
309
+ });
310
+ const marshalUpgradeInstanceRequest = (request, defaults) => ({
311
+ ...sdkClient.resolveOneOf([
312
+ { param: "volume_size_bytes", value: request.volumeSizeBytes }
313
+ ])
314
+ });
315
+ exports.marshalCreateEndpointRequest = marshalCreateEndpointRequest;
316
+ exports.marshalCreateInstanceRequest = marshalCreateInstanceRequest;
317
+ exports.marshalCreateSnapshotRequest = marshalCreateSnapshotRequest;
318
+ exports.marshalCreateUserRequest = marshalCreateUserRequest;
319
+ exports.marshalRestoreSnapshotRequest = marshalRestoreSnapshotRequest;
320
+ exports.marshalSetUserRoleRequest = marshalSetUserRoleRequest;
321
+ exports.marshalUpdateInstanceRequest = marshalUpdateInstanceRequest;
322
+ exports.marshalUpdateSnapshotRequest = marshalUpdateSnapshotRequest;
323
+ exports.marshalUpdateUserRequest = marshalUpdateUserRequest;
324
+ exports.marshalUpgradeInstanceRequest = marshalUpgradeInstanceRequest;
325
+ exports.unmarshalEndpoint = unmarshalEndpoint;
326
+ exports.unmarshalInstance = unmarshalInstance;
327
+ exports.unmarshalListInstancesResponse = unmarshalListInstancesResponse;
328
+ exports.unmarshalListNodeTypesResponse = unmarshalListNodeTypesResponse;
329
+ exports.unmarshalListSnapshotsResponse = unmarshalListSnapshotsResponse;
330
+ exports.unmarshalListUsersResponse = unmarshalListUsersResponse;
331
+ exports.unmarshalListVersionsResponse = unmarshalListVersionsResponse;
332
+ exports.unmarshalSnapshot = unmarshalSnapshot;
333
+ exports.unmarshalUser = unmarshalUser;
@@ -0,0 +1,21 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { CreateEndpointRequest, CreateInstanceRequest, CreateSnapshotRequest, CreateUserRequest, Endpoint, Instance, ListInstancesResponse, ListNodeTypesResponse, ListSnapshotsResponse, ListUsersResponse, ListVersionsResponse, RestoreSnapshotRequest, SetUserRoleRequest, Snapshot, UpdateInstanceRequest, UpdateSnapshotRequest, UpdateUserRequest, UpgradeInstanceRequest, User } from './types.gen';
3
+ export declare const unmarshalEndpoint: (data: unknown) => Endpoint;
4
+ export declare const unmarshalInstance: (data: unknown) => Instance;
5
+ export declare const unmarshalSnapshot: (data: unknown) => Snapshot;
6
+ export declare const unmarshalUser: (data: unknown) => User;
7
+ export declare const unmarshalListInstancesResponse: (data: unknown) => ListInstancesResponse;
8
+ export declare const unmarshalListNodeTypesResponse: (data: unknown) => ListNodeTypesResponse;
9
+ export declare const unmarshalListSnapshotsResponse: (data: unknown) => ListSnapshotsResponse;
10
+ export declare const unmarshalListUsersResponse: (data: unknown) => ListUsersResponse;
11
+ export declare const unmarshalListVersionsResponse: (data: unknown) => ListVersionsResponse;
12
+ export declare const marshalCreateEndpointRequest: (request: CreateEndpointRequest, defaults: DefaultValues) => Record<string, unknown>;
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 marshalCreateUserRequest: (request: CreateUserRequest, defaults: DefaultValues) => Record<string, unknown>;
16
+ export declare const marshalRestoreSnapshotRequest: (request: RestoreSnapshotRequest, defaults: DefaultValues) => Record<string, unknown>;
17
+ export declare const marshalSetUserRoleRequest: (request: SetUserRoleRequest, defaults: DefaultValues) => Record<string, unknown>;
18
+ export declare const marshalUpdateInstanceRequest: (request: UpdateInstanceRequest, defaults: DefaultValues) => Record<string, unknown>;
19
+ export declare const marshalUpdateSnapshotRequest: (request: UpdateSnapshotRequest, defaults: DefaultValues) => Record<string, unknown>;
20
+ export declare const marshalUpdateUserRequest: (request: UpdateUserRequest, defaults: DefaultValues) => Record<string, unknown>;
21
+ export declare const marshalUpgradeInstanceRequest: (request: UpgradeInstanceRequest, defaults: DefaultValues) => Record<string, unknown>;
@@ -0,0 +1,333 @@
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 unmarshalEndpointPublicNetworkDetails = (data) => {
14
+ if (!isJSONObject(data)) {
15
+ throw new TypeError(
16
+ `Unmarshalling the type 'EndpointPublicNetworkDetails' 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
+ dnsRecord: data.dns_record,
29
+ id: data.id,
30
+ port: data.port,
31
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
32
+ publicNetwork: data.public_network ? unmarshalEndpointPublicNetworkDetails(data.public_network) : void 0
33
+ };
34
+ };
35
+ const unmarshalInstanceSnapshotSchedule = (data) => {
36
+ if (!isJSONObject(data)) {
37
+ throw new TypeError(
38
+ `Unmarshalling the type 'InstanceSnapshotSchedule' failed as data isn't a dictionary.`
39
+ );
40
+ }
41
+ return {
42
+ enabled: data.enabled,
43
+ frequencyHours: data.frequency_hours,
44
+ lastRun: unmarshalDate(data.last_run),
45
+ nextUpdate: unmarshalDate(data.next_update),
46
+ retentionDays: data.retention_days
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
+ sizeBytes: data.size_bytes,
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
+ nodeAmount: data.node_amount,
72
+ nodeType: data.node_type,
73
+ organizationId: data.organization_id,
74
+ projectId: data.project_id,
75
+ region: data.region,
76
+ snapshotSchedule: data.snapshot_schedule ? unmarshalInstanceSnapshotSchedule(data.snapshot_schedule) : void 0,
77
+ status: data.status,
78
+ tags: data.tags,
79
+ version: data.version,
80
+ volume: data.volume ? unmarshalVolume(data.volume) : void 0
81
+ };
82
+ };
83
+ const unmarshalSnapshot = (data) => {
84
+ if (!isJSONObject(data)) {
85
+ throw new TypeError(
86
+ `Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`
87
+ );
88
+ }
89
+ return {
90
+ createdAt: unmarshalDate(data.created_at),
91
+ expiresAt: unmarshalDate(data.expires_at),
92
+ id: data.id,
93
+ instanceId: data.instance_id,
94
+ instanceName: data.instance_name,
95
+ name: data.name,
96
+ nodeType: data.node_type,
97
+ region: data.region,
98
+ sizeBytes: data.size_bytes,
99
+ status: data.status,
100
+ updatedAt: unmarshalDate(data.updated_at),
101
+ volumeType: data.volume_type
102
+ };
103
+ };
104
+ const unmarshalUserRole = (data) => {
105
+ if (!isJSONObject(data)) {
106
+ throw new TypeError(
107
+ `Unmarshalling the type 'UserRole' failed as data isn't a dictionary.`
108
+ );
109
+ }
110
+ return {
111
+ anyDatabase: data.any_database,
112
+ databaseName: data.database_name,
113
+ role: data.role
114
+ };
115
+ };
116
+ const unmarshalUser = (data) => {
117
+ if (!isJSONObject(data)) {
118
+ throw new TypeError(
119
+ `Unmarshalling the type 'User' failed as data isn't a dictionary.`
120
+ );
121
+ }
122
+ return {
123
+ name: data.name,
124
+ roles: unmarshalArrayOfObject(data.roles, unmarshalUserRole)
125
+ };
126
+ };
127
+ const unmarshalListInstancesResponse = (data) => {
128
+ if (!isJSONObject(data)) {
129
+ throw new TypeError(
130
+ `Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary.`
131
+ );
132
+ }
133
+ return {
134
+ instances: unmarshalArrayOfObject(data.instances, unmarshalInstance),
135
+ totalCount: data.total_count
136
+ };
137
+ };
138
+ const unmarshalNodeTypeVolumeType = (data) => {
139
+ if (!isJSONObject(data)) {
140
+ throw new TypeError(
141
+ `Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary.`
142
+ );
143
+ }
144
+ return {
145
+ chunkSizeBytes: data.chunk_size_bytes,
146
+ description: data.description,
147
+ maxSizeBytes: data.max_size_bytes,
148
+ minSizeBytes: data.min_size_bytes,
149
+ type: data.type
150
+ };
151
+ };
152
+ const unmarshalNodeType = (data) => {
153
+ if (!isJSONObject(data)) {
154
+ throw new TypeError(
155
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
156
+ );
157
+ }
158
+ return {
159
+ availableVolumeTypes: unmarshalArrayOfObject(
160
+ data.available_volume_types,
161
+ unmarshalNodeTypeVolumeType
162
+ ),
163
+ beta: data.beta,
164
+ description: data.description,
165
+ disabled: data.disabled,
166
+ instanceRange: data.instance_range,
167
+ memoryBytes: data.memory_bytes,
168
+ name: data.name,
169
+ stockStatus: data.stock_status,
170
+ vcpus: data.vcpus
171
+ };
172
+ };
173
+ const unmarshalListNodeTypesResponse = (data) => {
174
+ if (!isJSONObject(data)) {
175
+ throw new TypeError(
176
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
177
+ );
178
+ }
179
+ return {
180
+ nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
181
+ totalCount: data.total_count
182
+ };
183
+ };
184
+ const unmarshalListSnapshotsResponse = (data) => {
185
+ if (!isJSONObject(data)) {
186
+ throw new TypeError(
187
+ `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`
188
+ );
189
+ }
190
+ return {
191
+ snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
192
+ totalCount: data.total_count
193
+ };
194
+ };
195
+ const unmarshalListUsersResponse = (data) => {
196
+ if (!isJSONObject(data)) {
197
+ throw new TypeError(
198
+ `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
199
+ );
200
+ }
201
+ return {
202
+ totalCount: data.total_count,
203
+ users: unmarshalArrayOfObject(data.users, unmarshalUser)
204
+ };
205
+ };
206
+ const unmarshalVersion = (data) => {
207
+ if (!isJSONObject(data)) {
208
+ throw new TypeError(
209
+ `Unmarshalling the type 'Version' failed as data isn't a dictionary.`
210
+ );
211
+ }
212
+ return {
213
+ endOfLifeAt: unmarshalDate(data.end_of_life_at),
214
+ version: data.version
215
+ };
216
+ };
217
+ const unmarshalListVersionsResponse = (data) => {
218
+ if (!isJSONObject(data)) {
219
+ throw new TypeError(
220
+ `Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`
221
+ );
222
+ }
223
+ return {
224
+ totalCount: data.total_count,
225
+ versions: unmarshalArrayOfObject(data.versions, unmarshalVersion)
226
+ };
227
+ };
228
+ const marshalEndpointSpecPrivateNetworkDetails = (request, defaults) => ({
229
+ private_network_id: request.privateNetworkId
230
+ });
231
+ const marshalEndpointSpecPublicNetworkDetails = (request, defaults) => ({});
232
+ const marshalEndpointSpec = (request, defaults) => ({
233
+ ...resolveOneOf([
234
+ {
235
+ param: "public_network",
236
+ value: request.publicNetwork !== void 0 ? marshalEndpointSpecPublicNetworkDetails(
237
+ request.publicNetwork
238
+ ) : void 0
239
+ },
240
+ {
241
+ param: "private_network",
242
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkDetails(
243
+ request.privateNetwork
244
+ ) : void 0
245
+ }
246
+ ])
247
+ });
248
+ const marshalCreateEndpointRequest = (request, defaults) => ({
249
+ endpoint: marshalEndpointSpec(request.endpoint),
250
+ instance_id: request.instanceId
251
+ });
252
+ const marshalVolume = (request, defaults) => ({
253
+ size_bytes: request.sizeBytes,
254
+ type: request.type
255
+ });
256
+ const marshalCreateInstanceRequest = (request, defaults) => ({
257
+ endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
258
+ name: request.name || randomName("mgdb"),
259
+ node_amount: request.nodeAmount,
260
+ node_type: request.nodeType,
261
+ password: request.password,
262
+ project_id: request.projectId ?? defaults.defaultProjectId,
263
+ tags: request.tags,
264
+ user_name: request.userName,
265
+ version: request.version,
266
+ volume: request.volume !== void 0 ? marshalVolume(request.volume) : void 0
267
+ });
268
+ const marshalCreateSnapshotRequest = (request, defaults) => ({
269
+ expires_at: request.expiresAt,
270
+ instance_id: request.instanceId,
271
+ name: request.name
272
+ });
273
+ const marshalCreateUserRequest = (request, defaults) => ({
274
+ name: request.name,
275
+ password: request.password
276
+ });
277
+ const marshalRestoreSnapshotRequest = (request, defaults) => ({
278
+ instance_name: request.instanceName,
279
+ node_amount: request.nodeAmount,
280
+ node_type: request.nodeType,
281
+ volume_type: request.volumeType
282
+ });
283
+ const marshalUserRole = (request, defaults) => ({
284
+ role: request.role,
285
+ ...resolveOneOf([
286
+ { param: "database_name", value: request.databaseName },
287
+ { param: "any_database", value: request.anyDatabase }
288
+ ])
289
+ });
290
+ const marshalSetUserRoleRequest = (request, defaults) => ({
291
+ roles: request.roles !== void 0 ? request.roles.map((elt) => marshalUserRole(elt)) : void 0,
292
+ user_name: request.userName
293
+ });
294
+ const marshalUpdateInstanceRequest = (request, defaults) => ({
295
+ is_snapshot_schedule_enabled: request.isSnapshotScheduleEnabled,
296
+ name: request.name,
297
+ snapshot_schedule_frequency_hours: request.snapshotScheduleFrequencyHours,
298
+ snapshot_schedule_retention_days: request.snapshotScheduleRetentionDays,
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
+ ...resolveOneOf([
310
+ { param: "volume_size_bytes", value: request.volumeSizeBytes }
311
+ ])
312
+ });
313
+ export {
314
+ marshalCreateEndpointRequest,
315
+ marshalCreateInstanceRequest,
316
+ marshalCreateSnapshotRequest,
317
+ marshalCreateUserRequest,
318
+ marshalRestoreSnapshotRequest,
319
+ marshalSetUserRoleRequest,
320
+ marshalUpdateInstanceRequest,
321
+ marshalUpdateSnapshotRequest,
322
+ marshalUpdateUserRequest,
323
+ marshalUpgradeInstanceRequest,
324
+ unmarshalEndpoint,
325
+ unmarshalInstance,
326
+ unmarshalListInstancesResponse,
327
+ unmarshalListNodeTypesResponse,
328
+ unmarshalListSnapshotsResponse,
329
+ unmarshalListUsersResponse,
330
+ unmarshalListVersionsResponse,
331
+ unmarshalSnapshot,
332
+ unmarshalUser
333
+ };