@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,747 @@
1
+ import { API, urlParams, validatePathParam, enrichForPagination, waitForResource } from "@scaleway/sdk-client";
2
+ import { DOMAIN_TRANSIENT_STATUSES, HOSTING_TRANSIENT_STATUSES } from "./content.gen.js";
3
+ import { unmarshalListControlPanelsResponse, marshalDatabaseApiCreateDatabaseRequest, unmarshalDatabase, unmarshalListDatabasesResponse, marshalDatabaseApiCreateDatabaseUserRequest, unmarshalDatabaseUser, unmarshalListDatabaseUsersResponse, marshalDatabaseApiChangeDatabaseUserPasswordRequest, marshalDatabaseApiAssignDatabaseUserRequest, marshalDatabaseApiUnassignDatabaseUserRequest, unmarshalDnsRecords, marshalDnsApiCheckUserOwnsDomainRequest, unmarshalCheckUserOwnsDomainResponse, marshalDnsApiSyncDomainDnsRecordsRequest, unmarshalSearchDomainsResponse, unmarshalDomain, marshalFtpAccountApiCreateFtpAccountRequest, unmarshalFtpAccount, unmarshalListFtpAccountsResponse, marshalFtpAccountApiChangeFtpAccountPasswordRequest, marshalHostingApiCreateHostingRequest, unmarshalHosting, unmarshalListHostingsResponse, marshalHostingApiUpdateHostingRequest, unmarshalSession, unmarshalResetHostingPasswordResponse, unmarshalResourceSummary, marshalMailAccountApiCreateMailAccountRequest, unmarshalMailAccount, unmarshalListMailAccountsResponse, marshalMailAccountApiRemoveMailAccountRequest, marshalMailAccountApiChangeMailAccountPasswordRequest, unmarshalListOffersResponse, unmarshalListWebsitesResponse } from "./marshalling.gen.js";
4
+ const jsonContentHeaders = {
5
+ "Content-Type": "application/json; charset=utf-8"
6
+ };
7
+ class ControlPanelAPI extends API {
8
+ /** Lists the available regions of the API. */
9
+ static LOCALITIES = [
10
+ "fr-par",
11
+ "nl-ams",
12
+ "pl-waw"
13
+ ];
14
+ pageOfListControlPanels = (request = {}) => this.client.fetch(
15
+ {
16
+ method: "GET",
17
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/control-panels`,
18
+ urlParams: urlParams(
19
+ ["page", request.page],
20
+ [
21
+ "page_size",
22
+ request.pageSize ?? this.client.settings.defaultPageSize
23
+ ]
24
+ )
25
+ },
26
+ unmarshalListControlPanelsResponse
27
+ );
28
+ /**
29
+ * "List the control panels type: cpanel or plesk.".
30
+ *
31
+ * @param request - The request {@link ControlPanelApiListControlPanelsRequest}
32
+ * @returns A Promise of ListControlPanelsResponse
33
+ */
34
+ listControlPanels = (request = {}) => enrichForPagination("controlPanels", this.pageOfListControlPanels, request);
35
+ }
36
+ class DatabaseAPI extends API {
37
+ /** Lists the available regions of the API. */
38
+ static LOCALITIES = [
39
+ "fr-par",
40
+ "nl-ams",
41
+ "pl-waw"
42
+ ];
43
+ /**
44
+ * "Create a new database within your hosting plan".
45
+ *
46
+ * @param request - The request {@link DatabaseApiCreateDatabaseRequest}
47
+ * @returns A Promise of Database
48
+ */
49
+ createDatabase = (request) => this.client.fetch(
50
+ {
51
+ body: JSON.stringify(
52
+ marshalDatabaseApiCreateDatabaseRequest(
53
+ request,
54
+ this.client.settings
55
+ )
56
+ ),
57
+ headers: jsonContentHeaders,
58
+ method: "POST",
59
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases`
60
+ },
61
+ unmarshalDatabase
62
+ );
63
+ pageOfListDatabases = (request) => this.client.fetch(
64
+ {
65
+ method: "GET",
66
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases`,
67
+ urlParams: urlParams(
68
+ ["order_by", request.orderBy],
69
+ ["page", request.page],
70
+ [
71
+ "page_size",
72
+ request.pageSize ?? this.client.settings.defaultPageSize
73
+ ]
74
+ )
75
+ },
76
+ unmarshalListDatabasesResponse
77
+ );
78
+ /**
79
+ * "List all databases within your hosting plan".
80
+ *
81
+ * @param request - The request {@link DatabaseApiListDatabasesRequest}
82
+ * @returns A Promise of ListDatabasesResponse
83
+ */
84
+ listDatabases = (request) => enrichForPagination("databases", this.pageOfListDatabases, request);
85
+ /**
86
+ * "Get details of a database within your hosting plan".
87
+ *
88
+ * @param request - The request {@link DatabaseApiGetDatabaseRequest}
89
+ * @returns A Promise of Database
90
+ */
91
+ getDatabase = (request) => this.client.fetch(
92
+ {
93
+ method: "GET",
94
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases/${validatePathParam("databaseName", request.databaseName)}`
95
+ },
96
+ unmarshalDatabase
97
+ );
98
+ /**
99
+ * "Delete a database within your hosting plan".
100
+ *
101
+ * @param request - The request {@link DatabaseApiDeleteDatabaseRequest}
102
+ * @returns A Promise of Database
103
+ */
104
+ deleteDatabase = (request) => this.client.fetch(
105
+ {
106
+ method: "DELETE",
107
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases/${validatePathParam("databaseName", request.databaseName)}`
108
+ },
109
+ unmarshalDatabase
110
+ );
111
+ /**
112
+ * "Create a new database user".
113
+ *
114
+ * @param request - The request {@link DatabaseApiCreateDatabaseUserRequest}
115
+ * @returns A Promise of DatabaseUser
116
+ */
117
+ createDatabaseUser = (request) => this.client.fetch(
118
+ {
119
+ body: JSON.stringify(
120
+ marshalDatabaseApiCreateDatabaseUserRequest(
121
+ request,
122
+ this.client.settings
123
+ )
124
+ ),
125
+ headers: jsonContentHeaders,
126
+ method: "POST",
127
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases-users`
128
+ },
129
+ unmarshalDatabaseUser
130
+ );
131
+ pageOfListDatabaseUsers = (request) => this.client.fetch(
132
+ {
133
+ method: "GET",
134
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/database-users`,
135
+ urlParams: urlParams(
136
+ ["order_by", request.orderBy],
137
+ ["page", request.page],
138
+ [
139
+ "page_size",
140
+ request.pageSize ?? this.client.settings.defaultPageSize
141
+ ]
142
+ )
143
+ },
144
+ unmarshalListDatabaseUsersResponse
145
+ );
146
+ /**
147
+ * "List all database users".
148
+ *
149
+ * @param request - The request {@link DatabaseApiListDatabaseUsersRequest}
150
+ * @returns A Promise of ListDatabaseUsersResponse
151
+ */
152
+ listDatabaseUsers = (request) => enrichForPagination("users", this.pageOfListDatabaseUsers, request);
153
+ /**
154
+ * "Get details of a database user".
155
+ *
156
+ * @param request - The request {@link DatabaseApiGetDatabaseUserRequest}
157
+ * @returns A Promise of DatabaseUser
158
+ */
159
+ getDatabaseUser = (request) => this.client.fetch(
160
+ {
161
+ method: "GET",
162
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases-users/${validatePathParam("username", request.username)}`
163
+ },
164
+ unmarshalDatabaseUser
165
+ );
166
+ /**
167
+ * "Delete a database user".
168
+ *
169
+ * @param request - The request {@link DatabaseApiDeleteDatabaseUserRequest}
170
+ * @returns A Promise of DatabaseUser
171
+ */
172
+ deleteDatabaseUser = (request) => this.client.fetch(
173
+ {
174
+ method: "DELETE",
175
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/database-users/${validatePathParam("username", request.username)}`
176
+ },
177
+ unmarshalDatabaseUser
178
+ );
179
+ /**
180
+ * "Change the password of a database user".
181
+ *
182
+ * @param request - The request {@link DatabaseApiChangeDatabaseUserPasswordRequest}
183
+ * @returns A Promise of DatabaseUser
184
+ */
185
+ changeDatabaseUserPassword = (request) => this.client.fetch(
186
+ {
187
+ body: JSON.stringify(
188
+ marshalDatabaseApiChangeDatabaseUserPasswordRequest(
189
+ request,
190
+ this.client.settings
191
+ )
192
+ ),
193
+ headers: jsonContentHeaders,
194
+ method: "POST",
195
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases-users/${validatePathParam("username", request.username)}/change-password`
196
+ },
197
+ unmarshalDatabaseUser
198
+ );
199
+ /**
200
+ * "Assign a database user to a database".
201
+ *
202
+ * @param request - The request {@link DatabaseApiAssignDatabaseUserRequest}
203
+ * @returns A Promise of DatabaseUser
204
+ */
205
+ assignDatabaseUser = (request) => this.client.fetch(
206
+ {
207
+ body: JSON.stringify(
208
+ marshalDatabaseApiAssignDatabaseUserRequest(
209
+ request,
210
+ this.client.settings
211
+ )
212
+ ),
213
+ headers: jsonContentHeaders,
214
+ method: "POST",
215
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases/${validatePathParam("databaseName", request.databaseName)}/assign-user`
216
+ },
217
+ unmarshalDatabaseUser
218
+ );
219
+ /**
220
+ * "Unassign a database user from a database".
221
+ *
222
+ * @param request - The request {@link DatabaseApiUnassignDatabaseUserRequest}
223
+ * @returns A Promise of DatabaseUser
224
+ */
225
+ unassignDatabaseUser = (request) => this.client.fetch(
226
+ {
227
+ body: JSON.stringify(
228
+ marshalDatabaseApiUnassignDatabaseUserRequest(
229
+ request,
230
+ this.client.settings
231
+ )
232
+ ),
233
+ headers: jsonContentHeaders,
234
+ method: "POST",
235
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/databases/${validatePathParam("databaseName", request.databaseName)}/unassign-user`
236
+ },
237
+ unmarshalDatabaseUser
238
+ );
239
+ }
240
+ class DnsAPI extends API {
241
+ /** Lists the available regions of the API. */
242
+ static LOCALITIES = [
243
+ "fr-par",
244
+ "nl-ams",
245
+ "pl-waw"
246
+ ];
247
+ /**
248
+ * Get DNS records. Get the set of DNS records of a specified domain associated with a Web Hosting plan's domain.
249
+ *
250
+ * @param request - The request {@link DnsApiGetDomainDnsRecordsRequest}
251
+ * @returns A Promise of DnsRecords
252
+ */
253
+ getDomainDnsRecords = (request) => this.client.fetch(
254
+ {
255
+ method: "GET",
256
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domain", request.domain)}/dns-records`
257
+ },
258
+ unmarshalDnsRecords
259
+ );
260
+ /**
261
+ * Check whether you own this domain or not.. Check whether you own this domain or not.
262
+ *
263
+ * @param request - The request {@link DnsApiCheckUserOwnsDomainRequest}
264
+ * @returns A Promise of CheckUserOwnsDomainResponse
265
+ */
266
+ checkUserOwnsDomain = (request) => this.client.fetch(
267
+ {
268
+ body: JSON.stringify(
269
+ marshalDnsApiCheckUserOwnsDomainRequest(
270
+ request,
271
+ this.client.settings
272
+ )
273
+ ),
274
+ headers: jsonContentHeaders,
275
+ method: "POST",
276
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domain", request.domain)}/check-ownership`
277
+ },
278
+ unmarshalCheckUserOwnsDomainResponse
279
+ );
280
+ /**
281
+ * Synchronize your DNS records on the Elements Console and on cPanel.. Synchronize your DNS records on the Elements Console and on cPanel.
282
+ *
283
+ * @param request - The request {@link DnsApiSyncDomainDnsRecordsRequest}
284
+ * @returns A Promise of DnsRecords
285
+ */
286
+ syncDomainDnsRecords = (request) => this.client.fetch(
287
+ {
288
+ body: JSON.stringify(
289
+ marshalDnsApiSyncDomainDnsRecordsRequest(
290
+ request,
291
+ this.client.settings
292
+ )
293
+ ),
294
+ headers: jsonContentHeaders,
295
+ method: "POST",
296
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domain", request.domain)}/sync-domain-dns-records`
297
+ },
298
+ unmarshalDnsRecords
299
+ );
300
+ /**
301
+ * Search for available domains based on domain name.. Search for available domains based on domain name.
302
+ *
303
+ * @param request - The request {@link DnsApiSearchDomainsRequest}
304
+ * @returns A Promise of SearchDomainsResponse
305
+ */
306
+ searchDomains = (request) => this.client.fetch(
307
+ {
308
+ method: "GET",
309
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/search-domains`,
310
+ urlParams: urlParams(
311
+ ["domain_name", request.domainName],
312
+ [
313
+ "project_id",
314
+ request.projectId ?? this.client.settings.defaultProjectId
315
+ ]
316
+ )
317
+ },
318
+ unmarshalSearchDomainsResponse
319
+ );
320
+ /**
321
+ * Retrieve detailed information about a specific domain, including its status, DNS configuration, and ownership.. Retrieve detailed information about a specific domain, including its status, DNS configuration, and ownership.
322
+ *
323
+ * @param request - The request {@link DnsApiGetDomainRequest}
324
+ * @returns A Promise of Domain
325
+ */
326
+ getDomain = (request) => this.client.fetch(
327
+ {
328
+ method: "GET",
329
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam("domainName", request.domainName)}`,
330
+ urlParams: urlParams([
331
+ "project_id",
332
+ request.projectId ?? this.client.settings.defaultProjectId
333
+ ])
334
+ },
335
+ unmarshalDomain
336
+ );
337
+ /**
338
+ * Waits for {@link Domain} to be in a final state.
339
+ *
340
+ * @param request - The request {@link DnsApiGetDomainRequest}
341
+ * @param options - The waiting options
342
+ * @returns A Promise of Domain
343
+ */
344
+ waitForDomain = (request, options) => waitForResource(
345
+ options?.stop ?? ((res) => Promise.resolve(
346
+ !DOMAIN_TRANSIENT_STATUSES.includes(res.status)
347
+ )),
348
+ this.getDomain,
349
+ request,
350
+ options
351
+ );
352
+ }
353
+ class OfferAPI extends API {
354
+ /** Lists the available regions of the API. */
355
+ static LOCALITIES = [
356
+ "fr-par",
357
+ "nl-ams",
358
+ "pl-waw"
359
+ ];
360
+ pageOfListOffers = (request = {}) => this.client.fetch(
361
+ {
362
+ method: "GET",
363
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/offers`,
364
+ urlParams: urlParams(
365
+ ["control_panels", request.controlPanels],
366
+ ["hosting_id", request.hostingId],
367
+ ["order_by", request.orderBy],
368
+ ["page", request.page],
369
+ [
370
+ "page_size",
371
+ request.pageSize ?? this.client.settings.defaultPageSize
372
+ ]
373
+ )
374
+ },
375
+ unmarshalListOffersResponse
376
+ );
377
+ /**
378
+ * List all available hosting offers along with their specific options.. List all available hosting offers along with their specific options.
379
+ *
380
+ * @param request - The request {@link OfferApiListOffersRequest}
381
+ * @returns A Promise of ListOffersResponse
382
+ */
383
+ listOffers = (request = {}) => enrichForPagination("offers", this.pageOfListOffers, request);
384
+ }
385
+ class HostingAPI extends API {
386
+ /** Lists the available regions of the API. */
387
+ static LOCALITIES = [
388
+ "fr-par",
389
+ "nl-ams",
390
+ "pl-waw"
391
+ ];
392
+ /**
393
+ * Order a Web Hosting plan. Order a Web Hosting plan, specifying the offer type required via the `offer_id` parameter.
394
+ *
395
+ * @param request - The request {@link HostingApiCreateHostingRequest}
396
+ * @returns A Promise of Hosting
397
+ */
398
+ createHosting = (request) => this.client.fetch(
399
+ {
400
+ body: JSON.stringify(
401
+ marshalHostingApiCreateHostingRequest(request, this.client.settings)
402
+ ),
403
+ headers: jsonContentHeaders,
404
+ method: "POST",
405
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings`
406
+ },
407
+ unmarshalHosting
408
+ );
409
+ pageOfListHostings = (request = {}) => this.client.fetch(
410
+ {
411
+ method: "GET",
412
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings`,
413
+ urlParams: urlParams(
414
+ ["control_panels", request.controlPanels],
415
+ ["domain", request.domain],
416
+ ["order_by", request.orderBy],
417
+ ["organization_id", request.organizationId],
418
+ ["page", request.page],
419
+ [
420
+ "page_size",
421
+ request.pageSize ?? this.client.settings.defaultPageSize
422
+ ],
423
+ ["project_id", request.projectId],
424
+ ["statuses", request.statuses],
425
+ ["tags", request.tags]
426
+ )
427
+ },
428
+ unmarshalListHostingsResponse
429
+ );
430
+ /**
431
+ * List all Web Hosting plans. List all of your existing Web Hosting plans. Various filters are available to limit the results, including filtering by domain, status, tag and Project ID.
432
+ *
433
+ * @param request - The request {@link HostingApiListHostingsRequest}
434
+ * @returns A Promise of ListHostingsResponse
435
+ */
436
+ listHostings = (request = {}) => enrichForPagination("hostings", this.pageOfListHostings, request);
437
+ /**
438
+ * Get a Web Hosting plan. Get the details of one of your existing Web Hosting plans, specified by its `hosting_id`.
439
+ *
440
+ * @param request - The request {@link HostingApiGetHostingRequest}
441
+ * @returns A Promise of Hosting
442
+ */
443
+ getHosting = (request) => this.client.fetch(
444
+ {
445
+ method: "GET",
446
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}`
447
+ },
448
+ unmarshalHosting
449
+ );
450
+ /**
451
+ * Waits for {@link Hosting} to be in a final state.
452
+ *
453
+ * @param request - The request {@link HostingApiGetHostingRequest}
454
+ * @param options - The waiting options
455
+ * @returns A Promise of Hosting
456
+ */
457
+ waitForHosting = (request, options) => waitForResource(
458
+ options?.stop ?? ((res) => Promise.resolve(
459
+ !HOSTING_TRANSIENT_STATUSES.includes(res.status)
460
+ )),
461
+ this.getHosting,
462
+ request,
463
+ options
464
+ );
465
+ /**
466
+ * Update a Web Hosting plan. Update the details of one of your existing Web Hosting plans, specified by its `hosting_id`. You can update parameters including the contact email address, tags, options and offer.
467
+ *
468
+ * @param request - The request {@link HostingApiUpdateHostingRequest}
469
+ * @returns A Promise of Hosting
470
+ */
471
+ updateHosting = (request) => this.client.fetch(
472
+ {
473
+ body: JSON.stringify(
474
+ marshalHostingApiUpdateHostingRequest(request, this.client.settings)
475
+ ),
476
+ headers: jsonContentHeaders,
477
+ method: "PATCH",
478
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}`
479
+ },
480
+ unmarshalHosting
481
+ );
482
+ /**
483
+ * Delete a Web Hosting plan. Delete a Web Hosting plan, specified by its `hosting_id`. Note that deletion is not immediate: it will take place at the end of the calendar month, after which time your Web Hosting plan and all its data (files and emails) will be irreversibly lost.
484
+ *
485
+ * @param request - The request {@link HostingApiDeleteHostingRequest}
486
+ * @returns A Promise of Hosting
487
+ */
488
+ deleteHosting = (request) => this.client.fetch(
489
+ {
490
+ method: "DELETE",
491
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}`
492
+ },
493
+ unmarshalHosting
494
+ );
495
+ /**
496
+ * Create a user session.
497
+ *
498
+ * @param request - The request {@link HostingApiCreateSessionRequest}
499
+ * @returns A Promise of Session
500
+ */
501
+ createSession = (request) => this.client.fetch(
502
+ {
503
+ body: "{}",
504
+ headers: jsonContentHeaders,
505
+ method: "POST",
506
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/sessions`
507
+ },
508
+ unmarshalSession
509
+ );
510
+ /**
511
+ * Reset a Web Hosting plan password.
512
+ *
513
+ * @param request - The request {@link HostingApiResetHostingPasswordRequest}
514
+ * @returns A Promise of ResetHostingPasswordResponse
515
+ */
516
+ resetHostingPassword = (request) => this.client.fetch(
517
+ {
518
+ body: "{}",
519
+ headers: jsonContentHeaders,
520
+ method: "POST",
521
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/reset-password`
522
+ },
523
+ unmarshalResetHostingPasswordResponse
524
+ );
525
+ /**
526
+ * Get the total counts of websites, databases, email accounts, and FTP accounts of a Web Hosting plan.
527
+ *
528
+ * @param request - The request {@link HostingApiGetResourceSummaryRequest}
529
+ * @returns A Promise of ResourceSummary
530
+ */
531
+ getResourceSummary = (request) => this.client.fetch(
532
+ {
533
+ method: "GET",
534
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/resource-summary`
535
+ },
536
+ unmarshalResourceSummary
537
+ );
538
+ }
539
+ class FtpAccountAPI extends API {
540
+ /** Lists the available regions of the API. */
541
+ static LOCALITIES = [
542
+ "fr-par",
543
+ "nl-ams",
544
+ "pl-waw"
545
+ ];
546
+ /**
547
+ * Create a new FTP account within your hosting plan.. Create a new FTP account within your hosting plan.
548
+ *
549
+ * @param request - The request {@link FtpAccountApiCreateFtpAccountRequest}
550
+ * @returns A Promise of FtpAccount
551
+ */
552
+ createFtpAccount = (request) => this.client.fetch(
553
+ {
554
+ body: JSON.stringify(
555
+ marshalFtpAccountApiCreateFtpAccountRequest(
556
+ request,
557
+ this.client.settings
558
+ )
559
+ ),
560
+ headers: jsonContentHeaders,
561
+ method: "POST",
562
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/ftp-accounts`
563
+ },
564
+ unmarshalFtpAccount
565
+ );
566
+ pageOfListFtpAccounts = (request) => this.client.fetch(
567
+ {
568
+ method: "GET",
569
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/ftp-accounts`,
570
+ urlParams: urlParams(
571
+ ["domain", request.domain],
572
+ ["order_by", request.orderBy],
573
+ ["page", request.page],
574
+ [
575
+ "page_size",
576
+ request.pageSize ?? this.client.settings.defaultPageSize
577
+ ]
578
+ )
579
+ },
580
+ unmarshalListFtpAccountsResponse
581
+ );
582
+ /**
583
+ * List all FTP accounts within your hosting plan.. List all FTP accounts within your hosting plan.
584
+ *
585
+ * @param request - The request {@link FtpAccountApiListFtpAccountsRequest}
586
+ * @returns A Promise of ListFtpAccountsResponse
587
+ */
588
+ listFtpAccounts = (request) => enrichForPagination("ftpAccounts", this.pageOfListFtpAccounts, request);
589
+ /**
590
+ * Delete a specific FTP account within your hosting plan.. Delete a specific FTP account within your hosting plan.
591
+ *
592
+ * @param request - The request {@link FtpAccountApiRemoveFtpAccountRequest}
593
+ * @returns A Promise of FtpAccount
594
+ */
595
+ removeFtpAccount = (request) => this.client.fetch(
596
+ {
597
+ method: "DELETE",
598
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/ftp-accounts/${validatePathParam("username", request.username)}`
599
+ },
600
+ unmarshalFtpAccount
601
+ );
602
+ changeFtpAccountPassword = (request) => this.client.fetch(
603
+ {
604
+ body: JSON.stringify(
605
+ marshalFtpAccountApiChangeFtpAccountPasswordRequest(
606
+ request,
607
+ this.client.settings
608
+ )
609
+ ),
610
+ headers: jsonContentHeaders,
611
+ method: "POST",
612
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/ftp-accounts/${validatePathParam("username", request.username)}/change-password`
613
+ },
614
+ unmarshalFtpAccount
615
+ );
616
+ }
617
+ class MailAccountAPI extends API {
618
+ /** Lists the available regions of the API. */
619
+ static LOCALITIES = [
620
+ "fr-par",
621
+ "nl-ams",
622
+ "pl-waw"
623
+ ];
624
+ /**
625
+ * Create a new mail account within your hosting plan.. Create a new mail account within your hosting plan.
626
+ *
627
+ * @param request - The request {@link MailAccountApiCreateMailAccountRequest}
628
+ * @returns A Promise of MailAccount
629
+ */
630
+ createMailAccount = (request) => this.client.fetch(
631
+ {
632
+ body: JSON.stringify(
633
+ marshalMailAccountApiCreateMailAccountRequest(
634
+ request,
635
+ this.client.settings
636
+ )
637
+ ),
638
+ headers: jsonContentHeaders,
639
+ method: "POST",
640
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/mail-accounts`
641
+ },
642
+ unmarshalMailAccount
643
+ );
644
+ pageOfListMailAccounts = (request) => this.client.fetch(
645
+ {
646
+ method: "GET",
647
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/mail-accounts`,
648
+ urlParams: urlParams(
649
+ ["domain", request.domain],
650
+ ["order_by", request.orderBy],
651
+ ["page", request.page],
652
+ [
653
+ "page_size",
654
+ request.pageSize ?? this.client.settings.defaultPageSize
655
+ ]
656
+ )
657
+ },
658
+ unmarshalListMailAccountsResponse
659
+ );
660
+ /**
661
+ * List all mail accounts within your hosting plan.. List all mail accounts within your hosting plan.
662
+ *
663
+ * @param request - The request {@link MailAccountApiListMailAccountsRequest}
664
+ * @returns A Promise of ListMailAccountsResponse
665
+ */
666
+ listMailAccounts = (request) => enrichForPagination("mailAccounts", this.pageOfListMailAccounts, request);
667
+ /**
668
+ * Delete a mail account within your hosting plan.. Delete a mail account within your hosting plan.
669
+ *
670
+ * @param request - The request {@link MailAccountApiRemoveMailAccountRequest}
671
+ * @returns A Promise of MailAccount
672
+ */
673
+ removeMailAccount = (request) => this.client.fetch(
674
+ {
675
+ body: JSON.stringify(
676
+ marshalMailAccountApiRemoveMailAccountRequest(
677
+ request,
678
+ this.client.settings
679
+ )
680
+ ),
681
+ headers: jsonContentHeaders,
682
+ method: "POST",
683
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/remove-mail-account`
684
+ },
685
+ unmarshalMailAccount
686
+ );
687
+ /**
688
+ * Update the password of a mail account within your hosting plan.. Update the password of a mail account within your hosting plan.
689
+ *
690
+ * @param request - The request {@link MailAccountApiChangeMailAccountPasswordRequest}
691
+ * @returns A Promise of MailAccount
692
+ */
693
+ changeMailAccountPassword = (request) => this.client.fetch(
694
+ {
695
+ body: JSON.stringify(
696
+ marshalMailAccountApiChangeMailAccountPasswordRequest(
697
+ request,
698
+ this.client.settings
699
+ )
700
+ ),
701
+ headers: jsonContentHeaders,
702
+ method: "POST",
703
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/change-mail-password`
704
+ },
705
+ unmarshalMailAccount
706
+ );
707
+ }
708
+ class WebsiteAPI extends API {
709
+ /** Lists the available regions of the API. */
710
+ static LOCALITIES = [
711
+ "fr-par",
712
+ "nl-ams",
713
+ "pl-waw"
714
+ ];
715
+ pageOfListWebsites = (request) => this.client.fetch(
716
+ {
717
+ method: "GET",
718
+ path: `/webhosting/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/hostings/${validatePathParam("hostingId", request.hostingId)}/websites`,
719
+ urlParams: urlParams(
720
+ ["order_by", request.orderBy],
721
+ ["page", request.page],
722
+ [
723
+ "page_size",
724
+ request.pageSize ?? this.client.settings.defaultPageSize
725
+ ]
726
+ )
727
+ },
728
+ unmarshalListWebsitesResponse
729
+ );
730
+ /**
731
+ * List all websites for a specific hosting.. List all websites for a specific hosting.
732
+ *
733
+ * @param request - The request {@link WebsiteApiListWebsitesRequest}
734
+ * @returns A Promise of ListWebsitesResponse
735
+ */
736
+ listWebsites = (request) => enrichForPagination("websites", this.pageOfListWebsites, request);
737
+ }
738
+ export {
739
+ ControlPanelAPI,
740
+ DatabaseAPI,
741
+ DnsAPI,
742
+ FtpAccountAPI,
743
+ HostingAPI,
744
+ MailAccountAPI,
745
+ OfferAPI,
746
+ WebsiteAPI
747
+ };