@scaleway/sdk-datawarehouse 1.1.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.
@@ -0,0 +1,311 @@
1
+ import { API as API$1, toApiLocality, urlParams, validatePathParam, enrichForPagination, waitForResource } from "@scaleway/sdk-client";
2
+ import { DEPLOYMENT_TRANSIENT_STATUSES } from "./content.gen.js";
3
+ import { unmarshalListPresetsResponse, unmarshalListVersionsResponse, unmarshalListDeploymentsResponse, unmarshalDeployment, marshalCreateDeploymentRequest, marshalUpdateDeploymentRequest, unmarshalListUsersResponse, marshalCreateUserRequest, unmarshalUser, marshalUpdateUserRequest, marshalCreateEndpointRequest, unmarshalEndpoint, unmarshalListDatabasesResponse, marshalCreateDatabaseRequest, unmarshalDatabase } 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: ["fr-par"]
14
+ });
15
+ pageOfListPresets = (request = {}) => this.client.fetch(
16
+ {
17
+ method: "GET",
18
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/presets`,
19
+ urlParams: urlParams(
20
+ ["page", request.page],
21
+ [
22
+ "page_size",
23
+ request.pageSize ?? this.client.settings.defaultPageSize
24
+ ]
25
+ )
26
+ },
27
+ unmarshalListPresetsResponse
28
+ );
29
+ /**
30
+ * List available presets.
31
+ *
32
+ * @param request - The request {@link ListPresetsRequest}
33
+ * @returns A Promise of ListPresetsResponse
34
+ */
35
+ listPresets = (request = {}) => enrichForPagination("presets", this.pageOfListPresets, request);
36
+ pageOfListVersions = (request = {}) => this.client.fetch(
37
+ {
38
+ method: "GET",
39
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/versions`,
40
+ urlParams: urlParams(
41
+ ["page", request.page],
42
+ [
43
+ "page_size",
44
+ request.pageSize ?? this.client.settings.defaultPageSize
45
+ ],
46
+ ["version", request.version]
47
+ )
48
+ },
49
+ unmarshalListVersionsResponse
50
+ );
51
+ /**
52
+ * List available Clickhouse versions.
53
+ *
54
+ * @param request - The request {@link ListVersionsRequest}
55
+ * @returns A Promise of ListVersionsResponse
56
+ */
57
+ listVersions = (request = {}) => enrichForPagination("versions", this.pageOfListVersions, request);
58
+ pageOfListDeployments = (request = {}) => this.client.fetch(
59
+ {
60
+ method: "GET",
61
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments`,
62
+ urlParams: urlParams(
63
+ ["name", request.name],
64
+ ["order_by", request.orderBy],
65
+ ["organization_id", request.organizationId],
66
+ ["page", request.page],
67
+ [
68
+ "page_size",
69
+ request.pageSize ?? this.client.settings.defaultPageSize
70
+ ],
71
+ ["project_id", request.projectId],
72
+ ["tags", request.tags]
73
+ )
74
+ },
75
+ unmarshalListDeploymentsResponse
76
+ );
77
+ /**
78
+ * List deployments. List all deployments in the specified region, for a given Scaleway Project. By default, the deployments 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 provide will be checked against the whole name string to see if it includes the string you put in the parameter.
79
+ *
80
+ * @param request - The request {@link ListDeploymentsRequest}
81
+ * @returns A Promise of ListDeploymentsResponse
82
+ */
83
+ listDeployments = (request = {}) => enrichForPagination("deployments", this.pageOfListDeployments, request);
84
+ /**
85
+ * Get a deployment. Retrieve information about a given deployment, specified by the `region` and `deployment_id` parameters. Its full details, including name, status are returned in the response object.
86
+ *
87
+ * @param request - The request {@link GetDeploymentRequest}
88
+ * @returns A Promise of Deployment
89
+ */
90
+ getDeployment = (request) => this.client.fetch(
91
+ {
92
+ method: "GET",
93
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}`
94
+ },
95
+ unmarshalDeployment
96
+ );
97
+ /**
98
+ * Waits for {@link Deployment} to be in a final state.
99
+ *
100
+ * @param request - The request {@link GetDeploymentRequest}
101
+ * @param options - The waiting options
102
+ * @returns A Promise of Deployment
103
+ */
104
+ waitForDeployment = (request, options) => waitForResource(
105
+ options?.stop ?? ((res) => Promise.resolve(
106
+ !DEPLOYMENT_TRANSIENT_STATUSES.includes(res.status)
107
+ )),
108
+ this.getDeployment,
109
+ request,
110
+ options
111
+ );
112
+ /**
113
+ * Create a deployment. Create a new deployment.
114
+ *
115
+ * @param request - The request {@link CreateDeploymentRequest}
116
+ * @returns A Promise of Deployment
117
+ */
118
+ createDeployment = (request) => this.client.fetch(
119
+ {
120
+ body: JSON.stringify(
121
+ marshalCreateDeploymentRequest(request, this.client.settings)
122
+ ),
123
+ headers: jsonContentHeaders,
124
+ method: "POST",
125
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments`
126
+ },
127
+ unmarshalDeployment
128
+ );
129
+ /**
130
+ * Update a deployment. Update the parameters of a deployment.
131
+ *
132
+ * @param request - The request {@link UpdateDeploymentRequest}
133
+ * @returns A Promise of Deployment
134
+ */
135
+ updateDeployment = (request) => this.client.fetch(
136
+ {
137
+ body: JSON.stringify(
138
+ marshalUpdateDeploymentRequest(request, this.client.settings)
139
+ ),
140
+ headers: jsonContentHeaders,
141
+ method: "PATCH",
142
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}`
143
+ },
144
+ unmarshalDeployment
145
+ );
146
+ /**
147
+ * Delete a deployment. Delete a given deployment, specified by the `region` and `deployment_id` parameters. Deleting a deployment is permanent, and cannot be undone. Upon deletion, deletion all your data will be lost.
148
+ *
149
+ * @param request - The request {@link DeleteDeploymentRequest}
150
+ * @returns A Promise of Deployment
151
+ */
152
+ deleteDeployment = (request) => this.client.fetch(
153
+ {
154
+ method: "DELETE",
155
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}`
156
+ },
157
+ unmarshalDeployment
158
+ );
159
+ getDeploymentCertificate = (request) => this.client.fetch({
160
+ method: "GET",
161
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/certificate`,
162
+ urlParams: urlParams(["dl", 1]),
163
+ responseType: "blob"
164
+ });
165
+ pageOfListUsers = (request) => this.client.fetch(
166
+ {
167
+ method: "GET",
168
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/users`,
169
+ urlParams: urlParams(
170
+ ["name", request.name],
171
+ ["order_by", request.orderBy],
172
+ ["page", request.page],
173
+ [
174
+ "page_size",
175
+ request.pageSize ?? this.client.settings.defaultPageSize
176
+ ]
177
+ )
178
+ },
179
+ unmarshalListUsersResponse
180
+ );
181
+ /**
182
+ * List users associated with a deployment.
183
+ *
184
+ * @param request - The request {@link ListUsersRequest}
185
+ * @returns A Promise of ListUsersResponse
186
+ */
187
+ listUsers = (request) => enrichForPagination("users", this.pageOfListUsers, request);
188
+ /**
189
+ * Create a new user for a deployment.
190
+ *
191
+ * @param request - The request {@link CreateUserRequest}
192
+ * @returns A Promise of User
193
+ */
194
+ createUser = (request) => this.client.fetch(
195
+ {
196
+ body: JSON.stringify(
197
+ marshalCreateUserRequest(request, this.client.settings)
198
+ ),
199
+ headers: jsonContentHeaders,
200
+ method: "POST",
201
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/users`
202
+ },
203
+ unmarshalUser
204
+ );
205
+ /**
206
+ * Update an existing user for a deployment.
207
+ *
208
+ * @param request - The request {@link UpdateUserRequest}
209
+ * @returns A Promise of User
210
+ */
211
+ updateUser = (request) => this.client.fetch(
212
+ {
213
+ body: JSON.stringify(
214
+ marshalUpdateUserRequest(request, this.client.settings)
215
+ ),
216
+ headers: jsonContentHeaders,
217
+ method: "PATCH",
218
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/users/${validatePathParam("name", request.name)}`
219
+ },
220
+ unmarshalUser
221
+ );
222
+ /**
223
+ * Delete a user from a deployment.
224
+ *
225
+ * @param request - The request {@link DeleteUserRequest}
226
+ */
227
+ deleteUser = (request) => this.client.fetch({
228
+ body: "{}",
229
+ headers: jsonContentHeaders,
230
+ method: "DELETE",
231
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/users/${validatePathParam("name", request.name)}`
232
+ });
233
+ /**
234
+ * Delete an endpoint from a deployment.
235
+ *
236
+ * @param request - The request {@link DeleteEndpointRequest}
237
+ */
238
+ deleteEndpoint = (request) => this.client.fetch({
239
+ method: "DELETE",
240
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam("endpointId", request.endpointId)}`
241
+ });
242
+ /**
243
+ * Create a new endpoint for a deployment.
244
+ *
245
+ * @param request - The request {@link CreateEndpointRequest}
246
+ * @returns A Promise of Endpoint
247
+ */
248
+ createEndpoint = (request) => this.client.fetch(
249
+ {
250
+ body: JSON.stringify(
251
+ marshalCreateEndpointRequest(request, this.client.settings)
252
+ ),
253
+ headers: jsonContentHeaders,
254
+ method: "POST",
255
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints`
256
+ },
257
+ unmarshalEndpoint
258
+ );
259
+ pageOfListDatabases = (request) => this.client.fetch(
260
+ {
261
+ method: "GET",
262
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/databases`,
263
+ urlParams: urlParams(
264
+ ["name", request.name],
265
+ ["order_by", request.orderBy],
266
+ ["page", request.page],
267
+ [
268
+ "page_size",
269
+ request.pageSize ?? this.client.settings.defaultPageSize
270
+ ]
271
+ )
272
+ },
273
+ unmarshalListDatabasesResponse
274
+ );
275
+ /**
276
+ * List databases within a deployment.
277
+ *
278
+ * @param request - The request {@link ListDatabasesRequest}
279
+ * @returns A Promise of ListDatabasesResponse
280
+ */
281
+ listDatabases = (request) => enrichForPagination("databases", this.pageOfListDatabases, request);
282
+ /**
283
+ * Create a new database within a deployment.
284
+ *
285
+ * @param request - The request {@link CreateDatabaseRequest}
286
+ * @returns A Promise of Database
287
+ */
288
+ createDatabase = (request) => this.client.fetch(
289
+ {
290
+ body: JSON.stringify(
291
+ marshalCreateDatabaseRequest(request, this.client.settings)
292
+ ),
293
+ headers: jsonContentHeaders,
294
+ method: "POST",
295
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/databases`
296
+ },
297
+ unmarshalDatabase
298
+ );
299
+ /**
300
+ * Delete a database from a deployment.
301
+ *
302
+ * @param request - The request {@link DeleteDatabaseRequest}
303
+ */
304
+ deleteDatabase = (request) => this.client.fetch({
305
+ method: "DELETE",
306
+ path: `/datawarehouse/v1beta1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/databases/${validatePathParam("name", request.name)}`
307
+ });
308
+ }
309
+ export {
310
+ API
311
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const DEPLOYMENT_TRANSIENT_STATUSES = [
4
+ "creating",
5
+ "configuring",
6
+ "deleting",
7
+ "locking",
8
+ "unlocking"
9
+ ];
10
+ exports.DEPLOYMENT_TRANSIENT_STATUSES = DEPLOYMENT_TRANSIENT_STATUSES;
@@ -0,0 +1,3 @@
1
+ import type { DeploymentStatus } from './types.gen.js';
2
+ /** Lists transient statutes of the enum {@link DeploymentStatus}. */
3
+ export declare const DEPLOYMENT_TRANSIENT_STATUSES: DeploymentStatus[];
@@ -0,0 +1,10 @@
1
+ const DEPLOYMENT_TRANSIENT_STATUSES = [
2
+ "creating",
3
+ "configuring",
4
+ "deleting",
5
+ "locking",
6
+ "unlocking"
7
+ ];
8
+ export {
9
+ DEPLOYMENT_TRANSIENT_STATUSES
10
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const api_gen = require("./api.gen.cjs");
4
+ const content_gen = require("./content.gen.cjs");
5
+ const marshalling_gen = require("./marshalling.gen.cjs");
6
+ const validationRules_gen = require("./validation-rules.gen.cjs");
7
+ exports.API = api_gen.API;
8
+ exports.DEPLOYMENT_TRANSIENT_STATUSES = content_gen.DEPLOYMENT_TRANSIENT_STATUSES;
9
+ exports.marshalCreateDatabaseRequest = marshalling_gen.marshalCreateDatabaseRequest;
10
+ exports.marshalCreateDeploymentRequest = marshalling_gen.marshalCreateDeploymentRequest;
11
+ exports.marshalCreateEndpointRequest = marshalling_gen.marshalCreateEndpointRequest;
12
+ exports.marshalCreateUserRequest = marshalling_gen.marshalCreateUserRequest;
13
+ exports.marshalUpdateDeploymentRequest = marshalling_gen.marshalUpdateDeploymentRequest;
14
+ exports.marshalUpdateUserRequest = marshalling_gen.marshalUpdateUserRequest;
15
+ exports.unmarshalDatabase = marshalling_gen.unmarshalDatabase;
16
+ exports.unmarshalDeployment = marshalling_gen.unmarshalDeployment;
17
+ exports.unmarshalEndpoint = marshalling_gen.unmarshalEndpoint;
18
+ exports.unmarshalListDatabasesResponse = marshalling_gen.unmarshalListDatabasesResponse;
19
+ exports.unmarshalListDeploymentsResponse = marshalling_gen.unmarshalListDeploymentsResponse;
20
+ exports.unmarshalListPresetsResponse = marshalling_gen.unmarshalListPresetsResponse;
21
+ exports.unmarshalListUsersResponse = marshalling_gen.unmarshalListUsersResponse;
22
+ exports.unmarshalListVersionsResponse = marshalling_gen.unmarshalListVersionsResponse;
23
+ exports.unmarshalUser = marshalling_gen.unmarshalUser;
24
+ exports.ValidationRules = validationRules_gen;
@@ -0,0 +1,5 @@
1
+ export { API } from './api.gen.js';
2
+ export * from './content.gen.js';
3
+ export * from './marshalling.gen.js';
4
+ export type { CreateDatabaseRequest, CreateDeploymentRequest, CreateEndpointRequest, CreateUserRequest, Database, DeleteDatabaseRequest, DeleteDeploymentRequest, DeleteEndpointRequest, DeleteUserRequest, Deployment, DeploymentStatus, Endpoint, EndpointPrivateNetworkDetails, EndpointPublicDetails, EndpointService, EndpointServiceProtocol, EndpointSpec, EndpointSpecPrivateNetworkDetails, EndpointSpecPublicDetails, GetDeploymentCertificateRequest, GetDeploymentRequest, ListDatabasesRequest, ListDatabasesRequestOrderBy, ListDatabasesResponse, ListDeploymentsRequest, ListDeploymentsRequestOrderBy, ListDeploymentsResponse, ListPresetsRequest, ListPresetsResponse, ListUsersRequest, ListUsersRequestOrderBy, ListUsersResponse, ListVersionsRequest, ListVersionsResponse, Preset, UpdateDeploymentRequest, UpdateUserRequest, User, Version, } from './types.gen.js';
5
+ export * as ValidationRules from './validation-rules.gen.js';
@@ -0,0 +1,24 @@
1
+ import { API } from "./api.gen.js";
2
+ import { DEPLOYMENT_TRANSIENT_STATUSES } from "./content.gen.js";
3
+ import { marshalCreateDatabaseRequest, marshalCreateDeploymentRequest, marshalCreateEndpointRequest, marshalCreateUserRequest, marshalUpdateDeploymentRequest, marshalUpdateUserRequest, unmarshalDatabase, unmarshalDeployment, unmarshalEndpoint, unmarshalListDatabasesResponse, unmarshalListDeploymentsResponse, unmarshalListPresetsResponse, unmarshalListUsersResponse, unmarshalListVersionsResponse, unmarshalUser } from "./marshalling.gen.js";
4
+ import * as validationRules_gen from "./validation-rules.gen.js";
5
+ export {
6
+ API,
7
+ DEPLOYMENT_TRANSIENT_STATUSES,
8
+ validationRules_gen as ValidationRules,
9
+ marshalCreateDatabaseRequest,
10
+ marshalCreateDeploymentRequest,
11
+ marshalCreateEndpointRequest,
12
+ marshalCreateUserRequest,
13
+ marshalUpdateDeploymentRequest,
14
+ marshalUpdateUserRequest,
15
+ unmarshalDatabase,
16
+ unmarshalDeployment,
17
+ unmarshalEndpoint,
18
+ unmarshalListDatabasesResponse,
19
+ unmarshalListDeploymentsResponse,
20
+ unmarshalListPresetsResponse,
21
+ unmarshalListUsersResponse,
22
+ unmarshalListVersionsResponse,
23
+ unmarshalUser
24
+ };
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkClient = require("@scaleway/sdk-client");
4
+ const unmarshalEndpointPrivateNetworkDetails = (data) => {
5
+ if (!sdkClient.isJSONObject(data)) {
6
+ throw new TypeError(
7
+ `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`
8
+ );
9
+ }
10
+ return {
11
+ privateNetworkId: data.private_network_id
12
+ };
13
+ };
14
+ const unmarshalEndpointPublicDetails = (data) => {
15
+ if (!sdkClient.isJSONObject(data)) {
16
+ throw new TypeError(
17
+ `Unmarshalling the type 'EndpointPublicDetails' failed as data isn't a dictionary.`
18
+ );
19
+ }
20
+ return {};
21
+ };
22
+ const unmarshalEndpointService = (data) => {
23
+ if (!sdkClient.isJSONObject(data)) {
24
+ throw new TypeError(
25
+ `Unmarshalling the type 'EndpointService' failed as data isn't a dictionary.`
26
+ );
27
+ }
28
+ return {
29
+ port: data.port,
30
+ protocol: data.protocol
31
+ };
32
+ };
33
+ const unmarshalEndpoint = (data) => {
34
+ if (!sdkClient.isJSONObject(data)) {
35
+ throw new TypeError(
36
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
37
+ );
38
+ }
39
+ return {
40
+ dnsRecord: data.dns_record,
41
+ id: data.id,
42
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
43
+ public: data.public ? unmarshalEndpointPublicDetails(data.public) : void 0,
44
+ services: sdkClient.unmarshalArrayOfObject(data.services, unmarshalEndpointService)
45
+ };
46
+ };
47
+ const unmarshalDatabase = (data) => {
48
+ if (!sdkClient.isJSONObject(data)) {
49
+ throw new TypeError(
50
+ `Unmarshalling the type 'Database' failed as data isn't a dictionary.`
51
+ );
52
+ }
53
+ return {
54
+ name: data.name,
55
+ size: data.size
56
+ };
57
+ };
58
+ const unmarshalDeployment = (data) => {
59
+ if (!sdkClient.isJSONObject(data)) {
60
+ throw new TypeError(
61
+ `Unmarshalling the type 'Deployment' failed as data isn't a dictionary.`
62
+ );
63
+ }
64
+ return {
65
+ cpuMax: data.cpu_max,
66
+ cpuMin: data.cpu_min,
67
+ createdAt: sdkClient.unmarshalDate(data.created_at),
68
+ endpoints: sdkClient.unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
69
+ id: data.id,
70
+ name: data.name,
71
+ organizationId: data.organization_id,
72
+ projectId: data.project_id,
73
+ ramPerCpu: data.ram_per_cpu,
74
+ region: data.region,
75
+ replicaCount: data.replica_count,
76
+ status: data.status,
77
+ tags: data.tags,
78
+ updatedAt: sdkClient.unmarshalDate(data.updated_at),
79
+ version: data.version
80
+ };
81
+ };
82
+ const unmarshalUser = (data) => {
83
+ if (!sdkClient.isJSONObject(data)) {
84
+ throw new TypeError(
85
+ `Unmarshalling the type 'User' failed as data isn't a dictionary.`
86
+ );
87
+ }
88
+ return {
89
+ isAdmin: data.is_admin,
90
+ name: data.name
91
+ };
92
+ };
93
+ const unmarshalListDatabasesResponse = (data) => {
94
+ if (!sdkClient.isJSONObject(data)) {
95
+ throw new TypeError(
96
+ `Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary.`
97
+ );
98
+ }
99
+ return {
100
+ databases: sdkClient.unmarshalArrayOfObject(data.databases, unmarshalDatabase),
101
+ totalCount: data.total_count
102
+ };
103
+ };
104
+ const unmarshalListDeploymentsResponse = (data) => {
105
+ if (!sdkClient.isJSONObject(data)) {
106
+ throw new TypeError(
107
+ `Unmarshalling the type 'ListDeploymentsResponse' failed as data isn't a dictionary.`
108
+ );
109
+ }
110
+ return {
111
+ deployments: sdkClient.unmarshalArrayOfObject(data.deployments, unmarshalDeployment),
112
+ totalCount: data.total_count
113
+ };
114
+ };
115
+ const unmarshalPreset = (data) => {
116
+ if (!sdkClient.isJSONObject(data)) {
117
+ throw new TypeError(
118
+ `Unmarshalling the type 'Preset' failed as data isn't a dictionary.`
119
+ );
120
+ }
121
+ return {
122
+ category: data.category,
123
+ cpuMax: data.cpu_max,
124
+ cpuMin: data.cpu_min,
125
+ name: data.name,
126
+ ramPerCpu: data.ram_per_cpu,
127
+ replicaCount: data.replica_count
128
+ };
129
+ };
130
+ const unmarshalListPresetsResponse = (data) => {
131
+ if (!sdkClient.isJSONObject(data)) {
132
+ throw new TypeError(
133
+ `Unmarshalling the type 'ListPresetsResponse' failed as data isn't a dictionary.`
134
+ );
135
+ }
136
+ return {
137
+ presets: sdkClient.unmarshalArrayOfObject(data.presets, unmarshalPreset),
138
+ totalCount: data.total_count
139
+ };
140
+ };
141
+ const unmarshalListUsersResponse = (data) => {
142
+ if (!sdkClient.isJSONObject(data)) {
143
+ throw new TypeError(
144
+ `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
145
+ );
146
+ }
147
+ return {
148
+ totalCount: data.total_count,
149
+ users: sdkClient.unmarshalArrayOfObject(data.users, unmarshalUser)
150
+ };
151
+ };
152
+ const unmarshalVersion = (data) => {
153
+ if (!sdkClient.isJSONObject(data)) {
154
+ throw new TypeError(
155
+ `Unmarshalling the type 'Version' failed as data isn't a dictionary.`
156
+ );
157
+ }
158
+ return {
159
+ endOfLifeAt: sdkClient.unmarshalDate(data.end_of_life_at),
160
+ version: data.version
161
+ };
162
+ };
163
+ const unmarshalListVersionsResponse = (data) => {
164
+ if (!sdkClient.isJSONObject(data)) {
165
+ throw new TypeError(
166
+ `Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`
167
+ );
168
+ }
169
+ return {
170
+ totalCount: data.total_count,
171
+ versions: sdkClient.unmarshalArrayOfObject(data.versions, unmarshalVersion)
172
+ };
173
+ };
174
+ const marshalCreateDatabaseRequest = (request, defaults) => ({
175
+ name: request.name
176
+ });
177
+ const marshalEndpointSpecPrivateNetworkDetails = (request, defaults) => ({
178
+ private_network_id: request.privateNetworkId
179
+ });
180
+ const marshalEndpointSpecPublicDetails = (request, defaults) => ({});
181
+ const marshalEndpointSpec = (request, defaults) => ({
182
+ ...sdkClient.resolveOneOf([
183
+ {
184
+ param: "public",
185
+ value: request.public !== void 0 ? marshalEndpointSpecPublicDetails(request.public) : void 0
186
+ },
187
+ {
188
+ param: "private_network",
189
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkDetails(
190
+ request.privateNetwork
191
+ ) : void 0
192
+ }
193
+ ])
194
+ });
195
+ const marshalCreateDeploymentRequest = (request, defaults) => ({
196
+ cpu_max: request.cpuMax,
197
+ cpu_min: request.cpuMin,
198
+ endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
199
+ name: request.name,
200
+ password: request.password,
201
+ project_id: request.projectId ?? defaults.defaultProjectId,
202
+ ram_per_cpu: request.ramPerCpu,
203
+ replica_count: request.replicaCount,
204
+ tags: request.tags,
205
+ version: request.version
206
+ });
207
+ const marshalCreateEndpointRequest = (request, defaults) => ({
208
+ deployment_id: request.deploymentId,
209
+ endpoint: request.endpoint !== void 0 ? marshalEndpointSpec(request.endpoint) : void 0
210
+ });
211
+ const marshalCreateUserRequest = (request, defaults) => ({
212
+ is_admin: request.isAdmin,
213
+ name: request.name,
214
+ password: request.password
215
+ });
216
+ const marshalUpdateDeploymentRequest = (request, defaults) => ({
217
+ cpu_max: request.cpuMax,
218
+ cpu_min: request.cpuMin,
219
+ name: request.name,
220
+ replica_count: request.replicaCount,
221
+ tags: request.tags
222
+ });
223
+ const marshalUpdateUserRequest = (request, defaults) => ({
224
+ is_admin: request.isAdmin,
225
+ password: request.password
226
+ });
227
+ exports.marshalCreateDatabaseRequest = marshalCreateDatabaseRequest;
228
+ exports.marshalCreateDeploymentRequest = marshalCreateDeploymentRequest;
229
+ exports.marshalCreateEndpointRequest = marshalCreateEndpointRequest;
230
+ exports.marshalCreateUserRequest = marshalCreateUserRequest;
231
+ exports.marshalUpdateDeploymentRequest = marshalUpdateDeploymentRequest;
232
+ exports.marshalUpdateUserRequest = marshalUpdateUserRequest;
233
+ exports.unmarshalDatabase = unmarshalDatabase;
234
+ exports.unmarshalDeployment = unmarshalDeployment;
235
+ exports.unmarshalEndpoint = unmarshalEndpoint;
236
+ exports.unmarshalListDatabasesResponse = unmarshalListDatabasesResponse;
237
+ exports.unmarshalListDeploymentsResponse = unmarshalListDeploymentsResponse;
238
+ exports.unmarshalListPresetsResponse = unmarshalListPresetsResponse;
239
+ exports.unmarshalListUsersResponse = unmarshalListUsersResponse;
240
+ exports.unmarshalListVersionsResponse = unmarshalListVersionsResponse;
241
+ exports.unmarshalUser = unmarshalUser;
@@ -0,0 +1,17 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { CreateDatabaseRequest, CreateDeploymentRequest, CreateEndpointRequest, CreateUserRequest, Database, Deployment, Endpoint, ListDatabasesResponse, ListDeploymentsResponse, ListPresetsResponse, ListUsersResponse, ListVersionsResponse, UpdateDeploymentRequest, UpdateUserRequest, User } from './types.gen.js';
3
+ export declare const unmarshalEndpoint: (data: unknown) => Endpoint;
4
+ export declare const unmarshalDatabase: (data: unknown) => Database;
5
+ export declare const unmarshalDeployment: (data: unknown) => Deployment;
6
+ export declare const unmarshalUser: (data: unknown) => User;
7
+ export declare const unmarshalListDatabasesResponse: (data: unknown) => ListDatabasesResponse;
8
+ export declare const unmarshalListDeploymentsResponse: (data: unknown) => ListDeploymentsResponse;
9
+ export declare const unmarshalListPresetsResponse: (data: unknown) => ListPresetsResponse;
10
+ export declare const unmarshalListUsersResponse: (data: unknown) => ListUsersResponse;
11
+ export declare const unmarshalListVersionsResponse: (data: unknown) => ListVersionsResponse;
12
+ export declare const marshalCreateDatabaseRequest: (request: CreateDatabaseRequest, defaults: DefaultValues) => Record<string, unknown>;
13
+ export declare const marshalCreateDeploymentRequest: (request: CreateDeploymentRequest, defaults: DefaultValues) => Record<string, unknown>;
14
+ export declare const marshalCreateEndpointRequest: (request: CreateEndpointRequest, defaults: DefaultValues) => Record<string, unknown>;
15
+ export declare const marshalCreateUserRequest: (request: CreateUserRequest, defaults: DefaultValues) => Record<string, unknown>;
16
+ export declare const marshalUpdateDeploymentRequest: (request: UpdateDeploymentRequest, defaults: DefaultValues) => Record<string, unknown>;
17
+ export declare const marshalUpdateUserRequest: (request: UpdateUserRequest, defaults: DefaultValues) => Record<string, unknown>;