@scaleway/sdk 0.1.0-alpha.3 → 0.1.0-alpha.6

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.
package/README.md CHANGED
@@ -36,9 +36,9 @@ You'll need a pair of access and secret keys to connect to Scaleway API. Please
36
36
  **A minimal setup** would look like this:
37
37
 
38
38
  ```ts
39
- import { RegistryAPI, createScwClient } from '@scaleway/sdk'
39
+ import { RegistryAPI, createClient } from '@scaleway/sdk'
40
40
 
41
- const client = createScwClient({
41
+ const client = createClient({
42
42
  accessKey: 'SCWXXXXXXXXXXXXXXXXX',
43
43
  secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
44
44
  defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
@@ -57,7 +57,7 @@ import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader
57
57
 
58
58
  const profile = loadProfileFromConfigurationFile()
59
59
  // const profile = loadProfileFromEnvironmentValues()
60
- const client = createScwClient(profile)
60
+ const client = createClient(profile)
61
61
  ```
62
62
 
63
63
  **For more advanced needs**, please check the examples.
@@ -6,20 +6,30 @@ import { API } from '../../../helpers/API.js';
6
6
 
7
7
  const unmarshalClearDNSZoneRecordsResponse = data => unmarshalAnyRes(data);
8
8
 
9
+ const unmarshalContact = data => unmarshalAnyRes(data, [], ['publication_jo']);
10
+
9
11
  const unmarshalDNSZone = data => unmarshalAnyRes(data, [], ['updated_at']);
10
12
 
11
13
  const unmarshalDeleteDNSZoneResponse = data => unmarshalAnyRes(data);
12
14
 
15
+ const unmarshalDeleteExternalDomainResponse = data => unmarshalAnyRes(data);
16
+
13
17
  const unmarshalDeleteSSLCertificateResponse = data => unmarshalAnyRes(data);
14
18
 
19
+ const unmarshalDomain = data => unmarshalAnyRes(data, [], ['expired_at', 'publication_jo', 'updated_at']);
20
+
15
21
  const unmarshalGetDNSZoneTsigKeyResponse = data => unmarshalAnyRes(data);
16
22
 
17
23
  const unmarshalGetDNSZoneVersionDiffResponse = data => unmarshalAnyRes(data);
18
24
 
25
+ const unmarshalGetDomainAuthCodeResponse = data => unmarshalAnyRes(data);
26
+
19
27
  const unmarshalImportProviderDNSZoneResponse = data => unmarshalAnyRes(data);
20
28
 
21
29
  const unmarshalImportRawDNSZoneResponse = data => unmarshalAnyRes(data);
22
30
 
31
+ const unmarshalListContactsResponse = data => unmarshalAnyRes(data, [], ['publication_jo']);
32
+
23
33
  const unmarshalListDNSZoneNameserversResponse = data => unmarshalAnyRes(data);
24
34
 
25
35
  const unmarshalListDNSZoneRecordsResponse = data => unmarshalAnyRes(data);
@@ -30,14 +40,26 @@ const unmarshalListDNSZoneVersionsResponse = data => unmarshalAnyRes(data, [], [
30
40
 
31
41
  const unmarshalListDNSZonesResponse = data => unmarshalAnyRes(data, [], ['updated_at']);
32
42
 
43
+ const unmarshalListDomainsResponse = data => unmarshalAnyRes(data, [], ['expired_at', 'updated_at']);
44
+
45
+ const unmarshalListRenewableDomainsResponse = data => unmarshalAnyRes(data, [], ['expired_at']);
46
+
33
47
  const unmarshalListSSLCertificatesResponse = data => unmarshalAnyRes(data, [], ['created_at', 'expired_at']);
34
48
 
49
+ const unmarshalListTasksResponse = data => unmarshalAnyRes(data, [], ['started_at', 'updated_at']);
50
+
51
+ const unmarshalOrderResponse = data => unmarshalAnyRes(data, [], ['created_at']);
52
+
35
53
  const unmarshalRefreshDNSZoneResponse = data => unmarshalAnyRes(data, [], ['updated_at']);
36
54
 
55
+ const unmarshalRegisterExternalDomainResponse = data => unmarshalAnyRes(data, [], ['created_at']);
56
+
37
57
  const unmarshalRestoreDNSZoneVersionResponse = data => unmarshalAnyRes(data);
38
58
 
39
59
  const unmarshalSSLCertificate = data => unmarshalAnyRes(data, [], ['created_at', 'expired_at']);
40
60
 
61
+ const unmarshalSearchAvailableDomainsResponse = data => unmarshalAnyRes(data, ['specifications']);
62
+
41
63
  const unmarshalUpdateDNSZoneNameserversResponse = data => unmarshalAnyRes(data);
42
64
 
43
65
  const unmarshalUpdateDNSZoneRecordsResponse = data => unmarshalAnyRes(data);
@@ -275,6 +297,340 @@ class DomainAPI extends API {
275
297
  });
276
298
  }
277
299
 
300
+ }
301
+ class RegistrarDomainAPI extends API {
302
+ constructor() {
303
+ var _this;
304
+
305
+ super(...arguments);
306
+ _this = this;
307
+
308
+ this.pageOfListTasks = request => this.client.fetch({
309
+ method: 'GET',
310
+ path: `/domain/v2beta1/tasks`,
311
+ urlParams: urlParams(['domain', request.domain], ['organization_id', request.organizationId ?? this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize], ['project_id', request.projectId ?? this.client.settings.defaultProjectId])
312
+ }, unmarshalListTasksResponse);
313
+
314
+ this.listTasks = request => Object.assign(this.pageOfListTasks(request), {
315
+ all: () => fetchAll('tasks', this.pageOfListTasks, request),
316
+ [Symbol.asyncIterator]: () => fetchPaginated('tasks', this.pageOfListTasks, request),
317
+ page: async num => (await this.pageOfListTasks({ ...request,
318
+ page: num
319
+ })).tasks
320
+ });
321
+
322
+ this.buyDomains = request => {
323
+ const administrativeContactType = resolveOneOf([{
324
+ param: 'administrative_contact_id',
325
+ value: request.administrativeContactId
326
+ }, {
327
+ param: 'administrative_contact',
328
+ value: request.administrativeContact
329
+ }]);
330
+ const ownerContactType = resolveOneOf([{
331
+ param: 'owner_contact_id',
332
+ value: request.ownerContactId
333
+ }, {
334
+ param: 'owner_contact',
335
+ value: request.ownerContact
336
+ }]);
337
+ const technicalContactType = resolveOneOf([{
338
+ param: 'technical_contact_id',
339
+ value: request.technicalContactId
340
+ }, {
341
+ param: 'technical_contact',
342
+ value: request.technicalContact
343
+ }]);
344
+ return this.client.fetch({
345
+ body: JSON.stringify({
346
+ domains: request.domains,
347
+ duration_in_years: request.durationInYears,
348
+ project_id: request.projectId ?? this.client.settings.defaultProjectId,
349
+ ...administrativeContactType,
350
+ ...ownerContactType,
351
+ ...technicalContactType
352
+ }),
353
+ headers: jsonContentHeaders,
354
+ method: 'POST',
355
+ path: `/domain/v2beta1/buy-domains`
356
+ }, unmarshalOrderResponse);
357
+ };
358
+
359
+ this.renewDomains = request => this.client.fetch({
360
+ body: JSON.stringify({
361
+ domains: request.domains,
362
+ duration_in_years: request.durationInYears,
363
+ force_late_renewal: request.forceLateRenewal
364
+ }),
365
+ headers: jsonContentHeaders,
366
+ method: 'POST',
367
+ path: `/domain/v2beta1/renew-domains`
368
+ }, unmarshalOrderResponse);
369
+
370
+ this.transferInDomain = request => {
371
+ const administrativeContactType = resolveOneOf([{
372
+ param: 'administrative_contact_id',
373
+ value: request.administrativeContactId
374
+ }, {
375
+ param: 'administrative_contact',
376
+ value: request.administrativeContact
377
+ }]);
378
+ const ownerContactType = resolveOneOf([{
379
+ param: 'owner_contact_id',
380
+ value: request.ownerContactId
381
+ }, {
382
+ param: 'owner_contact',
383
+ value: request.ownerContact
384
+ }]);
385
+ const technicalContactType = resolveOneOf([{
386
+ param: 'technical_contact_id',
387
+ value: request.technicalContactId
388
+ }, {
389
+ param: 'technical_contact',
390
+ value: request.technicalContact
391
+ }]);
392
+ return this.client.fetch({
393
+ body: JSON.stringify({
394
+ domains: request.domains,
395
+ project_id: request.projectId ?? this.client.settings.defaultProjectId,
396
+ ...administrativeContactType,
397
+ ...ownerContactType,
398
+ ...technicalContactType
399
+ }),
400
+ headers: jsonContentHeaders,
401
+ method: 'POST',
402
+ path: `/domain/v2beta1/domains/transfer-domains`
403
+ }, unmarshalOrderResponse);
404
+ };
405
+
406
+ this.tradeDomain = request => {
407
+ const newOwnerContactType = resolveOneOf([{
408
+ param: 'new_owner_contact_id',
409
+ value: request.newOwnerContactId
410
+ }, {
411
+ param: 'new_owner_contact',
412
+ value: request.newOwnerContact
413
+ }]);
414
+ return this.client.fetch({
415
+ body: JSON.stringify({
416
+ project_id: request.projectId ?? this.client.settings.defaultProjectId,
417
+ ...newOwnerContactType
418
+ }),
419
+ headers: jsonContentHeaders,
420
+ method: 'POST',
421
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/trade`
422
+ }, unmarshalOrderResponse);
423
+ };
424
+
425
+ this.registerExternalDomain = request => this.client.fetch({
426
+ body: JSON.stringify({
427
+ domain: request.domain,
428
+ project_id: request.projectId ?? this.client.settings.defaultProjectId
429
+ }),
430
+ headers: jsonContentHeaders,
431
+ method: 'POST',
432
+ path: `/domain/v2beta1/external-domains`
433
+ }, unmarshalRegisterExternalDomainResponse);
434
+
435
+ this.deleteExternalDomain = request => this.client.fetch({
436
+ method: 'DELETE',
437
+ path: `/domain/v2beta1/external-domains/${validatePathParam('domain', request.domain)}`
438
+ }, unmarshalDeleteExternalDomainResponse);
439
+
440
+ this.pageOfListContacts = function (request) {
441
+ if (request === void 0) {
442
+ request = {};
443
+ }
444
+
445
+ return _this.client.fetch({
446
+ method: 'GET',
447
+ path: `/domain/v2beta1/contacts`,
448
+ urlParams: urlParams(['domain', request.domain], ['organization_id', request.organizationId ?? _this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId])
449
+ }, unmarshalListContactsResponse);
450
+ };
451
+
452
+ this.listContacts = function (request) {
453
+ if (request === void 0) {
454
+ request = {};
455
+ }
456
+
457
+ return Object.assign(_this.pageOfListContacts(request), {
458
+ all: () => fetchAll('contacts', _this.pageOfListContacts, request),
459
+ [Symbol.asyncIterator]: () => fetchPaginated('contacts', _this.pageOfListContacts, request),
460
+ page: async num => (await _this.pageOfListContacts({ ...request,
461
+ page: num
462
+ })).contacts
463
+ });
464
+ };
465
+
466
+ this.getContact = request => this.client.fetch({
467
+ method: 'GET',
468
+ path: `/domain/v2beta1/contacts/${validatePathParam('contactId', request.contactId)}`
469
+ }, unmarshalContact);
470
+
471
+ this.updateContact = request => this.client.fetch({
472
+ body: JSON.stringify({
473
+ address_line_1: request.addressLine1,
474
+ address_line_2: request.addressLine2,
475
+ city: request.city,
476
+ company_identification_code: request.companyIdentificationCode,
477
+ country: request.country,
478
+ email: request.email,
479
+ email_alt: request.emailAlt,
480
+ extension_eu: request.extensionEu,
481
+ extension_fr: request.extensionFr,
482
+ extension_nl: request.extensionNl,
483
+ fax_number: request.faxNumber,
484
+ lang: request.lang ?? 'unknown_language_code',
485
+ phone_number: request.phoneNumber,
486
+ questions: request.questions,
487
+ resale: request.resale,
488
+ state: request.state,
489
+ vat_identification_code: request.vatIdentificationCode,
490
+ whois_opt_in: request.whoisOptIn,
491
+ zip: request.zip
492
+ }),
493
+ headers: jsonContentHeaders,
494
+ method: 'PATCH',
495
+ path: `/domain/v2beta1/contacts/${validatePathParam('contactId', request.contactId)}`
496
+ }, unmarshalContact);
497
+
498
+ this.pageOfListDomains = function (request) {
499
+ if (request === void 0) {
500
+ request = {};
501
+ }
502
+
503
+ return _this.client.fetch({
504
+ method: 'GET',
505
+ path: `/domain/v2beta1/domains`,
506
+ urlParams: urlParams(['is_external', request.isExternal], ['order_by', request.orderBy ?? 'domain_asc'], ['organization_id', request.organizationId ?? _this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId], ['registrar', request.registrar], ['status', request.status ?? 'status_unknown'])
507
+ }, unmarshalListDomainsResponse);
508
+ };
509
+
510
+ this.listDomains = function (request) {
511
+ if (request === void 0) {
512
+ request = {};
513
+ }
514
+
515
+ return Object.assign(_this.pageOfListDomains(request), {
516
+ all: () => fetchAll('domains', _this.pageOfListDomains, request),
517
+ [Symbol.asyncIterator]: () => fetchPaginated('domains', _this.pageOfListDomains, request),
518
+ page: async num => (await _this.pageOfListDomains({ ...request,
519
+ page: num
520
+ })).domains
521
+ });
522
+ };
523
+
524
+ this.pageOfListRenewableDomains = function (request) {
525
+ if (request === void 0) {
526
+ request = {};
527
+ }
528
+
529
+ return _this.client.fetch({
530
+ method: 'GET',
531
+ path: `/domain/v2beta1/renewable-domains`,
532
+ urlParams: urlParams(['order_by', request.orderBy ?? 'domain_asc'], ['organization_id', request.organizationId ?? _this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId])
533
+ }, unmarshalListRenewableDomainsResponse);
534
+ };
535
+
536
+ this.listRenewableDomains = function (request) {
537
+ if (request === void 0) {
538
+ request = {};
539
+ }
540
+
541
+ return Object.assign(_this.pageOfListRenewableDomains(request), {
542
+ all: () => fetchAll('domains', _this.pageOfListRenewableDomains, request),
543
+ [Symbol.asyncIterator]: () => fetchPaginated('domains', _this.pageOfListRenewableDomains, request),
544
+ page: async num => (await _this.pageOfListRenewableDomains({ ...request,
545
+ page: num
546
+ })).domains
547
+ });
548
+ };
549
+
550
+ this.getDomain = request => this.client.fetch({
551
+ method: 'GET',
552
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}`
553
+ }, unmarshalDomain);
554
+
555
+ this.updateDomain = request => {
556
+ const administrativeContactInfo = resolveOneOf([{
557
+ param: 'administrative_contact_id',
558
+ value: request.administrativeContactId
559
+ }, {
560
+ param: 'administrative_contact',
561
+ value: request.administrativeContact
562
+ }]);
563
+ const ownerContactInfo = resolveOneOf([{
564
+ param: 'owner_contact_id',
565
+ value: request.ownerContactId
566
+ }, {
567
+ param: 'owner_contact',
568
+ value: request.ownerContact
569
+ }]);
570
+ const technicalContactInfo = resolveOneOf([{
571
+ param: 'technical_contact_id',
572
+ value: request.technicalContactId
573
+ }, {
574
+ param: 'technical_contact',
575
+ value: request.technicalContact
576
+ }]);
577
+ return this.client.fetch({
578
+ body: JSON.stringify({ ...administrativeContactInfo,
579
+ ...ownerContactInfo,
580
+ ...technicalContactInfo
581
+ }),
582
+ headers: jsonContentHeaders,
583
+ method: 'PATCH',
584
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}`
585
+ }, unmarshalDomain);
586
+ };
587
+
588
+ this.lockDomainTransfer = request => this.client.fetch({
589
+ method: 'POST',
590
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/lock-transfer`
591
+ }, unmarshalDomain);
592
+
593
+ this.unlockDomainTransfer = request => this.client.fetch({
594
+ method: 'POST',
595
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/unlock-transfer`
596
+ }, unmarshalDomain);
597
+
598
+ this.enableDomainAutoRenew = request => this.client.fetch({
599
+ method: 'POST',
600
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/enable-auto-renew`
601
+ }, unmarshalDomain);
602
+
603
+ this.disableDomainAutoRenew = request => this.client.fetch({
604
+ method: 'POST',
605
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/disable-auto-renew`
606
+ }, unmarshalDomain);
607
+
608
+ this.getDomainAuthCode = request => this.client.fetch({
609
+ method: 'GET',
610
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/auth-code`
611
+ }, unmarshalGetDomainAuthCodeResponse);
612
+
613
+ this.enableDomainDNSSEC = request => this.client.fetch({
614
+ body: JSON.stringify({
615
+ ds_record: request.dsRecord
616
+ }),
617
+ headers: jsonContentHeaders,
618
+ method: 'POST',
619
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/enable-dnssec`
620
+ }, unmarshalDomain);
621
+
622
+ this.disableDomainDNSSEC = request => this.client.fetch({
623
+ method: 'POST',
624
+ path: `/domain/v2beta1/domains/${validatePathParam('domain', request.domain)}/disable-dnssec`
625
+ }, unmarshalDomain);
626
+
627
+ this.searchAvailableDomains = request => this.client.fetch({
628
+ method: 'GET',
629
+ path: `/domain/v2beta1/search-domains`,
630
+ urlParams: urlParams(['domains', request.domains], ['tlds', request.tlds])
631
+ }, unmarshalSearchAvailableDomainsResponse);
632
+ }
633
+
278
634
  }
279
635
 
280
- export { DomainAPI };
636
+ export { DomainAPI, RegistrarDomainAPI };
@@ -22,6 +22,7 @@ class FlexibleipAPI extends API {
22
22
  this.createFlexibleIP = request => this.client.fetch({
23
23
  body: JSON.stringify({
24
24
  description: request.description,
25
+ is_ipv6: request.isIpv6,
25
26
  project_id: request.projectId ?? this.client.settings.defaultProjectId,
26
27
  reverse: request.reverse,
27
28
  server_id: request.serverId,
@@ -152,6 +152,7 @@ class FunctionAPI extends API {
152
152
  min_scale: request.minScale,
153
153
  privacy: request.privacy ?? 'unknown_privacy',
154
154
  redeploy: request.redeploy,
155
+ runtime: request.runtime ?? 'unknown_runtime',
155
156
  secret_environment_variables: request.secretEnvironmentVariables,
156
157
  timeout: request.timeout
157
158
  }),