@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,241 @@
1
+ import { resolveOneOf, isJSONObject, unmarshalArrayOfObject, unmarshalDate } from "@scaleway/sdk-client";
2
+ const unmarshalEndpointPrivateNetworkDetails = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ privateNetworkId: data.private_network_id
10
+ };
11
+ };
12
+ const unmarshalEndpointPublicDetails = (data) => {
13
+ if (!isJSONObject(data)) {
14
+ throw new TypeError(
15
+ `Unmarshalling the type 'EndpointPublicDetails' failed as data isn't a dictionary.`
16
+ );
17
+ }
18
+ return {};
19
+ };
20
+ const unmarshalEndpointService = (data) => {
21
+ if (!isJSONObject(data)) {
22
+ throw new TypeError(
23
+ `Unmarshalling the type 'EndpointService' failed as data isn't a dictionary.`
24
+ );
25
+ }
26
+ return {
27
+ port: data.port,
28
+ protocol: data.protocol
29
+ };
30
+ };
31
+ const unmarshalEndpoint = (data) => {
32
+ if (!isJSONObject(data)) {
33
+ throw new TypeError(
34
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
35
+ );
36
+ }
37
+ return {
38
+ dnsRecord: data.dns_record,
39
+ id: data.id,
40
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
41
+ public: data.public ? unmarshalEndpointPublicDetails(data.public) : void 0,
42
+ services: unmarshalArrayOfObject(data.services, unmarshalEndpointService)
43
+ };
44
+ };
45
+ const unmarshalDatabase = (data) => {
46
+ if (!isJSONObject(data)) {
47
+ throw new TypeError(
48
+ `Unmarshalling the type 'Database' failed as data isn't a dictionary.`
49
+ );
50
+ }
51
+ return {
52
+ name: data.name,
53
+ size: data.size
54
+ };
55
+ };
56
+ const unmarshalDeployment = (data) => {
57
+ if (!isJSONObject(data)) {
58
+ throw new TypeError(
59
+ `Unmarshalling the type 'Deployment' failed as data isn't a dictionary.`
60
+ );
61
+ }
62
+ return {
63
+ cpuMax: data.cpu_max,
64
+ cpuMin: data.cpu_min,
65
+ createdAt: unmarshalDate(data.created_at),
66
+ endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
67
+ id: data.id,
68
+ name: data.name,
69
+ organizationId: data.organization_id,
70
+ projectId: data.project_id,
71
+ ramPerCpu: data.ram_per_cpu,
72
+ region: data.region,
73
+ replicaCount: data.replica_count,
74
+ status: data.status,
75
+ tags: data.tags,
76
+ updatedAt: unmarshalDate(data.updated_at),
77
+ version: data.version
78
+ };
79
+ };
80
+ const unmarshalUser = (data) => {
81
+ if (!isJSONObject(data)) {
82
+ throw new TypeError(
83
+ `Unmarshalling the type 'User' failed as data isn't a dictionary.`
84
+ );
85
+ }
86
+ return {
87
+ isAdmin: data.is_admin,
88
+ name: data.name
89
+ };
90
+ };
91
+ const unmarshalListDatabasesResponse = (data) => {
92
+ if (!isJSONObject(data)) {
93
+ throw new TypeError(
94
+ `Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary.`
95
+ );
96
+ }
97
+ return {
98
+ databases: unmarshalArrayOfObject(data.databases, unmarshalDatabase),
99
+ totalCount: data.total_count
100
+ };
101
+ };
102
+ const unmarshalListDeploymentsResponse = (data) => {
103
+ if (!isJSONObject(data)) {
104
+ throw new TypeError(
105
+ `Unmarshalling the type 'ListDeploymentsResponse' failed as data isn't a dictionary.`
106
+ );
107
+ }
108
+ return {
109
+ deployments: unmarshalArrayOfObject(data.deployments, unmarshalDeployment),
110
+ totalCount: data.total_count
111
+ };
112
+ };
113
+ const unmarshalPreset = (data) => {
114
+ if (!isJSONObject(data)) {
115
+ throw new TypeError(
116
+ `Unmarshalling the type 'Preset' failed as data isn't a dictionary.`
117
+ );
118
+ }
119
+ return {
120
+ category: data.category,
121
+ cpuMax: data.cpu_max,
122
+ cpuMin: data.cpu_min,
123
+ name: data.name,
124
+ ramPerCpu: data.ram_per_cpu,
125
+ replicaCount: data.replica_count
126
+ };
127
+ };
128
+ const unmarshalListPresetsResponse = (data) => {
129
+ if (!isJSONObject(data)) {
130
+ throw new TypeError(
131
+ `Unmarshalling the type 'ListPresetsResponse' failed as data isn't a dictionary.`
132
+ );
133
+ }
134
+ return {
135
+ presets: unmarshalArrayOfObject(data.presets, unmarshalPreset),
136
+ totalCount: data.total_count
137
+ };
138
+ };
139
+ const unmarshalListUsersResponse = (data) => {
140
+ if (!isJSONObject(data)) {
141
+ throw new TypeError(
142
+ `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
143
+ );
144
+ }
145
+ return {
146
+ totalCount: data.total_count,
147
+ users: unmarshalArrayOfObject(data.users, unmarshalUser)
148
+ };
149
+ };
150
+ const unmarshalVersion = (data) => {
151
+ if (!isJSONObject(data)) {
152
+ throw new TypeError(
153
+ `Unmarshalling the type 'Version' failed as data isn't a dictionary.`
154
+ );
155
+ }
156
+ return {
157
+ endOfLifeAt: unmarshalDate(data.end_of_life_at),
158
+ version: data.version
159
+ };
160
+ };
161
+ const unmarshalListVersionsResponse = (data) => {
162
+ if (!isJSONObject(data)) {
163
+ throw new TypeError(
164
+ `Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`
165
+ );
166
+ }
167
+ return {
168
+ totalCount: data.total_count,
169
+ versions: unmarshalArrayOfObject(data.versions, unmarshalVersion)
170
+ };
171
+ };
172
+ const marshalCreateDatabaseRequest = (request, defaults) => ({
173
+ name: request.name
174
+ });
175
+ const marshalEndpointSpecPrivateNetworkDetails = (request, defaults) => ({
176
+ private_network_id: request.privateNetworkId
177
+ });
178
+ const marshalEndpointSpecPublicDetails = (request, defaults) => ({});
179
+ const marshalEndpointSpec = (request, defaults) => ({
180
+ ...resolveOneOf([
181
+ {
182
+ param: "public",
183
+ value: request.public !== void 0 ? marshalEndpointSpecPublicDetails(request.public) : void 0
184
+ },
185
+ {
186
+ param: "private_network",
187
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkDetails(
188
+ request.privateNetwork
189
+ ) : void 0
190
+ }
191
+ ])
192
+ });
193
+ const marshalCreateDeploymentRequest = (request, defaults) => ({
194
+ cpu_max: request.cpuMax,
195
+ cpu_min: request.cpuMin,
196
+ endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
197
+ name: request.name,
198
+ password: request.password,
199
+ project_id: request.projectId ?? defaults.defaultProjectId,
200
+ ram_per_cpu: request.ramPerCpu,
201
+ replica_count: request.replicaCount,
202
+ tags: request.tags,
203
+ version: request.version
204
+ });
205
+ const marshalCreateEndpointRequest = (request, defaults) => ({
206
+ deployment_id: request.deploymentId,
207
+ endpoint: request.endpoint !== void 0 ? marshalEndpointSpec(request.endpoint) : void 0
208
+ });
209
+ const marshalCreateUserRequest = (request, defaults) => ({
210
+ is_admin: request.isAdmin,
211
+ name: request.name,
212
+ password: request.password
213
+ });
214
+ const marshalUpdateDeploymentRequest = (request, defaults) => ({
215
+ cpu_max: request.cpuMax,
216
+ cpu_min: request.cpuMin,
217
+ name: request.name,
218
+ replica_count: request.replicaCount,
219
+ tags: request.tags
220
+ });
221
+ const marshalUpdateUserRequest = (request, defaults) => ({
222
+ is_admin: request.isAdmin,
223
+ password: request.password
224
+ });
225
+ export {
226
+ marshalCreateDatabaseRequest,
227
+ marshalCreateDeploymentRequest,
228
+ marshalCreateEndpointRequest,
229
+ marshalCreateUserRequest,
230
+ marshalUpdateDeploymentRequest,
231
+ marshalUpdateUserRequest,
232
+ unmarshalDatabase,
233
+ unmarshalDeployment,
234
+ unmarshalEndpoint,
235
+ unmarshalListDatabasesResponse,
236
+ unmarshalListDeploymentsResponse,
237
+ unmarshalListPresetsResponse,
238
+ unmarshalListUsersResponse,
239
+ unmarshalListVersionsResponse,
240
+ unmarshalUser
241
+ };