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