Skip to content

Commit a56836c

Browse files
feat(vpcgw): add support BastionAllowedIPs (#1703)
Co-authored-by: Laure-di <[email protected]>
1 parent b953767 commit a56836c

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ import {
1313
GATEWAY_TRANSIENT_STATUSES,
1414
} from './content.gen'
1515
import {
16+
marshalAddBastionAllowedIPsRequest,
1617
marshalCreateGatewayNetworkRequest,
1718
marshalCreateGatewayRequest,
1819
marshalCreateIPRequest,
1920
marshalCreatePatRuleRequest,
21+
marshalSetBastionAllowedIPsRequest,
2022
marshalSetPatRulesRequest,
2123
marshalUpdateGatewayNetworkRequest,
2224
marshalUpdateGatewayRequest,
2325
marshalUpdateIPRequest,
2426
marshalUpdatePatRuleRequest,
2527
marshalUpgradeGatewayRequest,
28+
unmarshalAddBastionAllowedIPsResponse,
2629
unmarshalGateway,
2730
unmarshalGatewayNetwork,
2831
unmarshalIP,
@@ -32,13 +35,17 @@ import {
3235
unmarshalListIPsResponse,
3336
unmarshalListPatRulesResponse,
3437
unmarshalPatRule,
38+
unmarshalSetBastionAllowedIPsResponse,
3539
unmarshalSetPatRulesResponse,
3640
} from './marshalling.gen'
3741
import type {
42+
AddBastionAllowedIPsRequest,
43+
AddBastionAllowedIPsResponse,
3844
CreateGatewayNetworkRequest,
3945
CreateGatewayRequest,
4046
CreateIPRequest,
4147
CreatePatRuleRequest,
48+
DeleteBastionAllowedIPsRequest,
4249
DeleteGatewayNetworkRequest,
4350
DeleteGatewayRequest,
4451
DeleteIPRequest,
@@ -62,6 +69,8 @@ import type {
6269
ListPatRulesResponse,
6370
PatRule,
6471
RefreshSSHKeysRequest,
72+
SetBastionAllowedIPsRequest,
73+
SetBastionAllowedIPsResponse,
6574
SetPatRulesRequest,
6675
SetPatRulesResponse,
6776
UpdateGatewayNetworkRequest,
@@ -660,4 +669,59 @@ export class API extends ParentAPI {
660669
},
661670
unmarshalGateway,
662671
)
672+
673+
/**
674+
* Add allowed IP range to SSH bastion. Add an IP range (in CIDR notation) to
675+
* be allowed to connect to the SSH bastion.
676+
*
677+
* @param request - The request {@link AddBastionAllowedIPsRequest}
678+
* @returns A Promise of AddBastionAllowedIPsResponse
679+
*/
680+
addBastionAllowedIPs = (request: Readonly<AddBastionAllowedIPsRequest>) =>
681+
this.client.fetch<AddBastionAllowedIPsResponse>(
682+
{
683+
body: JSON.stringify(
684+
marshalAddBastionAllowedIPsRequest(request, this.client.settings),
685+
),
686+
headers: jsonContentHeaders,
687+
method: 'POST',
688+
path: `/vpc-gw/v2/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam('gatewayId', request.gatewayId)}/bastion-allowed-ips`,
689+
},
690+
unmarshalAddBastionAllowedIPsResponse,
691+
)
692+
693+
/**
694+
* Set all IP ranges allowed for SSH bastion. Set a definitive list of IP
695+
* ranges (in CIDR notation) allowed to connect to the SSH bastion.
696+
*
697+
* @param request - The request {@link SetBastionAllowedIPsRequest}
698+
* @returns A Promise of SetBastionAllowedIPsResponse
699+
*/
700+
setBastionAllowedIPs = (request: Readonly<SetBastionAllowedIPsRequest>) =>
701+
this.client.fetch<SetBastionAllowedIPsResponse>(
702+
{
703+
body: JSON.stringify(
704+
marshalSetBastionAllowedIPsRequest(request, this.client.settings),
705+
),
706+
headers: jsonContentHeaders,
707+
method: 'PUT',
708+
path: `/vpc-gw/v2/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/gateways/${validatePathParam('gatewayId', request.gatewayId)}/bastion-allowed-ips`,
709+
},
710+
unmarshalSetBastionAllowedIPsResponse,
711+
)
712+
713+
/**
714+
* Delete allowed IP range from SSH bastion. Delete an IP range (defined in
715+
* CIDR notation) from SSH bastion, so that it is no longer allowed to
716+
* connect.
717+
*
718+
* @param request - The request {@link DeleteBastionAllowedIPsRequest}
719+
*/
720+
deleteBastionAllowedIPs = (
721+
request: Readonly<DeleteBastionAllowedIPsRequest>,
722+
) =>
723+
this.client.fetch<void>({
724+
method: 'DELETE',
725+
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)}`,
726+
})
663727
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
export { API } from './api.gen'
44
export * from './content.gen'
55
export type {
6+
AddBastionAllowedIPsRequest,
7+
AddBastionAllowedIPsResponse,
68
CreateGatewayNetworkRequest,
79
CreateGatewayRequest,
810
CreateIPRequest,
911
CreatePatRuleRequest,
12+
DeleteBastionAllowedIPsRequest,
1013
DeleteGatewayNetworkRequest,
1114
DeleteGatewayRequest,
1215
DeleteIPRequest,
@@ -38,6 +41,8 @@ export type {
3841
PatRule,
3942
PatRuleProtocol,
4043
RefreshSSHKeysRequest,
44+
SetBastionAllowedIPsRequest,
45+
SetBastionAllowedIPsResponse,
4146
SetPatRulesRequest,
4247
SetPatRulesRequestRule,
4348
SetPatRulesResponse,

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
} from '../../../bridge'
99
import type { DefaultValues } from '../../../bridge'
1010
import type {
11+
AddBastionAllowedIPsRequest,
12+
AddBastionAllowedIPsResponse,
1113
CreateGatewayNetworkRequest,
1214
CreateGatewayRequest,
1315
CreateIPRequest,
@@ -22,6 +24,8 @@ import type {
2224
ListIPsResponse,
2325
ListPatRulesResponse,
2426
PatRule,
27+
SetBastionAllowedIPsRequest,
28+
SetBastionAllowedIPsResponse,
2529
SetPatRulesRequest,
2630
SetPatRulesRequestRule,
2731
SetPatRulesResponse,
@@ -84,6 +88,7 @@ export const unmarshalGateway = (data: unknown): Gateway => {
8488

8589
return {
8690
bandwidth: data.bandwidth,
91+
bastionAllowedIps: data.bastion_allowed_ips,
8792
bastionEnabled: data.bastion_enabled,
8893
bastionPort: data.bastion_port,
8994
canUpgradeTo: data.can_upgrade_to,
@@ -128,6 +133,20 @@ export const unmarshalPatRule = (data: unknown): PatRule => {
128133
} as PatRule
129134
}
130135

136+
export const unmarshalAddBastionAllowedIPsResponse = (
137+
data: unknown,
138+
): AddBastionAllowedIPsResponse => {
139+
if (!isJSONObject(data)) {
140+
throw new TypeError(
141+
`Unmarshalling the type 'AddBastionAllowedIPsResponse' failed as data isn't a dictionary.`,
142+
)
143+
}
144+
145+
return {
146+
ipRanges: data.ip_ranges,
147+
} as AddBastionAllowedIPsResponse
148+
}
149+
131150
export const unmarshalListGatewayNetworksResponse = (
132151
data: unknown,
133152
): ListGatewayNetworksResponse => {
@@ -217,6 +236,20 @@ export const unmarshalListPatRulesResponse = (
217236
} as ListPatRulesResponse
218237
}
219238

239+
export const unmarshalSetBastionAllowedIPsResponse = (
240+
data: unknown,
241+
): SetBastionAllowedIPsResponse => {
242+
if (!isJSONObject(data)) {
243+
throw new TypeError(
244+
`Unmarshalling the type 'SetBastionAllowedIPsResponse' failed as data isn't a dictionary.`,
245+
)
246+
}
247+
248+
return {
249+
ipRanges: data.ip_ranges,
250+
} as SetBastionAllowedIPsResponse
251+
}
252+
220253
export const unmarshalSetPatRulesResponse = (
221254
data: unknown,
222255
): SetPatRulesResponse => {
@@ -231,6 +264,13 @@ export const unmarshalSetPatRulesResponse = (
231264
} as SetPatRulesResponse
232265
}
233266

267+
export const marshalAddBastionAllowedIPsRequest = (
268+
request: AddBastionAllowedIPsRequest,
269+
defaults: DefaultValues,
270+
): Record<string, unknown> => ({
271+
ip_range: request.ipRange,
272+
})
273+
234274
export const marshalCreateGatewayNetworkRequest = (
235275
request: CreateGatewayNetworkRequest,
236276
defaults: DefaultValues,
@@ -275,6 +315,13 @@ export const marshalCreatePatRuleRequest = (
275315
public_port: request.publicPort,
276316
})
277317

318+
export const marshalSetBastionAllowedIPsRequest = (
319+
request: SetBastionAllowedIPsRequest,
320+
defaults: DefaultValues,
321+
): Record<string, unknown> => ({
322+
ip_ranges: request.ipRanges,
323+
})
324+
278325
const marshalSetPatRulesRequestRule = (
279326
request: SetPatRulesRequestRule,
280327
defaults: DefaultValues,

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ export interface Gateway {
160160
smtpEnabled: boolean
161161
/** Defines whether the gateway uses non-IPAM IP configurations. */
162162
isLegacy: boolean
163+
/** Ranges of IP addresses allowed to connect to the gateway's SSH bastion. */
164+
bastionAllowedIps: string[]
163165
/** Zone of the gateway. */
164166
zone: Zone
165167
}
@@ -199,6 +201,20 @@ export interface SetPatRulesRequestRule {
199201
protocol: PatRuleProtocol
200202
}
201203

204+
export type AddBastionAllowedIPsRequest = {
205+
/** Zone to target. If none is passed will use default zone from the config. */
206+
zone?: Zone
207+
/** ID of the gateway to add the allowed IP range to. */
208+
gatewayId: string
209+
/** IP range allowed to connect to the SSH bastion. */
210+
ipRange: string
211+
}
212+
213+
export interface AddBastionAllowedIPsResponse {
214+
/** Ranges of IP addresses allowed to connect to the gateway's SSH bastion. */
215+
ipRanges: string[]
216+
}
217+
202218
export type CreateGatewayNetworkRequest = {
203219
/** Zone to target. If none is passed will use default zone from the config. */
204220
zone?: Zone
@@ -259,6 +275,15 @@ export type CreatePatRuleRequest = {
259275
protocol?: PatRuleProtocol
260276
}
261277

278+
export type DeleteBastionAllowedIPsRequest = {
279+
/** Zone to target. If none is passed will use default zone from the config. */
280+
zone?: Zone
281+
/** ID of the gateway on which to delete the allowed IP range. */
282+
gatewayId: string
283+
/** IP range to delete from SSH bastion's list of allowed IPs. */
284+
ipRange: string
285+
}
286+
262287
export type DeleteGatewayNetworkRequest = {
263288
/** Zone to target. If none is passed will use default zone from the config. */
264289
zone?: Zone
@@ -452,6 +477,23 @@ export type RefreshSSHKeysRequest = {
452477
gatewayId: string
453478
}
454479

480+
export type SetBastionAllowedIPsRequest = {
481+
/** Zone to target. If none is passed will use default zone from the config. */
482+
zone?: Zone
483+
/** ID of the gateway on which to set the allowed IP range. */
484+
gatewayId: string
485+
/**
486+
* New list of IP ranges (each range in CIDR notation) allowed to connect to
487+
* the SSH bastion.
488+
*/
489+
ipRanges?: string[]
490+
}
491+
492+
export interface SetBastionAllowedIPsResponse {
493+
/** Ranges of IP addresses allowed to connect to the gateway's SSH bastion. */
494+
ipRanges: string[]
495+
}
496+
455497
export type SetPatRulesRequest = {
456498
/** Zone to target. If none is passed will use default zone from the config. */
457499
zone?: Zone

0 commit comments

Comments
 (0)