Skip to content

Commit 3a17852

Browse files
authored
upcoming: [M3-9511] - VPC IPv6 - Update endpoints and types for VPC Entity (#11852)
## Description 📝 Update endpoints and types for VPC Entity ## Changes 🔄 - Add optional `ipv6` property to `VPC` and `CreateVPCPayload` interface - Add optional `ipv6` validation to `createVPCSchema` ### Verification steps (How to verify changes) - [ ] Cross-reference VPC IPv6 API spec (linked in parent ticket) and updated types for POST /v4/vpcs GET /v4/vpcs GET /v4/vpcs/{vpcId}
1 parent 9ff0e44 commit 3a17852

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Upcoming Features
3+
---
4+
5+
Added optional ipv6 property to VPC entity ([#11852](https://github.com/linode/manager/pull/11852))

packages/api-v4/src/vpcs/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
interface VPCIPv6 {
2+
range?: string;
3+
}
4+
5+
interface CreateVPCIPV6 extends VPCIPv6 {
6+
allocation_class?: string;
7+
}
8+
19
export interface VPC {
210
id: number;
311
label: string;
@@ -6,12 +14,14 @@ export interface VPC {
614
subnets: Subnet[];
715
created: string;
816
updated: string;
17+
ipv6?: VPCIPv6[];
918
}
1019

1120
export interface CreateVPCPayload {
1221
label: string;
1322
description?: string;
1423
region: string;
24+
ipv6?: CreateVPCIPV6[];
1525
subnets?: CreateSubnetPayload[];
1626
}
1727

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/validation": Upcoming Features
3+
---
4+
5+
Added optional ipv6 to `createVPCIPv6Schema` ([#11852](https://github.com/linode/manager/pull/11852))

packages/validation/src/vpcs.schema.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export const vpcsValidateIP = ({
9494
}
9595

9696
if (isIPv6) {
97+
// VPCs must be assigned an IPv6 prefix of /52, /48, or /44
98+
if (!['52', '48', '44'].includes(mask)) {
99+
return false;
100+
}
97101
if (shouldHaveIPMask) {
98102
ipaddr.IPv6.parseCIDR(value);
99103
} else {
@@ -210,11 +214,31 @@ export const createSubnetSchema = object().shape(
210214
]
211215
);
212216

217+
const createVPCIPv6Schema = object({
218+
range: string()
219+
.optional()
220+
.test({
221+
name: 'IPv6 prefix length',
222+
message: 'Must be the prefix length 52, 48, or 44 of the IP, e.g. /52',
223+
test: (value) => {
224+
if (value && value !== 'auto' && value.length > 0) {
225+
vpcsValidateIP({
226+
value,
227+
shouldHaveIPMask: true,
228+
mustBeIPMask: false,
229+
});
230+
}
231+
},
232+
}),
233+
allocation_class: string().optional(),
234+
});
235+
213236
export const createVPCSchema = object({
214237
label: labelValidation.required(LABEL_REQUIRED),
215238
description: string(),
216239
region: string().required('Region is required'),
217240
subnets: array().of(createSubnetSchema),
241+
ipv6: array().of(createVPCIPv6Schema).max(1).optional(),
218242
});
219243

220244
export const modifySubnetSchema = object({

0 commit comments

Comments
 (0)