Skip to content

Commit 1970d84

Browse files
authored
feat!: return full rebuild response in Client.servers.rebuild (#406)
The single action returned was deprecated and is now removed in favor of the full rebuild response with a root password.
1 parent 8375261 commit 1970d84

2 files changed

Lines changed: 4 additions & 21 deletions

File tree

hcloud/servers/client.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import warnings
43
from datetime import datetime
54
from typing import TYPE_CHECKING, Any, NamedTuple
65

@@ -1006,9 +1005,9 @@ def rebuild(
10061005
self,
10071006
server: Server | BoundServer,
10081007
image: Image | BoundImage,
1009-
*,
1010-
return_response: bool = False,
1011-
) -> RebuildResponse | BoundAction:
1008+
# pylint: disable=unused-argument
1009+
**kwargs: Any,
1010+
) -> RebuildResponse:
10121011
"""Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server.
10131012
10141013
:param server: Server to rebuild
@@ -1022,22 +1021,11 @@ def rebuild(
10221021
json=data,
10231022
)
10241023

1025-
rebuild_response = RebuildResponse(
1024+
return RebuildResponse(
10261025
action=BoundAction(self._client.actions, response["action"]),
10271026
root_password=response.get("root_password"),
10281027
)
10291028

1030-
if not return_response:
1031-
warnings.warn(
1032-
"Returning only the 'action' is deprecated, please set the "
1033-
"'return_response' keyword argument to 'True' to return the full "
1034-
"rebuild response and update your code accordingly.",
1035-
DeprecationWarning,
1036-
stacklevel=2,
1037-
)
1038-
return rebuild_response.action
1039-
return rebuild_response
1040-
10411029
def enable_backup(self, server: Server | BoundServer) -> BoundAction:
10421030
"""Enables and configures the automatic daily backup option for the server. Enabling automatic backups will increase the price of the server by 20%.
10431031

tests/unit/servers/test_client.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,11 +1085,6 @@ def test_rebuild(self, servers_client, server, generic_action):
10851085
assert response.action.progress == 0
10861086
assert response.root_password is None or isinstance(response.root_password, str)
10871087

1088-
def test_rebuild_return_response_deprecation(self, servers_client, generic_action):
1089-
servers_client._client.request.return_value = generic_action
1090-
with pytest.deprecated_call():
1091-
servers_client.rebuild(Server(id=1), Image(name="ubuntu-20.04"))
1092-
10931088
@pytest.mark.parametrize(
10941089
"server", [Server(id=1), BoundServer(mock.MagicMock(), dict(id=1))]
10951090
)

0 commit comments

Comments
 (0)