Skip to content

Commit 5232731

Browse files
committed
feat: change_home_directory
1 parent a763372 commit 5232731

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

hcloud/storage_boxes/client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,3 +1046,27 @@ def delete_subaccount(
10461046
return DeleteStorageBoxSubaccountResponse(
10471047
action=BoundAction(self._parent.actions, response["action"]),
10481048
)
1049+
1050+
def change_subaccount_home_directory(
1051+
self,
1052+
subaccount: StorageBoxSubaccount | BoundStorageBoxSubaccount,
1053+
home_directory: str,
1054+
) -> BoundAction:
1055+
"""
1056+
Change the home directory of a Storage Box Subaccount.
1057+
1058+
See https://docs.hetzner.cloud/reference/hetzner#storage-box-subaccount-actions-change-home-directory
1059+
1060+
:param subaccount: Storage Box Subaccount to update.
1061+
:param home_directory: Home directory for the Subaccount.
1062+
"""
1063+
data: dict[str, Any] = {
1064+
"home_directory": home_directory,
1065+
}
1066+
1067+
response = self._client.request(
1068+
method="POST",
1069+
url=f"{self._base_url}/{subaccount.storage_box.id}/subaccounts/{subaccount.id}/actions/change_home_directory",
1070+
json=data,
1071+
)
1072+
return BoundAction(self._parent.actions, response["action"])

tests/unit/storage_boxes/test_client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,3 +1045,26 @@ def test_delete_subaccount(
10451045
)
10461046

10471047
assert_bound_action1(result.action, resource_client._parent.actions)
1048+
1049+
def test_change_subaccount_home_directory(
1050+
self,
1051+
request_mock: mock.MagicMock,
1052+
resource_client: StorageBoxesClient,
1053+
action_response,
1054+
):
1055+
request_mock.return_value = action_response
1056+
1057+
action = resource_client.change_subaccount_home_directory(
1058+
StorageBoxSubaccount(id=45, storage_box=StorageBox(42)),
1059+
home_directory="path",
1060+
)
1061+
1062+
request_mock.assert_called_with(
1063+
method="POST",
1064+
url="/storage_boxes/42/subaccounts/45/actions/change_home_directory",
1065+
json={
1066+
"home_directory": "path",
1067+
},
1068+
)
1069+
1070+
assert_bound_action1(action, resource_client._parent.actions)

0 commit comments

Comments
 (0)