TPT-4602: Added support for NAT Service- #1033 - #738
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are a few correctness/maintainability issues in newly added NAT Gateway typing/fixtures (notably inconsistent NAT Gateway URL vs ID and mismatched NATGatewayType.id typing) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds NAT Gateway (NAT Service) support across VPC-related models and the Networking group in the Linode API v4 Python SDK, along with unit tests and fixtures to validate serialization and parsing of NAT Gateway data.
Changes:
- Added NAT Gateway models/endpoints under
networking(list/create/types/settings + per-gateway address/interface helpers). - Extended VPC subnet creation/update and VPC/VPC-IP/Linode-interface response parsing to include NAT Gateway data.
- Added/updated unit tests and fixtures to cover NAT Gateway serialization and response parsing.
File summaries
| File | Description |
|---|---|
| test/unit/objects/vpc_test.py | Adds subnet create/update tests for natgateway serialization and parsing assertions. |
| test/unit/objects/networking_test.py | Adds object-level tests for NATGateway methods and nested models. |
| test/unit/objects/linode_interface_test.py | Adds assertions for NAT Gateway data under VPC IPv4 interface config. |
| test/unit/groups/vpc_test.py | Adds group-level test for VPC create with subnet NAT Gateway serialization. |
| test/unit/groups/networking_test.py | Adds group-level tests for NAT Gateway list/create/types/settings. |
| test/fixtures/vpcs_ips.json | Adds natgateway payload under VPC IP fixtures. |
| test/fixtures/vpcs_123456_subnets.json | Adds natgateway payload under subnet list fixture. |
| test/fixtures/vpcs_123456_subnets_789.json | Adds natgateway payload under subnet detail fixture. |
| test/fixtures/vpcs_123456_ips.json | Adds natgateway payload under VPC-specific IP list fixture. |
| test/fixtures/networking_natgateways.json | New NAT Gateways list fixture. |
| test/fixtures/networking_natgateways_types.json | New NAT Gateway types fixture. |
| test/fixtures/networking_natgateways_settings.json | New NAT Gateway settings fixture. |
| test/fixtures/networking_natgateways_42_interfaces.json | New NAT Gateway interfaces fixture. |
| test/fixtures/networking_natgateways_42_addresses.json | New NAT Gateway address-assignments list fixture. |
| test/fixtures/networking_natgateways_42_addresses_203.0.113.42.json | New NAT Gateway address-assignment detail fixture. |
| test/fixtures/networking_natgateways_42_addresses_203.0.113.42_interfaces.json | New per-address interfaces fixture. |
| test/fixtures/linode_instances_124_upgrade-interfaces.json | Adds NAT Gateway data under interface VPC IPv4 fixture. |
| test/fixtures/linode_instances_124_interfaces.json | Adds NAT Gateway data under interfaces list fixture. |
| test/fixtures/linode_instances_124_interfaces_456.json | Adds NAT Gateway data under single interface fixture. |
| linode_api4/objects/vpc.py | Adds VPC subnet NAT Gateway option/response models and subnet create support. |
| linode_api4/objects/networking.py | Adds NAT Gateway-related models and NATGateway object methods. |
| linode_api4/objects/linode_interfaces.py | Adds NAT Gateway parsing under VPC IPv4 interface config. |
| linode_api4/groups/networking.py | Adds Networking group methods for NAT Gateways (list/create/types/settings). |
Review details
Suppressed comments (2)
linode_api4/objects/vpc.py:150
addressesis typed asList[str]but defaults toNone, which is inconsistent and can causeJSONObject._serializeto include"addresses": null. Make itOptional[List[str]]so missing/unknown values are omitted during serialization.
id: int = 0
label: str = ""
addresses: List[str] = None
portset_assignments: int = 0
linode_api4/objects/vpc.py:154
portsetsis typed asList[...]but initialized toNone(and explicitly documented as sometimes unavailable). Make itOptional[List[...]] = Noneto align typing with the actual runtime value and JSONObject serialization rules.
portsets: List[VPCSubnetNATGatewayPortset] = (
None # NOTE: This field may not be available to all users.
)
- Files reviewed: 23/23 changed files
- Comments generated: 8
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dbbda77 to
f4252a2
Compare
📝 Description
Added support and unit tests for NAT Service for VPC.
✔️ How to Test
make test-unit