@scaleway/sdk-vpcgw 2.2.1 → 2.3.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.
@@ -1,495 +1,344 @@
1
- import { API as API$1, toApiLocality, urlParams, validatePathParam, enrichForPagination, waitForResource } from "@scaleway/sdk-client";
2
- import { GATEWAY_TRANSIENT_STATUSES, GATEWAY_NETWORK_TRANSIENT_STATUSES } from "./content.gen.js";
3
- import { unmarshalListGatewaysResponse, unmarshalGateway, marshalCreateGatewayRequest, marshalUpdateGatewayRequest, marshalUpgradeGatewayRequest, unmarshalListGatewayNetworksResponse, unmarshalGatewayNetwork, marshalCreateGatewayNetworkRequest, marshalUpdateGatewayNetworkRequest, unmarshalListPatRulesResponse, unmarshalPatRule, marshalCreatePatRuleRequest, marshalUpdatePatRuleRequest, marshalSetPatRulesRequest, unmarshalSetPatRulesResponse, unmarshalListGatewayTypesResponse, unmarshalListIPsResponse, unmarshalIP, marshalCreateIPRequest, marshalUpdateIPRequest, marshalAddBastionAllowedIPsRequest, unmarshalAddBastionAllowedIPsResponse, marshalSetBastionAllowedIPsRequest, unmarshalSetBastionAllowedIPsResponse } from "./marshalling.gen.js";
4
- const jsonContentHeaders = {
5
- "Content-Type": "application/json; charset=utf-8"
6
- };
7
- class API extends API$1 {
8
- /**
9
- * Locality of this API.
10
- * type {'zone','region','global','unspecified'}
11
- */
12
- static LOCALITY = toApiLocality({
13
- zones: [
14
- "fr-par-1",
15
- "fr-par-2",
16
- "nl-ams-1",
17
- "nl-ams-2",
18
- "nl-ams-3",
19
- "pl-waw-1",
20
- "pl-waw-2",
21
- "pl-waw-3"
22
- ]
23
- });
24
- pageOfListGateways = (request = {}) => this.client.fetch(
25
- {
26
- method: "GET",
27
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways`,
28
- urlParams: urlParams(
29
- ["include_legacy", request.includeLegacy],
30
- ["name", request.name],
31
- ["order_by", request.orderBy],
32
- ["organization_id", request.organizationId],
33
- ["page", request.page],
34
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
35
- ["private_network_ids", request.privateNetworkIds],
36
- ["project_id", request.projectId],
37
- ["status", request.status],
38
- ["tags", request.tags],
39
- ["types", request.types]
40
- )
41
- },
42
- unmarshalListGatewaysResponse
43
- );
44
- /**
45
- * List Public Gateways. List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date.
46
- *
47
- * @param request - The request {@link ListGatewaysRequest}
48
- * @returns A Promise of ListGatewaysResponse
49
- */
50
- listGateways = (request = {}) => enrichForPagination("gateways", this.pageOfListGateways, request);
51
- /**
52
- * Get a Public Gateway. Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more.
53
- *
54
- * @param request - The request {@link GetGatewayRequest}
55
- * @returns A Promise of Gateway
56
- */
57
- getGateway = (request) => this.client.fetch(
58
- {
59
- method: "GET",
60
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}`
61
- },
62
- unmarshalGateway
63
- );
64
- /**
65
- * Waits for {@link Gateway} to be in a final state.
66
- *
67
- * @param request - The request {@link GetGatewayRequest}
68
- * @param options - The waiting options
69
- * @returns A Promise of Gateway
70
- */
71
- waitForGateway = (request, options) => waitForResource(
72
- options?.stop ?? ((res) => Promise.resolve(!GATEWAY_TRANSIENT_STATUSES.includes(res.status))),
73
- this.getGateway,
74
- request,
75
- options
76
- );
77
- /**
78
- * Create a Public Gateway. Create a new Public Gateway in the specified Scaleway Project, defining its **name**, **type** and other configuration details such as whether to enable SSH bastion.
79
- *
80
- * @param request - The request {@link CreateGatewayRequest}
81
- * @returns A Promise of Gateway
82
- */
83
- createGateway = (request) => this.client.fetch(
84
- {
85
- body: JSON.stringify(
86
- marshalCreateGatewayRequest(request, this.client.settings)
87
- ),
88
- headers: jsonContentHeaders,
89
- method: "POST",
90
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways`
91
- },
92
- unmarshalGateway
93
- );
94
- /**
95
- * Update a Public Gateway. Update the parameters of an existing Public Gateway, for example, its **name**, **tags**, **SSH bastion configuration**, and **DNS servers**.
96
- *
97
- * @param request - The request {@link UpdateGatewayRequest}
98
- * @returns A Promise of Gateway
99
- */
100
- updateGateway = (request) => this.client.fetch(
101
- {
102
- body: JSON.stringify(
103
- marshalUpdateGatewayRequest(request, this.client.settings)
104
- ),
105
- headers: jsonContentHeaders,
106
- method: "PATCH",
107
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}`
108
- },
109
- unmarshalGateway
110
- );
111
- /**
112
- * Delete a Public Gateway. Delete an existing Public Gateway, specified by its gateway ID. This action is irreversible.
113
- *
114
- * @param request - The request {@link DeleteGatewayRequest}
115
- * @returns A Promise of Gateway
116
- */
117
- deleteGateway = (request) => this.client.fetch(
118
- {
119
- method: "DELETE",
120
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}`,
121
- urlParams: urlParams(
122
- ["delete_ip", request.deleteIp]
123
- )
124
- },
125
- unmarshalGateway
126
- );
127
- /**
128
- * Upgrade a Public Gateway to the latest version and/or to a different commercial offer type. Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update.
129
- *
130
- * @param request - The request {@link UpgradeGatewayRequest}
131
- * @returns A Promise of Gateway
132
- */
133
- upgradeGateway = (request) => this.client.fetch(
134
- {
135
- body: JSON.stringify(
136
- marshalUpgradeGatewayRequest(request, this.client.settings)
137
- ),
138
- headers: jsonContentHeaders,
139
- method: "POST",
140
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/upgrade`
141
- },
142
- unmarshalGateway
143
- );
144
- pageOfListGatewayNetworks = (request = {}) => this.client.fetch(
145
- {
146
- method: "GET",
147
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks`,
148
- urlParams: urlParams(
149
- ["gateway_ids", request.gatewayIds],
150
- ["masquerade_enabled", request.masqueradeEnabled],
151
- ["order_by", request.orderBy],
152
- ["page", request.page],
153
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
154
- ["private_network_ids", request.privateNetworkIds],
155
- ["status", request.status]
156
- )
157
- },
158
- unmarshalListGatewayNetworksResponse
159
- );
160
- /**
161
- * List Public Gateway connections to Private Networks. List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network.
162
- *
163
- * @param request - The request {@link ListGatewayNetworksRequest}
164
- * @returns A Promise of ListGatewayNetworksResponse
165
- */
166
- listGatewayNetworks = (request = {}) => enrichForPagination("gatewayNetworks", this.pageOfListGatewayNetworks, request);
167
- /**
168
- * Get a Public Gateway connection to a Private Network. Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings.
169
- *
170
- * @param request - The request {@link GetGatewayNetworkRequest}
171
- * @returns A Promise of GatewayNetwork
172
- */
173
- getGatewayNetwork = (request) => this.client.fetch(
174
- {
175
- method: "GET",
176
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks/${validatePathParam("gatewayNetworkId", request.gatewayNetworkId)}`
177
- },
178
- unmarshalGatewayNetwork
179
- );
180
- /**
181
- * Waits for {@link GatewayNetwork} to be in a final state.
182
- *
183
- * @param request - The request {@link GetGatewayNetworkRequest}
184
- * @param options - The waiting options
185
- * @returns A Promise of GatewayNetwork
186
- */
187
- waitForGatewayNetwork = (request, options) => waitForResource(
188
- options?.stop ?? ((res) => Promise.resolve(!GATEWAY_NETWORK_TRANSIENT_STATUSES.includes(res.status))),
189
- this.getGatewayNetwork,
190
- request,
191
- options
192
- );
193
- /**
194
- * Attach a Public Gateway to a Private Network. Attach a specific Public Gateway to a specific Private Network (create a GatewayNetwork). You can configure parameters for the connection including whether to enable masquerade (dynamic NAT), and more.
195
- *
196
- * @param request - The request {@link CreateGatewayNetworkRequest}
197
- * @returns A Promise of GatewayNetwork
198
- */
199
- createGatewayNetwork = (request) => this.client.fetch(
200
- {
201
- body: JSON.stringify(
202
- marshalCreateGatewayNetworkRequest(request, this.client.settings)
203
- ),
204
- headers: jsonContentHeaders,
205
- method: "POST",
206
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks`
207
- },
208
- unmarshalGatewayNetwork
209
- );
210
- /**
211
- * Update a Public Gateway's connection to a Private Network. Update the configuration parameters of a connection between a given Public Gateway and Private Network (the connection = a GatewayNetwork). Updatable parameters include whether to enable traffic masquerade (dynamic NAT).
212
- *
213
- * @param request - The request {@link UpdateGatewayNetworkRequest}
214
- * @returns A Promise of GatewayNetwork
215
- */
216
- updateGatewayNetwork = (request) => this.client.fetch(
217
- {
218
- body: JSON.stringify(
219
- marshalUpdateGatewayNetworkRequest(request, this.client.settings)
220
- ),
221
- headers: jsonContentHeaders,
222
- method: "PATCH",
223
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks/${validatePathParam("gatewayNetworkId", request.gatewayNetworkId)}`
224
- },
225
- unmarshalGatewayNetwork
226
- );
227
- /**
228
- * Detach a Public Gateway from a Private Network. Detach a given Public Gateway from a given Private Network, i.e. delete a GatewayNetwork specified by a gateway_network_id.
229
- *
230
- * @param request - The request {@link DeleteGatewayNetworkRequest}
231
- * @returns A Promise of GatewayNetwork
232
- */
233
- deleteGatewayNetwork = (request) => this.client.fetch(
234
- {
235
- method: "DELETE",
236
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks/${validatePathParam("gatewayNetworkId", request.gatewayNetworkId)}`
237
- },
238
- unmarshalGatewayNetwork
239
- );
240
- pageOfListPatRules = (request = {}) => this.client.fetch(
241
- {
242
- method: "GET",
243
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules`,
244
- urlParams: urlParams(
245
- ["gateway_ids", request.gatewayIds],
246
- ["order_by", request.orderBy],
247
- ["page", request.page],
248
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
249
- ["private_ips", request.privateIps],
250
- ["protocol", request.protocol]
251
- )
252
- },
253
- unmarshalListPatRulesResponse
254
- );
255
- /**
256
- * List PAT rules. List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol.
257
- *
258
- * @param request - The request {@link ListPatRulesRequest}
259
- * @returns A Promise of ListPatRulesResponse
260
- */
261
- listPatRules = (request = {}) => enrichForPagination("patRules", this.pageOfListPatRules, request);
262
- /**
263
- * Get a PAT rule. Get a PAT rule, specified by its PAT rule ID. The response object gives full details of the PAT rule, including the Public Gateway it belongs to and the configuration settings in terms of public / private ports, private IP and protocol.
264
- *
265
- * @param request - The request {@link GetPatRuleRequest}
266
- * @returns A Promise of PatRule
267
- */
268
- getPatRule = (request) => this.client.fetch(
269
- {
270
- method: "GET",
271
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules/${validatePathParam("patRuleId", request.patRuleId)}`
272
- },
273
- unmarshalPatRule
274
- );
275
- /**
276
- * Create a PAT rule. Create a new PAT rule on a specified Public Gateway, defining the protocol to use, public port to listen on, and private port / IP address to map to.
277
- *
278
- * @param request - The request {@link CreatePatRuleRequest}
279
- * @returns A Promise of PatRule
280
- */
281
- createPatRule = (request) => this.client.fetch(
282
- {
283
- body: JSON.stringify(
284
- marshalCreatePatRuleRequest(request, this.client.settings)
285
- ),
286
- headers: jsonContentHeaders,
287
- method: "POST",
288
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules`
289
- },
290
- unmarshalPatRule
291
- );
292
- /**
293
- * Update a PAT rule. Update a PAT rule, specified by its PAT rule ID. Configuration settings including private/public port, private IP address and protocol can all be updated.
294
- *
295
- * @param request - The request {@link UpdatePatRuleRequest}
296
- * @returns A Promise of PatRule
297
- */
298
- updatePatRule = (request) => this.client.fetch(
299
- {
300
- body: JSON.stringify(
301
- marshalUpdatePatRuleRequest(request, this.client.settings)
302
- ),
303
- headers: jsonContentHeaders,
304
- method: "PATCH",
305
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules/${validatePathParam("patRuleId", request.patRuleId)}`
306
- },
307
- unmarshalPatRule
308
- );
309
- /**
310
- * Set all PAT rules. Set a definitive list of PAT rules attached to a Public Gateway. Each rule is identified by its public port and protocol. This will sync the current PAT rule list on the gateway with the new list, creating, updating or deleting PAT rules accordingly.
311
- *
312
- * @param request - The request {@link SetPatRulesRequest}
313
- * @returns A Promise of SetPatRulesResponse
314
- */
315
- setPatRules = (request) => this.client.fetch(
316
- {
317
- body: JSON.stringify(
318
- marshalSetPatRulesRequest(request, this.client.settings)
319
- ),
320
- headers: jsonContentHeaders,
321
- method: "PUT",
322
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules`
323
- },
324
- unmarshalSetPatRulesResponse
325
- );
326
- /**
327
- * Delete a PAT rule. Delete a PAT rule, identified by its PAT rule ID. This action is irreversible.
328
- *
329
- * @param request - The request {@link DeletePatRuleRequest}
330
- */
331
- deletePatRule = (request) => this.client.fetch(
332
- {
333
- method: "DELETE",
334
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules/${validatePathParam("patRuleId", request.patRuleId)}`
335
- }
336
- );
337
- /**
338
- * List Public Gateway types. List the different Public Gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available gateway type.
339
- *
340
- * @param request - The request {@link ListGatewayTypesRequest}
341
- * @returns A Promise of ListGatewayTypesResponse
342
- */
343
- listGatewayTypes = (request = {}) => this.client.fetch(
344
- {
345
- method: "GET",
346
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-types`
347
- },
348
- unmarshalListGatewayTypesResponse
349
- );
350
- pageOfListIPs = (request = {}) => this.client.fetch(
351
- {
352
- method: "GET",
353
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips`,
354
- urlParams: urlParams(
355
- ["is_free", request.isFree],
356
- ["order_by", request.orderBy],
357
- ["organization_id", request.organizationId],
358
- ["page", request.page],
359
- ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
360
- ["project_id", request.projectId],
361
- ["reverse", request.reverse],
362
- ["tags", request.tags]
363
- )
364
- },
365
- unmarshalListIPsResponse
366
- );
367
- /**
368
- * List IPs. List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response.
369
- *
370
- * @param request - The request {@link ListIPsRequest}
371
- * @returns A Promise of ListIPsResponse
372
- */
373
- listIPs = (request = {}) => enrichForPagination("ips", this.pageOfListIPs, request);
374
- /**
375
- * Get an IP. Get details of a Public Gateway flexible IP address, identified by its IP ID. The response object contains information including which (if any) Public Gateway using this IP address, the reverse and various other metadata.
376
- *
377
- * @param request - The request {@link GetIPRequest}
378
- * @returns A Promise of IP
379
- */
380
- getIP = (request) => this.client.fetch(
381
- {
382
- method: "GET",
383
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips/${validatePathParam("ipId", request.ipId)}`
384
- },
385
- unmarshalIP
386
- );
387
- /**
388
- * Reserve an IP. Create (reserve) a new flexible IP address that can be used for a Public Gateway in a specified Scaleway Project.
389
- *
390
- * @param request - The request {@link CreateIPRequest}
391
- * @returns A Promise of IP
392
- */
393
- createIP = (request = {}) => this.client.fetch(
394
- {
395
- body: JSON.stringify(
396
- marshalCreateIPRequest(request, this.client.settings)
397
- ),
398
- headers: jsonContentHeaders,
399
- method: "POST",
400
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips`
401
- },
402
- unmarshalIP
403
- );
404
- /**
405
- * Update an IP. Update details of an existing flexible IP address, including its tags, reverse and the Public Gateway it is assigned to.
406
- *
407
- * @param request - The request {@link UpdateIPRequest}
408
- * @returns A Promise of IP
409
- */
410
- updateIP = (request) => this.client.fetch(
411
- {
412
- body: JSON.stringify(
413
- marshalUpdateIPRequest(request, this.client.settings)
414
- ),
415
- headers: jsonContentHeaders,
416
- method: "PATCH",
417
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips/${validatePathParam("ipId", request.ipId)}`
418
- },
419
- unmarshalIP
420
- );
421
- /**
422
- * Delete an IP. Delete a flexible IP address from your account. This action is irreversible.
423
- *
424
- * @param request - The request {@link DeleteIPRequest}
425
- */
426
- deleteIP = (request) => this.client.fetch(
427
- {
428
- method: "DELETE",
429
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips/${validatePathParam("ipId", request.ipId)}`
430
- }
431
- );
432
- /**
433
- * Refresh a Public Gateway's SSH keys. Refresh the SSH keys of a given Public Gateway, specified by its gateway ID. This adds any new SSH keys in the gateway's Scaleway Project to the gateway itself.
434
- *
435
- * @param request - The request {@link RefreshSSHKeysRequest}
436
- * @returns A Promise of Gateway
437
- */
438
- refreshSSHKeys = (request) => this.client.fetch(
439
- {
440
- body: "{}",
441
- headers: jsonContentHeaders,
442
- method: "POST",
443
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/refresh-ssh-keys`
444
- },
445
- unmarshalGateway
446
- );
447
- /**
448
- * Add allowed IP range to SSH bastion. Add an IP range (in CIDR notation) to be allowed to connect to the SSH bastion.
449
- *
450
- * @param request - The request {@link AddBastionAllowedIPsRequest}
451
- * @returns A Promise of AddBastionAllowedIPsResponse
452
- */
453
- addBastionAllowedIPs = (request) => this.client.fetch(
454
- {
455
- body: JSON.stringify(
456
- marshalAddBastionAllowedIPsRequest(request, this.client.settings)
457
- ),
458
- headers: jsonContentHeaders,
459
- method: "POST",
460
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/bastion-allowed-ips`
461
- },
462
- unmarshalAddBastionAllowedIPsResponse
463
- );
464
- /**
465
- * Set all IP ranges allowed for SSH bastion. Set a definitive list of IP ranges (in CIDR notation) allowed to connect to the SSH bastion.
466
- *
467
- * @param request - The request {@link SetBastionAllowedIPsRequest}
468
- * @returns A Promise of SetBastionAllowedIPsResponse
469
- */
470
- setBastionAllowedIPs = (request) => this.client.fetch(
471
- {
472
- body: JSON.stringify(
473
- marshalSetBastionAllowedIPsRequest(request, this.client.settings)
474
- ),
475
- headers: jsonContentHeaders,
476
- method: "PUT",
477
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/bastion-allowed-ips`
478
- },
479
- unmarshalSetBastionAllowedIPsResponse
480
- );
481
- /**
482
- * Delete allowed IP range from SSH bastion. Delete an IP range (defined in CIDR notation) from SSH bastion, so that it is no longer allowed to connect.
483
- *
484
- * @param request - The request {@link DeleteBastionAllowedIPsRequest}
485
- */
486
- deleteBastionAllowedIPs = (request) => this.client.fetch(
487
- {
488
- method: "DELETE",
489
- path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/bastion-allowed-ips/${validatePathParam("ipRange", request.ipRange)}`
490
- }
491
- );
492
- }
493
- export {
494
- API
1
+ import { GATEWAY_NETWORK_TRANSIENT_STATUSES, GATEWAY_TRANSIENT_STATUSES } from "./content.gen.js";
2
+ import { marshalAddBastionAllowedIPsRequest, marshalCreateGatewayNetworkRequest, marshalCreateGatewayRequest, marshalCreateIPRequest, marshalCreatePatRuleRequest, marshalSetBastionAllowedIPsRequest, marshalSetPatRulesRequest, marshalUpdateGatewayNetworkRequest, marshalUpdateGatewayRequest, marshalUpdateIPRequest, marshalUpdatePatRuleRequest, marshalUpgradeGatewayRequest, unmarshalAddBastionAllowedIPsResponse, unmarshalGateway, unmarshalGatewayNetwork, unmarshalIP, unmarshalListGatewayNetworksResponse, unmarshalListGatewayTypesResponse, unmarshalListGatewaysResponse, unmarshalListIPsResponse, unmarshalListPatRulesResponse, unmarshalPatRule, unmarshalSetBastionAllowedIPsResponse, unmarshalSetPatRulesResponse } from "./marshalling.gen.js";
3
+ import { API, enrichForPagination, toApiLocality, urlParams, validatePathParam, waitForResource } from "@scaleway/sdk-client";
4
+ var jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
5
+ /**
6
+ * Public Gateways API.
7
+
8
+ This API allows you to manage your Public Gateways.
9
+ */
10
+ var API$1 = class extends API {
11
+ /**
12
+ * Locality of this API.
13
+ * type ∈ {'zone','region','global','unspecified'}
14
+ */
15
+ static LOCALITY = toApiLocality({ zones: [
16
+ "fr-par-1",
17
+ "fr-par-2",
18
+ "nl-ams-1",
19
+ "nl-ams-2",
20
+ "nl-ams-3",
21
+ "pl-waw-1",
22
+ "pl-waw-2",
23
+ "pl-waw-3"
24
+ ] });
25
+ pageOfListGateways = (request = {}) => this.client.fetch({
26
+ method: "GET",
27
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways`,
28
+ urlParams: urlParams(["include_legacy", request.includeLegacy], ["name", request.name], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["private_network_ids", request.privateNetworkIds], ["project_id", request.projectId], ["status", request.status], ["tags", request.tags], ["types", request.types])
29
+ }, unmarshalListGatewaysResponse);
30
+ /**
31
+ * List Public Gateways. List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date.
32
+ *
33
+ * @param request - The request {@link ListGatewaysRequest}
34
+ * @returns A Promise of ListGatewaysResponse
35
+ */
36
+ listGateways = (request = {}) => enrichForPagination("gateways", this.pageOfListGateways, request);
37
+ /**
38
+ * Get a Public Gateway. Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more.
39
+ *
40
+ * @param request - The request {@link GetGatewayRequest}
41
+ * @returns A Promise of Gateway
42
+ */
43
+ getGateway = (request) => this.client.fetch({
44
+ method: "GET",
45
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}`
46
+ }, unmarshalGateway);
47
+ /**
48
+ * Waits for {@link Gateway} to be in a final state.
49
+ *
50
+ * @param request - The request {@link GetGatewayRequest}
51
+ * @param options - The waiting options
52
+ * @returns A Promise of Gateway
53
+ */
54
+ waitForGateway = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!GATEWAY_TRANSIENT_STATUSES.includes(res.status))), this.getGateway, request, options);
55
+ /**
56
+ * Create a Public Gateway. Create a new Public Gateway in the specified Scaleway Project, defining its **name**, **type** and other configuration details such as whether to enable SSH bastion.
57
+ *
58
+ * @param request - The request {@link CreateGatewayRequest}
59
+ * @returns A Promise of Gateway
60
+ */
61
+ createGateway = (request) => this.client.fetch({
62
+ body: JSON.stringify(marshalCreateGatewayRequest(request, this.client.settings)),
63
+ headers: jsonContentHeaders,
64
+ method: "POST",
65
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways`
66
+ }, unmarshalGateway);
67
+ /**
68
+ * Update a Public Gateway. Update the parameters of an existing Public Gateway, for example, its **name**, **tags**, **SSH bastion configuration**, and **DNS servers**.
69
+ *
70
+ * @param request - The request {@link UpdateGatewayRequest}
71
+ * @returns A Promise of Gateway
72
+ */
73
+ updateGateway = (request) => this.client.fetch({
74
+ body: JSON.stringify(marshalUpdateGatewayRequest(request, this.client.settings)),
75
+ headers: jsonContentHeaders,
76
+ method: "PATCH",
77
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}`
78
+ }, unmarshalGateway);
79
+ /**
80
+ * Delete a Public Gateway. Delete an existing Public Gateway, specified by its gateway ID. This action is irreversible.
81
+ *
82
+ * @param request - The request {@link DeleteGatewayRequest}
83
+ * @returns A Promise of Gateway
84
+ */
85
+ deleteGateway = (request) => this.client.fetch({
86
+ method: "DELETE",
87
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}`,
88
+ urlParams: urlParams(["delete_ip", request.deleteIp])
89
+ }, unmarshalGateway);
90
+ /**
91
+ * Upgrade a Public Gateway to the latest version and/or to a different commercial offer type. Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update.
92
+ *
93
+ * @param request - The request {@link UpgradeGatewayRequest}
94
+ * @returns A Promise of Gateway
95
+ */
96
+ upgradeGateway = (request) => this.client.fetch({
97
+ body: JSON.stringify(marshalUpgradeGatewayRequest(request, this.client.settings)),
98
+ headers: jsonContentHeaders,
99
+ method: "POST",
100
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/upgrade`
101
+ }, unmarshalGateway);
102
+ pageOfListGatewayNetworks = (request = {}) => this.client.fetch({
103
+ method: "GET",
104
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks`,
105
+ urlParams: urlParams(["gateway_ids", request.gatewayIds], ["masquerade_enabled", request.masqueradeEnabled], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["private_network_ids", request.privateNetworkIds], ["status", request.status])
106
+ }, unmarshalListGatewayNetworksResponse);
107
+ /**
108
+ * List Public Gateway connections to Private Networks. List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network.
109
+ *
110
+ * @param request - The request {@link ListGatewayNetworksRequest}
111
+ * @returns A Promise of ListGatewayNetworksResponse
112
+ */
113
+ listGatewayNetworks = (request = {}) => enrichForPagination("gatewayNetworks", this.pageOfListGatewayNetworks, request);
114
+ /**
115
+ * Get a Public Gateway connection to a Private Network. Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings.
116
+ *
117
+ * @param request - The request {@link GetGatewayNetworkRequest}
118
+ * @returns A Promise of GatewayNetwork
119
+ */
120
+ getGatewayNetwork = (request) => this.client.fetch({
121
+ method: "GET",
122
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks/${validatePathParam("gatewayNetworkId", request.gatewayNetworkId)}`
123
+ }, unmarshalGatewayNetwork);
124
+ /**
125
+ * Waits for {@link GatewayNetwork} to be in a final state.
126
+ *
127
+ * @param request - The request {@link GetGatewayNetworkRequest}
128
+ * @param options - The waiting options
129
+ * @returns A Promise of GatewayNetwork
130
+ */
131
+ waitForGatewayNetwork = (request, options) => waitForResource(options?.stop ?? ((res) => Promise.resolve(!GATEWAY_NETWORK_TRANSIENT_STATUSES.includes(res.status))), this.getGatewayNetwork, request, options);
132
+ /**
133
+ * Attach a Public Gateway to a Private Network. Attach a specific Public Gateway to a specific Private Network (create a GatewayNetwork). You can configure parameters for the connection including whether to enable masquerade (dynamic NAT), and more.
134
+ *
135
+ * @param request - The request {@link CreateGatewayNetworkRequest}
136
+ * @returns A Promise of GatewayNetwork
137
+ */
138
+ createGatewayNetwork = (request) => this.client.fetch({
139
+ body: JSON.stringify(marshalCreateGatewayNetworkRequest(request, this.client.settings)),
140
+ headers: jsonContentHeaders,
141
+ method: "POST",
142
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks`
143
+ }, unmarshalGatewayNetwork);
144
+ /**
145
+ * Update a Public Gateway's connection to a Private Network. Update the configuration parameters of a connection between a given Public Gateway and Private Network (the connection = a GatewayNetwork). Updatable parameters include whether to enable traffic masquerade (dynamic NAT).
146
+ *
147
+ * @param request - The request {@link UpdateGatewayNetworkRequest}
148
+ * @returns A Promise of GatewayNetwork
149
+ */
150
+ updateGatewayNetwork = (request) => this.client.fetch({
151
+ body: JSON.stringify(marshalUpdateGatewayNetworkRequest(request, this.client.settings)),
152
+ headers: jsonContentHeaders,
153
+ method: "PATCH",
154
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks/${validatePathParam("gatewayNetworkId", request.gatewayNetworkId)}`
155
+ }, unmarshalGatewayNetwork);
156
+ /**
157
+ * Detach a Public Gateway from a Private Network. Detach a given Public Gateway from a given Private Network, i.e. delete a GatewayNetwork specified by a gateway_network_id.
158
+ *
159
+ * @param request - The request {@link DeleteGatewayNetworkRequest}
160
+ * @returns A Promise of GatewayNetwork
161
+ */
162
+ deleteGatewayNetwork = (request) => this.client.fetch({
163
+ method: "DELETE",
164
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-networks/${validatePathParam("gatewayNetworkId", request.gatewayNetworkId)}`
165
+ }, unmarshalGatewayNetwork);
166
+ pageOfListPatRules = (request = {}) => this.client.fetch({
167
+ method: "GET",
168
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules`,
169
+ urlParams: urlParams(["gateway_ids", request.gatewayIds], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["private_ips", request.privateIps], ["protocol", request.protocol])
170
+ }, unmarshalListPatRulesResponse);
171
+ /**
172
+ * List PAT rules. List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol.
173
+ *
174
+ * @param request - The request {@link ListPatRulesRequest}
175
+ * @returns A Promise of ListPatRulesResponse
176
+ */
177
+ listPatRules = (request = {}) => enrichForPagination("patRules", this.pageOfListPatRules, request);
178
+ /**
179
+ * Get a PAT rule. Get a PAT rule, specified by its PAT rule ID. The response object gives full details of the PAT rule, including the Public Gateway it belongs to and the configuration settings in terms of public / private ports, private IP and protocol.
180
+ *
181
+ * @param request - The request {@link GetPatRuleRequest}
182
+ * @returns A Promise of PatRule
183
+ */
184
+ getPatRule = (request) => this.client.fetch({
185
+ method: "GET",
186
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules/${validatePathParam("patRuleId", request.patRuleId)}`
187
+ }, unmarshalPatRule);
188
+ /**
189
+ * Create a PAT rule. Create a new PAT rule on a specified Public Gateway, defining the protocol to use, public port to listen on, and private port / IP address to map to.
190
+ *
191
+ * @param request - The request {@link CreatePatRuleRequest}
192
+ * @returns A Promise of PatRule
193
+ */
194
+ createPatRule = (request) => this.client.fetch({
195
+ body: JSON.stringify(marshalCreatePatRuleRequest(request, this.client.settings)),
196
+ headers: jsonContentHeaders,
197
+ method: "POST",
198
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules`
199
+ }, unmarshalPatRule);
200
+ /**
201
+ * Update a PAT rule. Update a PAT rule, specified by its PAT rule ID. Configuration settings including private/public port, private IP address and protocol can all be updated.
202
+ *
203
+ * @param request - The request {@link UpdatePatRuleRequest}
204
+ * @returns A Promise of PatRule
205
+ */
206
+ updatePatRule = (request) => this.client.fetch({
207
+ body: JSON.stringify(marshalUpdatePatRuleRequest(request, this.client.settings)),
208
+ headers: jsonContentHeaders,
209
+ method: "PATCH",
210
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules/${validatePathParam("patRuleId", request.patRuleId)}`
211
+ }, unmarshalPatRule);
212
+ /**
213
+ * Set all PAT rules. Set a definitive list of PAT rules attached to a Public Gateway. Each rule is identified by its public port and protocol. This will sync the current PAT rule list on the gateway with the new list, creating, updating or deleting PAT rules accordingly.
214
+ *
215
+ * @param request - The request {@link SetPatRulesRequest}
216
+ * @returns A Promise of SetPatRulesResponse
217
+ */
218
+ setPatRules = (request) => this.client.fetch({
219
+ body: JSON.stringify(marshalSetPatRulesRequest(request, this.client.settings)),
220
+ headers: jsonContentHeaders,
221
+ method: "PUT",
222
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules`
223
+ }, unmarshalSetPatRulesResponse);
224
+ /**
225
+ * Delete a PAT rule. Delete a PAT rule, identified by its PAT rule ID. This action is irreversible.
226
+ *
227
+ * @param request - The request {@link DeletePatRuleRequest}
228
+ */
229
+ deletePatRule = (request) => this.client.fetch({
230
+ method: "DELETE",
231
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/pat-rules/${validatePathParam("patRuleId", request.patRuleId)}`
232
+ });
233
+ /**
234
+ * List Public Gateway types. List the different Public Gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available gateway type.
235
+ *
236
+ * @param request - The request {@link ListGatewayTypesRequest}
237
+ * @returns A Promise of ListGatewayTypesResponse
238
+ */
239
+ listGatewayTypes = (request = {}) => this.client.fetch({
240
+ method: "GET",
241
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateway-types`
242
+ }, unmarshalListGatewayTypesResponse);
243
+ pageOfListIPs = (request = {}) => this.client.fetch({
244
+ method: "GET",
245
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips`,
246
+ urlParams: urlParams(["is_free", request.isFree], ["order_by", request.orderBy], ["organization_id", request.organizationId], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize], ["project_id", request.projectId], ["reverse", request.reverse], ["tags", request.tags])
247
+ }, unmarshalListIPsResponse);
248
+ /**
249
+ * List IPs. List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response.
250
+ *
251
+ * @param request - The request {@link ListIPsRequest}
252
+ * @returns A Promise of ListIPsResponse
253
+ */
254
+ listIPs = (request = {}) => enrichForPagination("ips", this.pageOfListIPs, request);
255
+ /**
256
+ * Get an IP. Get details of a Public Gateway flexible IP address, identified by its IP ID. The response object contains information including which (if any) Public Gateway using this IP address, the reverse and various other metadata.
257
+ *
258
+ * @param request - The request {@link GetIPRequest}
259
+ * @returns A Promise of IP
260
+ */
261
+ getIP = (request) => this.client.fetch({
262
+ method: "GET",
263
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips/${validatePathParam("ipId", request.ipId)}`
264
+ }, unmarshalIP);
265
+ /**
266
+ * Reserve an IP. Create (reserve) a new flexible IP address that can be used for a Public Gateway in a specified Scaleway Project.
267
+ *
268
+ * @param request - The request {@link CreateIPRequest}
269
+ * @returns A Promise of IP
270
+ */
271
+ createIP = (request = {}) => this.client.fetch({
272
+ body: JSON.stringify(marshalCreateIPRequest(request, this.client.settings)),
273
+ headers: jsonContentHeaders,
274
+ method: "POST",
275
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips`
276
+ }, unmarshalIP);
277
+ /**
278
+ * Update an IP. Update details of an existing flexible IP address, including its tags, reverse and the Public Gateway it is assigned to.
279
+ *
280
+ * @param request - The request {@link UpdateIPRequest}
281
+ * @returns A Promise of IP
282
+ */
283
+ updateIP = (request) => this.client.fetch({
284
+ body: JSON.stringify(marshalUpdateIPRequest(request, this.client.settings)),
285
+ headers: jsonContentHeaders,
286
+ method: "PATCH",
287
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips/${validatePathParam("ipId", request.ipId)}`
288
+ }, unmarshalIP);
289
+ /**
290
+ * Delete an IP. Delete a flexible IP address from your account. This action is irreversible.
291
+ *
292
+ * @param request - The request {@link DeleteIPRequest}
293
+ */
294
+ deleteIP = (request) => this.client.fetch({
295
+ method: "DELETE",
296
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/ips/${validatePathParam("ipId", request.ipId)}`
297
+ });
298
+ /**
299
+ * Refresh a Public Gateway's SSH keys. Refresh the SSH keys of a given Public Gateway, specified by its gateway ID. This adds any new SSH keys in the gateway's Scaleway Project to the gateway itself.
300
+ *
301
+ * @param request - The request {@link RefreshSSHKeysRequest}
302
+ * @returns A Promise of Gateway
303
+ */
304
+ refreshSSHKeys = (request) => this.client.fetch({
305
+ body: "{}",
306
+ headers: jsonContentHeaders,
307
+ method: "POST",
308
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/refresh-ssh-keys`
309
+ }, unmarshalGateway);
310
+ /**
311
+ * Add allowed IP range to SSH bastion. Add an IP range (in CIDR notation) to be allowed to connect to the SSH bastion.
312
+ *
313
+ * @param request - The request {@link AddBastionAllowedIPsRequest}
314
+ * @returns A Promise of AddBastionAllowedIPsResponse
315
+ */
316
+ addBastionAllowedIPs = (request) => this.client.fetch({
317
+ body: JSON.stringify(marshalAddBastionAllowedIPsRequest(request, this.client.settings)),
318
+ headers: jsonContentHeaders,
319
+ method: "POST",
320
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/bastion-allowed-ips`
321
+ }, unmarshalAddBastionAllowedIPsResponse);
322
+ /**
323
+ * Set all IP ranges allowed for SSH bastion. Set a definitive list of IP ranges (in CIDR notation) allowed to connect to the SSH bastion.
324
+ *
325
+ * @param request - The request {@link SetBastionAllowedIPsRequest}
326
+ * @returns A Promise of SetBastionAllowedIPsResponse
327
+ */
328
+ setBastionAllowedIPs = (request) => this.client.fetch({
329
+ body: JSON.stringify(marshalSetBastionAllowedIPsRequest(request, this.client.settings)),
330
+ headers: jsonContentHeaders,
331
+ method: "PUT",
332
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/bastion-allowed-ips`
333
+ }, unmarshalSetBastionAllowedIPsResponse);
334
+ /**
335
+ * Delete allowed IP range from SSH bastion. Delete an IP range (defined in CIDR notation) from SSH bastion, so that it is no longer allowed to connect.
336
+ *
337
+ * @param request - The request {@link DeleteBastionAllowedIPsRequest}
338
+ */
339
+ deleteBastionAllowedIPs = (request) => this.client.fetch({
340
+ method: "DELETE",
341
+ path: `/vpc-gw/v2/zones/${validatePathParam("zone", request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam("gatewayId", request.gatewayId)}/bastion-allowed-ips/${validatePathParam("ipRange", request.ipRange)}`
342
+ });
495
343
  };
344
+ export { API$1 as API };