Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions 8 linode_api4/objects/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_ranges: Optional[List[str]] = None


class VPCSubnet(DerivedBase):
"""
An instance of a VPC subnet.
Expand All @@ -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),
}
Expand Down
9 changes: 9 additions & 0 deletions 9 test/fixtures/vpcs_123456_subnets.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
]
}
],
"databases": [
{
"id": 12345,
"ipv4_range": "10.0.0.0/24",
"ipv6_ranges": [
"2001:db8::/64"
]
}
],
"created": "2018-01-01T00:01:01",
"updated": "2018-01-01T00:01:01"
}
Expand Down
9 changes: 9 additions & 0 deletions 9 test/fixtures/vpcs_123456_subnets_789.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
]
}
],
"databases": [
{
"id": 12345,
"ipv4_range": "10.0.0.0/24",
"ipv6_ranges": [
"2001:db8::/64"
]
}
],
"created": "2018-01-01T00:01:01",
"updated": "2018-01-01T00:01:01"
}
6 changes: 6 additions & 0 deletions 6 test/unit/objects/vpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_ranges, ["2001:db8::/64"])

self.assertEqual(subnet.created, expected_dt)
self.assertEqual(subnet.updated, expected_dt)

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.