@scaleway/sdk-redis 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,353 @@
1
+ import randomName from "@scaleway/random-name";
2
+ import { resolveOneOf, isJSONObject, unmarshalDate, unmarshalArrayOfObject, unmarshalTimeSeries } from "@scaleway/sdk-client";
3
+ const unmarshalACLRule = (data) => {
4
+ if (!isJSONObject(data)) {
5
+ throw new TypeError(
6
+ `Unmarshalling the type 'ACLRule' failed as data isn't a dictionary.`
7
+ );
8
+ }
9
+ return {
10
+ description: data.description,
11
+ id: data.id,
12
+ ipCidr: data.ip_cidr
13
+ };
14
+ };
15
+ const unmarshalPrivateNetwork = (data) => {
16
+ if (!isJSONObject(data)) {
17
+ throw new TypeError(
18
+ `Unmarshalling the type 'PrivateNetwork' failed as data isn't a dictionary.`
19
+ );
20
+ }
21
+ return {
22
+ id: data.id,
23
+ provisioningMode: data.provisioning_mode,
24
+ serviceIps: data.service_ips,
25
+ zone: data.zone
26
+ };
27
+ };
28
+ const unmarshalPublicNetwork = (data) => {
29
+ if (!isJSONObject(data)) {
30
+ throw new TypeError(
31
+ `Unmarshalling the type 'PublicNetwork' failed as data isn't a dictionary.`
32
+ );
33
+ }
34
+ return {};
35
+ };
36
+ const unmarshalEndpoint = (data) => {
37
+ if (!isJSONObject(data)) {
38
+ throw new TypeError(
39
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
40
+ );
41
+ }
42
+ return {
43
+ id: data.id,
44
+ ips: data.ips,
45
+ port: data.port,
46
+ privateNetwork: data.private_network ? unmarshalPrivateNetwork(data.private_network) : void 0,
47
+ publicNetwork: data.public_network ? unmarshalPublicNetwork(data.public_network) : void 0
48
+ };
49
+ };
50
+ const unmarshalClusterSetting = (data) => {
51
+ if (!isJSONObject(data)) {
52
+ throw new TypeError(
53
+ `Unmarshalling the type 'ClusterSetting' failed as data isn't a dictionary.`
54
+ );
55
+ }
56
+ return {
57
+ name: data.name,
58
+ value: data.value
59
+ };
60
+ };
61
+ const unmarshalCluster = (data) => {
62
+ if (!isJSONObject(data)) {
63
+ throw new TypeError(
64
+ `Unmarshalling the type 'Cluster' failed as data isn't a dictionary.`
65
+ );
66
+ }
67
+ return {
68
+ aclRules: unmarshalArrayOfObject(data.acl_rules, unmarshalACLRule),
69
+ clusterSettings: unmarshalArrayOfObject(
70
+ data.cluster_settings,
71
+ unmarshalClusterSetting
72
+ ),
73
+ clusterSize: data.cluster_size,
74
+ createdAt: unmarshalDate(data.created_at),
75
+ endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
76
+ id: data.id,
77
+ name: data.name,
78
+ nodeType: data.node_type,
79
+ projectId: data.project_id,
80
+ status: data.status,
81
+ tags: data.tags,
82
+ tlsEnabled: data.tls_enabled,
83
+ updatedAt: unmarshalDate(data.updated_at),
84
+ upgradableVersions: data.upgradable_versions,
85
+ userName: data.user_name,
86
+ version: data.version,
87
+ zone: data.zone
88
+ };
89
+ };
90
+ const unmarshalAddAclRulesResponse = (data) => {
91
+ if (!isJSONObject(data)) {
92
+ throw new TypeError(
93
+ `Unmarshalling the type 'AddAclRulesResponse' failed as data isn't a dictionary.`
94
+ );
95
+ }
96
+ return {
97
+ aclRules: unmarshalArrayOfObject(data.acl_rules, unmarshalACLRule),
98
+ totalCount: data.total_count
99
+ };
100
+ };
101
+ const unmarshalAddEndpointsResponse = (data) => {
102
+ if (!isJSONObject(data)) {
103
+ throw new TypeError(
104
+ `Unmarshalling the type 'AddEndpointsResponse' failed as data isn't a dictionary.`
105
+ );
106
+ }
107
+ return {
108
+ endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
109
+ totalCount: data.total_count
110
+ };
111
+ };
112
+ const unmarshalClusterMetricsResponse = (data) => {
113
+ if (!isJSONObject(data)) {
114
+ throw new TypeError(
115
+ `Unmarshalling the type 'ClusterMetricsResponse' failed as data isn't a dictionary.`
116
+ );
117
+ }
118
+ return {
119
+ timeseries: unmarshalArrayOfObject(data.timeseries, unmarshalTimeSeries)
120
+ };
121
+ };
122
+ const unmarshalClusterSettingsResponse = (data) => {
123
+ if (!isJSONObject(data)) {
124
+ throw new TypeError(
125
+ `Unmarshalling the type 'ClusterSettingsResponse' failed as data isn't a dictionary.`
126
+ );
127
+ }
128
+ return {
129
+ settings: unmarshalArrayOfObject(data.settings, unmarshalClusterSetting)
130
+ };
131
+ };
132
+ const unmarshalAvailableClusterSetting = (data) => {
133
+ if (!isJSONObject(data)) {
134
+ throw new TypeError(
135
+ `Unmarshalling the type 'AvailableClusterSetting' failed as data isn't a dictionary.`
136
+ );
137
+ }
138
+ return {
139
+ defaultValue: data.default_value,
140
+ deprecated: data.deprecated,
141
+ description: data.description,
142
+ maxValue: data.max_value,
143
+ minValue: data.min_value,
144
+ name: data.name,
145
+ regex: data.regex,
146
+ type: data.type
147
+ };
148
+ };
149
+ const unmarshalClusterVersion = (data) => {
150
+ if (!isJSONObject(data)) {
151
+ throw new TypeError(
152
+ `Unmarshalling the type 'ClusterVersion' failed as data isn't a dictionary.`
153
+ );
154
+ }
155
+ return {
156
+ availableSettings: unmarshalArrayOfObject(
157
+ data.available_settings,
158
+ unmarshalAvailableClusterSetting
159
+ ),
160
+ endOfLifeAt: unmarshalDate(data.end_of_life_at),
161
+ logoUrl: data.logo_url,
162
+ version: data.version,
163
+ zone: data.zone
164
+ };
165
+ };
166
+ const unmarshalListClusterVersionsResponse = (data) => {
167
+ if (!isJSONObject(data)) {
168
+ throw new TypeError(
169
+ `Unmarshalling the type 'ListClusterVersionsResponse' failed as data isn't a dictionary.`
170
+ );
171
+ }
172
+ return {
173
+ totalCount: data.total_count,
174
+ versions: unmarshalArrayOfObject(data.versions, unmarshalClusterVersion)
175
+ };
176
+ };
177
+ const unmarshalListClustersResponse = (data) => {
178
+ if (!isJSONObject(data)) {
179
+ throw new TypeError(
180
+ `Unmarshalling the type 'ListClustersResponse' failed as data isn't a dictionary.`
181
+ );
182
+ }
183
+ return {
184
+ clusters: unmarshalArrayOfObject(data.clusters, unmarshalCluster),
185
+ totalCount: data.total_count
186
+ };
187
+ };
188
+ const unmarshalNodeType = (data) => {
189
+ if (!isJSONObject(data)) {
190
+ throw new TypeError(
191
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
192
+ );
193
+ }
194
+ return {
195
+ beta: data.beta,
196
+ description: data.description,
197
+ disabled: data.disabled,
198
+ memory: data.memory,
199
+ name: data.name,
200
+ stockStatus: data.stock_status,
201
+ vcpus: data.vcpus,
202
+ zone: data.zone
203
+ };
204
+ };
205
+ const unmarshalListNodeTypesResponse = (data) => {
206
+ if (!isJSONObject(data)) {
207
+ throw new TypeError(
208
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
209
+ );
210
+ }
211
+ return {
212
+ nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
213
+ totalCount: data.total_count
214
+ };
215
+ };
216
+ const unmarshalSetAclRulesResponse = (data) => {
217
+ if (!isJSONObject(data)) {
218
+ throw new TypeError(
219
+ `Unmarshalling the type 'SetAclRulesResponse' failed as data isn't a dictionary.`
220
+ );
221
+ }
222
+ return {
223
+ aclRules: unmarshalArrayOfObject(data.acl_rules, unmarshalACLRule)
224
+ };
225
+ };
226
+ const unmarshalSetEndpointsResponse = (data) => {
227
+ if (!isJSONObject(data)) {
228
+ throw new TypeError(
229
+ `Unmarshalling the type 'SetEndpointsResponse' failed as data isn't a dictionary.`
230
+ );
231
+ }
232
+ return {
233
+ endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint)
234
+ };
235
+ };
236
+ const marshalACLRuleSpec = (request, defaults) => ({
237
+ description: request.description,
238
+ ip_cidr: request.ipCidr
239
+ });
240
+ const marshalAddAclRulesRequest = (request, defaults) => ({
241
+ acl_rules: request.aclRules.map((elt) => marshalACLRuleSpec(elt))
242
+ });
243
+ const marshalClusterSetting = (request, defaults) => ({
244
+ name: request.name,
245
+ value: request.value
246
+ });
247
+ const marshalAddClusterSettingsRequest = (request, defaults) => ({
248
+ settings: request.settings.map((elt) => marshalClusterSetting(elt))
249
+ });
250
+ const marshalEndpointSpecPrivateNetworkSpecIpamConfig = (request, defaults) => ({});
251
+ const marshalEndpointSpecPrivateNetworkSpec = (request, defaults) => ({
252
+ id: request.id,
253
+ ipam_config: request.ipamConfig !== void 0 ? marshalEndpointSpecPrivateNetworkSpecIpamConfig(
254
+ request.ipamConfig
255
+ ) : void 0,
256
+ service_ips: request.serviceIps
257
+ });
258
+ const marshalEndpointSpecPublicNetworkSpec = (request, defaults) => ({});
259
+ const marshalEndpointSpec = (request, defaults) => ({
260
+ ...resolveOneOf([
261
+ {
262
+ param: "private_network",
263
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkSpec(
264
+ request.privateNetwork
265
+ ) : void 0
266
+ },
267
+ {
268
+ param: "public_network",
269
+ value: request.publicNetwork !== void 0 ? marshalEndpointSpecPublicNetworkSpec(
270
+ request.publicNetwork
271
+ ) : void 0
272
+ }
273
+ ])
274
+ });
275
+ const marshalAddEndpointsRequest = (request, defaults) => ({
276
+ endpoints: request.endpoints.map((elt) => marshalEndpointSpec(elt))
277
+ });
278
+ const marshalCreateClusterRequest = (request, defaults) => ({
279
+ acl_rules: request.aclRules !== void 0 ? request.aclRules.map((elt) => marshalACLRuleSpec(elt)) : void 0,
280
+ cluster_settings: request.clusterSettings !== void 0 ? request.clusterSettings.map((elt) => marshalClusterSetting(elt)) : void 0,
281
+ cluster_size: request.clusterSize,
282
+ endpoints: request.endpoints !== void 0 ? request.endpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
283
+ name: request.name || randomName("ins"),
284
+ node_type: request.nodeType,
285
+ password: request.password,
286
+ project_id: request.projectId ?? defaults.defaultProjectId,
287
+ tags: request.tags,
288
+ tls_enabled: request.tlsEnabled,
289
+ user_name: request.userName,
290
+ version: request.version
291
+ });
292
+ const marshalMigrateClusterRequest = (request, defaults) => ({
293
+ ...resolveOneOf([
294
+ { param: "version", value: request.version },
295
+ { param: "node_type", value: request.nodeType },
296
+ { param: "cluster_size", value: request.clusterSize }
297
+ ])
298
+ });
299
+ const marshalSetAclRulesRequest = (request, defaults) => ({
300
+ acl_rules: request.aclRules.map((elt) => marshalACLRuleSpec(elt))
301
+ });
302
+ const marshalSetClusterSettingsRequest = (request, defaults) => ({
303
+ settings: request.settings.map((elt) => marshalClusterSetting(elt))
304
+ });
305
+ const marshalSetEndpointsRequest = (request, defaults) => ({
306
+ endpoints: request.endpoints.map((elt) => marshalEndpointSpec(elt))
307
+ });
308
+ const marshalUpdateClusterRequest = (request, defaults) => ({
309
+ name: request.name,
310
+ password: request.password,
311
+ tags: request.tags,
312
+ user_name: request.userName
313
+ });
314
+ const marshalUpdateEndpointRequest = (request, defaults) => ({
315
+ ...resolveOneOf([
316
+ {
317
+ param: "private_network",
318
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetworkSpec(
319
+ request.privateNetwork
320
+ ) : void 0
321
+ },
322
+ {
323
+ param: "public_network",
324
+ value: request.publicNetwork !== void 0 ? marshalEndpointSpecPublicNetworkSpec(
325
+ request.publicNetwork
326
+ ) : void 0
327
+ }
328
+ ])
329
+ });
330
+ export {
331
+ marshalAddAclRulesRequest,
332
+ marshalAddClusterSettingsRequest,
333
+ marshalAddEndpointsRequest,
334
+ marshalCreateClusterRequest,
335
+ marshalMigrateClusterRequest,
336
+ marshalSetAclRulesRequest,
337
+ marshalSetClusterSettingsRequest,
338
+ marshalSetEndpointsRequest,
339
+ marshalUpdateClusterRequest,
340
+ marshalUpdateEndpointRequest,
341
+ unmarshalACLRule,
342
+ unmarshalAddAclRulesResponse,
343
+ unmarshalAddEndpointsResponse,
344
+ unmarshalCluster,
345
+ unmarshalClusterMetricsResponse,
346
+ unmarshalClusterSettingsResponse,
347
+ unmarshalEndpoint,
348
+ unmarshalListClusterVersionsResponse,
349
+ unmarshalListClustersResponse,
350
+ unmarshalListNodeTypesResponse,
351
+ unmarshalSetAclRulesResponse,
352
+ unmarshalSetEndpointsResponse
353
+ };