Skip to content

Commit eb79524

Browse files
authored
feat: add new ip_range param to server attach_to_network (#561)
Related to https://docs.hetzner.cloud/changelog#2025-09-11-attach-to-network-support-ip-range
1 parent 18466c4 commit eb79524

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

hcloud/servers/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def attach_to_network(
424424
network: Network | BoundNetwork,
425425
ip: str | None = None,
426426
alias_ips: list[str] | None = None,
427+
ip_range: str | None = None,
427428
) -> BoundAction:
428429
"""Attaches a server to a network
429430
@@ -432,9 +433,11 @@ def attach_to_network(
432433
IP to request to be assigned to this server
433434
:param alias_ips: List[str]
434435
New alias IPs to set for this server.
436+
:param ip_range: str
437+
IP range in CIDR block notation of the subnet to attach to.
435438
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
436439
"""
437-
return self._client.attach_to_network(self, network, ip, alias_ips)
440+
return self._client.attach_to_network(self, network, ip, alias_ips, ip_range)
438441

439442
def detach_from_network(self, network: Network | BoundNetwork) -> BoundAction:
440443
"""Detaches a server from a network.
@@ -1154,6 +1157,7 @@ def attach_to_network(
11541157
network: Network | BoundNetwork,
11551158
ip: str | None = None,
11561159
alias_ips: list[str] | None = None,
1160+
ip_range: str | None = None,
11571161
) -> BoundAction:
11581162
"""Attaches a server to a network
11591163
@@ -1163,13 +1167,18 @@ def attach_to_network(
11631167
IP to request to be assigned to this server
11641168
:param alias_ips: List[str]
11651169
New alias IPs to set for this server.
1170+
:param ip_range: str
1171+
IP range in CIDR block notation of the subnet to attach to.
11661172
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
11671173
"""
11681174
data: dict[str, Any] = {"network": network.id}
11691175
if ip is not None:
11701176
data.update({"ip": ip})
11711177
if alias_ips is not None:
11721178
data.update({"alias_ips": alias_ips})
1179+
if ip_range is not None:
1180+
data.update({"ip_range": ip_range})
1181+
11731182
response = self._client.request(
11741183
url=f"{self._base_url}/{server.id}/actions/attach_to_network",
11751184
method="POST",

0 commit comments

Comments
 (0)