Skip to content

Commit

Permalink
fix: allow omitting the datacenter value when creating a primary IP
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Aug 7, 2023
1 parent 4399750 commit 2e8f6f1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hcloud/primary_ips/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def get_by_name(self, name: str) -> BoundPrimaryIP | None:
def create(
self,
type: str,
datacenter: Datacenter | BoundDatacenter,
# TODO: Make the datacenter argument optional
datacenter: Datacenter | BoundDatacenter | None,
name: str,
assignee_type: str | None = "server",
assignee_id: int | None = None,
Expand All @@ -203,12 +204,12 @@ def create(
"type": type,
"assignee_type": assignee_type,
"auto_delete": auto_delete,
"datacenter": datacenter.id_or_name,
"name": name,
}
if assignee_id:
if datacenter is not None:
data["datacenter"] = datacenter.id_or_name
if assignee_id is not None:
data["assignee_id"] = assignee_id
data.pop("datacenter")
if labels is not None:
data["labels"] = labels

Expand Down

0 comments on commit 2e8f6f1

Please sign in to comment.