File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -1094,3 +1094,25 @@ def reset_subaccount_password(
10941094 json = data ,
10951095 )
10961096 return BoundAction (self ._parent .actions , response ["action" ])
1097+
1098+ def update_subaccount_access_settings (
1099+ self ,
1100+ subaccount : StorageBoxSubaccount | BoundStorageBoxSubaccount ,
1101+ access_settings : StorageBoxSubaccountAccessSettings ,
1102+ ) -> BoundAction :
1103+ """
1104+ Update the access settings of a Storage Box Subaccount.
1105+
1106+ See https://docs.hetzner.cloud/reference/hetzner#storage-box-subaccount-actions-update-access-settings
1107+
1108+ :param subaccount: Storage Box Subaccount to update.
1109+ :param access_settings: Access settings for the Subaccount.
1110+ """
1111+ data : dict [str , Any ] = access_settings .to_payload ()
1112+
1113+ response = self ._client .request (
1114+ method = "POST" ,
1115+ url = f"{ self ._base_url } /{ subaccount .storage_box .id } /subaccounts/{ subaccount .id } /actions/update_access_settings" ,
1116+ json = data ,
1117+ )
1118+ return BoundAction (self ._parent .actions , response ["action" ])
Original file line number Diff line number Diff line change @@ -1091,3 +1091,32 @@ def test_reset_subaccount_password(
10911091 )
10921092
10931093 assert_bound_action1 (action , resource_client ._parent .actions )
1094+
1095+ def test_update_subaccount_access_settings (
1096+ self ,
1097+ request_mock : mock .MagicMock ,
1098+ resource_client : StorageBoxesClient ,
1099+ action_response ,
1100+ ):
1101+ request_mock .return_value = action_response
1102+
1103+ action = resource_client .update_subaccount_access_settings (
1104+ StorageBoxSubaccount (id = 45 , storage_box = StorageBox (42 )),
1105+ access_settings = StorageBoxSubaccountAccessSettings (
1106+ reachable_externally = True ,
1107+ ssh_enabled = True ,
1108+ samba_enabled = False ,
1109+ ),
1110+ )
1111+
1112+ request_mock .assert_called_with (
1113+ method = "POST" ,
1114+ url = "/storage_boxes/42/subaccounts/45/actions/update_access_settings" ,
1115+ json = {
1116+ "reachable_externally" : True ,
1117+ "ssh_enabled" : True ,
1118+ "samba_enabled" : False ,
1119+ },
1120+ )
1121+
1122+ assert_bound_action1 (action , resource_client ._parent .actions )
You can’t perform that action at this time.
0 commit comments