Skip to content

Commit 6787ab9

Browse files
committed
feat: add new ip_range param to load balancer attach_to_network
Related to https://docs.hetzner.cloud/changelog#2025-09-11-attach-to-network-support-ip-range
1 parent bbee5a7 commit 6787ab9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

hcloud/load_balancers/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,18 @@ def attach_to_network(
319319
self,
320320
network: Network | BoundNetwork,
321321
ip: str | None = None,
322+
ip_range: str | None = None,
322323
) -> BoundAction:
323324
"""Attaches a Load Balancer to a Network
324325
325326
:param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
326327
:param ip: str
327328
IP to request to be assigned to this Load Balancer
329+
:param ip_range: str
330+
IP range in CIDR block notation of the subnet to attach to.
328331
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
329332
"""
330-
return self._client.attach_to_network(self, network, ip)
333+
return self._client.attach_to_network(self, network, ip, ip_range)
331334

332335
def detach_from_network(self, network: Network | BoundNetwork) -> BoundAction:
333336
"""Detaches a Load Balancer from a Network.
@@ -840,18 +843,23 @@ def attach_to_network(
840843
load_balancer: LoadBalancer | BoundLoadBalancer,
841844
network: Network | BoundNetwork,
842845
ip: str | None = None,
846+
ip_range: str | None = None,
843847
) -> BoundAction:
844848
"""Attach a Load Balancer to a Network.
845849
846850
:param load_balancer: :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or :class:`LoadBalancer <hcloud.load_balancers.domain.LoadBalancer>`
847851
:param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
848852
:param ip: str
849853
IP to request to be assigned to this Load Balancer
854+
:param ip_range: str
855+
IP range in CIDR block notation of the subnet to attach to.
850856
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
851857
"""
852858
data: dict[str, Any] = {"network": network.id}
853859
if ip is not None:
854860
data.update({"ip": ip})
861+
if ip_range is not None:
862+
data.update({"ip_range": ip_range})
855863

856864
response = self._client.request(
857865
url=f"{self._base_url}/{load_balancer.id}/actions/attach_to_network",

0 commit comments

Comments
 (0)