@scaleway/sdk-vpc 1.0.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.
- package/LICENSE +191 -0
- package/dist/index.gen.cjs +4 -0
- package/dist/index.gen.d.ts +5 -0
- package/dist/index.gen.js +4 -0
- package/dist/v2/api.gen.cjs +366 -0
- package/dist/v2/api.gen.d.ts +168 -0
- package/dist/v2/api.gen.js +366 -0
- package/dist/v2/index.gen.cjs +26 -0
- package/dist/v2/index.gen.d.ts +4 -0
- package/dist/v2/index.gen.js +26 -0
- package/dist/v2/marshalling.gen.cjs +253 -0
- package/dist/v2/marshalling.gen.d.ts +21 -0
- package/dist/v2/marshalling.gen.js +253 -0
- package/dist/v2/types.gen.d.ts +648 -0
- package/dist/v2/validation-rules.gen.cjs +26 -0
- package/dist/v2/validation-rules.gen.d.ts +22 -0
- package/dist/v2/validation-rules.gen.js +26 -0
- package/package.json +51 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const randomName = require("@scaleway/random-name");
|
|
4
|
+
const sdkClient = require("@scaleway/sdk-client");
|
|
5
|
+
const unmarshalSubnet = (data) => {
|
|
6
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
7
|
+
throw new TypeError(
|
|
8
|
+
`Unmarshalling the type 'Subnet' failed as data isn't a dictionary.`
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
createdAt: sdkClient.unmarshalDate(data.created_at),
|
|
13
|
+
id: data.id,
|
|
14
|
+
privateNetworkId: data.private_network_id,
|
|
15
|
+
projectId: data.project_id,
|
|
16
|
+
subnet: data.subnet,
|
|
17
|
+
updatedAt: sdkClient.unmarshalDate(data.updated_at),
|
|
18
|
+
vpcId: data.vpc_id
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const unmarshalPrivateNetwork = (data) => {
|
|
22
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
23
|
+
throw new TypeError(
|
|
24
|
+
`Unmarshalling the type 'PrivateNetwork' failed as data isn't a dictionary.`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
createdAt: sdkClient.unmarshalDate(data.created_at),
|
|
29
|
+
dhcpEnabled: data.dhcp_enabled,
|
|
30
|
+
id: data.id,
|
|
31
|
+
name: data.name,
|
|
32
|
+
organizationId: data.organization_id,
|
|
33
|
+
projectId: data.project_id,
|
|
34
|
+
region: data.region,
|
|
35
|
+
subnets: sdkClient.unmarshalArrayOfObject(data.subnets, unmarshalSubnet),
|
|
36
|
+
tags: data.tags,
|
|
37
|
+
updatedAt: sdkClient.unmarshalDate(data.updated_at),
|
|
38
|
+
vpcId: data.vpc_id
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const unmarshalRoute = (data) => {
|
|
42
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
43
|
+
throw new TypeError(
|
|
44
|
+
`Unmarshalling the type 'Route' failed as data isn't a dictionary.`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
createdAt: sdkClient.unmarshalDate(data.created_at),
|
|
49
|
+
description: data.description,
|
|
50
|
+
destination: data.destination,
|
|
51
|
+
id: data.id,
|
|
52
|
+
isReadOnly: data.is_read_only,
|
|
53
|
+
nexthopPrivateNetworkId: data.nexthop_private_network_id,
|
|
54
|
+
nexthopResourceId: data.nexthop_resource_id,
|
|
55
|
+
region: data.region,
|
|
56
|
+
tags: data.tags,
|
|
57
|
+
updatedAt: sdkClient.unmarshalDate(data.updated_at),
|
|
58
|
+
vpcId: data.vpc_id
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const unmarshalVPC = (data) => {
|
|
62
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
63
|
+
throw new TypeError(
|
|
64
|
+
`Unmarshalling the type 'VPC' failed as data isn't a dictionary.`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
createdAt: sdkClient.unmarshalDate(data.created_at),
|
|
69
|
+
id: data.id,
|
|
70
|
+
isDefault: data.is_default,
|
|
71
|
+
name: data.name,
|
|
72
|
+
organizationId: data.organization_id,
|
|
73
|
+
privateNetworkCount: data.private_network_count,
|
|
74
|
+
projectId: data.project_id,
|
|
75
|
+
region: data.region,
|
|
76
|
+
routingEnabled: data.routing_enabled,
|
|
77
|
+
tags: data.tags,
|
|
78
|
+
updatedAt: sdkClient.unmarshalDate(data.updated_at)
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const unmarshalAddSubnetsResponse = (data) => {
|
|
82
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
83
|
+
throw new TypeError(
|
|
84
|
+
`Unmarshalling the type 'AddSubnetsResponse' failed as data isn't a dictionary.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
subnets: data.subnets
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const unmarshalDeleteSubnetsResponse = (data) => {
|
|
92
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
`Unmarshalling the type 'DeleteSubnetsResponse' failed as data isn't a dictionary.`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
subnets: data.subnets
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const unmarshalAclRule = (data) => {
|
|
102
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
103
|
+
throw new TypeError(
|
|
104
|
+
`Unmarshalling the type 'AclRule' failed as data isn't a dictionary.`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
action: data.action,
|
|
109
|
+
description: data.description,
|
|
110
|
+
destination: data.destination,
|
|
111
|
+
dstPortHigh: data.dst_port_high,
|
|
112
|
+
dstPortLow: data.dst_port_low,
|
|
113
|
+
protocol: data.protocol,
|
|
114
|
+
source: data.source,
|
|
115
|
+
srcPortHigh: data.src_port_high,
|
|
116
|
+
srcPortLow: data.src_port_low
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const unmarshalGetAclResponse = (data) => {
|
|
120
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
121
|
+
throw new TypeError(
|
|
122
|
+
`Unmarshalling the type 'GetAclResponse' failed as data isn't a dictionary.`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
defaultPolicy: data.default_policy,
|
|
127
|
+
rules: sdkClient.unmarshalArrayOfObject(data.rules, unmarshalAclRule)
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
const unmarshalListPrivateNetworksResponse = (data) => {
|
|
131
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
132
|
+
throw new TypeError(
|
|
133
|
+
`Unmarshalling the type 'ListPrivateNetworksResponse' failed as data isn't a dictionary.`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
privateNetworks: sdkClient.unmarshalArrayOfObject(
|
|
138
|
+
data.private_networks,
|
|
139
|
+
unmarshalPrivateNetwork
|
|
140
|
+
),
|
|
141
|
+
totalCount: data.total_count
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
const unmarshalListSubnetsResponse = (data) => {
|
|
145
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
146
|
+
throw new TypeError(
|
|
147
|
+
`Unmarshalling the type 'ListSubnetsResponse' failed as data isn't a dictionary.`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
subnets: sdkClient.unmarshalArrayOfObject(data.subnets, unmarshalSubnet),
|
|
152
|
+
totalCount: data.total_count
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const unmarshalListVPCsResponse = (data) => {
|
|
156
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
157
|
+
throw new TypeError(
|
|
158
|
+
`Unmarshalling the type 'ListVPCsResponse' failed as data isn't a dictionary.`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
totalCount: data.total_count,
|
|
163
|
+
vpcs: sdkClient.unmarshalArrayOfObject(data.vpcs, unmarshalVPC)
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const unmarshalSetAclResponse = (data) => {
|
|
167
|
+
if (!sdkClient.isJSONObject(data)) {
|
|
168
|
+
throw new TypeError(
|
|
169
|
+
`Unmarshalling the type 'SetAclResponse' failed as data isn't a dictionary.`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
defaultPolicy: data.default_policy,
|
|
174
|
+
rules: sdkClient.unmarshalArrayOfObject(data.rules, unmarshalAclRule)
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
const marshalAddSubnetsRequest = (request, defaults) => ({
|
|
178
|
+
subnets: request.subnets
|
|
179
|
+
});
|
|
180
|
+
const marshalCreatePrivateNetworkRequest = (request, defaults) => ({
|
|
181
|
+
name: request.name || randomName("pn"),
|
|
182
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
183
|
+
subnets: request.subnets,
|
|
184
|
+
tags: request.tags,
|
|
185
|
+
vpc_id: request.vpcId
|
|
186
|
+
});
|
|
187
|
+
const marshalCreateRouteRequest = (request, defaults) => ({
|
|
188
|
+
description: request.description,
|
|
189
|
+
destination: request.destination,
|
|
190
|
+
nexthop_private_network_id: request.nexthopPrivateNetworkId,
|
|
191
|
+
nexthop_resource_id: request.nexthopResourceId,
|
|
192
|
+
tags: request.tags,
|
|
193
|
+
vpc_id: request.vpcId
|
|
194
|
+
});
|
|
195
|
+
const marshalCreateVPCRequest = (request, defaults) => ({
|
|
196
|
+
enable_routing: request.enableRouting,
|
|
197
|
+
name: request.name || randomName("vpc"),
|
|
198
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
199
|
+
tags: request.tags
|
|
200
|
+
});
|
|
201
|
+
const marshalDeleteSubnetsRequest = (request, defaults) => ({
|
|
202
|
+
subnets: request.subnets
|
|
203
|
+
});
|
|
204
|
+
const marshalAclRule = (request, defaults) => ({
|
|
205
|
+
action: request.action,
|
|
206
|
+
description: request.description,
|
|
207
|
+
destination: request.destination,
|
|
208
|
+
dst_port_high: request.dstPortHigh,
|
|
209
|
+
dst_port_low: request.dstPortLow,
|
|
210
|
+
protocol: request.protocol,
|
|
211
|
+
source: request.source,
|
|
212
|
+
src_port_high: request.srcPortHigh,
|
|
213
|
+
src_port_low: request.srcPortLow
|
|
214
|
+
});
|
|
215
|
+
const marshalSetAclRequest = (request, defaults) => ({
|
|
216
|
+
default_policy: request.defaultPolicy,
|
|
217
|
+
is_ipv6: request.isIpv6,
|
|
218
|
+
rules: request.rules.map((elt) => marshalAclRule(elt))
|
|
219
|
+
});
|
|
220
|
+
const marshalUpdatePrivateNetworkRequest = (request, defaults) => ({
|
|
221
|
+
name: request.name,
|
|
222
|
+
tags: request.tags
|
|
223
|
+
});
|
|
224
|
+
const marshalUpdateRouteRequest = (request, defaults) => ({
|
|
225
|
+
description: request.description,
|
|
226
|
+
destination: request.destination,
|
|
227
|
+
nexthop_private_network_id: request.nexthopPrivateNetworkId,
|
|
228
|
+
nexthop_resource_id: request.nexthopResourceId,
|
|
229
|
+
tags: request.tags
|
|
230
|
+
});
|
|
231
|
+
const marshalUpdateVPCRequest = (request, defaults) => ({
|
|
232
|
+
name: request.name,
|
|
233
|
+
tags: request.tags
|
|
234
|
+
});
|
|
235
|
+
exports.marshalAddSubnetsRequest = marshalAddSubnetsRequest;
|
|
236
|
+
exports.marshalCreatePrivateNetworkRequest = marshalCreatePrivateNetworkRequest;
|
|
237
|
+
exports.marshalCreateRouteRequest = marshalCreateRouteRequest;
|
|
238
|
+
exports.marshalCreateVPCRequest = marshalCreateVPCRequest;
|
|
239
|
+
exports.marshalDeleteSubnetsRequest = marshalDeleteSubnetsRequest;
|
|
240
|
+
exports.marshalSetAclRequest = marshalSetAclRequest;
|
|
241
|
+
exports.marshalUpdatePrivateNetworkRequest = marshalUpdatePrivateNetworkRequest;
|
|
242
|
+
exports.marshalUpdateRouteRequest = marshalUpdateRouteRequest;
|
|
243
|
+
exports.marshalUpdateVPCRequest = marshalUpdateVPCRequest;
|
|
244
|
+
exports.unmarshalAddSubnetsResponse = unmarshalAddSubnetsResponse;
|
|
245
|
+
exports.unmarshalDeleteSubnetsResponse = unmarshalDeleteSubnetsResponse;
|
|
246
|
+
exports.unmarshalGetAclResponse = unmarshalGetAclResponse;
|
|
247
|
+
exports.unmarshalListPrivateNetworksResponse = unmarshalListPrivateNetworksResponse;
|
|
248
|
+
exports.unmarshalListSubnetsResponse = unmarshalListSubnetsResponse;
|
|
249
|
+
exports.unmarshalListVPCsResponse = unmarshalListVPCsResponse;
|
|
250
|
+
exports.unmarshalPrivateNetwork = unmarshalPrivateNetwork;
|
|
251
|
+
exports.unmarshalRoute = unmarshalRoute;
|
|
252
|
+
exports.unmarshalSetAclResponse = unmarshalSetAclResponse;
|
|
253
|
+
exports.unmarshalVPC = unmarshalVPC;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DefaultValues } from '@scaleway/sdk-client';
|
|
2
|
+
import type { AddSubnetsRequest, AddSubnetsResponse, CreatePrivateNetworkRequest, CreateRouteRequest, CreateVPCRequest, DeleteSubnetsRequest, DeleteSubnetsResponse, GetAclResponse, ListPrivateNetworksResponse, ListSubnetsResponse, ListVPCsResponse, PrivateNetwork, Route, SetAclRequest, SetAclResponse, UpdatePrivateNetworkRequest, UpdateRouteRequest, UpdateVPCRequest, VPC } from './types.gen';
|
|
3
|
+
export declare const unmarshalPrivateNetwork: (data: unknown) => PrivateNetwork;
|
|
4
|
+
export declare const unmarshalRoute: (data: unknown) => Route;
|
|
5
|
+
export declare const unmarshalVPC: (data: unknown) => VPC;
|
|
6
|
+
export declare const unmarshalAddSubnetsResponse: (data: unknown) => AddSubnetsResponse;
|
|
7
|
+
export declare const unmarshalDeleteSubnetsResponse: (data: unknown) => DeleteSubnetsResponse;
|
|
8
|
+
export declare const unmarshalGetAclResponse: (data: unknown) => GetAclResponse;
|
|
9
|
+
export declare const unmarshalListPrivateNetworksResponse: (data: unknown) => ListPrivateNetworksResponse;
|
|
10
|
+
export declare const unmarshalListSubnetsResponse: (data: unknown) => ListSubnetsResponse;
|
|
11
|
+
export declare const unmarshalListVPCsResponse: (data: unknown) => ListVPCsResponse;
|
|
12
|
+
export declare const unmarshalSetAclResponse: (data: unknown) => SetAclResponse;
|
|
13
|
+
export declare const marshalAddSubnetsRequest: (request: AddSubnetsRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
14
|
+
export declare const marshalCreatePrivateNetworkRequest: (request: CreatePrivateNetworkRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
15
|
+
export declare const marshalCreateRouteRequest: (request: CreateRouteRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
16
|
+
export declare const marshalCreateVPCRequest: (request: CreateVPCRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
17
|
+
export declare const marshalDeleteSubnetsRequest: (request: DeleteSubnetsRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
18
|
+
export declare const marshalSetAclRequest: (request: SetAclRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
19
|
+
export declare const marshalUpdatePrivateNetworkRequest: (request: UpdatePrivateNetworkRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
20
|
+
export declare const marshalUpdateRouteRequest: (request: UpdateRouteRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
21
|
+
export declare const marshalUpdateVPCRequest: (request: UpdateVPCRequest, defaults: DefaultValues) => Record<string, unknown>;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import randomName from "@scaleway/random-name";
|
|
2
|
+
import { isJSONObject, unmarshalDate, unmarshalArrayOfObject } from "@scaleway/sdk-client";
|
|
3
|
+
const unmarshalSubnet = (data) => {
|
|
4
|
+
if (!isJSONObject(data)) {
|
|
5
|
+
throw new TypeError(
|
|
6
|
+
`Unmarshalling the type 'Subnet' failed as data isn't a dictionary.`
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
createdAt: unmarshalDate(data.created_at),
|
|
11
|
+
id: data.id,
|
|
12
|
+
privateNetworkId: data.private_network_id,
|
|
13
|
+
projectId: data.project_id,
|
|
14
|
+
subnet: data.subnet,
|
|
15
|
+
updatedAt: unmarshalDate(data.updated_at),
|
|
16
|
+
vpcId: data.vpc_id
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const unmarshalPrivateNetwork = (data) => {
|
|
20
|
+
if (!isJSONObject(data)) {
|
|
21
|
+
throw new TypeError(
|
|
22
|
+
`Unmarshalling the type 'PrivateNetwork' failed as data isn't a dictionary.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
createdAt: unmarshalDate(data.created_at),
|
|
27
|
+
dhcpEnabled: data.dhcp_enabled,
|
|
28
|
+
id: data.id,
|
|
29
|
+
name: data.name,
|
|
30
|
+
organizationId: data.organization_id,
|
|
31
|
+
projectId: data.project_id,
|
|
32
|
+
region: data.region,
|
|
33
|
+
subnets: unmarshalArrayOfObject(data.subnets, unmarshalSubnet),
|
|
34
|
+
tags: data.tags,
|
|
35
|
+
updatedAt: unmarshalDate(data.updated_at),
|
|
36
|
+
vpcId: data.vpc_id
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const unmarshalRoute = (data) => {
|
|
40
|
+
if (!isJSONObject(data)) {
|
|
41
|
+
throw new TypeError(
|
|
42
|
+
`Unmarshalling the type 'Route' failed as data isn't a dictionary.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
createdAt: unmarshalDate(data.created_at),
|
|
47
|
+
description: data.description,
|
|
48
|
+
destination: data.destination,
|
|
49
|
+
id: data.id,
|
|
50
|
+
isReadOnly: data.is_read_only,
|
|
51
|
+
nexthopPrivateNetworkId: data.nexthop_private_network_id,
|
|
52
|
+
nexthopResourceId: data.nexthop_resource_id,
|
|
53
|
+
region: data.region,
|
|
54
|
+
tags: data.tags,
|
|
55
|
+
updatedAt: unmarshalDate(data.updated_at),
|
|
56
|
+
vpcId: data.vpc_id
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const unmarshalVPC = (data) => {
|
|
60
|
+
if (!isJSONObject(data)) {
|
|
61
|
+
throw new TypeError(
|
|
62
|
+
`Unmarshalling the type 'VPC' failed as data isn't a dictionary.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
createdAt: unmarshalDate(data.created_at),
|
|
67
|
+
id: data.id,
|
|
68
|
+
isDefault: data.is_default,
|
|
69
|
+
name: data.name,
|
|
70
|
+
organizationId: data.organization_id,
|
|
71
|
+
privateNetworkCount: data.private_network_count,
|
|
72
|
+
projectId: data.project_id,
|
|
73
|
+
region: data.region,
|
|
74
|
+
routingEnabled: data.routing_enabled,
|
|
75
|
+
tags: data.tags,
|
|
76
|
+
updatedAt: unmarshalDate(data.updated_at)
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const unmarshalAddSubnetsResponse = (data) => {
|
|
80
|
+
if (!isJSONObject(data)) {
|
|
81
|
+
throw new TypeError(
|
|
82
|
+
`Unmarshalling the type 'AddSubnetsResponse' failed as data isn't a dictionary.`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
subnets: data.subnets
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const unmarshalDeleteSubnetsResponse = (data) => {
|
|
90
|
+
if (!isJSONObject(data)) {
|
|
91
|
+
throw new TypeError(
|
|
92
|
+
`Unmarshalling the type 'DeleteSubnetsResponse' failed as data isn't a dictionary.`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
subnets: data.subnets
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const unmarshalAclRule = (data) => {
|
|
100
|
+
if (!isJSONObject(data)) {
|
|
101
|
+
throw new TypeError(
|
|
102
|
+
`Unmarshalling the type 'AclRule' failed as data isn't a dictionary.`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
action: data.action,
|
|
107
|
+
description: data.description,
|
|
108
|
+
destination: data.destination,
|
|
109
|
+
dstPortHigh: data.dst_port_high,
|
|
110
|
+
dstPortLow: data.dst_port_low,
|
|
111
|
+
protocol: data.protocol,
|
|
112
|
+
source: data.source,
|
|
113
|
+
srcPortHigh: data.src_port_high,
|
|
114
|
+
srcPortLow: data.src_port_low
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const unmarshalGetAclResponse = (data) => {
|
|
118
|
+
if (!isJSONObject(data)) {
|
|
119
|
+
throw new TypeError(
|
|
120
|
+
`Unmarshalling the type 'GetAclResponse' failed as data isn't a dictionary.`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
defaultPolicy: data.default_policy,
|
|
125
|
+
rules: unmarshalArrayOfObject(data.rules, unmarshalAclRule)
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const unmarshalListPrivateNetworksResponse = (data) => {
|
|
129
|
+
if (!isJSONObject(data)) {
|
|
130
|
+
throw new TypeError(
|
|
131
|
+
`Unmarshalling the type 'ListPrivateNetworksResponse' failed as data isn't a dictionary.`
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
privateNetworks: unmarshalArrayOfObject(
|
|
136
|
+
data.private_networks,
|
|
137
|
+
unmarshalPrivateNetwork
|
|
138
|
+
),
|
|
139
|
+
totalCount: data.total_count
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
const unmarshalListSubnetsResponse = (data) => {
|
|
143
|
+
if (!isJSONObject(data)) {
|
|
144
|
+
throw new TypeError(
|
|
145
|
+
`Unmarshalling the type 'ListSubnetsResponse' failed as data isn't a dictionary.`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
subnets: unmarshalArrayOfObject(data.subnets, unmarshalSubnet),
|
|
150
|
+
totalCount: data.total_count
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const unmarshalListVPCsResponse = (data) => {
|
|
154
|
+
if (!isJSONObject(data)) {
|
|
155
|
+
throw new TypeError(
|
|
156
|
+
`Unmarshalling the type 'ListVPCsResponse' failed as data isn't a dictionary.`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
totalCount: data.total_count,
|
|
161
|
+
vpcs: unmarshalArrayOfObject(data.vpcs, unmarshalVPC)
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
const unmarshalSetAclResponse = (data) => {
|
|
165
|
+
if (!isJSONObject(data)) {
|
|
166
|
+
throw new TypeError(
|
|
167
|
+
`Unmarshalling the type 'SetAclResponse' failed as data isn't a dictionary.`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
defaultPolicy: data.default_policy,
|
|
172
|
+
rules: unmarshalArrayOfObject(data.rules, unmarshalAclRule)
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const marshalAddSubnetsRequest = (request, defaults) => ({
|
|
176
|
+
subnets: request.subnets
|
|
177
|
+
});
|
|
178
|
+
const marshalCreatePrivateNetworkRequest = (request, defaults) => ({
|
|
179
|
+
name: request.name || randomName("pn"),
|
|
180
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
181
|
+
subnets: request.subnets,
|
|
182
|
+
tags: request.tags,
|
|
183
|
+
vpc_id: request.vpcId
|
|
184
|
+
});
|
|
185
|
+
const marshalCreateRouteRequest = (request, defaults) => ({
|
|
186
|
+
description: request.description,
|
|
187
|
+
destination: request.destination,
|
|
188
|
+
nexthop_private_network_id: request.nexthopPrivateNetworkId,
|
|
189
|
+
nexthop_resource_id: request.nexthopResourceId,
|
|
190
|
+
tags: request.tags,
|
|
191
|
+
vpc_id: request.vpcId
|
|
192
|
+
});
|
|
193
|
+
const marshalCreateVPCRequest = (request, defaults) => ({
|
|
194
|
+
enable_routing: request.enableRouting,
|
|
195
|
+
name: request.name || randomName("vpc"),
|
|
196
|
+
project_id: request.projectId ?? defaults.defaultProjectId,
|
|
197
|
+
tags: request.tags
|
|
198
|
+
});
|
|
199
|
+
const marshalDeleteSubnetsRequest = (request, defaults) => ({
|
|
200
|
+
subnets: request.subnets
|
|
201
|
+
});
|
|
202
|
+
const marshalAclRule = (request, defaults) => ({
|
|
203
|
+
action: request.action,
|
|
204
|
+
description: request.description,
|
|
205
|
+
destination: request.destination,
|
|
206
|
+
dst_port_high: request.dstPortHigh,
|
|
207
|
+
dst_port_low: request.dstPortLow,
|
|
208
|
+
protocol: request.protocol,
|
|
209
|
+
source: request.source,
|
|
210
|
+
src_port_high: request.srcPortHigh,
|
|
211
|
+
src_port_low: request.srcPortLow
|
|
212
|
+
});
|
|
213
|
+
const marshalSetAclRequest = (request, defaults) => ({
|
|
214
|
+
default_policy: request.defaultPolicy,
|
|
215
|
+
is_ipv6: request.isIpv6,
|
|
216
|
+
rules: request.rules.map((elt) => marshalAclRule(elt))
|
|
217
|
+
});
|
|
218
|
+
const marshalUpdatePrivateNetworkRequest = (request, defaults) => ({
|
|
219
|
+
name: request.name,
|
|
220
|
+
tags: request.tags
|
|
221
|
+
});
|
|
222
|
+
const marshalUpdateRouteRequest = (request, defaults) => ({
|
|
223
|
+
description: request.description,
|
|
224
|
+
destination: request.destination,
|
|
225
|
+
nexthop_private_network_id: request.nexthopPrivateNetworkId,
|
|
226
|
+
nexthop_resource_id: request.nexthopResourceId,
|
|
227
|
+
tags: request.tags
|
|
228
|
+
});
|
|
229
|
+
const marshalUpdateVPCRequest = (request, defaults) => ({
|
|
230
|
+
name: request.name,
|
|
231
|
+
tags: request.tags
|
|
232
|
+
});
|
|
233
|
+
export {
|
|
234
|
+
marshalAddSubnetsRequest,
|
|
235
|
+
marshalCreatePrivateNetworkRequest,
|
|
236
|
+
marshalCreateRouteRequest,
|
|
237
|
+
marshalCreateVPCRequest,
|
|
238
|
+
marshalDeleteSubnetsRequest,
|
|
239
|
+
marshalSetAclRequest,
|
|
240
|
+
marshalUpdatePrivateNetworkRequest,
|
|
241
|
+
marshalUpdateRouteRequest,
|
|
242
|
+
marshalUpdateVPCRequest,
|
|
243
|
+
unmarshalAddSubnetsResponse,
|
|
244
|
+
unmarshalDeleteSubnetsResponse,
|
|
245
|
+
unmarshalGetAclResponse,
|
|
246
|
+
unmarshalListPrivateNetworksResponse,
|
|
247
|
+
unmarshalListSubnetsResponse,
|
|
248
|
+
unmarshalListVPCsResponse,
|
|
249
|
+
unmarshalPrivateNetwork,
|
|
250
|
+
unmarshalRoute,
|
|
251
|
+
unmarshalSetAclResponse,
|
|
252
|
+
unmarshalVPC
|
|
253
|
+
};
|