Skip to content

Commit

Permalink
feat: set system configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuagruenstein committed Dec 22, 2024
1 parent fc28784 commit 3e19156
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion intellinet_pdu_ctrl/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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())
8 changes: 8 additions & 0 deletions intellinet_pdu_ctrl/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

0 comments on commit 3e19156

Please sign in to comment.