File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -421,3 +421,25 @@ def change_protection(
421421 json = data ,
422422 )
423423 return BoundAction (self ._parent .actions , response ["action" ])
424+
425+ def change_type (
426+ self ,
427+ storage_box : StorageBox | BoundStorageBox ,
428+ storage_box_type : StorageBoxType | BoundStorageBoxType ,
429+ ) -> BoundAction :
430+ """
431+ Changes the type of a Storage Box.
432+
433+ See https://docs.hetzner.cloud/reference/cloud#TODO
434+
435+ :param storage_box: Storage Box to update.
436+ :param storage_box_type: Type of Storage Box to change to.
437+ """
438+ data : dict [str , Any ] = {"storage_box_type" : storage_box_type .id_or_name }
439+
440+ response = self ._client .request (
441+ method = "POST" ,
442+ url = f"{ self ._base_url } /{ storage_box .id } /actions/change_type" ,
443+ json = data ,
444+ )
445+ return BoundAction (self ._parent .actions , response ["action" ])
Original file line number Diff line number Diff line change @@ -327,3 +327,24 @@ def test_change_protection(
327327 )
328328
329329 assert_bound_action1 (action , resource_client ._parent .actions )
330+
331+ def test_change_type (
332+ self ,
333+ request_mock : mock .MagicMock ,
334+ resource_client : StorageBoxesClient ,
335+ action_response ,
336+ ):
337+ request_mock .return_value = action_response
338+
339+ action = resource_client .change_type (
340+ StorageBox (id = 42 ),
341+ StorageBoxType (name = "bx21" ),
342+ )
343+
344+ request_mock .assert_called_with (
345+ method = "POST" ,
346+ url = "/storage_boxes/42/actions/change_type" ,
347+ json = {"storage_box_type" : "bx21" },
348+ )
349+
350+ assert_bound_action1 (action , resource_client ._parent .actions )
You can’t perform that action at this time.
0 commit comments