@scaleway/sdk 0.1.0-alpha.10 → 0.1.0-alpha.11

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
@@ -1,33 +1,16 @@
1
1
  # Scaleway SDK
2
2
 
3
- ## ALPHA
4
-
5
- The project is in an **early alpha** phase.
6
-
7
- * The generated code as well as the distribution is subject to change (i.e. we might have one package per product).
8
- * The code will be available on GitHub once it enters beta.
9
-
10
- **List of available APIs:**
11
-
12
- | **Name** | **Version** | **Class** |
13
- |:-------------:|:-----------:|:---------------:|
14
- | Account | v2alpha1 | AccountAPI |
15
- | Apple Silicon | v1alpha1 | ApplesiliconAPI |
16
- | Baremetal | v1 | BaremetalAPI |
17
- | Container | v1beta1 | ContainerAPI |
18
- | Domain | v2beta1 | DomainAPI |
19
- | Flexible IP | v1alpha1 | FlexibleipAPI |
20
- | Function | v1beta1 | FunctionAPI |
21
- | IOT | v1 | IotAPI |
22
- | K8S | v1 | K8SAPI |
23
- | LB | v1 | LbAPI |
24
- | Marketplace | v1 | MarketplaceAPI |
25
- | RDB | v1 | RdbAPI |
26
- | Redis | v1alpha1 | RedisAPI |
27
- | Registry | v1 | RegistryAPI |
28
- | VPC | v1 | VpcAPI |
29
- | VPC Gateway | v1 | VpcgwAPI |
3
+ Scaleway is a single way to create, deploy and scale your infrastructure in the cloud. This SDK enables you to interact with the APIs.
30
4
 
5
+ **⚠️  The project is in alpha:**
6
+ * Code is subject to breaking changes.
7
+ * Sources will be available on GitHub once the SDK enters beta.
8
+ * SDK only works from a server, browser calls aren't supported yet.
9
+
10
+ **🔗  Important links:**
11
+ * Reference documentation (soon)
12
+ * Example projects (soon)
13
+ * [Developers website](https://developers.scaleway.com) (API documentation)
31
14
 
32
15
  ## Getting Started
33
16
 
@@ -46,29 +29,52 @@ const client = createClient({
46
29
  defaultZone: 'fr-par-1',
47
30
  })
48
31
 
49
- const registryAPI = new RegistryAPI(client)
32
+ const api = new RegistryAPI(client)
50
33
  ```
51
34
 
52
35
  **In case of a NodeJS environment**, you could retrieve the profile from either the configuration file or the environment variables:
53
36
 
54
37
  ```ts
55
- import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
56
- // import { loadProfileFromEnvironmentValues } from '@scaleway/configuration-loader'
38
+ import {
39
+ loadProfileFromConfigurationFile,
40
+ // loadProfileFromEnvironmentValues,
41
+ } from '@scaleway/configuration-loader'
57
42
 
58
- const profile = loadProfileFromConfigurationFile()
59
- // const profile = loadProfileFromEnvironmentValues()
43
+ const profile = loadProfileFromConfigurationFile() // loadProfileFromEnvironmentValues()
60
44
  const client = createClient(profile)
61
45
  ```
62
46
 
63
47
  **For more advanced needs**, please check the examples.
64
48
 
65
- ## Usage
49
+ ## Pagination
50
+
51
+ We included some pagination helpers for the methods supporting the feature. Let's take `listNamespaces()` (Registry product) as an example:
52
+
53
+ Retrieve the **first page**:
54
+
55
+ ```ts
56
+ const namespaces = await api.listNamespaces(/*{ page: 1 }*/)
57
+ ```
58
+
59
+ Retrieve **all the pages**:
60
+ ```ts
61
+ const allNamespaces = await api.listNamespaces().all()
62
+ ```
63
+
64
+ **Iterate** over the pages:
65
+ ```ts
66
+ for await (const page of listNamespaces()) {
67
+ //
68
+ }
69
+ ```
70
+
71
+ ## Dependencies
66
72
 
67
73
  This SDK is based on the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API and use `Request`, `Response` & `Headers` interfaces. Those interfaces are native in modern browsers, node >=18 & deno environments.
68
74
 
69
75
  For `node` < 18 & `React Native` environments, the commonJS build requires [cross-fetch](https://www.npmjs.com/package/cross-fetch) package, it is listed in `dependencies` but not used in esm build.
70
76
 
71
- ## Troubleshooting
77
+ **Troubleshooting**
72
78
 
73
79
  In node environment, the commonJS module defined in `dist/index.cjs` entry file is used by default, thanks to the "main" `package.json` field.
74
80
 
@@ -6,6 +6,8 @@ import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
6
6
 
7
7
  const unmarshal0ECB = data => unmarshalAnyRes(data, [], ['created_at', 'updated_at']);
8
8
 
9
+ const unmarshal23C1 = data => unmarshalAnyRes(data, [], ['created_at', 'expires_at', 'updated_at']);
10
+
9
11
  const unmarshal41B8 = data => unmarshalAnyRes(data, [], ['expires_at']);
10
12
 
11
13
  const jsonContentHeaders = {
@@ -22,14 +24,14 @@ class BaremetalV1GenAPI extends API {
22
24
  method: 'GET',
23
25
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers`,
24
26
  urlParams: urlParams(['name', request.name], ['option_id', request.optionId], ['order_by', request.orderBy ?? 'created_at_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], ['status', request.status], ['tags', request.tags])
25
- }, unmarshal0ECB);
27
+ }, unmarshal23C1);
26
28
 
27
29
  this.listServers = request => enrichForPagination('servers', this.pageOfListServers, request);
28
30
 
29
31
  this.getServer = request => this.client.fetch({
30
32
  method: 'GET',
31
33
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`
32
- }, unmarshal0ECB);
34
+ }, unmarshal23C1);
33
35
 
34
36
  this.createServer = request => {
35
37
  const projectIdentifier = resolveOneOf([{
@@ -54,7 +56,7 @@ class BaremetalV1GenAPI extends API {
54
56
  headers: jsonContentHeaders,
55
57
  method: 'POST',
56
58
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers`
57
- }, unmarshal0ECB);
59
+ }, unmarshal23C1);
58
60
  };
59
61
 
60
62
  this.updateServer = request => this.client.fetch({
@@ -66,7 +68,7 @@ class BaremetalV1GenAPI extends API {
66
68
  headers: jsonContentHeaders,
67
69
  method: 'PATCH',
68
70
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`
69
- }, unmarshal0ECB);
71
+ }, unmarshal23C1);
70
72
 
71
73
  this.installServer = request => this.client.fetch({
72
74
  body: JSON.stringify({
@@ -81,7 +83,7 @@ class BaremetalV1GenAPI extends API {
81
83
  headers: jsonContentHeaders,
82
84
  method: 'POST',
83
85
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/install`
84
- }, unmarshal0ECB);
86
+ }, unmarshal23C1);
85
87
 
86
88
  this.getServerMetrics = request => this.client.fetch({
87
89
  method: 'GET',
@@ -91,7 +93,7 @@ class BaremetalV1GenAPI extends API {
91
93
  this.deleteServer = request => this.client.fetch({
92
94
  method: 'DELETE',
93
95
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`
94
- }, unmarshal0ECB);
96
+ }, unmarshal23C1);
95
97
 
96
98
  this.rebootServer = request => this.client.fetch({
97
99
  body: JSON.stringify({
@@ -100,7 +102,7 @@ class BaremetalV1GenAPI extends API {
100
102
  headers: jsonContentHeaders,
101
103
  method: 'POST',
102
104
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reboot`
103
- }, unmarshal0ECB);
105
+ }, unmarshal23C1);
104
106
 
105
107
  this.startServer = request => this.client.fetch({
106
108
  body: JSON.stringify({
@@ -109,14 +111,14 @@ class BaremetalV1GenAPI extends API {
109
111
  headers: jsonContentHeaders,
110
112
  method: 'POST',
111
113
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/start`
112
- }, unmarshal0ECB);
114
+ }, unmarshal23C1);
113
115
 
114
116
  this.stopServer = request => this.client.fetch({
115
117
  body: '{}',
116
118
  headers: jsonContentHeaders,
117
119
  method: 'POST',
118
120
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/stop`
119
- }, unmarshal0ECB);
121
+ }, unmarshal23C1);
120
122
 
121
123
  this.pageOfListServerEvents = request => this.client.fetch({
122
124
  method: 'GET',
@@ -155,16 +157,18 @@ class BaremetalV1GenAPI extends API {
155
157
  }, unmarshalAnyRes);
156
158
 
157
159
  this.addOptionServer = request => this.client.fetch({
158
- body: '{}',
160
+ body: JSON.stringify({
161
+ expires_at: request.expiresAt
162
+ }),
159
163
  headers: jsonContentHeaders,
160
164
  method: 'POST',
161
165
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/options/${validatePathParam('optionId', request.optionId)}`
162
- }, unmarshal0ECB);
166
+ }, unmarshal23C1);
163
167
 
164
168
  this.deleteOptionServer = request => this.client.fetch({
165
169
  method: 'DELETE',
166
170
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/options/${validatePathParam('optionId', request.optionId)}`
167
- }, unmarshal0ECB);
171
+ }, unmarshal23C1);
168
172
 
169
173
  this.pageOfListOffers = function (request) {
170
174
  if (request === void 0) {
@@ -4,6 +4,8 @@ import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
4
4
 
5
5
  // This file was automatically generated. DO NOT EDIT.
6
6
 
7
+ const unmarshal07B0 = data => unmarshalAnyRes(data, [], ['created_at']);
8
+
7
9
  const unmarshal3AEB = data => unmarshalAnyRes(data, [], ['created_at', 'expired_at', 'finished_at', 'rebooted_at', 'updated_at']);
8
10
 
9
11
  const unmarshal41B8 = data => unmarshalAnyRes(data, [], ['expires_at']);
@@ -617,22 +619,156 @@ class DediboxRpnV1GenAPI extends API {
617
619
  }
618
620
 
619
621
  }
620
- class DediboxRpnV2V1GenAPI extends API {
622
+ class DediboxRpnV1V1GenAPI extends API {
621
623
  constructor() {
622
624
  var _this5;
623
625
 
624
626
  super(...arguments);
625
627
  _this5 = this;
626
628
 
627
- this.pageOfListRpnV2Groups = function (request) {
629
+ this.pageOfListRpnGroups = function (request) {
628
630
  if (request === void 0) {
629
631
  request = {};
630
632
  }
631
633
 
632
634
  return _this5.client.fetch({
633
635
  method: 'GET',
634
- path: `/dedibox/v1/rpnv2/groups`,
636
+ path: `/dedibox/v1/rpnv1/groups`,
637
+ urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this5.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this5.client.settings.defaultProjectId])
638
+ }, unmarshal07B0);
639
+ };
640
+
641
+ this.listRpnGroups = function (request) {
642
+ if (request === void 0) {
643
+ request = {};
644
+ }
645
+
646
+ return enrichForPagination('rpnGroups', _this5.pageOfListRpnGroups, request);
647
+ };
648
+
649
+ this.getRpnGroup = request => this.client.fetch({
650
+ method: 'GET',
651
+ path: `/dedibox/v1/rpnv1/groups/${validatePathParam('groupId', request.groupId)}`
652
+ }, unmarshal07B0);
653
+
654
+ this.createRpnGroup = request => this.client.fetch({
655
+ body: JSON.stringify({
656
+ name: request.name,
657
+ project_id: request.projectId ?? this.client.settings.defaultProjectId,
658
+ san_server_ids: request.sanServerIds,
659
+ server_ids: request.serverIds
660
+ }),
661
+ headers: jsonContentHeaders,
662
+ method: 'POST',
663
+ path: `/dedibox/v1/rpnv1/groups`
664
+ }, unmarshal07B0);
665
+
666
+ this.deleteRpnGroup = request => this.client.fetch({
667
+ method: 'DELETE',
668
+ path: `/dedibox/v1/rpnv1/groups/${validatePathParam('groupId', request.groupId)}`
669
+ });
670
+
671
+ this.updateRpnGroupName = request => this.client.fetch({
672
+ body: JSON.stringify({
673
+ name: request.name
674
+ }),
675
+ headers: jsonContentHeaders,
676
+ method: 'PATCH',
677
+ path: `/dedibox/v1/rpnv1/groups/${validatePathParam('groupId', request.groupId)}`
678
+ }, unmarshal07B0);
679
+
680
+ this.pageOfListRpnGroupMembers = request => this.client.fetch({
681
+ method: 'GET',
682
+ path: `/dedibox/v1/rpnv1/groups/${validatePathParam('groupId', request.groupId)}/members`,
683
+ urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize], ['pending_invitations_only', request.pendingInvitationsOnly])
684
+ }, unmarshal847D);
685
+
686
+ this.listRpnGroupMembers = request => enrichForPagination('members', this.pageOfListRpnGroupMembers, request);
687
+
688
+ this.addRpnGroupMembers = request => this.client.fetch({
689
+ body: JSON.stringify({
690
+ san_server_ids: request.sanServerIds,
691
+ server_ids: request.serverIds
692
+ }),
693
+ headers: jsonContentHeaders,
694
+ method: 'POST',
695
+ path: `/dedibox/v1/rpnv1/groups/${validatePathParam('groupId', request.groupId)}/members`
696
+ }, unmarshal07B0);
697
+
698
+ this.deleteRpnGroupMembers = request => this.client.fetch({
699
+ method: 'DELETE',
700
+ path: `/dedibox/v1/rpnv1/groups/${validatePathParam('groupId', request.groupId)}/members`,
701
+ urlParams: urlParams(['members_ids', request.membersIds])
702
+ }, unmarshal07B0);
703
+
704
+ this.pageOfListRpnCapableServers = function (request) {
705
+ if (request === void 0) {
706
+ request = {};
707
+ }
708
+
709
+ return _this5.client.fetch({
710
+ method: 'GET',
711
+ path: `/dedibox/v1/rpnv1/capable-servers`,
712
+ urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this5.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this5.client.settings.defaultProjectId])
713
+ }, unmarshal847D);
714
+ };
715
+
716
+ this.listRpnCapableServers = function (request) {
717
+ if (request === void 0) {
718
+ request = {};
719
+ }
720
+
721
+ return enrichForPagination('servers', _this5.pageOfListRpnCapableServers, request);
722
+ };
723
+
724
+ this.pageOfListRpnCapableSanServers = function (request) {
725
+ if (request === void 0) {
726
+ request = {};
727
+ }
728
+
729
+ return _this5.client.fetch({
730
+ method: 'GET',
731
+ path: `/dedibox/v1/rpnv1/capable-san-servers`,
635
732
  urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this5.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this5.client.settings.defaultProjectId])
733
+ }, unmarshal07B0);
734
+ };
735
+
736
+ this.listRpnCapableSanServers = function (request) {
737
+ if (request === void 0) {
738
+ request = {};
739
+ }
740
+
741
+ return enrichForPagination('sanServers', _this5.pageOfListRpnCapableSanServers, request);
742
+ };
743
+
744
+ this.acceptRpnInvite = request => this.client.fetch({
745
+ method: 'POST',
746
+ path: `/dedibox/v1/rpnv1/invites/${validatePathParam('memberId', request.memberId)}/accept`
747
+ });
748
+
749
+ this.refuseRpnInvite = request => this.client.fetch({
750
+ method: 'POST',
751
+ path: `/dedibox/v1/rpnv1/invites/${validatePathParam('memberId', request.memberId)}/refuse`
752
+ });
753
+ }
754
+
755
+ }
756
+ class DediboxRpnV2V1GenAPI extends API {
757
+ constructor() {
758
+ var _this6;
759
+
760
+ super(...arguments);
761
+ _this6 = this;
762
+
763
+ this.pageOfListRpnV2Groups = function (request) {
764
+ if (request === void 0) {
765
+ request = {};
766
+ }
767
+
768
+ return _this6.client.fetch({
769
+ method: 'GET',
770
+ path: `/dedibox/v1/rpnv2/groups`,
771
+ urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this6.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this6.client.settings.defaultProjectId])
636
772
  }, unmarshalAnyRes);
637
773
  };
638
774
 
@@ -641,7 +777,7 @@ class DediboxRpnV2V1GenAPI extends API {
641
777
  request = {};
642
778
  }
643
779
 
644
- return enrichForPagination('rpnGroups', _this5.pageOfListRpnV2Groups, request);
780
+ return enrichForPagination('rpnGroups', _this6.pageOfListRpnV2Groups, request);
645
781
  };
646
782
 
647
783
  this.pageOfListRpnV2Members = request => this.client.fetch({
@@ -703,10 +839,10 @@ class DediboxRpnV2V1GenAPI extends API {
703
839
  request = {};
704
840
  }
705
841
 
706
- return _this5.client.fetch({
842
+ return _this6.client.fetch({
707
843
  method: 'GET',
708
844
  path: `/dedibox/v1/rpnv2/groups/capable`,
709
- urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this5.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this5.client.settings.defaultProjectId])
845
+ urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this6.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this6.client.settings.defaultProjectId])
710
846
  }, unmarshal847D);
711
847
  };
712
848
 
@@ -715,7 +851,7 @@ class DediboxRpnV2V1GenAPI extends API {
715
851
  request = {};
716
852
  }
717
853
 
718
- return enrichForPagination('servers', _this5.pageOfListRpnV2CapableResources, request);
854
+ return enrichForPagination('servers', _this6.pageOfListRpnV2CapableResources, request);
719
855
  };
720
856
 
721
857
  this.pageOfListRpnV2GroupLogs = request => this.client.fetch({
@@ -754,4 +890,4 @@ class DediboxRpnV2V1GenAPI extends API {
754
890
 
755
891
  }
756
892
 
757
- export { DediboxBillingV1GenAPI, DediboxIPv6BlockV1GenAPI, DediboxRpnV1GenAPI, DediboxRpnV2V1GenAPI, DediboxV1GenAPI };
893
+ export { DediboxBillingV1GenAPI, DediboxIPv6BlockV1GenAPI, DediboxRpnV1GenAPI, DediboxRpnV1V1GenAPI, DediboxRpnV2V1GenAPI, DediboxV1GenAPI };