From bce5e940e27f2c6d9d50016b5828c79aadfc4401 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Wed, 3 Jul 2024 12:52:56 +0200 Subject: [PATCH] fix: `assignee_type` is required when creating a primary ip (#409) The `assignee_type` is always required when creating a primary IP, also when creating an IP in a datacenter (without `assignee_id`). --- hcloud/primary_ips/client.py | 2 +- tests/unit/primary_ips/test_client.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hcloud/primary_ips/client.py b/hcloud/primary_ips/client.py index 40b47cb9..41ef3bfb 100644 --- a/hcloud/primary_ips/client.py +++ b/hcloud/primary_ips/client.py @@ -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 diff --git a/tests/unit/primary_ips/test_client.py b/tests/unit/primary_ips/test_client.py index dd4b1aae..9db08fe4 100644 --- a/tests/unit/primary_ips/test_client.py +++ b/tests/unit/primary_ips/test_client.py @@ -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, },