Skip to content

Commit

Permalink
fix: assignee_type is required when creating a primary ip (#409)
Browse files Browse the repository at this point in the history
The `assignee_type` is always required when creating a primary IP, also
when creating an IP in a datacenter (without `assignee_id`).
  • Loading branch information
jooola committed Jul 3, 2024
1 parent 6d33c3c commit bce5e94
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hcloud/primary_ips/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ def create(
data: dict[str, Any] = {
"name": name,
"type": type,
"assignee_type": assignee_type,
"auto_delete": auto_delete,
}
if datacenter is not None:
data["datacenter"] = datacenter.id_or_name
if assignee_id is not None:
data["assignee_type"] = assignee_type
data["assignee_id"] = assignee_id
if labels is not None:
data["labels"] = labels
Expand Down
1 change: 1 addition & 0 deletions tests/unit/primary_ips/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def test_create_with_datacenter(self, primary_ips_client, primary_ip_response):
json={
"name": "my-resource",
"type": "ipv6",
"assignee_type": "server",
"datacenter": "datacenter",
"auto_delete": False,
},
Expand Down

0 comments on commit bce5e94

Please sign in to comment.