Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion hcloud/load_balancers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,18 @@ def attach_to_network(
self,
network: Network | BoundNetwork,
ip: str | None = None,
ip_range: str | None = None,
) -> BoundAction:
"""Attaches a Load Balancer to a Network

:param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
:param ip: str
IP to request to be assigned to this Load Balancer
:param ip_range: str
IP range in CIDR block notation of the subnet to attach to.
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
"""
return self._client.attach_to_network(self, network, ip)
return self._client.attach_to_network(self, network, ip, ip_range)

def detach_from_network(self, network: Network | BoundNetwork) -> BoundAction:
"""Detaches a Load Balancer from a Network.
Expand Down Expand Up @@ -840,18 +843,23 @@ def attach_to_network(
load_balancer: LoadBalancer | BoundLoadBalancer,
network: Network | BoundNetwork,
ip: str | None = None,
ip_range: str | None = None,
) -> BoundAction:
"""Attach a Load Balancer to a Network.

:param load_balancer: :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or :class:`LoadBalancer <hcloud.load_balancers.domain.LoadBalancer>`
:param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
:param ip: str
IP to request to be assigned to this Load Balancer
:param ip_range: str
IP range in CIDR block notation of the subnet to attach to.
:return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
"""
data: dict[str, Any] = {"network": network.id}
if ip is not None:
data.update({"ip": ip})
if ip_range is not None:
data.update({"ip_range": ip_range})

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