Skip to content

Commit c659023

Browse files
committed
feat: update access settings
1 parent 28bcf34 commit c659023

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

hcloud/storage_boxes/client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,25 @@ def reset_password(
470470
json=data,
471471
)
472472
return BoundAction(self._parent.actions, response["action"])
473+
474+
def update_access_settings(
475+
self,
476+
storage_box: StorageBox | BoundStorageBox,
477+
access_settings: StorageBoxAccessSettings,
478+
) -> BoundAction:
479+
"""
480+
Reset the password of a Storage Box.
481+
482+
See https://docs.hetzner.cloud/reference/cloud#TODO
483+
484+
:param storage_box: Storage Box to update.
485+
:param access_settings: Access settings for the Storage Box.
486+
"""
487+
data: dict[str, Any] = access_settings.to_payload()
488+
489+
response = self._client.request(
490+
method="POST",
491+
url=f"{self._base_url}/{storage_box.id}/actions/update_access_settings",
492+
json=data,
493+
)
494+
return BoundAction(self._parent.actions, response["action"])

tests/unit/storage_boxes/test_client.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,32 @@ def test_reset_password(
369369
)
370370

371371
assert_bound_action1(action, resource_client._parent.actions)
372+
373+
def test_update_access_settings(
374+
self,
375+
request_mock: mock.MagicMock,
376+
resource_client: StorageBoxesClient,
377+
action_response,
378+
):
379+
request_mock.return_value = action_response
380+
381+
action = resource_client.update_access_settings(
382+
StorageBox(id=42),
383+
StorageBoxAccessSettings(
384+
reachable_externally=True,
385+
ssh_enabled=True,
386+
webdav_enabled=False,
387+
),
388+
)
389+
390+
request_mock.assert_called_with(
391+
method="POST",
392+
url="/storage_boxes/42/actions/update_access_settings",
393+
json={
394+
"reachable_externally": True,
395+
"ssh_enabled": True,
396+
"webdav_enabled": False,
397+
},
398+
)
399+
400+
assert_bound_action1(action, resource_client._parent.actions)

0 commit comments

Comments
 (0)