File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -396,3 +396,28 @@ def get_actions(
396396 status = status ,
397397 sort = sort ,
398398 )
399+
400+ def change_protection (
401+ self ,
402+ storage_box : StorageBox | BoundStorageBox ,
403+ * ,
404+ delete : bool | None = None ,
405+ ) -> BoundAction :
406+ """
407+ Changes the protection of a Storage Box.
408+
409+ See https://docs.hetzner.cloud/reference/cloud#TODO
410+
411+ :param storage_box: Storage Box to update.
412+ :param delete: Prevents the Storage Box from being deleted.
413+ """
414+ data : dict [str , Any ] = {}
415+ if delete is not None :
416+ data ["delete" ] = delete
417+
418+ response = self ._client .request (
419+ method = "POST" ,
420+ url = f"{ self ._base_url } /{ storage_box .id } /actions/change_protection" ,
421+ json = data ,
422+ )
423+ return BoundAction (self ._parent .actions , response ["action" ])
Original file line number Diff line number Diff line change @@ -309,3 +309,21 @@ def test_get_folders(
309309 )
310310
311311 assert result .folders == ["dir1" , "dir2" ]
312+
313+ def test_change_protection (
314+ self ,
315+ request_mock : mock .MagicMock ,
316+ resource_client : StorageBoxesClient ,
317+ action_response ,
318+ ):
319+ request_mock .return_value = action_response
320+
321+ action = resource_client .change_protection (StorageBox (id = 42 ), delete = True )
322+
323+ request_mock .assert_called_with (
324+ method = "POST" ,
325+ url = "/storage_boxes/42/actions/change_protection" ,
326+ json = {"delete" : True },
327+ )
328+
329+ assert_bound_action1 (action , resource_client ._parent .actions )
You can’t perform that action at this time.
0 commit comments