diff --git a/intellinet_pdu_ctrl/api.py b/intellinet_pdu_ctrl/api.py index 3522fcb..a0a8222 100644 --- a/intellinet_pdu_ctrl/api.py +++ b/intellinet_pdu_ctrl/api.py @@ -119,7 +119,9 @@ async def set_credentials(self, new_credentials: aiohttp.BasicAuth) -> None: status = await self.get_status() - assert status.user_verify_result == UserVerifyResult.CREDENTIALS_CHANGED + assert ( + status.user_verify_result == UserVerifyResult.CREDENTIALS_CHANGED + ), f"Credentials were not changed {status.user_verify_result=}" self.session._default_auth = new_credentials @@ -137,3 +139,8 @@ async def get_system_configuration(self) -> SystemConfiguration: return SystemConfiguration.from_xml( await self._get_request(PDUEndpoints.system) ) + + async def set_system_configuration( + self, system_config: SystemConfiguration + ) -> None: + await self._post_request(PDUEndpoints.system, data=system_config.to_dict()) diff --git a/intellinet_pdu_ctrl/types.py b/intellinet_pdu_ctrl/types.py index ad0d00f..f67e679 100644 --- a/intellinet_pdu_ctrl/types.py +++ b/intellinet_pdu_ctrl/types.py @@ -220,3 +220,11 @@ def from_xml(cls, e: et._Element) -> Self: administrator=find_input_value_in_xml(e, "admin"), system_location=find_input_value_in_xml(e, "loc"), ) + + def to_dict(self) -> dict[str, str]: + return { + "mac": self.mac_address, + "sysnm": self.system_name, + "admin": self.administrator, + "loc": self.system_location, + }