Skip to content

Commit 40eaea5

Browse files
committed
feat: update generated APIs
1 parent 3b966b1 commit 40eaea5

File tree

5 files changed

+230
-0
lines changed

5 files changed

+230
-0
lines changed

packages/clients/src/api/vpc/v2/api.gen.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ import {
1313
marshalCreateRouteRequest,
1414
marshalCreateVPCRequest,
1515
marshalDeleteSubnetsRequest,
16+
marshalSetAclRequest,
1617
marshalSetSubnetsRequest,
1718
marshalUpdatePrivateNetworkRequest,
1819
marshalUpdateRouteRequest,
1920
marshalUpdateVPCRequest,
2021
unmarshalAddSubnetsResponse,
2122
unmarshalDeleteSubnetsResponse,
23+
unmarshalGetAclResponse,
2224
unmarshalListPrivateNetworksResponse,
2325
unmarshalListSubnetsResponse,
2426
unmarshalListVPCsResponse,
2527
unmarshalPrivateNetwork,
2628
unmarshalRoute,
29+
unmarshalSetAclResponse,
2730
unmarshalSetSubnetsResponse,
2831
unmarshalVPC,
2932
} from './marshalling.gen'
@@ -40,6 +43,8 @@ import type {
4043
DeleteVPCRequest,
4144
EnableDHCPRequest,
4245
EnableRoutingRequest,
46+
GetAclRequest,
47+
GetAclResponse,
4348
GetPrivateNetworkRequest,
4449
GetRouteRequest,
4550
GetVPCRequest,
@@ -51,6 +56,8 @@ import type {
5156
ListVPCsResponse,
5257
PrivateNetwork,
5358
Route,
59+
SetAclRequest,
60+
SetAclResponse,
5461
SetSubnetsRequest,
5562
SetSubnetsResponse,
5663
UpdatePrivateNetworkRequest,
@@ -479,4 +486,41 @@ export class API extends ParentAPI {
479486
method: 'DELETE',
480487
path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/routes/${validatePathParam('routeId', request.routeId)}`,
481488
})
489+
490+
/**
491+
* Get Acl Rules for VPC. Retrieve a list of ACL rules for a VPC, specified by
492+
* its VPC ID.
493+
*
494+
* @param request - The request {@link GetAclRequest}
495+
* @returns A Promise of GetAclResponse
496+
*/
497+
getAcl = (request: Readonly<GetAclRequest>) =>
498+
this.client.fetch<GetAclResponse>(
499+
{
500+
method: 'GET',
501+
path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/vpc/${validatePathParam('vpcId', request.vpcId)}/acl-rules`,
502+
urlParams: urlParams(['is_ipv6', request.isIpv6]),
503+
},
504+
unmarshalGetAclResponse,
505+
)
506+
507+
/**
508+
* Set VPC ACL rules. Set the list of ACL rules and the default routing policy
509+
* for a VPC.
510+
*
511+
* @param request - The request {@link SetAclRequest}
512+
* @returns A Promise of SetAclResponse
513+
*/
514+
setAcl = (request: Readonly<SetAclRequest>) =>
515+
this.client.fetch<SetAclResponse>(
516+
{
517+
body: JSON.stringify(
518+
marshalSetAclRequest(request, this.client.settings),
519+
),
520+
headers: jsonContentHeaders,
521+
method: 'PUT',
522+
path: `/vpc/v2/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/vpc/${validatePathParam('vpcId', request.vpcId)}/acl-rules`,
523+
},
524+
unmarshalSetAclResponse,
525+
)
482526
}

packages/clients/src/api/vpc/v2/index.gen.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
export { API } from './api.gen'
44
export type {
5+
AclRule,
6+
AclRuleProtocol,
7+
Action,
58
AddSubnetsRequest,
69
AddSubnetsResponse,
710
CreatePrivateNetworkRequest,
@@ -14,6 +17,8 @@ export type {
1417
DeleteVPCRequest,
1518
EnableDHCPRequest,
1619
EnableRoutingRequest,
20+
GetAclRequest,
21+
GetAclResponse,
1722
GetPrivateNetworkRequest,
1823
GetRouteRequest,
1924
GetVPCRequest,
@@ -28,6 +33,8 @@ export type {
2833
ListVPCsResponse,
2934
PrivateNetwork,
3035
Route,
36+
SetAclRequest,
37+
SetAclResponse,
3138
SetSubnetsRequest,
3239
SetSubnetsResponse,
3340
Subnet,

packages/clients/src/api/vpc/v2/marshalling.gen.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ import {
88
} from '../../../bridge'
99
import type { DefaultValues } from '../../../bridge'
1010
import type {
11+
AclRule,
1112
AddSubnetsRequest,
1213
AddSubnetsResponse,
1314
CreatePrivateNetworkRequest,
1415
CreateRouteRequest,
1516
CreateVPCRequest,
1617
DeleteSubnetsRequest,
1718
DeleteSubnetsResponse,
19+
GetAclResponse,
1820
ListPrivateNetworksResponse,
1921
ListSubnetsResponse,
2022
ListVPCsResponse,
2123
PrivateNetwork,
2224
Route,
25+
SetAclRequest,
26+
SetAclResponse,
2327
SetSubnetsRequest,
2428
SetSubnetsResponse,
2529
Subnet,
@@ -141,6 +145,39 @@ export const unmarshalDeleteSubnetsResponse = (
141145
} as DeleteSubnetsResponse
142146
}
143147

148+
const unmarshalAclRule = (data: unknown): AclRule => {
149+
if (!isJSONObject(data)) {
150+
throw new TypeError(
151+
`Unmarshalling the type 'AclRule' failed as data isn't a dictionary.`,
152+
)
153+
}
154+
155+
return {
156+
action: data.action,
157+
description: data.description,
158+
destination: data.destination,
159+
dstPortHigh: data.dst_port_high,
160+
dstPortLow: data.dst_port_low,
161+
protocol: data.protocol,
162+
source: data.source,
163+
srcPortHigh: data.src_port_high,
164+
srcPortLow: data.src_port_low,
165+
} as AclRule
166+
}
167+
168+
export const unmarshalGetAclResponse = (data: unknown): GetAclResponse => {
169+
if (!isJSONObject(data)) {
170+
throw new TypeError(
171+
`Unmarshalling the type 'GetAclResponse' failed as data isn't a dictionary.`,
172+
)
173+
}
174+
175+
return {
176+
defaultPolicy: data.default_policy,
177+
rules: unmarshalArrayOfObject(data.rules, unmarshalAclRule),
178+
} as GetAclResponse
179+
}
180+
144181
export const unmarshalListPrivateNetworksResponse = (
145182
data: unknown,
146183
): ListPrivateNetworksResponse => {
@@ -187,6 +224,19 @@ export const unmarshalListVPCsResponse = (data: unknown): ListVPCsResponse => {
187224
} as ListVPCsResponse
188225
}
189226

227+
export const unmarshalSetAclResponse = (data: unknown): SetAclResponse => {
228+
if (!isJSONObject(data)) {
229+
throw new TypeError(
230+
`Unmarshalling the type 'SetAclResponse' failed as data isn't a dictionary.`,
231+
)
232+
}
233+
234+
return {
235+
defaultPolicy: data.default_policy,
236+
rules: unmarshalArrayOfObject(data.rules, unmarshalAclRule),
237+
} as SetAclResponse
238+
}
239+
190240
export const unmarshalSetSubnetsResponse = (
191241
data: unknown,
192242
): SetSubnetsResponse => {
@@ -248,6 +298,30 @@ export const marshalDeleteSubnetsRequest = (
248298
subnets: request.subnets,
249299
})
250300

301+
const marshalAclRule = (
302+
request: AclRule,
303+
defaults: DefaultValues,
304+
): Record<string, unknown> => ({
305+
action: request.action,
306+
description: request.description,
307+
destination: request.destination,
308+
dst_port_high: request.dstPortHigh,
309+
dst_port_low: request.dstPortLow,
310+
protocol: request.protocol,
311+
source: request.source,
312+
src_port_high: request.srcPortHigh,
313+
src_port_low: request.srcPortLow,
314+
})
315+
316+
export const marshalSetAclRequest = (
317+
request: SetAclRequest,
318+
defaults: DefaultValues,
319+
): Record<string, unknown> => ({
320+
default_policy: request.defaultPolicy,
321+
is_ipv6: request.isIpv6,
322+
rules: request.rules.map(elt => marshalAclRule(elt, defaults)),
323+
})
324+
251325
export const marshalSetSubnetsRequest = (
252326
request: SetSubnetsRequest,
253327
defaults: DefaultValues,

packages/clients/src/api/vpc/v2/types.gen.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
import type { Region as ScwRegion } from '../../../bridge'
44

5+
export type AclRuleProtocol = 'ANY' | 'TCP' | 'UDP' | 'ICMP'
6+
7+
export type Action = 'unknown_action' | 'accept' | 'drop'
8+
59
export type ListPrivateNetworksRequestOrderBy =
610
| 'created_at_asc'
711
| 'created_at_desc'
@@ -83,6 +87,45 @@ export interface Route {
8387
region: ScwRegion
8488
}
8589

90+
export interface AclRule {
91+
/** Protocol to which this rule applies. */
92+
protocol: AclRuleProtocol
93+
/**
94+
* Source IP range to which this rule applies (CIDR notation with subnet
95+
* mask).
96+
*/
97+
source: string
98+
/**
99+
* Starting port of the source port range to which this rule applies
100+
* (inclusive).
101+
*/
102+
srcPortLow: number
103+
/**
104+
* Ending port of the source port range to which this rule applies
105+
* (inclusive).
106+
*/
107+
srcPortHigh: number
108+
/**
109+
* Destination IP range to which this rule applies (CIDR notation with subnet
110+
* mask).
111+
*/
112+
destination: string
113+
/**
114+
* Starting port of the destination port range to which this rule applies
115+
* (inclusive).
116+
*/
117+
dstPortLow: number
118+
/**
119+
* Ending port of the destination port range to which this rule applies
120+
* (inclusive).
121+
*/
122+
dstPortHigh: number
123+
/** Policy to apply to the packet. */
124+
action: Action
125+
/** Rule description. */
126+
description?: string
127+
}
128+
86129
export interface VPC {
87130
/** VPC ID. */
88131
id: string
@@ -244,6 +287,26 @@ export type EnableRoutingRequest = {
244287
vpcId: string
245288
}
246289

290+
export type GetAclRequest = {
291+
/**
292+
* Region to target. If none is passed will use default region from the
293+
* config.
294+
*/
295+
region?: ScwRegion
296+
/** ID of the Network ACL's VPC. */
297+
vpcId: string
298+
/**
299+
* Defines whether this set of ACL rules is for IPv6 (false = IPv4). Each
300+
* Network ACL can have rules for only one IP type.
301+
*/
302+
isIpv6: boolean
303+
}
304+
305+
export interface GetAclResponse {
306+
rules: AclRule[]
307+
defaultPolicy: Action
308+
}
309+
247310
export type GetPrivateNetworkRequest = {
248311
/**
249312
* Region to target. If none is passed will use default region from the
@@ -413,6 +476,30 @@ export interface ListVPCsResponse {
413476
totalCount: number
414477
}
415478

479+
export type SetAclRequest = {
480+
/**
481+
* Region to target. If none is passed will use default region from the
482+
* config.
483+
*/
484+
region?: ScwRegion
485+
/** ID of the Network ACL's VPC. */
486+
vpcId: string
487+
/** List of Network ACL rules. */
488+
rules: AclRule[]
489+
/**
490+
* Defines whether this set of ACL rules is for IPv6 (false = IPv4). Each
491+
* Network ACL can have rules for only one IP type.
492+
*/
493+
isIpv6: boolean
494+
/** Action to take for packets which do not match any rules. */
495+
defaultPolicy: Action
496+
}
497+
498+
export interface SetAclResponse {
499+
rules: AclRule[]
500+
defaultPolicy: Action
501+
}
502+
416503
export type SetSubnetsRequest = {
417504
/**
418505
* Region to target. If none is passed will use default region from the

packages/clients/src/api/vpc/v2/validation-rules.gen.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
// This file was automatically generated. DO NOT EDIT.
22
// If you have any remark or suggestion do not hesitate to open an issue.
33

4+
export const AclRule = {
5+
description: {
6+
maxLength: 200,
7+
},
8+
dstPortHigh: {
9+
lessThanOrEqual: 65536,
10+
},
11+
dstPortLow: {
12+
lessThanOrEqual: 65536,
13+
},
14+
srcPortHigh: {
15+
lessThanOrEqual: 65536,
16+
},
17+
srcPortLow: {
18+
lessThanOrEqual: 65536,
19+
},
20+
}
21+
422
export const Route = {
523
description: {
624
maxLength: 200,

0 commit comments

Comments
 (0)