@scaleway/sdk-webhosting 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,578 @@
1
+ import { resolveOneOf, isJSONObject, unmarshalArrayOfObject, unmarshalDate, unmarshalMoney } from "@scaleway/sdk-client";
2
+ const unmarshalDatabaseUser = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'DatabaseUser' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ databases: data.databases,
10
+ username: data.username
11
+ };
12
+ };
13
+ const unmarshalDatabase = (data) => {
14
+ if (!isJSONObject(data)) {
15
+ throw new TypeError(
16
+ `Unmarshalling the type 'Database' failed as data isn't a dictionary.`
17
+ );
18
+ }
19
+ return {
20
+ databaseName: data.database_name,
21
+ users: data.users
22
+ };
23
+ };
24
+ const unmarshalFtpAccount = (data) => {
25
+ if (!isJSONObject(data)) {
26
+ throw new TypeError(
27
+ `Unmarshalling the type 'FtpAccount' failed as data isn't a dictionary.`
28
+ );
29
+ }
30
+ return {
31
+ path: data.path,
32
+ username: data.username
33
+ };
34
+ };
35
+ const unmarshalMailAccount = (data) => {
36
+ if (!isJSONObject(data)) {
37
+ throw new TypeError(
38
+ `Unmarshalling the type 'MailAccount' failed as data isn't a dictionary.`
39
+ );
40
+ }
41
+ return {
42
+ domain: data.domain,
43
+ username: data.username
44
+ };
45
+ };
46
+ const unmarshalCheckUserOwnsDomainResponse = (data) => {
47
+ if (!isJSONObject(data)) {
48
+ throw new TypeError(
49
+ `Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary.`
50
+ );
51
+ }
52
+ return {
53
+ ownsDomain: data.owns_domain
54
+ };
55
+ };
56
+ const unmarshalAutoConfigDomainDns = (data) => {
57
+ if (!isJSONObject(data)) {
58
+ throw new TypeError(
59
+ `Unmarshalling the type 'AutoConfigDomainDns' failed as data isn't a dictionary.`
60
+ );
61
+ }
62
+ return {
63
+ allRecords: data.all_records,
64
+ mailRecords: data.mail_records,
65
+ nameservers: data.nameservers,
66
+ none: data.none,
67
+ webRecords: data.web_records
68
+ };
69
+ };
70
+ const unmarshalDnsRecord = (data) => {
71
+ if (!isJSONObject(data)) {
72
+ throw new TypeError(
73
+ `Unmarshalling the type 'DnsRecord' failed as data isn't a dictionary.`
74
+ );
75
+ }
76
+ return {
77
+ name: data.name,
78
+ priority: data.priority,
79
+ rawData: data.raw_data,
80
+ status: data.status,
81
+ ttl: data.ttl,
82
+ type: data.type,
83
+ value: data.value
84
+ };
85
+ };
86
+ const unmarshalNameserver = (data) => {
87
+ if (!isJSONObject(data)) {
88
+ throw new TypeError(
89
+ `Unmarshalling the type 'Nameserver' failed as data isn't a dictionary.`
90
+ );
91
+ }
92
+ return {
93
+ hostname: data.hostname,
94
+ isDefault: data.is_default,
95
+ status: data.status
96
+ };
97
+ };
98
+ const unmarshalDnsRecords = (data) => {
99
+ if (!isJSONObject(data)) {
100
+ throw new TypeError(
101
+ `Unmarshalling the type 'DnsRecords' failed as data isn't a dictionary.`
102
+ );
103
+ }
104
+ return {
105
+ autoConfigDomainDns: data.auto_config_domain_dns ? unmarshalAutoConfigDomainDns(data.auto_config_domain_dns) : void 0,
106
+ dnsConfig: data.dns_config ? data.dns_config : void 0,
107
+ nameServers: unmarshalArrayOfObject(data.name_servers, unmarshalNameserver),
108
+ records: unmarshalArrayOfObject(data.records, unmarshalDnsRecord),
109
+ status: data.status
110
+ };
111
+ };
112
+ const unmarshalDomain = (data) => {
113
+ if (!isJSONObject(data)) {
114
+ throw new TypeError(
115
+ `Unmarshalling the type 'Domain' failed as data isn't a dictionary.`
116
+ );
117
+ }
118
+ return {
119
+ autoConfigDomainDns: data.auto_config_domain_dns ? unmarshalAutoConfigDomainDns(data.auto_config_domain_dns) : void 0,
120
+ availableActions: data.available_actions,
121
+ availableDnsActions: data.available_dns_actions ? data.available_dns_actions : void 0,
122
+ name: data.name,
123
+ owner: data.owner,
124
+ status: data.status
125
+ };
126
+ };
127
+ const unmarshalPlatformControlPanelUrls = (data) => {
128
+ if (!isJSONObject(data)) {
129
+ throw new TypeError(
130
+ `Unmarshalling the type 'PlatformControlPanelUrls' failed as data isn't a dictionary.`
131
+ );
132
+ }
133
+ return {
134
+ dashboard: data.dashboard,
135
+ webmail: data.webmail
136
+ };
137
+ };
138
+ const unmarshalOfferOption = (data) => {
139
+ if (!isJSONObject(data)) {
140
+ throw new TypeError(
141
+ `Unmarshalling the type 'OfferOption' failed as data isn't a dictionary.`
142
+ );
143
+ }
144
+ return {
145
+ billingOperationPath: data.billing_operation_path,
146
+ currentValue: data.current_value,
147
+ id: data.id,
148
+ maxValue: data.max_value,
149
+ minValue: data.min_value,
150
+ name: data.name,
151
+ price: data.price ? unmarshalMoney(data.price) : void 0,
152
+ quotaWarning: data.quota_warning
153
+ };
154
+ };
155
+ const unmarshalPlatformControlPanel = (data) => {
156
+ if (!isJSONObject(data)) {
157
+ throw new TypeError(
158
+ `Unmarshalling the type 'PlatformControlPanel' failed as data isn't a dictionary.`
159
+ );
160
+ }
161
+ return {
162
+ name: data.name,
163
+ urls: data.urls ? unmarshalPlatformControlPanelUrls(data.urls) : void 0
164
+ };
165
+ };
166
+ const unmarshalHostingUser = (data) => {
167
+ if (!isJSONObject(data)) {
168
+ throw new TypeError(
169
+ `Unmarshalling the type 'HostingUser' failed as data isn't a dictionary.`
170
+ );
171
+ }
172
+ return {
173
+ contactEmail: data.contact_email,
174
+ oneTimePassword: data.one_time_password,
175
+ username: data.username
176
+ };
177
+ };
178
+ const unmarshalOffer = (data) => {
179
+ if (!isJSONObject(data)) {
180
+ throw new TypeError(
181
+ `Unmarshalling the type 'Offer' failed as data isn't a dictionary.`
182
+ );
183
+ }
184
+ return {
185
+ available: data.available,
186
+ billingOperationPath: data.billing_operation_path,
187
+ controlPanelName: data.control_panel_name,
188
+ endOfLife: data.end_of_life,
189
+ id: data.id,
190
+ name: data.name,
191
+ options: unmarshalArrayOfObject(data.options, unmarshalOfferOption),
192
+ price: data.price ? unmarshalMoney(data.price) : void 0,
193
+ quotaWarning: data.quota_warning
194
+ };
195
+ };
196
+ const unmarshalPlatform = (data) => {
197
+ if (!isJSONObject(data)) {
198
+ throw new TypeError(
199
+ `Unmarshalling the type 'Platform' failed as data isn't a dictionary.`
200
+ );
201
+ }
202
+ return {
203
+ controlPanel: data.control_panel ? unmarshalPlatformControlPanel(data.control_panel) : void 0,
204
+ groupName: data.group_name,
205
+ hostname: data.hostname,
206
+ ipv4: data.ipv4,
207
+ ipv6: data.ipv6,
208
+ number: data.number
209
+ };
210
+ };
211
+ const unmarshalHosting = (data) => {
212
+ if (!isJSONObject(data)) {
213
+ throw new TypeError(
214
+ `Unmarshalling the type 'Hosting' failed as data isn't a dictionary.`
215
+ );
216
+ }
217
+ return {
218
+ createdAt: unmarshalDate(data.created_at),
219
+ dnsStatus: data.dns_status ? data.dns_status : void 0,
220
+ domain: data.domain,
221
+ domainStatus: data.domain_status,
222
+ id: data.id,
223
+ ipv4: data.ipv4,
224
+ offer: data.offer ? unmarshalOffer(data.offer) : void 0,
225
+ platform: data.platform ? unmarshalPlatform(data.platform) : void 0,
226
+ projectId: data.project_id,
227
+ protected: data.protected,
228
+ region: data.region,
229
+ status: data.status,
230
+ tags: data.tags,
231
+ updatedAt: unmarshalDate(data.updated_at),
232
+ user: data.user ? unmarshalHostingUser(data.user) : void 0
233
+ };
234
+ };
235
+ const unmarshalControlPanel = (data) => {
236
+ if (!isJSONObject(data)) {
237
+ throw new TypeError(
238
+ `Unmarshalling the type 'ControlPanel' failed as data isn't a dictionary.`
239
+ );
240
+ }
241
+ return {
242
+ available: data.available,
243
+ availableLanguages: data.available_languages,
244
+ logoUrl: data.logo_url,
245
+ name: data.name
246
+ };
247
+ };
248
+ const unmarshalListControlPanelsResponse = (data) => {
249
+ if (!isJSONObject(data)) {
250
+ throw new TypeError(
251
+ `Unmarshalling the type 'ListControlPanelsResponse' failed as data isn't a dictionary.`
252
+ );
253
+ }
254
+ return {
255
+ controlPanels: unmarshalArrayOfObject(
256
+ data.control_panels,
257
+ unmarshalControlPanel
258
+ ),
259
+ totalCount: data.total_count
260
+ };
261
+ };
262
+ const unmarshalListDatabaseUsersResponse = (data) => {
263
+ if (!isJSONObject(data)) {
264
+ throw new TypeError(
265
+ `Unmarshalling the type 'ListDatabaseUsersResponse' failed as data isn't a dictionary.`
266
+ );
267
+ }
268
+ return {
269
+ totalCount: data.total_count,
270
+ users: unmarshalArrayOfObject(data.users, unmarshalDatabaseUser)
271
+ };
272
+ };
273
+ const unmarshalListDatabasesResponse = (data) => {
274
+ if (!isJSONObject(data)) {
275
+ throw new TypeError(
276
+ `Unmarshalling the type 'ListDatabasesResponse' failed as data isn't a dictionary.`
277
+ );
278
+ }
279
+ return {
280
+ databases: unmarshalArrayOfObject(data.databases, unmarshalDatabase),
281
+ totalCount: data.total_count
282
+ };
283
+ };
284
+ const unmarshalListFtpAccountsResponse = (data) => {
285
+ if (!isJSONObject(data)) {
286
+ throw new TypeError(
287
+ `Unmarshalling the type 'ListFtpAccountsResponse' failed as data isn't a dictionary.`
288
+ );
289
+ }
290
+ return {
291
+ ftpAccounts: unmarshalArrayOfObject(data.ftp_accounts, unmarshalFtpAccount),
292
+ totalCount: data.total_count
293
+ };
294
+ };
295
+ const unmarshalHostingSummary = (data) => {
296
+ if (!isJSONObject(data)) {
297
+ throw new TypeError(
298
+ `Unmarshalling the type 'HostingSummary' failed as data isn't a dictionary.`
299
+ );
300
+ }
301
+ return {
302
+ createdAt: unmarshalDate(data.created_at),
303
+ dnsStatus: data.dns_status ? data.dns_status : void 0,
304
+ domain: data.domain,
305
+ domainStatus: data.domain_status,
306
+ id: data.id,
307
+ offerName: data.offer_name,
308
+ projectId: data.project_id,
309
+ protected: data.protected,
310
+ region: data.region,
311
+ status: data.status,
312
+ updatedAt: unmarshalDate(data.updated_at)
313
+ };
314
+ };
315
+ const unmarshalListHostingsResponse = (data) => {
316
+ if (!isJSONObject(data)) {
317
+ throw new TypeError(
318
+ `Unmarshalling the type 'ListHostingsResponse' failed as data isn't a dictionary.`
319
+ );
320
+ }
321
+ return {
322
+ hostings: unmarshalArrayOfObject(data.hostings, unmarshalHostingSummary),
323
+ totalCount: data.total_count
324
+ };
325
+ };
326
+ const unmarshalListMailAccountsResponse = (data) => {
327
+ if (!isJSONObject(data)) {
328
+ throw new TypeError(
329
+ `Unmarshalling the type 'ListMailAccountsResponse' failed as data isn't a dictionary.`
330
+ );
331
+ }
332
+ return {
333
+ mailAccounts: unmarshalArrayOfObject(
334
+ data.mail_accounts,
335
+ unmarshalMailAccount
336
+ ),
337
+ totalCount: data.total_count
338
+ };
339
+ };
340
+ const unmarshalListOffersResponse = (data) => {
341
+ if (!isJSONObject(data)) {
342
+ throw new TypeError(
343
+ `Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`
344
+ );
345
+ }
346
+ return {
347
+ offers: unmarshalArrayOfObject(data.offers, unmarshalOffer),
348
+ totalCount: data.total_count
349
+ };
350
+ };
351
+ const unmarshalWebsite = (data) => {
352
+ if (!isJSONObject(data)) {
353
+ throw new TypeError(
354
+ `Unmarshalling the type 'Website' failed as data isn't a dictionary.`
355
+ );
356
+ }
357
+ return {
358
+ domain: data.domain,
359
+ path: data.path,
360
+ sslStatus: data.ssl_status
361
+ };
362
+ };
363
+ const unmarshalListWebsitesResponse = (data) => {
364
+ if (!isJSONObject(data)) {
365
+ throw new TypeError(
366
+ `Unmarshalling the type 'ListWebsitesResponse' failed as data isn't a dictionary.`
367
+ );
368
+ }
369
+ return {
370
+ totalCount: data.total_count,
371
+ websites: unmarshalArrayOfObject(data.websites, unmarshalWebsite)
372
+ };
373
+ };
374
+ const unmarshalResetHostingPasswordResponse = (data) => {
375
+ if (!isJSONObject(data)) {
376
+ throw new TypeError(
377
+ `Unmarshalling the type 'ResetHostingPasswordResponse' failed as data isn't a dictionary.`
378
+ );
379
+ }
380
+ return {
381
+ oneTimePassword: data.one_time_password
382
+ };
383
+ };
384
+ const unmarshalResourceSummary = (data) => {
385
+ if (!isJSONObject(data)) {
386
+ throw new TypeError(
387
+ `Unmarshalling the type 'ResourceSummary' failed as data isn't a dictionary.`
388
+ );
389
+ }
390
+ return {
391
+ databasesCount: data.databases_count,
392
+ ftpAccountsCount: data.ftp_accounts_count,
393
+ mailAccountsCount: data.mail_accounts_count,
394
+ websitesCount: data.websites_count
395
+ };
396
+ };
397
+ const unmarshalDomainAvailability = (data) => {
398
+ if (!isJSONObject(data)) {
399
+ throw new TypeError(
400
+ `Unmarshalling the type 'DomainAvailability' failed as data isn't a dictionary.`
401
+ );
402
+ }
403
+ return {
404
+ availableActions: data.available_actions,
405
+ canCreateHosting: data.can_create_hosting,
406
+ name: data.name,
407
+ price: data.price ? unmarshalMoney(data.price) : void 0,
408
+ status: data.status,
409
+ zoneName: data.zone_name
410
+ };
411
+ };
412
+ const unmarshalSearchDomainsResponse = (data) => {
413
+ if (!isJSONObject(data)) {
414
+ throw new TypeError(
415
+ `Unmarshalling the type 'SearchDomainsResponse' failed as data isn't a dictionary.`
416
+ );
417
+ }
418
+ return {
419
+ domainsAvailable: unmarshalArrayOfObject(
420
+ data.domains_available,
421
+ unmarshalDomainAvailability
422
+ )
423
+ };
424
+ };
425
+ const unmarshalSession = (data) => {
426
+ if (!isJSONObject(data)) {
427
+ throw new TypeError(
428
+ `Unmarshalling the type 'Session' failed as data isn't a dictionary.`
429
+ );
430
+ }
431
+ return {
432
+ url: data.url
433
+ };
434
+ };
435
+ const marshalDatabaseApiAssignDatabaseUserRequest = (request, defaults) => ({
436
+ username: request.username
437
+ });
438
+ const marshalDatabaseApiChangeDatabaseUserPasswordRequest = (request, defaults) => ({
439
+ password: request.password
440
+ });
441
+ const marshalCreateDatabaseRequestUser = (request, defaults) => ({
442
+ password: request.password,
443
+ username: request.username
444
+ });
445
+ const marshalDatabaseApiCreateDatabaseRequest = (request, defaults) => ({
446
+ database_name: request.databaseName,
447
+ ...resolveOneOf([
448
+ {
449
+ param: "new_user",
450
+ value: request.newUser !== void 0 ? marshalCreateDatabaseRequestUser(request.newUser) : void 0
451
+ },
452
+ { param: "existing_username", value: request.existingUsername }
453
+ ])
454
+ });
455
+ const marshalDatabaseApiCreateDatabaseUserRequest = (request, defaults) => ({
456
+ password: request.password,
457
+ username: request.username
458
+ });
459
+ const marshalDatabaseApiUnassignDatabaseUserRequest = (request, defaults) => ({
460
+ username: request.username
461
+ });
462
+ const marshalDnsApiCheckUserOwnsDomainRequest = (request, defaults) => ({
463
+ project_id: request.projectId ?? defaults.defaultProjectId
464
+ });
465
+ const marshalAutoConfigDomainDns = (request, defaults) => ({
466
+ all_records: request.allRecords,
467
+ mail_records: request.mailRecords,
468
+ nameservers: request.nameservers,
469
+ none: request.none,
470
+ web_records: request.webRecords
471
+ });
472
+ const marshalSyncDomainDnsRecordsRequestRecord = (request, defaults) => ({
473
+ name: request.name,
474
+ type: request.type
475
+ });
476
+ const marshalDnsApiSyncDomainDnsRecordsRequest = (request, defaults) => ({
477
+ auto_config_domain_dns: request.autoConfigDomainDns !== void 0 ? marshalAutoConfigDomainDns(request.autoConfigDomainDns) : void 0,
478
+ custom_records: request.customRecords !== void 0 ? request.customRecords.map(
479
+ (elt) => marshalSyncDomainDnsRecordsRequestRecord(elt)
480
+ ) : void 0,
481
+ update_all_records: request.updateAllRecords,
482
+ update_mail_records: request.updateMailRecords,
483
+ update_nameservers: request.updateNameservers,
484
+ update_web_records: request.updateWebRecords
485
+ });
486
+ const marshalFtpAccountApiChangeFtpAccountPasswordRequest = (request, defaults) => ({
487
+ password: request.password
488
+ });
489
+ const marshalFtpAccountApiCreateFtpAccountRequest = (request, defaults) => ({
490
+ password: request.password,
491
+ path: request.path,
492
+ username: request.username
493
+ });
494
+ const marshalCreateHostingRequestDomainConfiguration = (request, defaults) => ({
495
+ update_all_records: request.updateAllRecords,
496
+ update_mail_record: request.updateMailRecord,
497
+ update_nameservers: request.updateNameservers,
498
+ update_web_record: request.updateWebRecord
499
+ });
500
+ const marshalOfferOptionRequest = (request, defaults) => ({
501
+ id: request.id,
502
+ quantity: request.quantity
503
+ });
504
+ const marshalHostingApiCreateHostingRequest = (request, defaults) => ({
505
+ auto_config_domain_dns: request.autoConfigDomainDns !== void 0 ? marshalAutoConfigDomainDns(request.autoConfigDomainDns) : void 0,
506
+ domain: request.domain,
507
+ domain_configuration: request.domainConfiguration !== void 0 ? marshalCreateHostingRequestDomainConfiguration(
508
+ request.domainConfiguration
509
+ ) : void 0,
510
+ email: request.email,
511
+ language: request.language,
512
+ offer_id: request.offerId,
513
+ offer_options: request.offerOptions !== void 0 ? request.offerOptions.map(
514
+ (elt) => marshalOfferOptionRequest(elt)
515
+ ) : void 0,
516
+ project_id: request.projectId ?? defaults.defaultProjectId,
517
+ skip_welcome_email: request.skipWelcomeEmail,
518
+ tags: request.tags
519
+ });
520
+ const marshalHostingApiUpdateHostingRequest = (request, defaults) => ({
521
+ email: request.email,
522
+ offer_id: request.offerId,
523
+ offer_options: request.offerOptions !== void 0 ? request.offerOptions.map(
524
+ (elt) => marshalOfferOptionRequest(elt)
525
+ ) : void 0,
526
+ protected: request.protected,
527
+ tags: request.tags
528
+ });
529
+ const marshalMailAccountApiChangeMailAccountPasswordRequest = (request, defaults) => ({
530
+ domain: request.domain,
531
+ password: request.password,
532
+ username: request.username
533
+ });
534
+ const marshalMailAccountApiCreateMailAccountRequest = (request, defaults) => ({
535
+ domain: request.domain,
536
+ password: request.password,
537
+ username: request.username
538
+ });
539
+ const marshalMailAccountApiRemoveMailAccountRequest = (request, defaults) => ({
540
+ domain: request.domain,
541
+ username: request.username
542
+ });
543
+ export {
544
+ marshalDatabaseApiAssignDatabaseUserRequest,
545
+ marshalDatabaseApiChangeDatabaseUserPasswordRequest,
546
+ marshalDatabaseApiCreateDatabaseRequest,
547
+ marshalDatabaseApiCreateDatabaseUserRequest,
548
+ marshalDatabaseApiUnassignDatabaseUserRequest,
549
+ marshalDnsApiCheckUserOwnsDomainRequest,
550
+ marshalDnsApiSyncDomainDnsRecordsRequest,
551
+ marshalFtpAccountApiChangeFtpAccountPasswordRequest,
552
+ marshalFtpAccountApiCreateFtpAccountRequest,
553
+ marshalHostingApiCreateHostingRequest,
554
+ marshalHostingApiUpdateHostingRequest,
555
+ marshalMailAccountApiChangeMailAccountPasswordRequest,
556
+ marshalMailAccountApiCreateMailAccountRequest,
557
+ marshalMailAccountApiRemoveMailAccountRequest,
558
+ unmarshalCheckUserOwnsDomainResponse,
559
+ unmarshalDatabase,
560
+ unmarshalDatabaseUser,
561
+ unmarshalDnsRecords,
562
+ unmarshalDomain,
563
+ unmarshalFtpAccount,
564
+ unmarshalHosting,
565
+ unmarshalListControlPanelsResponse,
566
+ unmarshalListDatabaseUsersResponse,
567
+ unmarshalListDatabasesResponse,
568
+ unmarshalListFtpAccountsResponse,
569
+ unmarshalListHostingsResponse,
570
+ unmarshalListMailAccountsResponse,
571
+ unmarshalListOffersResponse,
572
+ unmarshalListWebsitesResponse,
573
+ unmarshalMailAccount,
574
+ unmarshalResetHostingPasswordResponse,
575
+ unmarshalResourceSummary,
576
+ unmarshalSearchDomainsResponse,
577
+ unmarshalSession
578
+ };