TPT-4278: python-sdk: Implement support for Reserved IP for IPv4#672
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Reserved IPv4 (Reserved IP) support across the SDK, including new networking objects, networking group endpoints, and integration with existing tagging and allocation flows.
Changes:
- Introduces Reserved IP models (
ReservedIPAddress,ReservedIPType,ReservedIPAssignedEntity) and exposesreserved/tags/assigned_entityonIPAddress. - Adds networking group methods for listing/creating reserved IPs and fetching reserved IP types/pricing.
- Extends tagging and allocation APIs/tests to support reserved IPv4 assignment (Instance/NodeBalancer/Tag flows), plus new fixtures and pytest config.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/objects/tag_test.py | Adds unit coverage for tagged reserved IPv4 objects and tag creation with reserved IPv4s. |
| test/unit/objects/networking_test.py | Adds unit coverage for Reserved IP fields, save/delete flows, and Instance IP allocation with explicit address. |
| test/unit/groups/networking_test.py | Adds unit coverage for networking group reserved IP list/create/types and reserved-vs-ephemeral allocation behavior. |
| test/fixtures/networking_reserved_ips.json | Fixture data for listing reserved IPs. |
| test/fixtures/networking_reserved_ips_types.json | Fixture data for reserved IP type pricing. |
| pytest.ini | Adds pytest discovery defaults and marker declarations. |
| conftest.py | Ensures repo root is importable for pytest runs from arbitrary working dirs. |
| linode_api4/objects/tag.py | Enables tagged object resolution for reserved_ipv4_address and supports non-id identifiers via id_attribute. |
| linode_api4/objects/networking.py | Adds Reserved IP object models and new/updated IP-related properties. |
| linode_api4/objects/linode.py | Extends Instance.ip_allocate to optionally assign a reserved IPv4 address. |
| linode_api4/groups/tag.py | Adds reserved_ipv4_addresses support to tag creation. |
| linode_api4/groups/nodebalancer.py | Adds optional ipv4 param to assign a reserved IPv4 at NodeBalancer creation. |
| linode_api4/groups/networking.py | Extends ip_allocate for reserved IP allocation and adds reserved IP list/create/types group methods. |
| linode_api4/groups/linode.py | Adds ipv4 parameter for assigning reserved IPv4s at instance creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| data = { | ||
| "type": "ipv4", | ||
| "public": public, | ||
| } | ||
|
|
There was a problem hiding this comment.
ip_allocate's docstring describes required arguments (linode required when reserved=False; region or linode required when reserved=True), but the implementation never validates these combinations. This allows requests to be sent without linode_id/region (or with region while reserved is False), which will fail at the API with a less actionable error. Add explicit argument validation (raise ValueError) to enforce the documented contract before building/sending the request body.
| entities=[], | ||
| ): |
There was a problem hiding this comment.
entities uses a mutable default ([]). Even though this method currently only iterates it, mutable defaults are easy to misuse later and are discouraged because they can create cross-call shared state if mutated. Prefer entities=None and then set entities = entities or [] inside the function.
📝 Description
Add full Reserved IP support to the Python SDK (linode_api4-python). Currently there is no reserved IP support in the SDK. This story covers new object classes, networking group methods, and updates to existing objects.
✔️ How to Test