@scaleway/sdk 1.12.0 → 1.14.0

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,231 @@
1
+ import { API as API$1 } from '../../../scw/api.js';
2
+ import { validatePathParam, urlParams } from '../../../helpers/marshalling.js';
3
+ import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
4
+ import { unmarshalListVPCsResponse, marshalCreateVPCRequest, unmarshalVPC, marshalUpdateVPCRequest, unmarshalListPrivateNetworksResponse, marshalCreatePrivateNetworkRequest, unmarshalPrivateNetwork, marshalUpdatePrivateNetworkRequest, marshalMigrateZonalPrivateNetworksRequest, marshalSetSubnetsRequest, unmarshalSetSubnetsResponse, marshalAddSubnetsRequest, unmarshalAddSubnetsResponse, marshalDeleteSubnetsRequest, unmarshalDeleteSubnetsResponse } from './marshalling.gen.js';
5
+
6
+ // This file was automatically generated. DO NOT EDIT.
7
+ // If you have any remark or suggestion do not hesitate to open an issue.
8
+ const jsonContentHeaders = {
9
+ 'Content-Type': 'application/json; charset=utf-8'
10
+ };
11
+
12
+ /** VPC API. */
13
+ class API extends API$1 {
14
+ constructor() {
15
+ var _this;
16
+ super(...arguments);
17
+ _this = this;
18
+ this.pageOfListVPCs = function (request) {
19
+ if (request === void 0) {
20
+ request = {};
21
+ }
22
+ return _this.client.fetch({
23
+ method: 'GET',
24
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/vpcs`,
25
+ urlParams: urlParams(['is_default', request.isDefault], ['name', request.name], ['order_by', request.orderBy ?? 'created_at_asc'], ['organization_id', request.organizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId], ['tags', request.tags])
26
+ }, unmarshalListVPCsResponse);
27
+ };
28
+ /**
29
+ * List VPCs. List existing VPCs in the specified region.
30
+ *
31
+ * @param request - The request {@link ListVPCsRequest}
32
+ * @returns A Promise of ListVPCsResponse
33
+ */
34
+ this.listVPCs = function (request) {
35
+ if (request === void 0) {
36
+ request = {};
37
+ }
38
+ return enrichForPagination('vpcs', _this.pageOfListVPCs, request);
39
+ };
40
+ /**
41
+ * Create a VPC. Create a new VPC in the specified region.
42
+ *
43
+ * @param request - The request {@link CreateVPCRequest}
44
+ * @returns A Promise of VPC
45
+ */
46
+ this.createVPC = function (request) {
47
+ if (request === void 0) {
48
+ request = {};
49
+ }
50
+ return _this.client.fetch({
51
+ body: JSON.stringify(marshalCreateVPCRequest(request, _this.client.settings)),
52
+ headers: jsonContentHeaders,
53
+ method: 'POST',
54
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/vpcs`
55
+ }, unmarshalVPC);
56
+ };
57
+ /**
58
+ * Get a VPC. Retrieve details of an existing VPC, specified by its VPC ID.
59
+ *
60
+ * @param request - The request {@link GetVPCRequest}
61
+ * @returns A Promise of VPC
62
+ */
63
+ this.getVPC = request => this.client.fetch({
64
+ method: 'GET',
65
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/vpcs/${validatePathParam('vpcId', request.vpcId)}`
66
+ }, unmarshalVPC);
67
+ /**
68
+ * Update VPC. Update parameters including name and tags of the specified VPC.
69
+ *
70
+ * @param request - The request {@link UpdateVPCRequest}
71
+ * @returns A Promise of VPC
72
+ */
73
+ this.updateVPC = request => this.client.fetch({
74
+ body: JSON.stringify(marshalUpdateVPCRequest(request, this.client.settings)),
75
+ headers: jsonContentHeaders,
76
+ method: 'PATCH',
77
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/vpcs/${validatePathParam('vpcId', request.vpcId)}`
78
+ }, unmarshalVPC);
79
+ /**
80
+ * Delete a VPC. Delete a VPC specified by its VPC ID.
81
+ *
82
+ * @param request - The request {@link DeleteVPCRequest}
83
+ */
84
+ this.deleteVPC = request => this.client.fetch({
85
+ method: 'DELETE',
86
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/vpcs/${validatePathParam('vpcId', request.vpcId)}`
87
+ });
88
+ this.pageOfListPrivateNetworks = function (request) {
89
+ if (request === void 0) {
90
+ request = {};
91
+ }
92
+ return _this.client.fetch({
93
+ method: 'GET',
94
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/private-networks`,
95
+ urlParams: urlParams(['name', request.name], ['order_by', request.orderBy ?? 'created_at_asc'], ['organization_id', request.organizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['private_network_ids', request.privateNetworkIds], ['project_id', request.projectId], ['tags', request.tags], ['vpc_id', request.vpcId])
96
+ }, unmarshalListPrivateNetworksResponse);
97
+ };
98
+ /**
99
+ * List Private Networks. List existing Private Networks in the specified
100
+ * region. By default, the Private Networks returned in the list are ordered
101
+ * by creation date in ascending order, though this can be modified via the
102
+ * order_by field.
103
+ *
104
+ * @param request - The request {@link ListPrivateNetworksRequest}
105
+ * @returns A Promise of ListPrivateNetworksResponse
106
+ */
107
+ this.listPrivateNetworks = function (request) {
108
+ if (request === void 0) {
109
+ request = {};
110
+ }
111
+ return enrichForPagination('privateNetworks', _this.pageOfListPrivateNetworks, request);
112
+ };
113
+ /**
114
+ * Create a Private Network. Create a new Private Network. Once created, you
115
+ * can attach Scaleway resources which are in the same region.
116
+ *
117
+ * @param request - The request {@link CreatePrivateNetworkRequest}
118
+ * @returns A Promise of PrivateNetwork
119
+ */
120
+ this.createPrivateNetwork = function (request) {
121
+ if (request === void 0) {
122
+ request = {};
123
+ }
124
+ return _this.client.fetch({
125
+ body: JSON.stringify(marshalCreatePrivateNetworkRequest(request, _this.client.settings)),
126
+ headers: jsonContentHeaders,
127
+ method: 'POST',
128
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/private-networks`
129
+ }, unmarshalPrivateNetwork);
130
+ };
131
+ /**
132
+ * Get a Private Network. Retrieve information about an existing Private
133
+ * Network, specified by its Private Network ID. Its full details are returned
134
+ * in the response object.
135
+ *
136
+ * @param request - The request {@link GetPrivateNetworkRequest}
137
+ * @returns A Promise of PrivateNetwork
138
+ */
139
+ this.getPrivateNetwork = request => this.client.fetch({
140
+ method: 'GET',
141
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`
142
+ }, unmarshalPrivateNetwork);
143
+ /**
144
+ * Update Private Network. Update parameters (such as name or tags) of an
145
+ * existing Private Network, specified by its Private Network ID.
146
+ *
147
+ * @param request - The request {@link UpdatePrivateNetworkRequest}
148
+ * @returns A Promise of PrivateNetwork
149
+ */
150
+ this.updatePrivateNetwork = request => this.client.fetch({
151
+ body: JSON.stringify(marshalUpdatePrivateNetworkRequest(request, this.client.settings)),
152
+ headers: jsonContentHeaders,
153
+ method: 'PATCH',
154
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`
155
+ }, unmarshalPrivateNetwork);
156
+ /**
157
+ * Delete a Private Network. Delete an existing Private Network. Note that you
158
+ * must first detach all resources from the network, in order to delete it.
159
+ *
160
+ * @param request - The request {@link DeletePrivateNetworkRequest}
161
+ */
162
+ this.deletePrivateNetwork = request => this.client.fetch({
163
+ method: 'DELETE',
164
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`
165
+ });
166
+ /**
167
+ * Migrate Private Networks from zoned to regional. Transform multiple
168
+ * existing zoned Private Networks (scoped to a single Availability Zone) into
169
+ * regional Private Networks, scoped to an entire region. You can transform
170
+ * one or many Private Networks (specified by their Private Network IDs)
171
+ * within a single Scaleway Organization or Project, with the same call.
172
+ *
173
+ * @param request - The request {@link MigrateZonalPrivateNetworksRequest}
174
+ */
175
+ this.migrateZonalPrivateNetworks = function (request) {
176
+ if (request === void 0) {
177
+ request = {};
178
+ }
179
+ return _this.client.fetch({
180
+ body: JSON.stringify(marshalMigrateZonalPrivateNetworksRequest(request, _this.client.settings)),
181
+ headers: jsonContentHeaders,
182
+ method: 'POST',
183
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/private-networks/migrate-zonal`
184
+ });
185
+ };
186
+ /**
187
+ * Set the subnets of a Private Network. Set subnets for an existing Private
188
+ * Network. Note that the method is PUT and not PATCH. Any existing subnets
189
+ * will be removed in favor of the new specified set of subnets.
190
+ *
191
+ * @param request - The request {@link SetSubnetsRequest}
192
+ * @returns A Promise of SetSubnetsResponse
193
+ */
194
+ this.setSubnets = request => this.client.fetch({
195
+ body: JSON.stringify(marshalSetSubnetsRequest(request, this.client.settings)),
196
+ headers: jsonContentHeaders,
197
+ method: 'PUT',
198
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}/subnets`
199
+ }, unmarshalSetSubnetsResponse);
200
+ /**
201
+ * Add subnets to a Private Network. Add new subnets to an existing Private
202
+ * Network.
203
+ *
204
+ * @param request - The request {@link AddSubnetsRequest}
205
+ * @returns A Promise of AddSubnetsResponse
206
+ */
207
+ this.addSubnets = request => this.client.fetch({
208
+ body: JSON.stringify(marshalAddSubnetsRequest(request, this.client.settings)),
209
+ headers: jsonContentHeaders,
210
+ method: 'POST',
211
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}/subnets`
212
+ }, unmarshalAddSubnetsResponse);
213
+ /**
214
+ * Delete subnets from a Private Network. Delete the specified subnets from a
215
+ * Private Network.
216
+ *
217
+ * @param request - The request {@link DeleteSubnetsRequest}
218
+ * @returns A Promise of DeleteSubnetsResponse
219
+ */
220
+ this.deleteSubnets = request => this.client.fetch({
221
+ body: JSON.stringify(marshalDeleteSubnetsRequest(request, this.client.settings)),
222
+ headers: jsonContentHeaders,
223
+ method: 'DELETE',
224
+ path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}/subnets`
225
+ }, unmarshalDeleteSubnetsResponse);
226
+ }
227
+ }
228
+ /** Lists the available regions of the API. */
229
+ API.LOCALITIES = ['fr-par', 'nl-ams', 'pl-waw'];
230
+
231
+ export { API };
@@ -0,0 +1,4 @@
1
+ export { API } from './api.gen.js';
2
+
3
+ // This file was automatically generated. DO NOT EDIT.
4
+ // If you have any remark or suggestion do not hesitate to open an issue.
@@ -0,0 +1,136 @@
1
+ import randomName from '../../../node_modules/.pnpm/@scaleway_random-name@4.0.1/node_modules/@scaleway/random-name/dist/index.js';
2
+ import { isJSONObject } from '../../../helpers/json.js';
3
+ import { unmarshalDate, unmarshalArrayOfObject, resolveOneOf } from '../../../helpers/marshalling.js';
4
+
5
+ // This file was automatically generated. DO NOT EDIT.
6
+ // If you have any remark or suggestion do not hesitate to open an issue.
7
+ const unmarshalSubnet = data => {
8
+ if (!isJSONObject(data)) {
9
+ throw new TypeError(`Unmarshalling the type 'Subnet' failed as data isn't a dictionary.`);
10
+ }
11
+ return {
12
+ createdAt: unmarshalDate(data.created_at),
13
+ id: data.id,
14
+ subnet: data.subnet,
15
+ updatedAt: unmarshalDate(data.updated_at)
16
+ };
17
+ };
18
+ const unmarshalPrivateNetwork = data => {
19
+ if (!isJSONObject(data)) {
20
+ throw new TypeError(`Unmarshalling the type 'PrivateNetwork' failed as data isn't a dictionary.`);
21
+ }
22
+ return {
23
+ createdAt: unmarshalDate(data.created_at),
24
+ id: data.id,
25
+ name: data.name,
26
+ organizationId: data.organization_id,
27
+ projectId: data.project_id,
28
+ region: data.region,
29
+ subnets: unmarshalArrayOfObject(data.subnets, unmarshalSubnet),
30
+ tags: data.tags,
31
+ updatedAt: unmarshalDate(data.updated_at),
32
+ vpcId: data.vpc_id
33
+ };
34
+ };
35
+ const unmarshalVPC = data => {
36
+ if (!isJSONObject(data)) {
37
+ throw new TypeError(`Unmarshalling the type 'VPC' failed as data isn't a dictionary.`);
38
+ }
39
+ return {
40
+ createdAt: unmarshalDate(data.created_at),
41
+ id: data.id,
42
+ isDefault: data.is_default,
43
+ name: data.name,
44
+ organizationId: data.organization_id,
45
+ privateNetworkCount: data.private_network_count,
46
+ projectId: data.project_id,
47
+ region: data.region,
48
+ tags: data.tags,
49
+ updatedAt: unmarshalDate(data.updated_at)
50
+ };
51
+ };
52
+ const unmarshalAddSubnetsResponse = data => {
53
+ if (!isJSONObject(data)) {
54
+ throw new TypeError(`Unmarshalling the type 'AddSubnetsResponse' failed as data isn't a dictionary.`);
55
+ }
56
+ return {
57
+ subnets: data.subnets
58
+ };
59
+ };
60
+ const unmarshalDeleteSubnetsResponse = data => {
61
+ if (!isJSONObject(data)) {
62
+ throw new TypeError(`Unmarshalling the type 'DeleteSubnetsResponse' failed as data isn't a dictionary.`);
63
+ }
64
+ return {
65
+ subnets: data.subnets
66
+ };
67
+ };
68
+ const unmarshalListPrivateNetworksResponse = data => {
69
+ if (!isJSONObject(data)) {
70
+ throw new TypeError(`Unmarshalling the type 'ListPrivateNetworksResponse' failed as data isn't a dictionary.`);
71
+ }
72
+ return {
73
+ privateNetworks: unmarshalArrayOfObject(data.private_networks, unmarshalPrivateNetwork),
74
+ totalCount: data.total_count
75
+ };
76
+ };
77
+ const unmarshalListVPCsResponse = data => {
78
+ if (!isJSONObject(data)) {
79
+ throw new TypeError(`Unmarshalling the type 'ListVPCsResponse' failed as data isn't a dictionary.`);
80
+ }
81
+ return {
82
+ totalCount: data.total_count,
83
+ vpcs: unmarshalArrayOfObject(data.vpcs, unmarshalVPC)
84
+ };
85
+ };
86
+ const unmarshalSetSubnetsResponse = data => {
87
+ if (!isJSONObject(data)) {
88
+ throw new TypeError(`Unmarshalling the type 'SetSubnetsResponse' failed as data isn't a dictionary.`);
89
+ }
90
+ return {
91
+ subnets: data.subnets
92
+ };
93
+ };
94
+ const marshalAddSubnetsRequest = (request, defaults) => ({
95
+ subnets: request.subnets
96
+ });
97
+ const marshalCreatePrivateNetworkRequest = (request, defaults) => ({
98
+ name: request.name || randomName('pn'),
99
+ project_id: request.projectId ?? defaults.defaultProjectId,
100
+ subnets: request.subnets,
101
+ tags: request.tags,
102
+ vpc_id: request.vpcId
103
+ });
104
+ const marshalCreateVPCRequest = (request, defaults) => ({
105
+ name: request.name || randomName('vpc'),
106
+ project_id: request.projectId ?? defaults.defaultProjectId,
107
+ tags: request.tags
108
+ });
109
+ const marshalDeleteSubnetsRequest = (request, defaults) => ({
110
+ subnets: request.subnets
111
+ });
112
+ const marshalMigrateZonalPrivateNetworksRequest = (request, defaults) => ({
113
+ private_network_ids: request.privateNetworkIds,
114
+ ...resolveOneOf([{
115
+ default: defaults.defaultProjectId,
116
+ param: 'project_id',
117
+ value: request.projectId
118
+ }, {
119
+ default: defaults.defaultOrganizationId,
120
+ param: 'organization_id',
121
+ value: request.organizationId
122
+ }])
123
+ });
124
+ const marshalSetSubnetsRequest = (request, defaults) => ({
125
+ subnets: request.subnets
126
+ });
127
+ const marshalUpdatePrivateNetworkRequest = (request, defaults) => ({
128
+ name: request.name,
129
+ tags: request.tags
130
+ });
131
+ const marshalUpdateVPCRequest = (request, defaults) => ({
132
+ name: request.name,
133
+ tags: request.tags
134
+ });
135
+
136
+ export { marshalAddSubnetsRequest, marshalCreatePrivateNetworkRequest, marshalCreateVPCRequest, marshalDeleteSubnetsRequest, marshalMigrateZonalPrivateNetworksRequest, marshalSetSubnetsRequest, marshalUpdatePrivateNetworkRequest, marshalUpdateVPCRequest, unmarshalAddSubnetsResponse, unmarshalDeleteSubnetsResponse, unmarshalListPrivateNetworksResponse, unmarshalListVPCsResponse, unmarshalPrivateNetwork, unmarshalSetSubnetsResponse, unmarshalVPC };
@@ -588,8 +588,8 @@ class API extends API$1 {
588
588
  path: `/vpc-gw/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam('gatewayId', request.gatewayId)}/refresh-ssh-keys`
589
589
  }, unmarshalGateway);
590
590
  }
591
- /** Lists the available zones of the API. */
592
591
  }
592
+ /** Lists the available zones of the API. */
593
593
  API.LOCALITIES = ['fr-par-1', 'fr-par-2', 'nl-ams-1', 'nl-ams-2', 'pl-waw-1', 'pl-waw-2'];
594
594
 
595
595
  export { API };
@@ -141,8 +141,8 @@ class API extends API$1 {
141
141
  urlParams: urlParams(['hosting_id', request.hostingId], ['only_options', request.onlyOptions], ['order_by', request.orderBy ?? 'price_asc'], ['without_options', request.withoutOptions])
142
142
  }, unmarshalListOffersResponse);
143
143
  }
144
- /** Lists the available regions of the API. */
145
144
  }
145
+ /** Lists the available regions of the API. */
146
146
  API.LOCALITIES = ['fr-par'];
147
147
 
148
148
  export { API };