@scaleway/sdk-s2s-vpn 1.1.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,368 @@
1
+ import { resolveOneOf, isJSONObject, unmarshalArrayOfObject, unmarshalDate } from "@scaleway/sdk-client";
2
+ const unmarshalBgpSession = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'BgpSession' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ peerPrivateIp: data.peer_private_ip,
10
+ privateIp: data.private_ip,
11
+ routingPolicyId: data.routing_policy_id
12
+ };
13
+ };
14
+ const unmarshalConnectionCipher = (data) => {
15
+ if (!isJSONObject(data)) {
16
+ throw new TypeError(
17
+ `Unmarshalling the type 'ConnectionCipher' failed as data isn't a dictionary.`
18
+ );
19
+ }
20
+ return {
21
+ dhGroup: data.dh_group ? data.dh_group : void 0,
22
+ encryption: data.encryption,
23
+ integrity: data.integrity ? data.integrity : void 0
24
+ };
25
+ };
26
+ const unmarshalConnection = (data) => {
27
+ if (!isJSONObject(data)) {
28
+ throw new TypeError(
29
+ `Unmarshalling the type 'Connection' failed as data isn't a dictionary.`
30
+ );
31
+ }
32
+ return {
33
+ bgpSessionIpv4: data.bgp_session_ipv4 ? unmarshalBgpSession(data.bgp_session_ipv4) : void 0,
34
+ bgpSessionIpv6: data.bgp_session_ipv6 ? unmarshalBgpSession(data.bgp_session_ipv6) : void 0,
35
+ bgpStatusIpv4: data.bgp_status_ipv4,
36
+ bgpStatusIpv6: data.bgp_status_ipv6,
37
+ createdAt: unmarshalDate(data.created_at),
38
+ customerGatewayId: data.customer_gateway_id,
39
+ espCiphers: unmarshalArrayOfObject(
40
+ data.esp_ciphers,
41
+ unmarshalConnectionCipher
42
+ ),
43
+ id: data.id,
44
+ ikev2Ciphers: unmarshalArrayOfObject(
45
+ data.ikev2_ciphers,
46
+ unmarshalConnectionCipher
47
+ ),
48
+ initiationPolicy: data.initiation_policy,
49
+ isIpv6: data.is_ipv6,
50
+ name: data.name,
51
+ organizationId: data.organization_id,
52
+ projectId: data.project_id,
53
+ region: data.region,
54
+ routePropagationEnabled: data.route_propagation_enabled,
55
+ status: data.status,
56
+ tags: data.tags,
57
+ tunnelStatus: data.tunnel_status,
58
+ tunnelStatusIpv4: data.tunnel_status_ipv4 ? data.tunnel_status_ipv4 : void 0,
59
+ tunnelStatusIpv6: data.tunnel_status_ipv6 ? data.tunnel_status_ipv6 : void 0,
60
+ updatedAt: unmarshalDate(data.updated_at),
61
+ vpnGatewayId: data.vpn_gateway_id
62
+ };
63
+ };
64
+ const unmarshalCustomerGateway = (data) => {
65
+ if (!isJSONObject(data)) {
66
+ throw new TypeError(
67
+ `Unmarshalling the type 'CustomerGateway' failed as data isn't a dictionary.`
68
+ );
69
+ }
70
+ return {
71
+ asn: data.asn,
72
+ createdAt: unmarshalDate(data.created_at),
73
+ id: data.id,
74
+ name: data.name,
75
+ organizationId: data.organization_id,
76
+ projectId: data.project_id,
77
+ publicIpv4: data.public_ipv4,
78
+ publicIpv6: data.public_ipv6,
79
+ tags: data.tags,
80
+ updatedAt: unmarshalDate(data.updated_at)
81
+ };
82
+ };
83
+ const unmarshalRoutingPolicy = (data) => {
84
+ if (!isJSONObject(data)) {
85
+ throw new TypeError(
86
+ `Unmarshalling the type 'RoutingPolicy' failed as data isn't a dictionary.`
87
+ );
88
+ }
89
+ return {
90
+ createdAt: unmarshalDate(data.created_at),
91
+ id: data.id,
92
+ isIpv6: data.is_ipv6,
93
+ name: data.name,
94
+ organizationId: data.organization_id,
95
+ prefixFilterIn: data.prefix_filter_in,
96
+ prefixFilterOut: data.prefix_filter_out,
97
+ projectId: data.project_id,
98
+ region: data.region,
99
+ tags: data.tags,
100
+ updatedAt: unmarshalDate(data.updated_at)
101
+ };
102
+ };
103
+ const unmarshalVpnGatewayPrivateConfig = (data) => {
104
+ if (!isJSONObject(data)) {
105
+ throw new TypeError(
106
+ `Unmarshalling the type 'VpnGatewayPrivateConfig' failed as data isn't a dictionary.`
107
+ );
108
+ }
109
+ return {};
110
+ };
111
+ const unmarshalVpnGatewayPublicConfig = (data) => {
112
+ if (!isJSONObject(data)) {
113
+ throw new TypeError(
114
+ `Unmarshalling the type 'VpnGatewayPublicConfig' failed as data isn't a dictionary.`
115
+ );
116
+ }
117
+ return {
118
+ ipamIpv4Id: data.ipam_ipv4_id,
119
+ ipamIpv6Id: data.ipam_ipv6_id
120
+ };
121
+ };
122
+ const unmarshalVpnGateway = (data) => {
123
+ if (!isJSONObject(data)) {
124
+ throw new TypeError(
125
+ `Unmarshalling the type 'VpnGateway' failed as data isn't a dictionary.`
126
+ );
127
+ }
128
+ return {
129
+ asn: data.asn,
130
+ createdAt: unmarshalDate(data.created_at),
131
+ gatewayType: data.gateway_type,
132
+ id: data.id,
133
+ ipamPrivateIpv4Id: data.ipam_private_ipv4_id,
134
+ ipamPrivateIpv6Id: data.ipam_private_ipv6_id,
135
+ name: data.name,
136
+ organizationId: data.organization_id,
137
+ privateConfig: data.private_config ? unmarshalVpnGatewayPrivateConfig(data.private_config) : void 0,
138
+ privateNetworkId: data.private_network_id,
139
+ projectId: data.project_id,
140
+ publicConfig: data.public_config ? unmarshalVpnGatewayPublicConfig(data.public_config) : void 0,
141
+ region: data.region,
142
+ status: data.status,
143
+ tags: data.tags,
144
+ updatedAt: unmarshalDate(data.updated_at),
145
+ zone: data.zone
146
+ };
147
+ };
148
+ const unmarshalCreateConnectionResponse = (data) => {
149
+ if (!isJSONObject(data)) {
150
+ throw new TypeError(
151
+ `Unmarshalling the type 'CreateConnectionResponse' failed as data isn't a dictionary.`
152
+ );
153
+ }
154
+ return {
155
+ connection: data.connection ? unmarshalConnection(data.connection) : void 0,
156
+ preSharedKey: data.pre_shared_key
157
+ };
158
+ };
159
+ const unmarshalListConnectionsResponse = (data) => {
160
+ if (!isJSONObject(data)) {
161
+ throw new TypeError(
162
+ `Unmarshalling the type 'ListConnectionsResponse' failed as data isn't a dictionary.`
163
+ );
164
+ }
165
+ return {
166
+ connections: unmarshalArrayOfObject(data.connections, unmarshalConnection),
167
+ totalCount: data.total_count
168
+ };
169
+ };
170
+ const unmarshalListCustomerGatewaysResponse = (data) => {
171
+ if (!isJSONObject(data)) {
172
+ throw new TypeError(
173
+ `Unmarshalling the type 'ListCustomerGatewaysResponse' failed as data isn't a dictionary.`
174
+ );
175
+ }
176
+ return {
177
+ gateways: unmarshalArrayOfObject(data.gateways, unmarshalCustomerGateway),
178
+ totalCount: data.total_count
179
+ };
180
+ };
181
+ const unmarshalListRoutingPoliciesResponse = (data) => {
182
+ if (!isJSONObject(data)) {
183
+ throw new TypeError(
184
+ `Unmarshalling the type 'ListRoutingPoliciesResponse' failed as data isn't a dictionary.`
185
+ );
186
+ }
187
+ return {
188
+ routingPolicies: unmarshalArrayOfObject(
189
+ data.routing_policies,
190
+ unmarshalRoutingPolicy
191
+ ),
192
+ totalCount: data.total_count
193
+ };
194
+ };
195
+ const unmarshalGatewayType = (data) => {
196
+ if (!isJSONObject(data)) {
197
+ throw new TypeError(
198
+ `Unmarshalling the type 'GatewayType' failed as data isn't a dictionary.`
199
+ );
200
+ }
201
+ return {
202
+ allowedConnections: data.allowed_connections,
203
+ bandwidth: data.bandwidth,
204
+ name: data.name,
205
+ region: data.region
206
+ };
207
+ };
208
+ const unmarshalListVpnGatewayTypesResponse = (data) => {
209
+ if (!isJSONObject(data)) {
210
+ throw new TypeError(
211
+ `Unmarshalling the type 'ListVpnGatewayTypesResponse' failed as data isn't a dictionary.`
212
+ );
213
+ }
214
+ return {
215
+ gatewayTypes: unmarshalArrayOfObject(
216
+ data.gateway_types,
217
+ unmarshalGatewayType
218
+ ),
219
+ totalCount: data.total_count
220
+ };
221
+ };
222
+ const unmarshalListVpnGatewaysResponse = (data) => {
223
+ if (!isJSONObject(data)) {
224
+ throw new TypeError(
225
+ `Unmarshalling the type 'ListVpnGatewaysResponse' failed as data isn't a dictionary.`
226
+ );
227
+ }
228
+ return {
229
+ gateways: unmarshalArrayOfObject(data.gateways, unmarshalVpnGateway),
230
+ totalCount: data.total_count
231
+ };
232
+ };
233
+ const unmarshalRenewConnectionPskResponse = (data) => {
234
+ if (!isJSONObject(data)) {
235
+ throw new TypeError(
236
+ `Unmarshalling the type 'RenewConnectionPskResponse' failed as data isn't a dictionary.`
237
+ );
238
+ }
239
+ return {
240
+ connection: data.connection ? unmarshalConnection(data.connection) : void 0,
241
+ preSharedKey: data.pre_shared_key
242
+ };
243
+ };
244
+ const marshalConnectionCipher = (request, defaults) => ({
245
+ dh_group: request.dhGroup,
246
+ encryption: request.encryption,
247
+ integrity: request.integrity
248
+ });
249
+ const marshalCreateConnectionRequestBgpConfig = (request, defaults) => ({
250
+ peer_private_ip: request.peerPrivateIp,
251
+ private_ip: request.privateIp,
252
+ routing_policy_id: request.routingPolicyId
253
+ });
254
+ const marshalCreateConnectionRequest = (request, defaults) => ({
255
+ bgp_config_ipv4: request.bgpConfigIpv4 !== void 0 ? marshalCreateConnectionRequestBgpConfig(request.bgpConfigIpv4) : void 0,
256
+ bgp_config_ipv6: request.bgpConfigIpv6 !== void 0 ? marshalCreateConnectionRequestBgpConfig(request.bgpConfigIpv6) : void 0,
257
+ customer_gateway_id: request.customerGatewayId,
258
+ enable_route_propagation: request.enableRoutePropagation,
259
+ esp_ciphers: request.espCiphers.map(
260
+ (elt) => marshalConnectionCipher(elt)
261
+ ),
262
+ ikev2_ciphers: request.ikev2Ciphers.map(
263
+ (elt) => marshalConnectionCipher(elt)
264
+ ),
265
+ initiation_policy: request.initiationPolicy,
266
+ is_ipv6: request.isIpv6,
267
+ name: request.name,
268
+ project_id: request.projectId ?? defaults.defaultProjectId,
269
+ tags: request.tags,
270
+ vpn_gateway_id: request.vpnGatewayId
271
+ });
272
+ const marshalCreateCustomerGatewayRequest = (request, defaults) => ({
273
+ asn: request.asn,
274
+ ipv4_public: request.ipv4Public,
275
+ ipv6_public: request.ipv6Public,
276
+ name: request.name,
277
+ project_id: request.projectId ?? defaults.defaultProjectId,
278
+ tags: request.tags
279
+ });
280
+ const marshalCreateRoutingPolicyRequest = (request, defaults) => ({
281
+ is_ipv6: request.isIpv6,
282
+ name: request.name,
283
+ prefix_filter_in: request.prefixFilterIn,
284
+ prefix_filter_out: request.prefixFilterOut,
285
+ project_id: request.projectId ?? defaults.defaultProjectId,
286
+ tags: request.tags
287
+ });
288
+ const marshalCreateVpnGatewayRequestPublicConfig = (request, defaults) => ({
289
+ ipam_ipv4_id: request.ipamIpv4Id,
290
+ ipam_ipv6_id: request.ipamIpv6Id
291
+ });
292
+ const marshalCreateVpnGatewayRequest = (request, defaults) => ({
293
+ gateway_type: request.gatewayType,
294
+ ipam_private_ipv4_id: request.ipamPrivateIpv4Id,
295
+ ipam_private_ipv6_id: request.ipamPrivateIpv6Id,
296
+ name: request.name,
297
+ private_network_id: request.privateNetworkId,
298
+ project_id: request.projectId ?? defaults.defaultProjectId,
299
+ tags: request.tags,
300
+ zone: request.zone ?? defaults.defaultZone,
301
+ ...resolveOneOf([
302
+ {
303
+ param: "public_config",
304
+ value: request.publicConfig !== void 0 ? marshalCreateVpnGatewayRequestPublicConfig(
305
+ request.publicConfig
306
+ ) : void 0
307
+ }
308
+ ])
309
+ });
310
+ const marshalDetachRoutingPolicyRequest = (request, defaults) => ({
311
+ ...resolveOneOf([
312
+ { param: "routing_policy_v4", value: request.routingPolicyV4 },
313
+ { param: "routing_policy_v6", value: request.routingPolicyV6 }
314
+ ])
315
+ });
316
+ const marshalSetRoutingPolicyRequest = (request, defaults) => ({
317
+ ...resolveOneOf([
318
+ { param: "routing_policy_v4", value: request.routingPolicyV4 },
319
+ { param: "routing_policy_v6", value: request.routingPolicyV6 }
320
+ ])
321
+ });
322
+ const marshalUpdateConnectionRequest = (request, defaults) => ({
323
+ esp_ciphers: request.espCiphers !== void 0 ? request.espCiphers.map((elt) => marshalConnectionCipher(elt)) : void 0,
324
+ ikev2_ciphers: request.ikev2Ciphers !== void 0 ? request.ikev2Ciphers.map((elt) => marshalConnectionCipher(elt)) : void 0,
325
+ initiation_policy: request.initiationPolicy,
326
+ name: request.name,
327
+ tags: request.tags
328
+ });
329
+ const marshalUpdateCustomerGatewayRequest = (request, defaults) => ({
330
+ asn: request.asn,
331
+ ipv4_public: request.ipv4Public,
332
+ ipv6_public: request.ipv6Public,
333
+ name: request.name,
334
+ tags: request.tags
335
+ });
336
+ const marshalUpdateRoutingPolicyRequest = (request, defaults) => ({
337
+ name: request.name,
338
+ prefix_filter_in: request.prefixFilterIn,
339
+ prefix_filter_out: request.prefixFilterOut,
340
+ tags: request.tags
341
+ });
342
+ const marshalUpdateVpnGatewayRequest = (request, defaults) => ({
343
+ name: request.name,
344
+ tags: request.tags
345
+ });
346
+ export {
347
+ marshalCreateConnectionRequest,
348
+ marshalCreateCustomerGatewayRequest,
349
+ marshalCreateRoutingPolicyRequest,
350
+ marshalCreateVpnGatewayRequest,
351
+ marshalDetachRoutingPolicyRequest,
352
+ marshalSetRoutingPolicyRequest,
353
+ marshalUpdateConnectionRequest,
354
+ marshalUpdateCustomerGatewayRequest,
355
+ marshalUpdateRoutingPolicyRequest,
356
+ marshalUpdateVpnGatewayRequest,
357
+ unmarshalConnection,
358
+ unmarshalCreateConnectionResponse,
359
+ unmarshalCustomerGateway,
360
+ unmarshalListConnectionsResponse,
361
+ unmarshalListCustomerGatewaysResponse,
362
+ unmarshalListRoutingPoliciesResponse,
363
+ unmarshalListVpnGatewayTypesResponse,
364
+ unmarshalListVpnGatewaysResponse,
365
+ unmarshalRenewConnectionPskResponse,
366
+ unmarshalRoutingPolicy,
367
+ unmarshalVpnGateway
368
+ };