From 7dd1c5c9b946295a856cc9f96e9f9625287e2257 Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Fri, 3 Oct 2025 13:56:27 -0400 Subject: [PATCH 1/3] Add support for VPCSubnet.databases field --- linode_api4/objects/vpc.py | 8 ++++++++ test/fixtures/vpcs_123456_subnets.json | 7 +++++++ test/fixtures/vpcs_123456_subnets_789.json | 7 +++++++ test/unit/objects/vpc_test.py | 6 ++++++ 4 files changed, 28 insertions(+) diff --git a/linode_api4/objects/vpc.py b/linode_api4/objects/vpc.py index 3c9a4aaba..7af13fcc5 100644 --- a/linode_api4/objects/vpc.py +++ b/linode_api4/objects/vpc.py @@ -20,6 +20,13 @@ class VPCSubnetLinode(JSONObject): interfaces: Optional[List[VPCSubnetLinodeInterface]] = None +@dataclass +class VPCSubnetDatabase(JSONObject): + id: int = 0 + ipv4_range: Optional[str] = None + ipv6_range: Optional[str] = None + + class VPCSubnet(DerivedBase): """ An instance of a VPC subnet. @@ -36,6 +43,7 @@ class VPCSubnet(DerivedBase): "label": Property(mutable=True), "ipv4": Property(), "linodes": Property(json_object=VPCSubnetLinode, unordered=True), + "databases": Property(json_object=VPCSubnetDatabase, unordered=True), "created": Property(is_datetime=True), "updated": Property(is_datetime=True), } diff --git a/test/fixtures/vpcs_123456_subnets.json b/test/fixtures/vpcs_123456_subnets.json index f846399df..b7b63925d 100644 --- a/test/fixtures/vpcs_123456_subnets.json +++ b/test/fixtures/vpcs_123456_subnets.json @@ -19,6 +19,13 @@ ] } ], + "databases": [ + { + "id": 12345, + "ipv4_range": "10.0.0.0/24", + "ipv6_range": "2001:db8::/64" + } + ], "created": "2018-01-01T00:01:01", "updated": "2018-01-01T00:01:01" } diff --git a/test/fixtures/vpcs_123456_subnets_789.json b/test/fixtures/vpcs_123456_subnets_789.json index ba6973472..757dbbadd 100644 --- a/test/fixtures/vpcs_123456_subnets_789.json +++ b/test/fixtures/vpcs_123456_subnets_789.json @@ -17,6 +17,13 @@ ] } ], + "databases": [ + { + "id": 12345, + "ipv4_range": "10.0.0.0/24", + "ipv6_range": "2001:db8::/64" + } + ], "created": "2018-01-01T00:01:01", "updated": "2018-01-01T00:01:01" } \ No newline at end of file diff --git a/test/unit/objects/vpc_test.py b/test/unit/objects/vpc_test.py index 5e7be1b69..95a1d3fb5 100644 --- a/test/unit/objects/vpc_test.py +++ b/test/unit/objects/vpc_test.py @@ -120,7 +120,13 @@ def validate_vpc_subnet_789(self, subnet: VPCSubnet): self.assertEqual(subnet.label, "test-subnet") self.assertEqual(subnet.ipv4, "10.0.0.0/24") + self.assertEqual(subnet.linodes[0].id, 12345) + + self.assertEqual(subnet.databases[0].id, 12345) + self.assertEqual(subnet.databases[0].ipv4_range, "10.0.0.0/24") + self.assertEqual(subnet.databases[0].ipv6_range, "2001:db8::/64") + self.assertEqual(subnet.created, expected_dt) self.assertEqual(subnet.updated, expected_dt) From 15e11f05761cc0302086dfd1d20a1467e4fb6506 Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Sun, 5 Oct 2025 02:36:10 -0400 Subject: [PATCH 2/3] ipv6_range -> ipv6_ranges --- linode_api4/objects/vpc.py | 2 +- test/fixtures/vpcs_123456_subnets.json | 2 +- test/fixtures/vpcs_123456_subnets_789.json | 2 +- test/unit/objects/vpc_test.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/linode_api4/objects/vpc.py b/linode_api4/objects/vpc.py index 7af13fcc5..bf49b98f7 100644 --- a/linode_api4/objects/vpc.py +++ b/linode_api4/objects/vpc.py @@ -24,7 +24,7 @@ class VPCSubnetLinode(JSONObject): class VPCSubnetDatabase(JSONObject): id: int = 0 ipv4_range: Optional[str] = None - ipv6_range: Optional[str] = None + ipv6_ranges: Optional[str] = None class VPCSubnet(DerivedBase): diff --git a/test/fixtures/vpcs_123456_subnets.json b/test/fixtures/vpcs_123456_subnets.json index b7b63925d..e1fbae961 100644 --- a/test/fixtures/vpcs_123456_subnets.json +++ b/test/fixtures/vpcs_123456_subnets.json @@ -23,7 +23,7 @@ { "id": 12345, "ipv4_range": "10.0.0.0/24", - "ipv6_range": "2001:db8::/64" + "ipv6_ranges": "2001:db8::/64" } ], "created": "2018-01-01T00:01:01", diff --git a/test/fixtures/vpcs_123456_subnets_789.json b/test/fixtures/vpcs_123456_subnets_789.json index 757dbbadd..038b631fc 100644 --- a/test/fixtures/vpcs_123456_subnets_789.json +++ b/test/fixtures/vpcs_123456_subnets_789.json @@ -21,7 +21,7 @@ { "id": 12345, "ipv4_range": "10.0.0.0/24", - "ipv6_range": "2001:db8::/64" + "ipv6_ranges": "2001:db8::/64" } ], "created": "2018-01-01T00:01:01", diff --git a/test/unit/objects/vpc_test.py b/test/unit/objects/vpc_test.py index 95a1d3fb5..a72284619 100644 --- a/test/unit/objects/vpc_test.py +++ b/test/unit/objects/vpc_test.py @@ -125,7 +125,7 @@ def validate_vpc_subnet_789(self, subnet: VPCSubnet): self.assertEqual(subnet.databases[0].id, 12345) self.assertEqual(subnet.databases[0].ipv4_range, "10.0.0.0/24") - self.assertEqual(subnet.databases[0].ipv6_range, "2001:db8::/64") + self.assertEqual(subnet.databases[0].ipv6_ranges, "2001:db8::/64") self.assertEqual(subnet.created, expected_dt) self.assertEqual(subnet.updated, expected_dt) From c0c5907e2e445c587508fa7e137b426582131268 Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Mon, 6 Oct 2025 14:12:16 -0400 Subject: [PATCH 3/3] ipv6_range -> ipv6_ranges (list) --- linode_api4/objects/vpc.py | 2 +- test/fixtures/vpcs_123456_subnets.json | 4 +++- test/fixtures/vpcs_123456_subnets_789.json | 4 +++- test/unit/objects/vpc_test.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/linode_api4/objects/vpc.py b/linode_api4/objects/vpc.py index bf49b98f7..384a43f33 100644 --- a/linode_api4/objects/vpc.py +++ b/linode_api4/objects/vpc.py @@ -24,7 +24,7 @@ class VPCSubnetLinode(JSONObject): class VPCSubnetDatabase(JSONObject): id: int = 0 ipv4_range: Optional[str] = None - ipv6_ranges: Optional[str] = None + ipv6_ranges: Optional[List[str]] = None class VPCSubnet(DerivedBase): diff --git a/test/fixtures/vpcs_123456_subnets.json b/test/fixtures/vpcs_123456_subnets.json index e1fbae961..4cecf3aef 100644 --- a/test/fixtures/vpcs_123456_subnets.json +++ b/test/fixtures/vpcs_123456_subnets.json @@ -23,7 +23,9 @@ { "id": 12345, "ipv4_range": "10.0.0.0/24", - "ipv6_ranges": "2001:db8::/64" + "ipv6_ranges": [ + "2001:db8::/64" + ] } ], "created": "2018-01-01T00:01:01", diff --git a/test/fixtures/vpcs_123456_subnets_789.json b/test/fixtures/vpcs_123456_subnets_789.json index 038b631fc..5f3275bc9 100644 --- a/test/fixtures/vpcs_123456_subnets_789.json +++ b/test/fixtures/vpcs_123456_subnets_789.json @@ -21,7 +21,9 @@ { "id": 12345, "ipv4_range": "10.0.0.0/24", - "ipv6_ranges": "2001:db8::/64" + "ipv6_ranges": [ + "2001:db8::/64" + ] } ], "created": "2018-01-01T00:01:01", diff --git a/test/unit/objects/vpc_test.py b/test/unit/objects/vpc_test.py index a72284619..34431a3b7 100644 --- a/test/unit/objects/vpc_test.py +++ b/test/unit/objects/vpc_test.py @@ -125,7 +125,7 @@ def validate_vpc_subnet_789(self, subnet: VPCSubnet): self.assertEqual(subnet.databases[0].id, 12345) self.assertEqual(subnet.databases[0].ipv4_range, "10.0.0.0/24") - self.assertEqual(subnet.databases[0].ipv6_ranges, "2001:db8::/64") + self.assertEqual(subnet.databases[0].ipv6_ranges, ["2001:db8::/64"]) self.assertEqual(subnet.created, expected_dt) self.assertEqual(subnet.updated, expected_dt)