diff --git a/packages/api-v4/.changeset/pr-11852-upcoming-features-1742414634244.md b/packages/api-v4/.changeset/pr-11852-upcoming-features-1742414634244.md new file mode 100644 index 00000000000..356dab73d57 --- /dev/null +++ b/packages/api-v4/.changeset/pr-11852-upcoming-features-1742414634244.md @@ -0,0 +1,5 @@ +--- +"@linode/api-v4": Upcoming Features +--- + +Added optional ipv6 property to VPC entity ([#11852](https://github.com/linode/manager/pull/11852)) diff --git a/packages/api-v4/src/vpcs/types.ts b/packages/api-v4/src/vpcs/types.ts index cf15d1112dd..28ce606fdc8 100644 --- a/packages/api-v4/src/vpcs/types.ts +++ b/packages/api-v4/src/vpcs/types.ts @@ -1,3 +1,11 @@ +interface VPCIPv6 { + range?: string; +} + +interface CreateVPCIPV6 extends VPCIPv6 { + allocation_class?: string; +} + export interface VPC { id: number; label: string; @@ -6,12 +14,14 @@ export interface VPC { subnets: Subnet[]; created: string; updated: string; + ipv6?: VPCIPv6[]; } export interface CreateVPCPayload { label: string; description?: string; region: string; + ipv6?: CreateVPCIPV6[]; subnets?: CreateSubnetPayload[]; } diff --git a/packages/validation/.changeset/pr-11852-upcoming-features-1742414737915.md b/packages/validation/.changeset/pr-11852-upcoming-features-1742414737915.md new file mode 100644 index 00000000000..65066688c58 --- /dev/null +++ b/packages/validation/.changeset/pr-11852-upcoming-features-1742414737915.md @@ -0,0 +1,5 @@ +--- +"@linode/validation": Upcoming Features +--- + +Added optional ipv6 to `createVPCIPv6Schema` ([#11852](https://github.com/linode/manager/pull/11852)) diff --git a/packages/validation/src/vpcs.schema.ts b/packages/validation/src/vpcs.schema.ts index 1196436186c..076eaa8ca81 100644 --- a/packages/validation/src/vpcs.schema.ts +++ b/packages/validation/src/vpcs.schema.ts @@ -94,6 +94,10 @@ export const vpcsValidateIP = ({ } if (isIPv6) { + // VPCs must be assigned an IPv6 prefix of /52, /48, or /44 + if (!['52', '48', '44'].includes(mask)) { + return false; + } if (shouldHaveIPMask) { ipaddr.IPv6.parseCIDR(value); } else { @@ -210,11 +214,31 @@ export const createSubnetSchema = object().shape( ] ); +const createVPCIPv6Schema = object({ + range: string() + .optional() + .test({ + name: 'IPv6 prefix length', + message: 'Must be the prefix length 52, 48, or 44 of the IP, e.g. /52', + test: (value) => { + if (value && value !== 'auto' && value.length > 0) { + vpcsValidateIP({ + value, + shouldHaveIPMask: true, + mustBeIPMask: false, + }); + } + }, + }), + allocation_class: string().optional(), +}); + export const createVPCSchema = object({ label: labelValidation.required(LABEL_REQUIRED), description: string(), region: string().required('Region is required'), subnets: array().of(createSubnetSchema), + ipv6: array().of(createVPCIPv6Schema).max(1).optional(), }); export const modifySubnetSchema = object({