@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.
@@ -0,0 +1,194 @@
1
+ import { API as ParentAPI } from '@scaleway/sdk-client';
2
+ import type { Region as ScwRegion, WaitForOptions } from '@scaleway/sdk-client';
3
+ import type { CreateEndpointRequest, CreateInstanceRequest, CreateSnapshotRequest, CreateUserRequest, DeleteEndpointRequest, DeleteInstanceRequest, DeleteSnapshotRequest, DeleteUserRequest, Endpoint, GetInstanceCertificateRequest, GetInstanceRequest, GetSnapshotRequest, Instance, ListInstancesRequest, ListInstancesResponse, ListNodeTypesRequest, ListNodeTypesResponse, ListSnapshotsRequest, ListSnapshotsResponse, ListUsersRequest, ListUsersResponse, ListVersionsRequest, ListVersionsResponse, RestoreSnapshotRequest, SetUserRoleRequest, Snapshot, UpdateInstanceRequest, UpdateSnapshotRequest, UpdateUserRequest, UpgradeInstanceRequest, User } from './types.gen';
4
+ /**
5
+ * Managed MongoDB®.
6
+
7
+ This API allows you to manage your Managed Databases for MongoDB®.
8
+ */
9
+ export declare class API extends ParentAPI {
10
+ /** Lists the available regions of the API. */
11
+ static readonly LOCALITIES: ScwRegion[];
12
+ protected pageOfListNodeTypes: (request?: Readonly<ListNodeTypesRequest>) => Promise<ListNodeTypesResponse>;
13
+ /**
14
+ * List available node types.
15
+ *
16
+ * @param request - The request {@link ListNodeTypesRequest}
17
+ * @returns A Promise of ListNodeTypesResponse
18
+ */
19
+ listNodeTypes: (request?: Readonly<ListNodeTypesRequest>) => Promise<ListNodeTypesResponse> & {
20
+ all: () => Promise<import("./types.gen").NodeType[]>;
21
+ [Symbol.asyncIterator]: () => AsyncGenerator<import("./types.gen").NodeType[], void, void>;
22
+ };
23
+ protected pageOfListVersions: (request?: Readonly<ListVersionsRequest>) => Promise<ListVersionsResponse>;
24
+ /**
25
+ * List available MongoDB® versions.
26
+ *
27
+ * @param request - The request {@link ListVersionsRequest}
28
+ * @returns A Promise of ListVersionsResponse
29
+ */
30
+ listVersions: (request?: Readonly<ListVersionsRequest>) => Promise<ListVersionsResponse> & {
31
+ all: () => Promise<import("./types.gen").Version[]>;
32
+ [Symbol.asyncIterator]: () => AsyncGenerator<import("./types.gen").Version[], void, void>;
33
+ };
34
+ protected pageOfListInstances: (request?: Readonly<ListInstancesRequest>) => Promise<ListInstancesResponse>;
35
+ /**
36
+ * 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.
37
+ *
38
+ * @param request - The request {@link ListInstancesRequest}
39
+ * @returns A Promise of ListInstancesResponse
40
+ */
41
+ listInstances: (request?: Readonly<ListInstancesRequest>) => Promise<ListInstancesResponse> & {
42
+ all: () => Promise<Instance[]>;
43
+ [Symbol.asyncIterator]: () => AsyncGenerator<Instance[], void, void>;
44
+ };
45
+ /**
46
+ * 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.
47
+ *
48
+ * @param request - The request {@link GetInstanceRequest}
49
+ * @returns A Promise of Instance
50
+ */
51
+ getInstance: (request: Readonly<GetInstanceRequest>) => Promise<Instance>;
52
+ /**
53
+ * Waits for {@link Instance} to be in a final state.
54
+ *
55
+ * @param request - The request {@link GetInstanceRequest}
56
+ * @param options - The waiting options
57
+ * @returns A Promise of Instance
58
+ */
59
+ waitForInstance: (request: Readonly<GetInstanceRequest>, options?: Readonly<WaitForOptions<Instance>>) => Promise<Instance>;
60
+ /**
61
+ * Create a MongoDB® Database Instance. Create a new MongoDB® Database Instance.
62
+ *
63
+ * @param request - The request {@link CreateInstanceRequest}
64
+ * @returns A Promise of Instance
65
+ */
66
+ createInstance: (request: Readonly<CreateInstanceRequest>) => Promise<Instance>;
67
+ /**
68
+ * Update a MongoDB® Database Instance. Update the parameters of a MongoDB® Database Instance.
69
+ *
70
+ * @param request - The request {@link UpdateInstanceRequest}
71
+ * @returns A Promise of Instance
72
+ */
73
+ updateInstance: (request: Readonly<UpdateInstanceRequest>) => Promise<Instance>;
74
+ /**
75
+ * 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.
76
+ *
77
+ * @param request - The request {@link DeleteInstanceRequest}
78
+ * @returns A Promise of Instance
79
+ */
80
+ deleteInstance: (request: Readonly<DeleteInstanceRequest>) => Promise<Instance>;
81
+ /**
82
+ * Upgrade a Database Instance. Upgrade your current Database Instance specifications like volume size.
83
+ *
84
+ * @param request - The request {@link UpgradeInstanceRequest}
85
+ * @returns A Promise of Instance
86
+ */
87
+ upgradeInstance: (request: Readonly<UpgradeInstanceRequest>) => Promise<Instance>;
88
+ /**
89
+ * Get the certificate of a Database Instance. Retrieve the certificate of a given Database Instance, specified by the `instance_id` parameter.
90
+ *
91
+ * @param request - The request {@link GetInstanceCertificateRequest}
92
+ * @returns A Promise of Blob
93
+ */
94
+ getInstanceCertificate: (request: Readonly<GetInstanceCertificateRequest>) => Promise<Blob>;
95
+ /**
96
+ * 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.
97
+ *
98
+ * @param request - The request {@link CreateSnapshotRequest}
99
+ * @returns A Promise of Snapshot
100
+ */
101
+ createSnapshot: (request: Readonly<CreateSnapshotRequest>) => Promise<Snapshot>;
102
+ /**
103
+ * 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.
104
+ *
105
+ * @param request - The request {@link GetSnapshotRequest}
106
+ * @returns A Promise of Snapshot
107
+ */
108
+ getSnapshot: (request: Readonly<GetSnapshotRequest>) => Promise<Snapshot>;
109
+ /**
110
+ * Waits for {@link Snapshot} to be in a final state.
111
+ *
112
+ * @param request - The request {@link GetSnapshotRequest}
113
+ * @param options - The waiting options
114
+ * @returns A Promise of Snapshot
115
+ */
116
+ waitForSnapshot: (request: Readonly<GetSnapshotRequest>, options?: Readonly<WaitForOptions<Snapshot>>) => Promise<Snapshot>;
117
+ /**
118
+ * Update a Database Instance snapshot. Update the parameters of a snapshot of a Database Instance. You can update the `name` and `expires_at` parameters.
119
+ *
120
+ * @param request - The request {@link UpdateSnapshotRequest}
121
+ * @returns A Promise of Snapshot
122
+ */
123
+ updateSnapshot: (request: Readonly<UpdateSnapshotRequest>) => Promise<Snapshot>;
124
+ /**
125
+ * 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_number` of the new Database Instance.
126
+ *
127
+ * @param request - The request {@link RestoreSnapshotRequest}
128
+ * @returns A Promise of Instance
129
+ */
130
+ restoreSnapshot: (request: Readonly<RestoreSnapshotRequest>) => Promise<Instance>;
131
+ protected pageOfListSnapshots: (request?: Readonly<ListSnapshotsRequest>) => Promise<ListSnapshotsResponse>;
132
+ /**
133
+ * 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.
134
+ *
135
+ * @param request - The request {@link ListSnapshotsRequest}
136
+ * @returns A Promise of ListSnapshotsResponse
137
+ */
138
+ listSnapshots: (request?: Readonly<ListSnapshotsRequest>) => Promise<ListSnapshotsResponse> & {
139
+ all: () => Promise<Snapshot[]>;
140
+ [Symbol.asyncIterator]: () => AsyncGenerator<Snapshot[], void, void>;
141
+ };
142
+ /**
143
+ * 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.
144
+ *
145
+ * @param request - The request {@link DeleteSnapshotRequest}
146
+ * @returns A Promise of Snapshot
147
+ */
148
+ deleteSnapshot: (request: Readonly<DeleteSnapshotRequest>) => Promise<Snapshot>;
149
+ protected pageOfListUsers: (request: Readonly<ListUsersRequest>) => Promise<ListUsersResponse>;
150
+ /**
151
+ * List users of a Database Instance. List all users of a given Database Instance.
152
+ *
153
+ * @param request - The request {@link ListUsersRequest}
154
+ * @returns A Promise of ListUsersResponse
155
+ */
156
+ listUsers: (request: Readonly<ListUsersRequest>) => Promise<ListUsersResponse> & {
157
+ all: () => Promise<User[]>;
158
+ [Symbol.asyncIterator]: () => AsyncGenerator<User[], void, void>;
159
+ };
160
+ /**
161
+ * 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.
162
+ *
163
+ * @param request - The request {@link CreateUserRequest}
164
+ * @returns A Promise of User
165
+ */
166
+ createUser: (request: Readonly<CreateUserRequest>) => Promise<User>;
167
+ /**
168
+ * 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.
169
+ *
170
+ * @param request - The request {@link UpdateUserRequest}
171
+ * @returns A Promise of User
172
+ */
173
+ updateUser: (request: Readonly<UpdateUserRequest>) => Promise<User>;
174
+ /**
175
+ * Delete a user on a Database Instance. Delete an existing user on a Database Instance.
176
+ *
177
+ * @param request - The request {@link DeleteUserRequest}
178
+ */
179
+ deleteUser: (request: Readonly<DeleteUserRequest>) => Promise<void>;
180
+ setUserRole: (request: Readonly<SetUserRoleRequest>) => Promise<User>;
181
+ /**
182
+ * 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.
183
+ *
184
+ * @param request - The request {@link DeleteEndpointRequest}
185
+ */
186
+ deleteEndpoint: (request: Readonly<DeleteEndpointRequest>) => Promise<void>;
187
+ /**
188
+ * 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.
189
+ *
190
+ * @param request - The request {@link CreateEndpointRequest}
191
+ * @returns A Promise of Endpoint
192
+ */
193
+ createEndpoint: (request: Readonly<CreateEndpointRequest>) => Promise<Endpoint>;
194
+ }
@@ -0,0 +1,410 @@
1
+ import { API as API$1, urlParams, validatePathParam, enrichForPagination, waitForResource } from "@scaleway/sdk-client";
2
+ import { INSTANCE_TRANSIENT_STATUSES, SNAPSHOT_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, marshalCreateEndpointRequest, unmarshalEndpoint } from "./marshalling.gen.js";
4
+ const jsonContentHeaders = {
5
+ "Content-Type": "application/json; charset=utf-8"
6
+ };
7
+ class API extends API$1 {
8
+ /** Lists the available regions of the API. */
9
+ static LOCALITIES = ["fr-par"];
10
+ pageOfListNodeTypes = (request = {}) => this.client.fetch(
11
+ {
12
+ method: "GET",
13
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/node-types`,
14
+ urlParams: urlParams(
15
+ ["include_disabled_types", request.includeDisabledTypes],
16
+ ["page", request.page],
17
+ [
18
+ "page_size",
19
+ request.pageSize ?? this.client.settings.defaultPageSize
20
+ ]
21
+ )
22
+ },
23
+ unmarshalListNodeTypesResponse
24
+ );
25
+ /**
26
+ * List available node types.
27
+ *
28
+ * @param request - The request {@link ListNodeTypesRequest}
29
+ * @returns A Promise of ListNodeTypesResponse
30
+ */
31
+ listNodeTypes = (request = {}) => enrichForPagination("nodeTypes", this.pageOfListNodeTypes, request);
32
+ pageOfListVersions = (request = {}) => this.client.fetch(
33
+ {
34
+ method: "GET",
35
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/versions`,
36
+ urlParams: urlParams(
37
+ ["page", request.page],
38
+ [
39
+ "page_size",
40
+ request.pageSize ?? this.client.settings.defaultPageSize
41
+ ],
42
+ ["version", request.version]
43
+ )
44
+ },
45
+ unmarshalListVersionsResponse
46
+ );
47
+ /**
48
+ * List available MongoDB® versions.
49
+ *
50
+ * @param request - The request {@link ListVersionsRequest}
51
+ * @returns A Promise of ListVersionsResponse
52
+ */
53
+ listVersions = (request = {}) => enrichForPagination("versions", this.pageOfListVersions, request);
54
+ pageOfListInstances = (request = {}) => this.client.fetch(
55
+ {
56
+ method: "GET",
57
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances`,
58
+ urlParams: urlParams(
59
+ ["name", request.name],
60
+ ["order_by", request.orderBy],
61
+ ["organization_id", request.organizationId],
62
+ ["page", request.page],
63
+ [
64
+ "page_size",
65
+ request.pageSize ?? this.client.settings.defaultPageSize
66
+ ],
67
+ ["project_id", request.projectId],
68
+ ["tags", request.tags]
69
+ )
70
+ },
71
+ unmarshalListInstancesResponse
72
+ );
73
+ /**
74
+ * 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.
75
+ *
76
+ * @param request - The request {@link ListInstancesRequest}
77
+ * @returns A Promise of ListInstancesResponse
78
+ */
79
+ listInstances = (request = {}) => enrichForPagination("instances", this.pageOfListInstances, request);
80
+ /**
81
+ * 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.
82
+ *
83
+ * @param request - The request {@link GetInstanceRequest}
84
+ * @returns A Promise of Instance
85
+ */
86
+ getInstance = (request) => this.client.fetch(
87
+ {
88
+ method: "GET",
89
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
90
+ },
91
+ unmarshalInstance
92
+ );
93
+ /**
94
+ * Waits for {@link Instance} to be in a final state.
95
+ *
96
+ * @param request - The request {@link GetInstanceRequest}
97
+ * @param options - The waiting options
98
+ * @returns A Promise of Instance
99
+ */
100
+ waitForInstance = (request, options) => waitForResource(
101
+ options?.stop ?? ((res) => Promise.resolve(
102
+ !INSTANCE_TRANSIENT_STATUSES.includes(res.status)
103
+ )),
104
+ this.getInstance,
105
+ request,
106
+ options
107
+ );
108
+ /**
109
+ * Create a MongoDB® Database Instance. Create a new MongoDB® Database Instance.
110
+ *
111
+ * @param request - The request {@link CreateInstanceRequest}
112
+ * @returns A Promise of Instance
113
+ */
114
+ createInstance = (request) => this.client.fetch(
115
+ {
116
+ body: JSON.stringify(
117
+ marshalCreateInstanceRequest(request, this.client.settings)
118
+ ),
119
+ headers: jsonContentHeaders,
120
+ method: "POST",
121
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances`
122
+ },
123
+ unmarshalInstance
124
+ );
125
+ /**
126
+ * Update a MongoDB® Database Instance. Update the parameters of a MongoDB® Database Instance.
127
+ *
128
+ * @param request - The request {@link UpdateInstanceRequest}
129
+ * @returns A Promise of Instance
130
+ */
131
+ updateInstance = (request) => this.client.fetch(
132
+ {
133
+ body: JSON.stringify(
134
+ marshalUpdateInstanceRequest(request, this.client.settings)
135
+ ),
136
+ headers: jsonContentHeaders,
137
+ method: "PATCH",
138
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
139
+ },
140
+ unmarshalInstance
141
+ );
142
+ /**
143
+ * 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.
144
+ *
145
+ * @param request - The request {@link DeleteInstanceRequest}
146
+ * @returns A Promise of Instance
147
+ */
148
+ deleteInstance = (request) => this.client.fetch(
149
+ {
150
+ method: "DELETE",
151
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}`
152
+ },
153
+ unmarshalInstance
154
+ );
155
+ /**
156
+ * Upgrade a Database Instance. Upgrade your current Database Instance specifications like volume size.
157
+ *
158
+ * @param request - The request {@link UpgradeInstanceRequest}
159
+ * @returns A Promise of Instance
160
+ */
161
+ upgradeInstance = (request) => this.client.fetch(
162
+ {
163
+ body: JSON.stringify(
164
+ marshalUpgradeInstanceRequest(request, this.client.settings)
165
+ ),
166
+ headers: jsonContentHeaders,
167
+ method: "POST",
168
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/upgrade`
169
+ },
170
+ unmarshalInstance
171
+ );
172
+ /**
173
+ * Get the certificate of a Database Instance. Retrieve the certificate of a given Database Instance, specified by the `instance_id` parameter.
174
+ *
175
+ * @param request - The request {@link GetInstanceCertificateRequest}
176
+ * @returns A Promise of Blob
177
+ */
178
+ getInstanceCertificate = (request) => this.client.fetch({
179
+ method: "GET",
180
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/certificate`,
181
+ urlParams: urlParams(["dl", 1]),
182
+ responseType: "blob"
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/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/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/v1alpha1/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(
223
+ !SNAPSHOT_TRANSIENT_STATUSES.includes(res.status)
224
+ )),
225
+ this.getSnapshot,
226
+ request,
227
+ options
228
+ );
229
+ /**
230
+ * Update a Database Instance snapshot. Update the parameters of a snapshot of a Database Instance. You can update the `name` and `expires_at` parameters.
231
+ *
232
+ * @param request - The request {@link UpdateSnapshotRequest}
233
+ * @returns A Promise of Snapshot
234
+ */
235
+ updateSnapshot = (request) => this.client.fetch(
236
+ {
237
+ body: JSON.stringify(
238
+ marshalUpdateSnapshotRequest(request, this.client.settings)
239
+ ),
240
+ headers: jsonContentHeaders,
241
+ method: "POST",
242
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
243
+ },
244
+ unmarshalSnapshot
245
+ );
246
+ /**
247
+ * 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_number` of the new Database Instance.
248
+ *
249
+ * @param request - The request {@link RestoreSnapshotRequest}
250
+ * @returns A Promise of Instance
251
+ */
252
+ restoreSnapshot = (request) => this.client.fetch(
253
+ {
254
+ body: JSON.stringify(
255
+ marshalRestoreSnapshotRequest(request, this.client.settings)
256
+ ),
257
+ headers: jsonContentHeaders,
258
+ method: "POST",
259
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}/restore`
260
+ },
261
+ unmarshalInstance
262
+ );
263
+ pageOfListSnapshots = (request = {}) => this.client.fetch(
264
+ {
265
+ method: "GET",
266
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots`,
267
+ urlParams: urlParams(
268
+ ["instance_id", request.instanceId],
269
+ ["name", request.name],
270
+ ["order_by", request.orderBy],
271
+ ["organization_id", request.organizationId],
272
+ ["page", request.page],
273
+ [
274
+ "page_size",
275
+ request.pageSize ?? this.client.settings.defaultPageSize
276
+ ],
277
+ ["project_id", request.projectId]
278
+ )
279
+ },
280
+ unmarshalListSnapshotsResponse
281
+ );
282
+ /**
283
+ * 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.
284
+ *
285
+ * @param request - The request {@link ListSnapshotsRequest}
286
+ * @returns A Promise of ListSnapshotsResponse
287
+ */
288
+ listSnapshots = (request = {}) => enrichForPagination("snapshots", this.pageOfListSnapshots, request);
289
+ /**
290
+ * 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.
291
+ *
292
+ * @param request - The request {@link DeleteSnapshotRequest}
293
+ * @returns A Promise of Snapshot
294
+ */
295
+ deleteSnapshot = (request) => this.client.fetch(
296
+ {
297
+ method: "DELETE",
298
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/snapshots/${validatePathParam("snapshotId", request.snapshotId)}`
299
+ },
300
+ unmarshalSnapshot
301
+ );
302
+ pageOfListUsers = (request) => this.client.fetch(
303
+ {
304
+ method: "GET",
305
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users`,
306
+ urlParams: urlParams(
307
+ ["name", request.name],
308
+ ["order_by", request.orderBy],
309
+ ["page", request.page],
310
+ [
311
+ "page_size",
312
+ request.pageSize ?? this.client.settings.defaultPageSize
313
+ ]
314
+ )
315
+ },
316
+ unmarshalListUsersResponse
317
+ );
318
+ /**
319
+ * List users of a Database Instance. List all users of a given Database Instance.
320
+ *
321
+ * @param request - The request {@link ListUsersRequest}
322
+ * @returns A Promise of ListUsersResponse
323
+ */
324
+ listUsers = (request) => enrichForPagination("users", this.pageOfListUsers, request);
325
+ /**
326
+ * 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.
327
+ *
328
+ * @param request - The request {@link CreateUserRequest}
329
+ * @returns A Promise of User
330
+ */
331
+ createUser = (request) => this.client.fetch(
332
+ {
333
+ body: JSON.stringify(
334
+ marshalCreateUserRequest(request, this.client.settings)
335
+ ),
336
+ headers: jsonContentHeaders,
337
+ method: "POST",
338
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users`
339
+ },
340
+ unmarshalUser
341
+ );
342
+ /**
343
+ * 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.
344
+ *
345
+ * @param request - The request {@link UpdateUserRequest}
346
+ * @returns A Promise of User
347
+ */
348
+ updateUser = (request) => this.client.fetch(
349
+ {
350
+ body: JSON.stringify(
351
+ marshalUpdateUserRequest(request, this.client.settings)
352
+ ),
353
+ headers: jsonContentHeaders,
354
+ method: "PATCH",
355
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users/${validatePathParam("name", request.name)}`
356
+ },
357
+ unmarshalUser
358
+ );
359
+ /**
360
+ * Delete a user on a Database Instance. Delete an existing user on a Database Instance.
361
+ *
362
+ * @param request - The request {@link DeleteUserRequest}
363
+ */
364
+ deleteUser = (request) => this.client.fetch({
365
+ body: "{}",
366
+ headers: jsonContentHeaders,
367
+ method: "DELETE",
368
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/users/${validatePathParam("name", request.name)}`
369
+ });
370
+ setUserRole = (request) => this.client.fetch(
371
+ {
372
+ body: JSON.stringify(
373
+ marshalSetUserRoleRequest(request, this.client.settings)
374
+ ),
375
+ headers: jsonContentHeaders,
376
+ method: "PUT",
377
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/instances/${validatePathParam("instanceId", request.instanceId)}/roles`
378
+ },
379
+ unmarshalUser
380
+ );
381
+ /**
382
+ * 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.
383
+ *
384
+ * @param request - The request {@link DeleteEndpointRequest}
385
+ */
386
+ deleteEndpoint = (request) => this.client.fetch({
387
+ method: "DELETE",
388
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam("endpointId", request.endpointId)}`
389
+ });
390
+ /**
391
+ * 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.
392
+ *
393
+ * @param request - The request {@link CreateEndpointRequest}
394
+ * @returns A Promise of Endpoint
395
+ */
396
+ createEndpoint = (request) => this.client.fetch(
397
+ {
398
+ body: JSON.stringify(
399
+ marshalCreateEndpointRequest(request, this.client.settings)
400
+ ),
401
+ headers: jsonContentHeaders,
402
+ method: "POST",
403
+ path: `/mongodb/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints`
404
+ },
405
+ unmarshalEndpoint
406
+ );
407
+ }
408
+ export {
409
+ API
410
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const INSTANCE_TRANSIENT_STATUSES = [
4
+ "provisioning",
5
+ "configuring",
6
+ "deleting",
7
+ "initializing",
8
+ "snapshotting"
9
+ ];
10
+ const SNAPSHOT_TRANSIENT_STATUSES = [
11
+ "creating",
12
+ "restoring",
13
+ "deleting"
14
+ ];
15
+ exports.INSTANCE_TRANSIENT_STATUSES = INSTANCE_TRANSIENT_STATUSES;
16
+ exports.SNAPSHOT_TRANSIENT_STATUSES = SNAPSHOT_TRANSIENT_STATUSES;
@@ -0,0 +1,5 @@
1
+ import type { InstanceStatus, SnapshotStatus } from './types.gen';
2
+ /** Lists transient statutes of the enum {@link InstanceStatus}. */
3
+ export declare const INSTANCE_TRANSIENT_STATUSES: InstanceStatus[];
4
+ /** Lists transient statutes of the enum {@link SnapshotStatus}. */
5
+ export declare const SNAPSHOT_TRANSIENT_STATUSES: SnapshotStatus[];
@@ -0,0 +1,16 @@
1
+ const INSTANCE_TRANSIENT_STATUSES = [
2
+ "provisioning",
3
+ "configuring",
4
+ "deleting",
5
+ "initializing",
6
+ "snapshotting"
7
+ ];
8
+ const SNAPSHOT_TRANSIENT_STATUSES = [
9
+ "creating",
10
+ "restoring",
11
+ "deleting"
12
+ ];
13
+ export {
14
+ INSTANCE_TRANSIENT_STATUSES,
15
+ SNAPSHOT_TRANSIENT_STATUSES
16
+ };