Skip to content

Commit 4375dc6

Browse files
83hd4djooola
andauthored
fix: allow omitting datacenter when creating a primary ip (#171)
* omitting "datacenter" if "assignee_id" is passed * fix: allow omitting the datacenter value when creating a primary IP --------- Co-authored-by: jo <ljonas@riseup.net>
1 parent e8ec3a3 commit 4375dc6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

hcloud/primary_ips/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def get_by_name(self, name: str) -> BoundPrimaryIP | None:
178178
def create(
179179
self,
180180
type: str,
181-
datacenter: Datacenter | BoundDatacenter,
181+
# TODO: Make the datacenter argument optional
182+
datacenter: Datacenter | BoundDatacenter | None,
182183
name: str,
183184
assignee_type: str | None = "server",
184185
assignee_id: int | None = None,
@@ -203,10 +204,11 @@ def create(
203204
"type": type,
204205
"assignee_type": assignee_type,
205206
"auto_delete": auto_delete,
206-
"datacenter": datacenter.id_or_name,
207207
"name": name,
208208
}
209-
if assignee_id:
209+
if datacenter is not None:
210+
data["datacenter"] = datacenter.id_or_name
211+
if assignee_id is not None:
210212
data["assignee_id"] = assignee_id
211213
if labels is not None:
212214
data["labels"] = labels

0 commit comments

Comments
 (0)