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
11 changes: 10 additions & 1 deletion hcloud/servers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def attach_to_network(
network: Network | BoundNetwork,
ip: str | None = None,
alias_ips: list[str] | None = None,
ip_range: str | None = None,
) -> BoundAction:
"""Attaches a server to a network

Expand All @@ -432,9 +433,11 @@ def attach_to_network(
IP to request to be assigned to this server
:param alias_ips: List[str]
New alias IPs to set for this server.
: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, alias_ips)
return self._client.attach_to_network(self, network, ip, alias_ips, ip_range)

def detach_from_network(self, network: Network | BoundNetwork) -> BoundAction:
"""Detaches a server from a network.
Expand Down Expand Up @@ -1154,6 +1157,7 @@ def attach_to_network(
network: Network | BoundNetwork,
ip: str | None = None,
alias_ips: list[str] | None = None,
ip_range: str | None = None,
) -> BoundAction:
"""Attaches a server to a network

Expand All @@ -1163,13 +1167,18 @@ def attach_to_network(
IP to request to be assigned to this server
:param alias_ips: List[str]
New alias IPs to set for this server.
: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 alias_ips is not None:
data.update({"alias_ips": alias_ips})
if ip_range is not None:
data.update({"ip_range": ip_range})

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