|
11 | 11 | if TYPE_CHECKING: |
12 | 12 | from types import TracebackType |
13 | 13 |
|
14 | | - from ._types import Device, NetworkInfo, Ram, State |
| 14 | + from ._types import ( |
| 15 | + ActionsConfig, |
| 16 | + ButtonsConfig, |
| 17 | + ConfigDump, |
| 18 | + DdiConfig, |
| 19 | + Device, |
| 20 | + InputsConfig, |
| 21 | + LuxConfig, |
| 22 | + NetworkInfo, |
| 23 | + OutputsConfig, |
| 24 | + PirsConfig, |
| 25 | + Ram, |
| 26 | + ServicesConfig, |
| 27 | + State, |
| 28 | + SystemConfig, |
| 29 | + ) |
15 | 30 |
|
16 | 31 |
|
17 | 32 | class RestClient: |
@@ -78,15 +93,21 @@ async def close(self) -> None: |
78 | 93 | if self._session_owner: |
79 | 94 | await self._session.close() |
80 | 95 |
|
81 | | - async def _request(self, method: Literal["GET"], endpoint: URL) -> Any: # noqa: ANN401 The return value really could be anything! |
| 96 | + async def _request( |
| 97 | + self, |
| 98 | + method: Literal["GET"], |
| 99 | + endpoint: URL, |
| 100 | + *, |
| 101 | + ignore_content_type: bool = False, |
| 102 | + ) -> Any: # noqa: ANN401 The return value really could be anything! |
82 | 103 | async with self._session.request( |
83 | 104 | method, |
84 | 105 | self._base_url.join(endpoint), |
85 | 106 | headers=self._headers, |
86 | 107 | timeout=self._timeout, |
87 | 108 | ) as resp: |
88 | 109 | resp.raise_for_status() |
89 | | - return await resp.json() |
| 110 | + return await resp.json(content_type=None if ignore_content_type else CONTENT_TYPE_JSON) |
90 | 111 |
|
91 | 112 | async def get_firmware_version(self) -> str: |
92 | 113 | """Get the firmware version of the dingz device. |
@@ -134,6 +155,47 @@ async def get_network_info(self) -> NetworkInfo: |
134 | 155 | """Get general network settings.""" |
135 | 156 | return await self._request("GET", URL("/api/v1/info")) |
136 | 157 |
|
| 158 | + async def get_button_config(self) -> ButtonsConfig: |
| 159 | + """Get the button configuration.""" |
| 160 | + return await self._request("GET", URL("/api/v1/button_config")) |
| 161 | + |
| 162 | + async def get_input_config(self) -> InputsConfig: |
| 163 | + """Get the input configuration.""" |
| 164 | + return await self._request("GET", URL("/api/v1/input_config")) |
| 165 | + |
| 166 | + async def get_pir_config(self) -> PirsConfig: |
| 167 | + """Get the PIR configuration.""" |
| 168 | + return await self._request("GET", URL("/api/v1/pir_config")) |
| 169 | + |
| 170 | + async def get_lux_config(self) -> LuxConfig: |
| 171 | + """Get the Lux configuration.""" |
| 172 | + return await self._request("GET", URL("/api/v1/lux_config")) |
| 173 | + |
| 174 | + async def get_output_config(self) -> OutputsConfig: |
| 175 | + """Get the output configuration.""" |
| 176 | + return await self._request("GET", URL("/api/v1/output_config")) |
| 177 | + |
| 178 | + async def get_services_config(self) -> ServicesConfig: |
| 179 | + """Get the services configuration.""" |
| 180 | + return await self._request("GET", URL("/api/v1/services_config")) |
| 181 | + |
| 182 | + async def get_system_config(self) -> SystemConfig: |
| 183 | + """Get the system configuration.""" |
| 184 | + return await self._request("GET", URL("/api/v1/system_config")) |
| 185 | + |
| 186 | + async def get_ddi_config(self) -> DdiConfig: |
| 187 | + """Get the DDI configuration.""" |
| 188 | + return await self._request("GET", URL("/api/v1/ddi_config")) |
| 189 | + |
| 190 | + async def get_actions_config(self) -> ActionsConfig: |
| 191 | + """Get the actions configuration.""" |
| 192 | + return await self._request("GET", URL("/api/v1/actions")) |
| 193 | + |
| 194 | + async def get_config_dump(self) -> ConfigDump: |
| 195 | + """Get the full configuration dump.""" |
| 196 | + # dump_config reports content type application/octet-stream for some reason |
| 197 | + return await self._request("GET", URL("/api/v1/dump_config"), ignore_content_type=True) |
| 198 | + |
137 | 199 | async def get_state(self) -> State: |
138 | 200 | """Get the full dingz status. |
139 | 201 |
|
|
0 commit comments