@scaleway/sdk-rdb 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,922 @@
1
+ import randomName from "@scaleway/random-name";
2
+ import { resolveOneOf, isJSONObject, unmarshalDate, unmarshalArrayOfObject, unmarshalTimeSeries } from "@scaleway/sdk-client";
3
+ const unmarshalEndpointDirectAccessDetails = (data) => {
4
+ if (!isJSONObject(data)) {
5
+ throw new TypeError(
6
+ `Unmarshalling the type 'EndpointDirectAccessDetails' failed as data isn't a dictionary.`
7
+ );
8
+ }
9
+ return {};
10
+ };
11
+ const unmarshalEndpointLoadBalancerDetails = (data) => {
12
+ if (!isJSONObject(data)) {
13
+ throw new TypeError(
14
+ `Unmarshalling the type 'EndpointLoadBalancerDetails' failed as data isn't a dictionary.`
15
+ );
16
+ }
17
+ return {};
18
+ };
19
+ const unmarshalEndpointPrivateNetworkDetails = (data) => {
20
+ if (!isJSONObject(data)) {
21
+ throw new TypeError(
22
+ `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`
23
+ );
24
+ }
25
+ return {
26
+ privateNetworkId: data.private_network_id,
27
+ provisioningMode: data.provisioning_mode,
28
+ serviceIp: data.service_ip,
29
+ zone: data.zone
30
+ };
31
+ };
32
+ const unmarshalEndpoint = (data) => {
33
+ if (!isJSONObject(data)) {
34
+ throw new TypeError(
35
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
36
+ );
37
+ }
38
+ return {
39
+ directAccess: data.direct_access ? unmarshalEndpointDirectAccessDetails(data.direct_access) : void 0,
40
+ hostname: data.hostname,
41
+ id: data.id,
42
+ ip: data.ip,
43
+ loadBalancer: data.load_balancer ? unmarshalEndpointLoadBalancerDetails(data.load_balancer) : void 0,
44
+ name: data.name,
45
+ port: data.port,
46
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0
47
+ };
48
+ };
49
+ const unmarshalMaintenance = (data) => {
50
+ if (!isJSONObject(data)) {
51
+ throw new TypeError(
52
+ `Unmarshalling the type 'Maintenance' failed as data isn't a dictionary.`
53
+ );
54
+ }
55
+ return {
56
+ closedAt: unmarshalDate(data.closed_at),
57
+ forcedAt: unmarshalDate(data.forced_at),
58
+ reason: data.reason,
59
+ startsAt: unmarshalDate(data.starts_at),
60
+ status: data.status,
61
+ stopsAt: unmarshalDate(data.stops_at)
62
+ };
63
+ };
64
+ const unmarshalReadReplica = (data) => {
65
+ if (!isJSONObject(data)) {
66
+ throw new TypeError(
67
+ `Unmarshalling the type 'ReadReplica' failed as data isn't a dictionary.`
68
+ );
69
+ }
70
+ return {
71
+ endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
72
+ id: data.id,
73
+ instanceId: data.instance_id,
74
+ region: data.region,
75
+ sameZone: data.same_zone,
76
+ status: data.status
77
+ };
78
+ };
79
+ const unmarshalDatabaseBackup = (data) => {
80
+ if (!isJSONObject(data)) {
81
+ throw new TypeError(
82
+ `Unmarshalling the type 'DatabaseBackup' failed as data isn't a dictionary.`
83
+ );
84
+ }
85
+ return {
86
+ createdAt: unmarshalDate(data.created_at),
87
+ databaseName: data.database_name,
88
+ downloadUrl: data.download_url,
89
+ downloadUrlExpiresAt: unmarshalDate(data.download_url_expires_at),
90
+ expiresAt: unmarshalDate(data.expires_at),
91
+ id: data.id,
92
+ instanceId: data.instance_id,
93
+ instanceName: data.instance_name,
94
+ name: data.name,
95
+ region: data.region,
96
+ sameRegion: data.same_region,
97
+ size: data.size,
98
+ status: data.status,
99
+ updatedAt: unmarshalDate(data.updated_at)
100
+ };
101
+ };
102
+ const unmarshalDatabase = (data) => {
103
+ if (!isJSONObject(data)) {
104
+ throw new TypeError(
105
+ `Unmarshalling the type 'Database' failed as data isn't a dictionary.`
106
+ );
107
+ }
108
+ return {
109
+ managed: data.managed,
110
+ name: data.name,
111
+ owner: data.owner,
112
+ size: data.size
113
+ };
114
+ };
115
+ const unmarshalInstanceLog = (data) => {
116
+ if (!isJSONObject(data)) {
117
+ throw new TypeError(
118
+ `Unmarshalling the type 'InstanceLog' failed as data isn't a dictionary.`
119
+ );
120
+ }
121
+ return {
122
+ createdAt: unmarshalDate(data.created_at),
123
+ downloadUrl: data.download_url,
124
+ expiresAt: unmarshalDate(data.expires_at),
125
+ id: data.id,
126
+ nodeName: data.node_name,
127
+ region: data.region,
128
+ status: data.status
129
+ };
130
+ };
131
+ const unmarshalBackupSchedule = (data) => {
132
+ if (!isJSONObject(data)) {
133
+ throw new TypeError(
134
+ `Unmarshalling the type 'BackupSchedule' failed as data isn't a dictionary.`
135
+ );
136
+ }
137
+ return {
138
+ disabled: data.disabled,
139
+ frequency: data.frequency,
140
+ nextRunAt: unmarshalDate(data.next_run_at),
141
+ retention: data.retention
142
+ };
143
+ };
144
+ const unmarshalEncryptionAtRest = (data) => {
145
+ if (!isJSONObject(data)) {
146
+ throw new TypeError(
147
+ `Unmarshalling the type 'EncryptionAtRest' failed as data isn't a dictionary.`
148
+ );
149
+ }
150
+ return {
151
+ enabled: data.enabled
152
+ };
153
+ };
154
+ const unmarshalInstanceSetting = (data) => {
155
+ if (!isJSONObject(data)) {
156
+ throw new TypeError(
157
+ `Unmarshalling the type 'InstanceSetting' failed as data isn't a dictionary.`
158
+ );
159
+ }
160
+ return {
161
+ name: data.name,
162
+ value: data.value
163
+ };
164
+ };
165
+ const unmarshalLogsPolicy = (data) => {
166
+ if (!isJSONObject(data)) {
167
+ throw new TypeError(
168
+ `Unmarshalling the type 'LogsPolicy' failed as data isn't a dictionary.`
169
+ );
170
+ }
171
+ return {
172
+ maxAgeRetention: data.max_age_retention,
173
+ totalDiskRetention: data.total_disk_retention
174
+ };
175
+ };
176
+ const unmarshalUpgradableVersion = (data) => {
177
+ if (!isJSONObject(data)) {
178
+ throw new TypeError(
179
+ `Unmarshalling the type 'UpgradableVersion' failed as data isn't a dictionary.`
180
+ );
181
+ }
182
+ return {
183
+ id: data.id,
184
+ minorVersion: data.minor_version,
185
+ name: data.name,
186
+ version: data.version
187
+ };
188
+ };
189
+ const unmarshalVolume = (data) => {
190
+ if (!isJSONObject(data)) {
191
+ throw new TypeError(
192
+ `Unmarshalling the type 'Volume' failed as data isn't a dictionary.`
193
+ );
194
+ }
195
+ return {
196
+ class: data.class,
197
+ size: data.size,
198
+ type: data.type
199
+ };
200
+ };
201
+ const unmarshalInstance = (data) => {
202
+ if (!isJSONObject(data)) {
203
+ throw new TypeError(
204
+ `Unmarshalling the type 'Instance' failed as data isn't a dictionary.`
205
+ );
206
+ }
207
+ return {
208
+ backupSameRegion: data.backup_same_region,
209
+ backupSchedule: data.backup_schedule ? unmarshalBackupSchedule(data.backup_schedule) : void 0,
210
+ createdAt: unmarshalDate(data.created_at),
211
+ encryption: data.encryption ? unmarshalEncryptionAtRest(data.encryption) : void 0,
212
+ endpoint: data.endpoint ? unmarshalEndpoint(data.endpoint) : void 0,
213
+ endpoints: unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
214
+ engine: data.engine,
215
+ id: data.id,
216
+ initSettings: unmarshalArrayOfObject(
217
+ data.init_settings,
218
+ unmarshalInstanceSetting
219
+ ),
220
+ isHaCluster: data.is_ha_cluster,
221
+ logsPolicy: data.logs_policy ? unmarshalLogsPolicy(data.logs_policy) : void 0,
222
+ maintenances: unmarshalArrayOfObject(
223
+ data.maintenances,
224
+ unmarshalMaintenance
225
+ ),
226
+ name: data.name,
227
+ nodeType: data.node_type,
228
+ organizationId: data.organization_id,
229
+ projectId: data.project_id,
230
+ readReplicas: unmarshalArrayOfObject(
231
+ data.read_replicas,
232
+ unmarshalReadReplica
233
+ ),
234
+ region: data.region,
235
+ settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting),
236
+ status: data.status,
237
+ tags: data.tags,
238
+ upgradableVersion: unmarshalArrayOfObject(
239
+ data.upgradable_version,
240
+ unmarshalUpgradableVersion
241
+ ),
242
+ volume: data.volume ? unmarshalVolume(data.volume) : void 0
243
+ };
244
+ };
245
+ const unmarshalPrivilege = (data) => {
246
+ if (!isJSONObject(data)) {
247
+ throw new TypeError(
248
+ `Unmarshalling the type 'Privilege' failed as data isn't a dictionary.`
249
+ );
250
+ }
251
+ return {
252
+ databaseName: data.database_name,
253
+ permission: data.permission,
254
+ userName: data.user_name
255
+ };
256
+ };
257
+ const unmarshalSnapshotVolumeType = (data) => {
258
+ if (!isJSONObject(data)) {
259
+ throw new TypeError(
260
+ `Unmarshalling the type 'SnapshotVolumeType' failed as data isn't a dictionary.`
261
+ );
262
+ }
263
+ return {
264
+ class: data.class,
265
+ type: data.type
266
+ };
267
+ };
268
+ const unmarshalSnapshot = (data) => {
269
+ if (!isJSONObject(data)) {
270
+ throw new TypeError(
271
+ `Unmarshalling the type 'Snapshot' failed as data isn't a dictionary.`
272
+ );
273
+ }
274
+ return {
275
+ createdAt: unmarshalDate(data.created_at),
276
+ expiresAt: unmarshalDate(data.expires_at),
277
+ id: data.id,
278
+ instanceId: data.instance_id,
279
+ instanceName: data.instance_name,
280
+ name: data.name,
281
+ nodeType: data.node_type,
282
+ region: data.region,
283
+ size: data.size,
284
+ status: data.status,
285
+ updatedAt: unmarshalDate(data.updated_at),
286
+ volumeType: data.volume_type ? unmarshalSnapshotVolumeType(data.volume_type) : void 0
287
+ };
288
+ };
289
+ const unmarshalUser = (data) => {
290
+ if (!isJSONObject(data)) {
291
+ throw new TypeError(
292
+ `Unmarshalling the type 'User' failed as data isn't a dictionary.`
293
+ );
294
+ }
295
+ return {
296
+ isAdmin: data.is_admin,
297
+ name: data.name
298
+ };
299
+ };
300
+ const unmarshalACLRule = (data) => {
301
+ if (!isJSONObject(data)) {
302
+ throw new TypeError(
303
+ `Unmarshalling the type 'ACLRule' failed as data isn't a dictionary.`
304
+ );
305
+ }
306
+ return {
307
+ action: data.action,
308
+ description: data.description,
309
+ direction: data.direction,
310
+ ip: data.ip,
311
+ port: data.port,
312
+ protocol: data.protocol
313
+ };
314
+ };
315
+ const unmarshalAddInstanceACLRulesResponse = (data) => {
316
+ if (!isJSONObject(data)) {
317
+ throw new TypeError(
318
+ `Unmarshalling the type 'AddInstanceACLRulesResponse' failed as data isn't a dictionary.`
319
+ );
320
+ }
321
+ return {
322
+ rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule)
323
+ };
324
+ };
325
+ const unmarshalAddInstanceSettingsResponse = (data) => {
326
+ if (!isJSONObject(data)) {
327
+ throw new TypeError(
328
+ `Unmarshalling the type 'AddInstanceSettingsResponse' failed as data isn't a dictionary.`
329
+ );
330
+ }
331
+ return {
332
+ settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting)
333
+ };
334
+ };
335
+ const unmarshalDeleteInstanceACLRulesResponse = (data) => {
336
+ if (!isJSONObject(data)) {
337
+ throw new TypeError(
338
+ `Unmarshalling the type 'DeleteInstanceACLRulesResponse' failed as data isn't a dictionary.`
339
+ );
340
+ }
341
+ return {
342
+ rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule)
343
+ };
344
+ };
345
+ const unmarshalDeleteInstanceSettingsResponse = (data) => {
346
+ if (!isJSONObject(data)) {
347
+ throw new TypeError(
348
+ `Unmarshalling the type 'DeleteInstanceSettingsResponse' failed as data isn't a dictionary.`
349
+ );
350
+ }
351
+ return {
352
+ settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting)
353
+ };
354
+ };
355
+ const unmarshalInstanceMetrics = (data) => {
356
+ if (!isJSONObject(data)) {
357
+ throw new TypeError(
358
+ `Unmarshalling the type 'InstanceMetrics' failed as data isn't a dictionary.`
359
+ );
360
+ }
361
+ return {
362
+ timeseries: unmarshalArrayOfObject(data.timeseries, unmarshalTimeSeries)
363
+ };
364
+ };
365
+ const unmarshalListDatabaseBackupsResponse = (data) => {
366
+ if (!isJSONObject(data)) {
367
+ throw new TypeError(
368
+ `Unmarshalling the type 'ListDatabaseBackupsResponse' failed as data isn't a dictionary.`
369
+ );
370
+ }
371
+ return {
372
+ databaseBackups: unmarshalArrayOfObject(
373
+ data.database_backups,
374
+ unmarshalDatabaseBackup
375
+ ),
376
+ totalCount: data.total_count
377
+ };
378
+ };
379
+ const unmarshalEngineSetting = (data) => {
380
+ if (!isJSONObject(data)) {
381
+ throw new TypeError(
382
+ `Unmarshalling the type 'EngineSetting' failed as data isn't a dictionary.`
383
+ );
384
+ }
385
+ return {
386
+ defaultValue: data.default_value,
387
+ description: data.description,
388
+ floatMax: data.float_max,
389
+ floatMin: data.float_min,
390
+ hotConfigurable: data.hot_configurable,
391
+ intMax: data.int_max,
392
+ intMin: data.int_min,
393
+ name: data.name,
394
+ propertyType: data.property_type,
395
+ stringConstraint: data.string_constraint,
396
+ unit: data.unit
397
+ };
398
+ };
399
+ const unmarshalEngineVersion = (data) => {
400
+ if (!isJSONObject(data)) {
401
+ throw new TypeError(
402
+ `Unmarshalling the type 'EngineVersion' failed as data isn't a dictionary.`
403
+ );
404
+ }
405
+ return {
406
+ availableInitSettings: unmarshalArrayOfObject(
407
+ data.available_init_settings,
408
+ unmarshalEngineSetting
409
+ ),
410
+ availableSettings: unmarshalArrayOfObject(
411
+ data.available_settings,
412
+ unmarshalEngineSetting
413
+ ),
414
+ beta: data.beta,
415
+ disabled: data.disabled,
416
+ endOfLife: unmarshalDate(data.end_of_life),
417
+ name: data.name,
418
+ version: data.version
419
+ };
420
+ };
421
+ const unmarshalDatabaseEngine = (data) => {
422
+ if (!isJSONObject(data)) {
423
+ throw new TypeError(
424
+ `Unmarshalling the type 'DatabaseEngine' failed as data isn't a dictionary.`
425
+ );
426
+ }
427
+ return {
428
+ logoUrl: data.logo_url,
429
+ name: data.name,
430
+ region: data.region,
431
+ versions: unmarshalArrayOfObject(data.versions, unmarshalEngineVersion)
432
+ };
433
+ };
434
+ const unmarshalListDatabaseEnginesResponse = (data) => {
435
+ if (!isJSONObject(data)) {
436
+ throw new TypeError(
437
+ `Unmarshalling the type 'ListDatabaseEnginesResponse' failed as data isn't a dictionary.`
438
+ );
439
+ }
440
+ return {
441
+ engines: unmarshalArrayOfObject(data.engines, unmarshalDatabaseEngine),
442
+ totalCount: data.total_count
443
+ };
444
+ };
445
+ const unmarshalListDatabasesResponse = (data) => {
446
+ if (!isJSONObject(data)) {
447
+ throw new TypeError(
448
+ `Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary.`
449
+ );
450
+ }
451
+ return {
452
+ databases: unmarshalArrayOfObject(data.databases, unmarshalDatabase),
453
+ totalCount: data.total_count
454
+ };
455
+ };
456
+ const unmarshalListInstanceACLRulesResponse = (data) => {
457
+ if (!isJSONObject(data)) {
458
+ throw new TypeError(
459
+ `Unmarshalling the type 'ListInstanceACLRulesResponse' failed as data isn't a dictionary.`
460
+ );
461
+ }
462
+ return {
463
+ rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule),
464
+ totalCount: data.total_count
465
+ };
466
+ };
467
+ const unmarshalListInstanceLogsDetailsResponseInstanceLogDetail = (data) => {
468
+ if (!isJSONObject(data)) {
469
+ throw new TypeError(
470
+ `Unmarshalling the type 'ListInstanceLogsDetailsResponseInstanceLogDetail' failed as data isn't a dictionary.`
471
+ );
472
+ }
473
+ return {
474
+ logName: data.log_name,
475
+ size: data.size
476
+ };
477
+ };
478
+ const unmarshalListInstanceLogsDetailsResponse = (data) => {
479
+ if (!isJSONObject(data)) {
480
+ throw new TypeError(
481
+ `Unmarshalling the type 'ListInstanceLogsDetailsResponse' failed as data isn't a dictionary.`
482
+ );
483
+ }
484
+ return {
485
+ details: unmarshalArrayOfObject(
486
+ data.details,
487
+ unmarshalListInstanceLogsDetailsResponseInstanceLogDetail
488
+ )
489
+ };
490
+ };
491
+ const unmarshalListInstanceLogsResponse = (data) => {
492
+ if (!isJSONObject(data)) {
493
+ throw new TypeError(
494
+ `Unmarshalling the type 'ListInstanceLogsResponse' failed as data isn't a dictionary.`
495
+ );
496
+ }
497
+ return {
498
+ instanceLogs: unmarshalArrayOfObject(
499
+ data.instance_logs,
500
+ unmarshalInstanceLog
501
+ )
502
+ };
503
+ };
504
+ const unmarshalListInstancesResponse = (data) => {
505
+ if (!isJSONObject(data)) {
506
+ throw new TypeError(
507
+ `Unmarshalling the type 'ListInstancesResponse' failed as data isn't a dictionary.`
508
+ );
509
+ }
510
+ return {
511
+ instances: unmarshalArrayOfObject(data.instances, unmarshalInstance),
512
+ totalCount: data.total_count
513
+ };
514
+ };
515
+ const unmarshalNodeTypeVolumeConstraintSizes = (data) => {
516
+ if (!isJSONObject(data)) {
517
+ throw new TypeError(
518
+ `Unmarshalling the type 'NodeTypeVolumeConstraintSizes' failed as data isn't a dictionary.`
519
+ );
520
+ }
521
+ return {
522
+ maxSize: data.max_size,
523
+ minSize: data.min_size
524
+ };
525
+ };
526
+ const unmarshalNodeTypeVolumeType = (data) => {
527
+ if (!isJSONObject(data)) {
528
+ throw new TypeError(
529
+ `Unmarshalling the type 'NodeTypeVolumeType' failed as data isn't a dictionary.`
530
+ );
531
+ }
532
+ return {
533
+ chunkSize: data.chunk_size,
534
+ class: data.class,
535
+ description: data.description,
536
+ maxSize: data.max_size,
537
+ minSize: data.min_size,
538
+ type: data.type
539
+ };
540
+ };
541
+ const unmarshalNodeType = (data) => {
542
+ if (!isJSONObject(data)) {
543
+ throw new TypeError(
544
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
545
+ );
546
+ }
547
+ return {
548
+ availableVolumeTypes: unmarshalArrayOfObject(
549
+ data.available_volume_types,
550
+ unmarshalNodeTypeVolumeType
551
+ ),
552
+ beta: data.beta,
553
+ description: data.description,
554
+ disabled: data.disabled,
555
+ generation: data.generation,
556
+ instanceRange: data.instance_range,
557
+ isBssdCompatible: data.is_bssd_compatible,
558
+ isHaRequired: data.is_ha_required,
559
+ memory: data.memory,
560
+ name: data.name,
561
+ region: data.region,
562
+ stockStatus: data.stock_status,
563
+ vcpus: data.vcpus,
564
+ volumeConstraint: data.volume_constraint ? unmarshalNodeTypeVolumeConstraintSizes(data.volume_constraint) : void 0
565
+ };
566
+ };
567
+ const unmarshalListNodeTypesResponse = (data) => {
568
+ if (!isJSONObject(data)) {
569
+ throw new TypeError(
570
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
571
+ );
572
+ }
573
+ return {
574
+ nodeTypes: unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
575
+ totalCount: data.total_count
576
+ };
577
+ };
578
+ const unmarshalListPrivilegesResponse = (data) => {
579
+ if (!isJSONObject(data)) {
580
+ throw new TypeError(
581
+ `Unmarshalling the type 'ListPrivilegesResponse' failed as data isn't a dictionary.`
582
+ );
583
+ }
584
+ return {
585
+ privileges: unmarshalArrayOfObject(data.privileges, unmarshalPrivilege),
586
+ totalCount: data.total_count
587
+ };
588
+ };
589
+ const unmarshalListSnapshotsResponse = (data) => {
590
+ if (!isJSONObject(data)) {
591
+ throw new TypeError(
592
+ `Unmarshalling the type 'ListSnapshotsResponse' failed as data isn't a dictionary.`
593
+ );
594
+ }
595
+ return {
596
+ snapshots: unmarshalArrayOfObject(data.snapshots, unmarshalSnapshot),
597
+ totalCount: data.total_count
598
+ };
599
+ };
600
+ const unmarshalListUsersResponse = (data) => {
601
+ if (!isJSONObject(data)) {
602
+ throw new TypeError(
603
+ `Unmarshalling the type 'ListUsersResponse' failed as data isn't a dictionary.`
604
+ );
605
+ }
606
+ return {
607
+ totalCount: data.total_count,
608
+ users: unmarshalArrayOfObject(data.users, unmarshalUser)
609
+ };
610
+ };
611
+ const unmarshalPrepareInstanceLogsResponse = (data) => {
612
+ if (!isJSONObject(data)) {
613
+ throw new TypeError(
614
+ `Unmarshalling the type 'PrepareInstanceLogsResponse' failed as data isn't a dictionary.`
615
+ );
616
+ }
617
+ return {
618
+ instanceLogs: unmarshalArrayOfObject(
619
+ data.instance_logs,
620
+ unmarshalInstanceLog
621
+ )
622
+ };
623
+ };
624
+ const unmarshalSetInstanceACLRulesResponse = (data) => {
625
+ if (!isJSONObject(data)) {
626
+ throw new TypeError(
627
+ `Unmarshalling the type 'SetInstanceACLRulesResponse' failed as data isn't a dictionary.`
628
+ );
629
+ }
630
+ return {
631
+ rules: unmarshalArrayOfObject(data.rules, unmarshalACLRule)
632
+ };
633
+ };
634
+ const unmarshalSetInstanceSettingsResponse = (data) => {
635
+ if (!isJSONObject(data)) {
636
+ throw new TypeError(
637
+ `Unmarshalling the type 'SetInstanceSettingsResponse' failed as data isn't a dictionary.`
638
+ );
639
+ }
640
+ return {
641
+ settings: unmarshalArrayOfObject(data.settings, unmarshalInstanceSetting)
642
+ };
643
+ };
644
+ const marshalACLRuleRequest = (request, defaults) => ({
645
+ description: request.description,
646
+ ip: request.ip
647
+ });
648
+ const marshalAddInstanceACLRulesRequest = (request, defaults) => ({
649
+ rules: request.rules.map((elt) => marshalACLRuleRequest(elt))
650
+ });
651
+ const marshalInstanceSetting = (request, defaults) => ({
652
+ name: request.name,
653
+ value: request.value
654
+ });
655
+ const marshalAddInstanceSettingsRequest = (request, defaults) => ({
656
+ settings: request.settings.map((elt) => marshalInstanceSetting(elt))
657
+ });
658
+ const marshalCloneInstanceRequest = (request, defaults) => ({
659
+ name: request.name,
660
+ node_type: request.nodeType
661
+ });
662
+ const marshalCreateDatabaseBackupRequest = (request, defaults) => ({
663
+ database_name: request.databaseName,
664
+ expires_at: request.expiresAt,
665
+ instance_id: request.instanceId,
666
+ name: request.name || randomName("bkp")
667
+ });
668
+ const marshalCreateDatabaseRequest = (request, defaults) => ({
669
+ name: request.name
670
+ });
671
+ const marshalEndpointSpecPrivateNetworkIpamConfig = (request, defaults) => ({});
672
+ const marshalEndpointSpecLoadBalancer = (request, defaults) => ({});
673
+ const marshalEndpointSpecPrivateNetwork = (request, defaults) => ({
674
+ private_network_id: request.privateNetworkId,
675
+ ...resolveOneOf([
676
+ { param: "service_ip", value: request.serviceIp },
677
+ {
678
+ param: "ipam_config",
679
+ value: request.ipamConfig !== void 0 ? marshalEndpointSpecPrivateNetworkIpamConfig(
680
+ request.ipamConfig
681
+ ) : void 0
682
+ }
683
+ ])
684
+ });
685
+ const marshalEndpointSpec = (request, defaults) => ({
686
+ ...resolveOneOf([
687
+ {
688
+ param: "load_balancer",
689
+ value: request.loadBalancer !== void 0 ? marshalEndpointSpecLoadBalancer(request.loadBalancer) : void 0
690
+ },
691
+ {
692
+ param: "private_network",
693
+ value: request.privateNetwork !== void 0 ? marshalEndpointSpecPrivateNetwork(request.privateNetwork) : void 0
694
+ }
695
+ ])
696
+ });
697
+ const marshalCreateEndpointRequest = (request, defaults) => ({
698
+ endpoint_spec: request.endpointSpec !== void 0 ? marshalEndpointSpec(request.endpointSpec) : void 0
699
+ });
700
+ const marshalCreateInstanceFromSnapshotRequest = (request, defaults) => ({
701
+ instance_name: request.instanceName,
702
+ is_ha_cluster: request.isHaCluster,
703
+ node_type: request.nodeType
704
+ });
705
+ const marshalEncryptionAtRest = (request, defaults) => ({
706
+ enabled: request.enabled
707
+ });
708
+ const marshalCreateInstanceRequest = (request, defaults) => ({
709
+ backup_same_region: request.backupSameRegion,
710
+ disable_backup: request.disableBackup,
711
+ encryption: request.encryption !== void 0 ? marshalEncryptionAtRest(request.encryption) : void 0,
712
+ engine: request.engine,
713
+ init_endpoints: request.initEndpoints !== void 0 ? request.initEndpoints.map((elt) => marshalEndpointSpec(elt)) : void 0,
714
+ init_settings: request.initSettings !== void 0 ? request.initSettings.map((elt) => marshalInstanceSetting(elt)) : void 0,
715
+ is_ha_cluster: request.isHaCluster,
716
+ name: request.name || randomName("ins"),
717
+ node_type: request.nodeType,
718
+ password: request.password,
719
+ tags: request.tags,
720
+ user_name: request.userName,
721
+ volume_size: request.volumeSize,
722
+ volume_type: request.volumeType,
723
+ ...resolveOneOf([
724
+ {
725
+ default: defaults.defaultProjectId,
726
+ param: "project_id",
727
+ value: request.projectId
728
+ },
729
+ {
730
+ default: defaults.defaultOrganizationId,
731
+ param: "organization_id",
732
+ value: request.organizationId
733
+ }
734
+ ])
735
+ });
736
+ const marshalReadReplicaEndpointSpecPrivateNetworkIpamConfig = (request, defaults) => ({});
737
+ const marshalReadReplicaEndpointSpecDirectAccess = (request, defaults) => ({});
738
+ const marshalReadReplicaEndpointSpecPrivateNetwork = (request, defaults) => ({
739
+ private_network_id: request.privateNetworkId,
740
+ ...resolveOneOf([
741
+ { param: "service_ip", value: request.serviceIp },
742
+ {
743
+ param: "ipam_config",
744
+ value: request.ipamConfig !== void 0 ? marshalReadReplicaEndpointSpecPrivateNetworkIpamConfig(
745
+ request.ipamConfig
746
+ ) : void 0
747
+ }
748
+ ])
749
+ });
750
+ const marshalReadReplicaEndpointSpec = (request, defaults) => ({
751
+ ...resolveOneOf([
752
+ {
753
+ param: "direct_access",
754
+ value: request.directAccess !== void 0 ? marshalReadReplicaEndpointSpecDirectAccess(
755
+ request.directAccess
756
+ ) : void 0
757
+ },
758
+ {
759
+ param: "private_network",
760
+ value: request.privateNetwork !== void 0 ? marshalReadReplicaEndpointSpecPrivateNetwork(
761
+ request.privateNetwork
762
+ ) : void 0
763
+ }
764
+ ])
765
+ });
766
+ const marshalCreateReadReplicaEndpointRequest = (request, defaults) => ({
767
+ endpoint_spec: request.endpointSpec.map(
768
+ (elt) => marshalReadReplicaEndpointSpec(elt)
769
+ )
770
+ });
771
+ const marshalCreateReadReplicaRequest = (request, defaults) => ({
772
+ endpoint_spec: request.endpointSpec !== void 0 ? request.endpointSpec.map(
773
+ (elt) => marshalReadReplicaEndpointSpec(elt)
774
+ ) : void 0,
775
+ instance_id: request.instanceId,
776
+ same_zone: request.sameZone
777
+ });
778
+ const marshalCreateSnapshotRequest = (request, defaults) => ({
779
+ expires_at: request.expiresAt,
780
+ name: request.name || randomName("snp")
781
+ });
782
+ const marshalCreateUserRequest = (request, defaults) => ({
783
+ is_admin: request.isAdmin,
784
+ name: request.name,
785
+ password: request.password
786
+ });
787
+ const marshalDeleteInstanceACLRulesRequest = (request, defaults) => ({
788
+ acl_rule_ips: request.aclRuleIps
789
+ });
790
+ const marshalDeleteInstanceSettingsRequest = (request, defaults) => ({
791
+ setting_names: request.settingNames
792
+ });
793
+ const marshalMigrateEndpointRequest = (request, defaults) => ({
794
+ instance_id: request.instanceId
795
+ });
796
+ const marshalPrepareInstanceLogsRequest = (request, defaults) => ({
797
+ end_date: request.endDate,
798
+ start_date: request.startDate
799
+ });
800
+ const marshalPurgeInstanceLogsRequest = (request, defaults) => ({
801
+ log_name: request.logName
802
+ });
803
+ const marshalRestoreDatabaseBackupRequest = (request, defaults) => ({
804
+ database_name: request.databaseName,
805
+ instance_id: request.instanceId
806
+ });
807
+ const marshalSetInstanceACLRulesRequest = (request, defaults) => ({
808
+ rules: request.rules.map((elt) => marshalACLRuleRequest(elt))
809
+ });
810
+ const marshalSetInstanceSettingsRequest = (request, defaults) => ({
811
+ settings: request.settings.map((elt) => marshalInstanceSetting(elt))
812
+ });
813
+ const marshalSetPrivilegeRequest = (request, defaults) => ({
814
+ database_name: request.databaseName,
815
+ permission: request.permission,
816
+ user_name: request.userName
817
+ });
818
+ const marshalUpdateDatabaseBackupRequest = (request, defaults) => ({
819
+ expires_at: request.expiresAt,
820
+ name: request.name
821
+ });
822
+ const marshalLogsPolicy = (request, defaults) => ({
823
+ max_age_retention: request.maxAgeRetention,
824
+ total_disk_retention: request.totalDiskRetention
825
+ });
826
+ const marshalUpdateInstanceRequest = (request, defaults) => ({
827
+ backup_same_region: request.backupSameRegion,
828
+ backup_schedule_frequency: request.backupScheduleFrequency,
829
+ backup_schedule_retention: request.backupScheduleRetention,
830
+ backup_schedule_start_hour: request.backupScheduleStartHour,
831
+ is_backup_schedule_disabled: request.isBackupScheduleDisabled,
832
+ logs_policy: request.logsPolicy !== void 0 ? marshalLogsPolicy(request.logsPolicy) : void 0,
833
+ name: request.name,
834
+ tags: request.tags
835
+ });
836
+ const marshalUpdateSnapshotRequest = (request, defaults) => ({
837
+ expires_at: request.expiresAt,
838
+ name: request.name
839
+ });
840
+ const marshalUpdateUserRequest = (request, defaults) => ({
841
+ is_admin: request.isAdmin,
842
+ password: request.password
843
+ });
844
+ const marshalUpgradeInstanceRequestMajorUpgradeWorkflow = (request, defaults) => ({
845
+ upgradable_version_id: request.upgradableVersionId,
846
+ with_endpoints: request.withEndpoints
847
+ });
848
+ const marshalUpgradeInstanceRequest = (request, defaults) => ({
849
+ ...resolveOneOf([
850
+ { param: "node_type", value: request.nodeType },
851
+ { param: "enable_ha", value: request.enableHa },
852
+ { param: "volume_size", value: request.volumeSize },
853
+ { param: "volume_type", value: request.volumeType },
854
+ { param: "upgradable_version_id", value: request.upgradableVersionId },
855
+ {
856
+ param: "major_upgrade_workflow",
857
+ value: request.majorUpgradeWorkflow !== void 0 ? marshalUpgradeInstanceRequestMajorUpgradeWorkflow(
858
+ request.majorUpgradeWorkflow
859
+ ) : void 0
860
+ },
861
+ { param: "enable_encryption", value: request.enableEncryption }
862
+ ])
863
+ });
864
+ export {
865
+ marshalAddInstanceACLRulesRequest,
866
+ marshalAddInstanceSettingsRequest,
867
+ marshalCloneInstanceRequest,
868
+ marshalCreateDatabaseBackupRequest,
869
+ marshalCreateDatabaseRequest,
870
+ marshalCreateEndpointRequest,
871
+ marshalCreateInstanceFromSnapshotRequest,
872
+ marshalCreateInstanceRequest,
873
+ marshalCreateReadReplicaEndpointRequest,
874
+ marshalCreateReadReplicaRequest,
875
+ marshalCreateSnapshotRequest,
876
+ marshalCreateUserRequest,
877
+ marshalDeleteInstanceACLRulesRequest,
878
+ marshalDeleteInstanceSettingsRequest,
879
+ marshalMigrateEndpointRequest,
880
+ marshalPrepareInstanceLogsRequest,
881
+ marshalPurgeInstanceLogsRequest,
882
+ marshalRestoreDatabaseBackupRequest,
883
+ marshalSetInstanceACLRulesRequest,
884
+ marshalSetInstanceSettingsRequest,
885
+ marshalSetPrivilegeRequest,
886
+ marshalUpdateDatabaseBackupRequest,
887
+ marshalUpdateInstanceRequest,
888
+ marshalUpdateSnapshotRequest,
889
+ marshalUpdateUserRequest,
890
+ marshalUpgradeInstanceRequest,
891
+ unmarshalACLRule,
892
+ unmarshalAddInstanceACLRulesResponse,
893
+ unmarshalAddInstanceSettingsResponse,
894
+ unmarshalBackupSchedule,
895
+ unmarshalDatabase,
896
+ unmarshalDatabaseBackup,
897
+ unmarshalDeleteInstanceACLRulesResponse,
898
+ unmarshalDeleteInstanceSettingsResponse,
899
+ unmarshalEndpoint,
900
+ unmarshalInstance,
901
+ unmarshalInstanceLog,
902
+ unmarshalInstanceMetrics,
903
+ unmarshalListDatabaseBackupsResponse,
904
+ unmarshalListDatabaseEnginesResponse,
905
+ unmarshalListDatabasesResponse,
906
+ unmarshalListInstanceACLRulesResponse,
907
+ unmarshalListInstanceLogsDetailsResponse,
908
+ unmarshalListInstanceLogsResponse,
909
+ unmarshalListInstancesResponse,
910
+ unmarshalListNodeTypesResponse,
911
+ unmarshalListPrivilegesResponse,
912
+ unmarshalListSnapshotsResponse,
913
+ unmarshalListUsersResponse,
914
+ unmarshalMaintenance,
915
+ unmarshalPrepareInstanceLogsResponse,
916
+ unmarshalPrivilege,
917
+ unmarshalReadReplica,
918
+ unmarshalSetInstanceACLRulesResponse,
919
+ unmarshalSetInstanceSettingsResponse,
920
+ unmarshalSnapshot,
921
+ unmarshalUser
922
+ };