@scaleway/sdk-mongodb 2.3.1 → 2.4.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.
@@ -1,490 +1,337 @@
1
- import { API as API$1, toApiLocality, urlParams, validatePathParam, enrichForPagination, waitForResource } from "@scaleway/sdk-client";
2
- import { INSTANCE_TRANSIENT_STATUSES, SNAPSHOT_TRANSIENT_STATUSES, MAINTENANCE_TRANSIENT_STATUSES } from "./content.gen.js";
3
- import { unmarshalListNodeTypesResponse, unmarshalListVersionsResponse, unmarshalListInstancesResponse, unmarshalInstance, marshalCreateInstanceRequest, marshalUpdateInstanceRequest, marshalUpgradeInstanceRequest, marshalCreateSnapshotRequest, unmarshalSnapshot, marshalUpdateSnapshotRequest, marshalRestoreSnapshotRequest, unmarshalListSnapshotsResponse, unmarshalListUsersResponse, marshalCreateUserRequest, unmarshalUser, marshalUpdateUserRequest, marshalSetUserRoleRequest, unmarshalListDatabasesResponse, marshalCreateEndpointRequest, unmarshalEndpoint, unmarshalListMaintenancesResponse, unmarshalMaintenance } from "./marshalling.gen.js";
4
- const jsonContentHeaders = {
5
- "Content-Type": "application/json; charset=utf-8"
6
- };
7
- class API extends API$1 {
8
- /**
9
- * Locality of this API.
10
- * type {'zone','region','global','unspecified'}
11
- */
12
- static LOCALITY = toApiLocality({
13
- regions: [
14
- "fr-par"
15
- ]
16
- });
17
- pageOfListNodeTypes = (request = {}) => this.client.fetch(
18
- {
19
- method: "GET",
20
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/node-types`,
21
- urlParams: urlParams(
22
- ["include_disabled", request.includeDisabled],
23
- ["page", request.page],
24
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize]
25
- )
26
- },
27
- unmarshalListNodeTypesResponse
28
- );
29
- /**
30
- * List available node types.
31
- *
32
- * @param request - The request {@link ListNodeTypesRequest}
33
- * @returns A Promise of ListNodeTypesResponse
34
- */
35
- listNodeTypes = (request = {}) => enrichForPagination("nodeTypes", this.pageOfListNodeTypes, request);
36
- pageOfListVersions = (request = {}) => this.client.fetch(
37
- {
38
- method: "GET",
39
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/versions`,
40
- urlParams: urlParams(
41
- ["page", request.page],
42
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
43
- ["version", request.version]
44
- )
45
- },
46
- unmarshalListVersionsResponse
47
- );
48
- /**
49
- * List available MongoDB® major versions.
50
- *
51
- * @param request - The request {@link ListVersionsRequest}
52
- * @returns A Promise of ListVersionsResponse
53
- */
54
- listVersions = (request = {}) => enrichForPagination("versions", this.pageOfListVersions, request);
55
- pageOfListInstances = (request = {}) => this.client.fetch(
56
- {
57
- method: "GET",
58
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances`,
59
- urlParams: urlParams(
60
- ["name", request.name],
61
- ["order_by", request.orderBy],
62
- ["organization_id", request.organizationId],
63
- ["page", request.page],
64
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
65
- ["project_id", request.projectId],
66
- ["tags", request.tags]
67
- )
68
- },
69
- unmarshalListInstancesResponse
70
- );
71
- /**
72
- * List MongoDB® Database Instances. List all MongoDB® Database Instances in the specified region. By default, the MongoDB® Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter.
73
- *
74
- * @param request - The request {@link ListInstancesRequest}
75
- * @returns A Promise of ListInstancesResponse
76
- */
77
- listInstances = (request = {}) => enrichForPagination("instances", this.pageOfListInstances, request);
78
- /**
79
- * Get a MongoDB® Database Instance. Retrieve information about a given MongoDB® Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object.
80
- *
81
- * @param request - The request {@link GetInstanceRequest}
82
- * @returns A Promise of Instance
83
- */
84
- getInstance = (request) => this.client.fetch(
85
- {
86
- method: "GET",
87
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
88
- },
89
- unmarshalInstance
90
- );
91
- /**
92
- * Waits for {@link Instance} to be in a final state.
93
- *
94
- * @param request - The request {@link GetInstanceRequest}
95
- * @param options - The waiting options
96
- * @returns A Promise of Instance
97
- */
98
- waitForInstance = (request, options) => waitForResource(
99
- options?.stop ?? ((res) => Promise.resolve(!INSTANCE_TRANSIENT_STATUSES.includes(res.status))),
100
- this.getInstance,
101
- request,
102
- options
103
- );
104
- /**
105
- * Create a MongoDB® Database Instance. Create a new MongoDB® Database Instance.
106
- *
107
- * @param request - The request {@link CreateInstanceRequest}
108
- * @returns A Promise of Instance
109
- */
110
- createInstance = (request) => this.client.fetch(
111
- {
112
- body: JSON.stringify(
113
- marshalCreateInstanceRequest(request, this.client.settings)
114
- ),
115
- headers: jsonContentHeaders,
116
- method: "POST",
117
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances`
118
- },
119
- unmarshalInstance
120
- );
121
- /**
122
- * Update a MongoDB® Database Instance. Update the parameters of a MongoDB® Database Instance.
123
- *
124
- * @param request - The request {@link UpdateInstanceRequest}
125
- * @returns A Promise of Instance
126
- */
127
- updateInstance = (request) => this.client.fetch(
128
- {
129
- body: JSON.stringify(
130
- marshalUpdateInstanceRequest(request, this.client.settings)
131
- ),
132
- headers: jsonContentHeaders,
133
- method: "PATCH",
134
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
135
- },
136
- unmarshalInstance
137
- );
138
- /**
139
- * Delete a MongoDB® Database Instance. Delete a given MongoDB® Database Instance, specified by the `region` and `instance_id` parameters. Deleting a MongoDB® Database Instance is permanent, and cannot be undone. Note that upon deletion all your data will be lost.
140
- *
141
- * @param request - The request {@link DeleteInstanceRequest}
142
- * @returns A Promise of Instance
143
- */
144
- deleteInstance = (request) => this.client.fetch(
145
- {
146
- method: "DELETE",
147
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
148
- },
149
- unmarshalInstance
150
- );
151
- /**
152
- * Upgrade a Database Instance. Upgrade your current Database Instance specifications like volume size.
153
- *
154
- * @param request - The request {@link UpgradeInstanceRequest}
155
- * @returns A Promise of Instance
156
- */
157
- upgradeInstance = (request) => this.client.fetch(
158
- {
159
- body: JSON.stringify(
160
- marshalUpgradeInstanceRequest(request, this.client.settings)
161
- ),
162
- headers: jsonContentHeaders,
163
- method: "POST",
164
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/upgrade`
165
- },
166
- unmarshalInstance
167
- );
168
- /**
169
- * Get the certificate of a Database Instance. Retrieve the certificate of a given Database Instance, specified by the `instance_id` parameter.
170
- *
171
- * @param request - The request {@link GetInstanceCertificateRequest}
172
- * @returns A Promise of Blob
173
- */
174
- getInstanceCertificate = (request) => this.client.fetch(
175
- {
176
- method: "GET",
177
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/certificate`,
178
- urlParams: urlParams(
179
- ["dl", 1]
180
- ),
181
- responseType: "blob"
182
- }
183
- );
184
- /**
185
- * Create a Database Instance snapshot. Create a new snapshot of a Database Instance. You must define the `name` and `instance_id` parameters in the request.
186
- *
187
- * @param request - The request {@link CreateSnapshotRequest}
188
- * @returns A Promise of Snapshot
189
- */
190
- createSnapshot = (request) => this.client.fetch(
191
- {
192
- body: JSON.stringify(
193
- marshalCreateSnapshotRequest(request, this.client.settings)
194
- ),
195
- headers: jsonContentHeaders,
196
- method: "POST",
197
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots`
198
- },
199
- unmarshalSnapshot
200
- );
201
- /**
202
- * Get a Database Instance snapshot. Retrieve information about a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to retrieve.
203
- *
204
- * @param request - The request {@link GetSnapshotRequest}
205
- * @returns A Promise of Snapshot
206
- */
207
- getSnapshot = (request) => this.client.fetch(
208
- {
209
- method: "GET",
210
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
211
- },
212
- unmarshalSnapshot
213
- );
214
- /**
215
- * Waits for {@link Snapshot} to be in a final state.
216
- *
217
- * @param request - The request {@link GetSnapshotRequest}
218
- * @param options - The waiting options
219
- * @returns A Promise of Snapshot
220
- */
221
- waitForSnapshot = (request, options) => waitForResource(
222
- options?.stop ?? ((res) => Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))),
223
- this.getSnapshot,
224
- request,
225
- options
226
- );
227
- /**
228
- * Update a Database Instance snapshot. Update the parameters of a snapshot of a Database Instance. You can update the `name` and `expires_at` parameters.
229
- *
230
- * @param request - The request {@link UpdateSnapshotRequest}
231
- * @returns A Promise of Snapshot
232
- */
233
- updateSnapshot = (request) => this.client.fetch(
234
- {
235
- body: JSON.stringify(
236
- marshalUpdateSnapshotRequest(request, this.client.settings)
237
- ),
238
- headers: jsonContentHeaders,
239
- method: "PATCH",
240
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
241
- },
242
- unmarshalSnapshot
243
- );
244
- /**
245
- * Restore a Database Instance snapshot. Restore a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to restore, the `instance_name` of the new Database Instance, `node_type` of the new Database Instance and `node_amount` of the new Database Instance.
246
- *
247
- * @param request - The request {@link RestoreSnapshotRequest}
248
- * @returns A Promise of Instance
249
- */
250
- restoreSnapshot = (request) => this.client.fetch(
251
- {
252
- body: JSON.stringify(
253
- marshalRestoreSnapshotRequest(request, this.client.settings)
254
- ),
255
- headers: jsonContentHeaders,
256
- method: "POST",
257
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}/restore`
258
- },
259
- unmarshalInstance
260
- );
261
- pageOfListSnapshots = (request = {}) => this.client.fetch(
262
- {
263
- method: "GET",
264
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots`,
265
- urlParams: urlParams(
266
- ["instance_id", request.instanceId],
267
- ["name", request.name],
268
- ["order_by", request.orderBy],
269
- ["organization_id", request.organizationId],
270
- ["page", request.page],
271
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
272
- ["project_id", request.projectId]
273
- )
274
- },
275
- unmarshalListSnapshotsResponse
276
- );
277
- /**
278
- * List snapshots. List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field.
279
- *
280
- * @param request - The request {@link ListSnapshotsRequest}
281
- * @returns A Promise of ListSnapshotsResponse
282
- */
283
- listSnapshots = (request = {}) => enrichForPagination("snapshots", this.pageOfListSnapshots, request);
284
- /**
285
- * Delete a Database Instance snapshot. Delete a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to delete.
286
- *
287
- * @param request - The request {@link DeleteSnapshotRequest}
288
- * @returns A Promise of Snapshot
289
- */
290
- deleteSnapshot = (request) => this.client.fetch(
291
- {
292
- method: "DELETE",
293
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
294
- },
295
- unmarshalSnapshot
296
- );
297
- pageOfListUsers = (request) => this.client.fetch(
298
- {
299
- method: "GET",
300
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users`,
301
- urlParams: urlParams(
302
- ["name", request.name],
303
- ["order_by", request.orderBy],
304
- ["page", request.page],
305
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize]
306
- )
307
- },
308
- unmarshalListUsersResponse
309
- );
310
- /**
311
- * List users of a Database Instance. List all users of a given Database Instance.
312
- *
313
- * @param request - The request {@link ListUsersRequest}
314
- * @returns A Promise of ListUsersResponse
315
- */
316
- listUsers = (request) => enrichForPagination("users", this.pageOfListUsers, request);
317
- /**
318
- * Create an user on a Database Instance. Create an user on a Database Instance. You must define the `name`, `password` of the user and `instance_id` parameters in the request.
319
- *
320
- * @param request - The request {@link CreateUserRequest}
321
- * @returns A Promise of User
322
- */
323
- createUser = (request) => this.client.fetch(
324
- {
325
- body: JSON.stringify(
326
- marshalCreateUserRequest(request, this.client.settings)
327
- ),
328
- headers: jsonContentHeaders,
329
- method: "POST",
330
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users`
331
- },
332
- unmarshalUser
333
- );
334
- /**
335
- * Update a user on a Database Instance. Update the parameters of a user on a Database Instance. You can update the `password` parameter, but you cannot change the name of the user.
336
- *
337
- * @param request - The request {@link UpdateUserRequest}
338
- * @returns A Promise of User
339
- */
340
- updateUser = (request) => this.client.fetch(
341
- {
342
- body: JSON.stringify(
343
- marshalUpdateUserRequest(request, this.client.settings)
344
- ),
345
- headers: jsonContentHeaders,
346
- method: "PATCH",
347
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users/${validatePathParam("name", request.name)}`
348
- },
349
- unmarshalUser
350
- );
351
- /**
352
- * Delete a user on a Database Instance. Delete an existing user on a Database Instance.
353
- *
354
- * @param request - The request {@link DeleteUserRequest}
355
- */
356
- deleteUser = (request) => this.client.fetch(
357
- {
358
- method: "DELETE",
359
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users/${validatePathParam("name", request.name)}`
360
- }
361
- );
362
- /**
363
- * Apply user roles. Apply preset roles for a user in a Database Instance.
364
- *
365
- * @param request - The request {@link SetUserRoleRequest}
366
- * @returns A Promise of User
367
- */
368
- setUserRole = (request) => this.client.fetch(
369
- {
370
- body: JSON.stringify(
371
- marshalSetUserRoleRequest(request, this.client.settings)
372
- ),
373
- headers: jsonContentHeaders,
374
- method: "PUT",
375
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/set-user-roles`
376
- },
377
- unmarshalUser
378
- );
379
- pageOfListDatabases = (request) => this.client.fetch(
380
- {
381
- method: "GET",
382
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/databases`,
383
- urlParams: urlParams(
384
- ["order_by", request.orderBy],
385
- ["page", request.page],
386
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize]
387
- )
388
- },
389
- unmarshalListDatabasesResponse
390
- );
391
- /**
392
- * List databases in a Database Instance. List all databases of a given Database Instance.
393
- *
394
- * @param request - The request {@link ListDatabasesRequest}
395
- * @returns A Promise of ListDatabasesResponse
396
- */
397
- listDatabases = (request) => enrichForPagination("databases", this.pageOfListDatabases, request);
398
- /**
399
- * Delete a Database Instance endpoint. Delete the endpoint of a Database Instance. You must specify the `endpoint_id` parameter of the endpoint you want to delete. Note that you might need to update any environment configurations that point to the deleted endpoint.
400
- *
401
- * @param request - The request {@link DeleteEndpointRequest}
402
- */
403
- deleteEndpoint = (request) => this.client.fetch(
404
- {
405
- method: "DELETE",
406
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam("endpointId", request.endpointId)}`
407
- }
408
- );
409
- /**
410
- * Create a new Instance endpoint. Create a new endpoint for a MongoDB® Database Instance. You can add `public_network` or `private_network` specifications to the body of the request.
411
- *
412
- * @param request - The request {@link CreateEndpointRequest}
413
- * @returns A Promise of Endpoint
414
- */
415
- createEndpoint = (request) => this.client.fetch(
416
- {
417
- body: JSON.stringify(
418
- marshalCreateEndpointRequest(request, this.client.settings)
419
- ),
420
- headers: jsonContentHeaders,
421
- method: "POST",
422
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints`
423
- },
424
- unmarshalEndpoint
425
- );
426
- pageOfListMaintenances = (request) => this.client.fetch(
427
- {
428
- method: "GET",
429
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/maintenances`,
430
- urlParams: urlParams(
431
- ["instance_id", request.instanceId],
432
- ["order_by", request.orderBy],
433
- ["page", request.page],
434
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize]
435
- )
436
- },
437
- unmarshalListMaintenancesResponse
438
- );
439
- /**
440
- * List all the maintenances of a MongoDB® Database Instance.. List all the maintenances of a MongoDB® Database Instance.
441
- *
442
- * @param request - The request {@link ListMaintenancesRequest}
443
- * @returns A Promise of ListMaintenancesResponse
444
- */
445
- listMaintenances = (request) => enrichForPagination("maintenances", this.pageOfListMaintenances, request);
446
- /**
447
- * Get a maintenance of a MongoDB® Database Instance.. Get a maintenance of a MongoDB® Database Instance.
448
- *
449
- * @param request - The request {@link GetMaintenanceRequest}
450
- * @returns A Promise of Maintenance
451
- */
452
- getMaintenance = (request) => this.client.fetch(
453
- {
454
- method: "GET",
455
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/maintenances/${validatePathParam("maintenanceId", request.maintenanceId)}`
456
- },
457
- unmarshalMaintenance
458
- );
459
- /**
460
- * Waits for {@link Maintenance} to be in a final state.
461
- *
462
- * @param request - The request {@link GetMaintenanceRequest}
463
- * @param options - The waiting options
464
- * @returns A Promise of Maintenance
465
- */
466
- waitForMaintenance = (request, options) => waitForResource(
467
- options?.stop ?? ((res) => Promise.resolve(!MAINTENANCE_TRANSIENT_STATUSES.includes(res.status))),
468
- this.getMaintenance,
469
- request,
470
- options
471
- );
472
- /**
473
- * Apply a maintenance of a MongoDB® Database Instance.. Apply a maintenance of a MongoDB® Database Instance.
474
- *
475
- * @param request - The request {@link ApplyMaintenanceRequest}
476
- * @returns A Promise of Maintenance
477
- */
478
- applyMaintenance = (request) => this.client.fetch(
479
- {
480
- body: "{}",
481
- headers: jsonContentHeaders,
482
- method: "POST",
483
- path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/maintenances/${validatePathParam("maintenanceId", request.maintenanceId)}/apply`
484
- },
485
- unmarshalMaintenance
486
- );
487
- }
488
- export {
489
- API
1
+ import { INSTANCE_TRANSIENT_STATUSES, MAINTENANCE_TRANSIENT_STATUSES, SNAPSHOT_TRANSIENT_STATUSES } from "./content.gen.js";
2
+ import { marshalCreateEndpointRequest, marshalCreateInstanceRequest, marshalCreateSnapshotRequest, marshalCreateUserRequest, marshalRestoreSnapshotRequest, marshalSetUserRoleRequest, marshalUpdateInstanceRequest, marshalUpdateSnapshotRequest, marshalUpdateUserRequest, marshalUpgradeInstanceRequest, unmarshalEndpoint, unmarshalInstance, unmarshalListDatabasesResponse, unmarshalListInstancesResponse, unmarshalListMaintenancesResponse, unmarshalListNodeTypesResponse, unmarshalListSnapshotsResponse, unmarshalListUsersResponse, unmarshalListVersionsResponse, unmarshalMaintenance, unmarshalSnapshot, unmarshalUser } from "./marshalling.gen.js";
3
+ import { API, enrichForPagination, toApiLocality, urlParams, validatePathParam, waitForResource } from "@scaleway/sdk-client";
4
+ var jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
5
+ /**
6
+ * Managed MongoDB®.
7
+
8
+ This API allows you to manage your Managed Databases for MongoDB®.
9
+ */
10
+ var API$1 = class extends API {
11
+ /**
12
+ * Locality of this API.
13
+ * type ∈ {'zone','region','global','unspecified'}
14
+ */
15
+ static LOCALITY = toApiLocality({ regions: ["fr-par"] });
16
+ pageOfListNodeTypes = (request = {}) => this.client.fetch({
17
+ method: "GET",
18
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/node-types`,
19
+ urlParams: urlParams(["include_disabled", request.includeDisabled], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
20
+ }, unmarshalListNodeTypesResponse);
21
+ /**
22
+ * List available node types.
23
+ *
24
+ * @param request - The request {@link ListNodeTypesRequest}
25
+ * @returns A Promise of ListNodeTypesResponse
26
+ */
27
+ listNodeTypes = (request = {}) => enrichForPagination("nodeTypes", this.pageOfListNodeTypes, request);
28
+ pageOfListVersions = (request = {}) => this.client.fetch({
29
+ method: "GET",
30
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/versions`,
31
+ urlParams: urlParams(["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["version", request.version])
32
+ }, unmarshalListVersionsResponse);
33
+ /**
34
+ * List available MongoDB® major versions.
35
+ *
36
+ * @param request - The request {@link ListVersionsRequest}
37
+ * @returns A Promise of ListVersionsResponse
38
+ */
39
+ listVersions = (request = {}) => enrichForPagination("versions", this.pageOfListVersions, request);
40
+ pageOfListInstances = (request = {}) => this.client.fetch({
41
+ method: "GET",
42
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances`,
43
+ urlParams: urlParams(["name", request.name], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId], ["tags", request.tags])
44
+ }, unmarshalListInstancesResponse);
45
+ /**
46
+ * List MongoDB® Database Instances. List all MongoDB® Database Instances in the specified region. By default, the MongoDB® Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter.
47
+ *
48
+ * @param request - The request {@link ListInstancesRequest}
49
+ * @returns A Promise of ListInstancesResponse
50
+ */
51
+ listInstances = (request = {}) => enrichForPagination("instances", this.pageOfListInstances, request);
52
+ /**
53
+ * Get a MongoDB® Database Instance. Retrieve information about a given MongoDB® Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object.
54
+ *
55
+ * @param request - The request {@link GetInstanceRequest}
56
+ * @returns A Promise of Instance
57
+ */
58
+ getInstance = (request) => this.client.fetch({
59
+ method: "GET",
60
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
61
+ }, unmarshalInstance);
62
+ /**
63
+ * Waits for {@link Instance} to be in a final state.
64
+ *
65
+ * @param request - The request {@link GetInstanceRequest}
66
+ * @param options - The waiting options
67
+ * @returns A Promise of Instance
68
+ */
69
+ waitForInstance = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!INSTANCE_TRANSIENT_STATUSES.includes(res.status))), this.getInstance, request, options);
70
+ /**
71
+ * Create a MongoDB® Database Instance. Create a new MongoDB® Database Instance.
72
+ *
73
+ * @param request - The request {@link CreateInstanceRequest}
74
+ * @returns A Promise of Instance
75
+ */
76
+ createInstance = (request) => this.client.fetch({
77
+ body: JSON.stringify(marshalCreateInstanceRequest(request, this.client.settings)),
78
+ headers: jsonContentHeaders,
79
+ method: "POST",
80
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances`
81
+ }, unmarshalInstance);
82
+ /**
83
+ * Update a MongoDB® Database Instance. Update the parameters of a MongoDB® Database Instance.
84
+ *
85
+ * @param request - The request {@link UpdateInstanceRequest}
86
+ * @returns A Promise of Instance
87
+ */
88
+ updateInstance = (request) => this.client.fetch({
89
+ body: JSON.stringify(marshalUpdateInstanceRequest(request, this.client.settings)),
90
+ headers: jsonContentHeaders,
91
+ method: "PATCH",
92
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
93
+ }, unmarshalInstance);
94
+ /**
95
+ * Delete a MongoDB® Database Instance. Delete a given MongoDB® Database Instance, specified by the `region` and `instance_id` parameters. Deleting a MongoDB® Database Instance is permanent, and cannot be undone. Note that upon deletion all your data will be lost.
96
+ *
97
+ * @param request - The request {@link DeleteInstanceRequest}
98
+ * @returns A Promise of Instance
99
+ */
100
+ deleteInstance = (request) => this.client.fetch({
101
+ method: "DELETE",
102
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
103
+ }, unmarshalInstance);
104
+ /**
105
+ * Upgrade a Database Instance. Upgrade your current Database Instance specifications like volume size.
106
+ *
107
+ * @param request - The request {@link UpgradeInstanceRequest}
108
+ * @returns A Promise of Instance
109
+ */
110
+ upgradeInstance = (request) => this.client.fetch({
111
+ body: JSON.stringify(marshalUpgradeInstanceRequest(request, this.client.settings)),
112
+ headers: jsonContentHeaders,
113
+ method: "POST",
114
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/upgrade`
115
+ }, unmarshalInstance);
116
+ /**
117
+ * Get the certificate of a Database Instance. Retrieve the certificate of a given Database Instance, specified by the `instance_id` parameter.
118
+ *
119
+ * @param request - The request {@link GetInstanceCertificateRequest}
120
+ * @returns A Promise of Blob
121
+ */
122
+ getInstanceCertificate = (request) => this.client.fetch({
123
+ method: "GET",
124
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/certificate`,
125
+ urlParams: urlParams(["dl", 1]),
126
+ responseType: "blob"
127
+ });
128
+ /**
129
+ * Create a Database Instance snapshot. Create a new snapshot of a Database Instance. You must define the `name` and `instance_id` parameters in the request.
130
+ *
131
+ * @param request - The request {@link CreateSnapshotRequest}
132
+ * @returns A Promise of Snapshot
133
+ */
134
+ createSnapshot = (request) => this.client.fetch({
135
+ body: JSON.stringify(marshalCreateSnapshotRequest(request, this.client.settings)),
136
+ headers: jsonContentHeaders,
137
+ method: "POST",
138
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots`
139
+ }, unmarshalSnapshot);
140
+ /**
141
+ * Get a Database Instance snapshot. Retrieve information about a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to retrieve.
142
+ *
143
+ * @param request - The request {@link GetSnapshotRequest}
144
+ * @returns A Promise of Snapshot
145
+ */
146
+ getSnapshot = (request) => this.client.fetch({
147
+ method: "GET",
148
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
149
+ }, unmarshalSnapshot);
150
+ /**
151
+ * Waits for {@link Snapshot} to be in a final state.
152
+ *
153
+ * @param request - The request {@link GetSnapshotRequest}
154
+ * @param options - The waiting options
155
+ * @returns A Promise of Snapshot
156
+ */
157
+ waitForSnapshot = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!SNAPSHOT_TRANSIENT_STATUSES.includes(res.status))), this.getSnapshot, request, options);
158
+ /**
159
+ * Update a Database Instance snapshot. Update the parameters of a snapshot of a Database Instance. You can update the `name` and `expires_at` parameters.
160
+ *
161
+ * @param request - The request {@link UpdateSnapshotRequest}
162
+ * @returns A Promise of Snapshot
163
+ */
164
+ updateSnapshot = (request) => this.client.fetch({
165
+ body: JSON.stringify(marshalUpdateSnapshotRequest(request, this.client.settings)),
166
+ headers: jsonContentHeaders,
167
+ method: "PATCH",
168
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
169
+ }, unmarshalSnapshot);
170
+ /**
171
+ * Restore a Database Instance snapshot. Restore a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to restore, the `instance_name` of the new Database Instance, `node_type` of the new Database Instance and `node_amount` of the new Database Instance.
172
+ *
173
+ * @param request - The request {@link RestoreSnapshotRequest}
174
+ * @returns A Promise of Instance
175
+ */
176
+ restoreSnapshot = (request) => this.client.fetch({
177
+ body: JSON.stringify(marshalRestoreSnapshotRequest(request, this.client.settings)),
178
+ headers: jsonContentHeaders,
179
+ method: "POST",
180
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}/restore`
181
+ }, unmarshalInstance);
182
+ pageOfListSnapshots = (request = {}) => this.client.fetch({
183
+ method: "GET",
184
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots`,
185
+ urlParams: urlParams(["instance_id", request.instanceId], ["name", request.name], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId])
186
+ }, unmarshalListSnapshotsResponse);
187
+ /**
188
+ * List snapshots. List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field.
189
+ *
190
+ * @param request - The request {@link ListSnapshotsRequest}
191
+ * @returns A Promise of ListSnapshotsResponse
192
+ */
193
+ listSnapshots = (request = {}) => enrichForPagination("snapshots", this.pageOfListSnapshots, request);
194
+ /**
195
+ * Delete a Database Instance snapshot. Delete a given snapshot of a Database Instance. You must specify, in the endpoint, the `snapshot_id` parameter of the snapshot you want to delete.
196
+ *
197
+ * @param request - The request {@link DeleteSnapshotRequest}
198
+ * @returns A Promise of Snapshot
199
+ */
200
+ deleteSnapshot = (request) => this.client.fetch({
201
+ method: "DELETE",
202
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
203
+ }, unmarshalSnapshot);
204
+ pageOfListUsers = (request) => this.client.fetch({
205
+ method: "GET",
206
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users`,
207
+ urlParams: urlParams(["name", request.name], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
208
+ }, unmarshalListUsersResponse);
209
+ /**
210
+ * List users of a Database Instance. List all users of a given Database Instance.
211
+ *
212
+ * @param request - The request {@link ListUsersRequest}
213
+ * @returns A Promise of ListUsersResponse
214
+ */
215
+ listUsers = (request) => enrichForPagination("users", this.pageOfListUsers, request);
216
+ /**
217
+ * Create an user on a Database Instance. Create an user on a Database Instance. You must define the `name`, `password` of the user and `instance_id` parameters in the request.
218
+ *
219
+ * @param request - The request {@link CreateUserRequest}
220
+ * @returns A Promise of User
221
+ */
222
+ createUser = (request) => this.client.fetch({
223
+ body: JSON.stringify(marshalCreateUserRequest(request, this.client.settings)),
224
+ headers: jsonContentHeaders,
225
+ method: "POST",
226
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users`
227
+ }, unmarshalUser);
228
+ /**
229
+ * Update a user on a Database Instance. Update the parameters of a user on a Database Instance. You can update the `password` parameter, but you cannot change the name of the user.
230
+ *
231
+ * @param request - The request {@link UpdateUserRequest}
232
+ * @returns A Promise of User
233
+ */
234
+ updateUser = (request) => this.client.fetch({
235
+ body: JSON.stringify(marshalUpdateUserRequest(request, this.client.settings)),
236
+ headers: jsonContentHeaders,
237
+ method: "PATCH",
238
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users/${validatePathParam("name", request.name)}`
239
+ }, unmarshalUser);
240
+ /**
241
+ * Delete a user on a Database Instance. Delete an existing user on a Database Instance.
242
+ *
243
+ * @param request - The request {@link DeleteUserRequest}
244
+ */
245
+ deleteUser = (request) => this.client.fetch({
246
+ method: "DELETE",
247
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users/${validatePathParam("name", request.name)}`
248
+ });
249
+ /**
250
+ * Apply user roles. Apply preset roles for a user in a Database Instance.
251
+ *
252
+ * @param request - The request {@link SetUserRoleRequest}
253
+ * @returns A Promise of User
254
+ */
255
+ setUserRole = (request) => this.client.fetch({
256
+ body: JSON.stringify(marshalSetUserRoleRequest(request, this.client.settings)),
257
+ headers: jsonContentHeaders,
258
+ method: "PUT",
259
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/set-user-roles`
260
+ }, unmarshalUser);
261
+ pageOfListDatabases = (request) => this.client.fetch({
262
+ method: "GET",
263
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/databases`,
264
+ urlParams: urlParams(["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
265
+ }, unmarshalListDatabasesResponse);
266
+ /**
267
+ * List databases in a Database Instance. List all databases of a given Database Instance.
268
+ *
269
+ * @param request - The request {@link ListDatabasesRequest}
270
+ * @returns A Promise of ListDatabasesResponse
271
+ */
272
+ listDatabases = (request) => enrichForPagination("databases", this.pageOfListDatabases, request);
273
+ /**
274
+ * Delete a Database Instance endpoint. Delete the endpoint of a Database Instance. You must specify the `endpoint_id` parameter of the endpoint you want to delete. Note that you might need to update any environment configurations that point to the deleted endpoint.
275
+ *
276
+ * @param request - The request {@link DeleteEndpointRequest}
277
+ */
278
+ deleteEndpoint = (request) => this.client.fetch({
279
+ method: "DELETE",
280
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam("endpointId", request.endpointId)}`
281
+ });
282
+ /**
283
+ * Create a new Instance endpoint. Create a new endpoint for a MongoDB® Database Instance. You can add `public_network` or `private_network` specifications to the body of the request.
284
+ *
285
+ * @param request - The request {@link CreateEndpointRequest}
286
+ * @returns A Promise of Endpoint
287
+ */
288
+ createEndpoint = (request) => this.client.fetch({
289
+ body: JSON.stringify(marshalCreateEndpointRequest(request, this.client.settings)),
290
+ headers: jsonContentHeaders,
291
+ method: "POST",
292
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints`
293
+ }, unmarshalEndpoint);
294
+ pageOfListMaintenances = (request) => this.client.fetch({
295
+ method: "GET",
296
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/maintenances`,
297
+ urlParams: urlParams(["instance_id", request.instanceId], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
298
+ }, unmarshalListMaintenancesResponse);
299
+ /**
300
+ * List all the maintenances of a MongoDB® Database Instance.. List all the maintenances of a MongoDB® Database Instance.
301
+ *
302
+ * @param request - The request {@link ListMaintenancesRequest}
303
+ * @returns A Promise of ListMaintenancesResponse
304
+ */
305
+ listMaintenances = (request) => enrichForPagination("maintenances", this.pageOfListMaintenances, request);
306
+ /**
307
+ * Get a maintenance of a MongoDB® Database Instance.. Get a maintenance of a MongoDB® Database Instance.
308
+ *
309
+ * @param request - The request {@link GetMaintenanceRequest}
310
+ * @returns A Promise of Maintenance
311
+ */
312
+ getMaintenance = (request) => this.client.fetch({
313
+ method: "GET",
314
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/maintenances/${validatePathParam("maintenanceId", request.maintenanceId)}`
315
+ }, unmarshalMaintenance);
316
+ /**
317
+ * Waits for {@link Maintenance} to be in a final state.
318
+ *
319
+ * @param request - The request {@link GetMaintenanceRequest}
320
+ * @param options - The waiting options
321
+ * @returns A Promise of Maintenance
322
+ */
323
+ waitForMaintenance = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!MAINTENANCE_TRANSIENT_STATUSES.includes(res.status))), this.getMaintenance, request, options);
324
+ /**
325
+ * Apply a maintenance of a MongoDB® Database Instance.. Apply a maintenance of a MongoDB® Database Instance.
326
+ *
327
+ * @param request - The request {@link ApplyMaintenanceRequest}
328
+ * @returns A Promise of Maintenance
329
+ */
330
+ applyMaintenance = (request) => this.client.fetch({
331
+ body: "{}",
332
+ headers: jsonContentHeaders,
333
+ method: "POST",
334
+ path: `/mongodb/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/maintenances/${validatePathParam("maintenanceId", request.maintenanceId)}/apply`
335
+ }, unmarshalMaintenance);
490
336
  };
337
+ export { API$1 as API };