Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions nanokvm/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
GetHardwareRsp,
GetHdmiStateRsp,
GetHidModeRsp,
GetHostnameRsp,
GetImagesRsp,
GetInfoRsp,
GetMdnsStateRsp,
Expand All @@ -54,6 +55,7 @@
PasteReq,
SetGpioReq,
SetHidModeReq,
SetHostnameReq,
SetMemoryLimitReq,
SetMouseJigglerReq,
SetOledReq,
Expand Down Expand Up @@ -323,6 +325,22 @@ async def get_hardware(self) -> GetHardwareRsp:
response_model=GetHardwareRsp,
)

async def get_hostname(self) -> GetHostnameRsp:
"""Get the configured hostname."""
return await self._api_request_json(
hdrs.METH_GET,
"/vm/hostname",
response_model=GetHostnameRsp,
)

async def set_hostname(self, hostname: str) -> None:
"""Set the device hostname (applies after reboot)."""
await self._api_request_json(
hdrs.METH_POST,
"/vm/hostname",
data=SetHostnameReq(hostname=hostname),
)

async def get_gpio(self) -> GetGpioRsp:
"""Get GPIO LED status."""
return await self._api_request_json(
Expand Down
8 changes: 8 additions & 0 deletions nanokvm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ class GetInfoRsp(BaseModel):
device_key: str = Field(alias="deviceKey")


class GetHostnameRsp(BaseModel):
hostname: str


class SetHostnameReq(BaseModel):
hostname: str # Applies after reboot


class GetHardwareRsp(BaseModel):
version: HWVersion

Expand Down
Loading