diff --git a/src/infuse_iot/api_client/api/admin/__init__.py b/src/infuse_iot/api_client/api/admin/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/infuse_iot/api_client/api/admin/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/infuse_iot/api_client/api/admin/generate_api_key.py b/src/infuse_iot/api_client/api/admin/generate_api_key.py new file mode 100644 index 0000000..4e3d800 --- /dev/null +++ b/src/infuse_iot/api_client/api/admin/generate_api_key.py @@ -0,0 +1,169 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.error import Error +from ...models.generate_api_key_body import GenerateAPIKeyBody +from ...models.generated_api_key import GeneratedAPIKey +from ...types import Response + + +def _get_kwargs( + *, + body: GenerateAPIKeyBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/admin/apiKey", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Error | GeneratedAPIKey | None: + if response.status_code == 200: + response_200 = GeneratedAPIKey.from_dict(response.json()) + + return response_200 + if response.status_code == 400: + response_400 = Error.from_dict(response.json()) + + return response_400 + if response.status_code == 500: + response_500 = Error.from_dict(response.json()) + + return response_500 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | GeneratedAPIKey]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: GenerateAPIKeyBody, +) -> Response[Error | GeneratedAPIKey]: + """Generate an API key + + Args: + body (GenerateAPIKeyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Error, GeneratedAPIKey]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + body: GenerateAPIKeyBody, +) -> Error | GeneratedAPIKey | None: + """Generate an API key + + Args: + body (GenerateAPIKeyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Error, GeneratedAPIKey] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: GenerateAPIKeyBody, +) -> Response[Error | GeneratedAPIKey]: + """Generate an API key + + Args: + body (GenerateAPIKeyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Error, GeneratedAPIKey]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + body: GenerateAPIKeyBody, +) -> Error | GeneratedAPIKey | None: + """Generate an API key + + Args: + body (GenerateAPIKeyBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Error, GeneratedAPIKey] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/board/create_board.py b/src/infuse_iot/api_client/api/board/create_board.py index 70eca07..fee19cc 100644 --- a/src/infuse_iot/api_client/api/board/create_board.py +++ b/src/infuse_iot/api_client/api/board/create_board.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -30,9 +30,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Board]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Board | None: if response.status_code == 201: response_201 = Board.from_dict(response.json()) @@ -49,9 +47,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Board]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,9 +58,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewBoard, -) -> Response[Union[Any, Board]]: +) -> Response[Any | Board]: """Create a new board Args: @@ -91,9 +87,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewBoard, -) -> Optional[Union[Any, Board]]: +) -> Any | Board | None: """Create a new board Args: @@ -115,9 +111,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewBoard, -) -> Response[Union[Any, Board]]: +) -> Response[Any | Board]: """Create a new board Args: @@ -142,9 +138,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewBoard, -) -> Optional[Union[Any, Board]]: +) -> Any | Board | None: """Create a new board Args: diff --git a/src/infuse_iot/api_client/api/board/get_board_by_id.py b/src/infuse_iot/api_client/api/board/get_board_by_id.py index 0ea48f8..dd79470 100644 --- a/src/infuse_iot/api_client/api/board/get_board_by_id.py +++ b/src/infuse_iot/api_client/api/board/get_board_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast from uuid import UUID import httpx @@ -21,9 +21,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Board]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Board | None: if response.status_code == 200: response_200 = Board.from_dict(response.json()) @@ -37,9 +35,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Board]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,8 +47,8 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Board]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Board]: """Get a board by ID Args: @@ -80,8 +76,8 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Board]]: + client: AuthenticatedClient | Client, +) -> Any | Board | None: """Get a board by ID Args: @@ -104,8 +100,8 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Board]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Board]: """Get a board by ID Args: @@ -131,8 +127,8 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Board]]: + client: AuthenticatedClient | Client, +) -> Any | Board | None: """Get a board by ID Args: diff --git a/src/infuse_iot/api_client/api/board/get_boards.py b/src/infuse_iot/api_client/api/board/get_boards.py index f655c14..437554b 100644 --- a/src/infuse_iot/api_client/api/board/get_boards.py +++ b/src/infuse_iot/api_client/api/board/get_boards.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any from uuid import UUID import httpx @@ -30,7 +30,7 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list["Board"]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list["Board"] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -46,7 +46,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list["Board"]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list["Board"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -57,7 +57,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, ) -> Response[list["Board"]]: """Get all boards in an organisation @@ -86,9 +86,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, -) -> Optional[list["Board"]]: +) -> list["Board"] | None: """Get all boards in an organisation Args: @@ -110,7 +110,7 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, ) -> Response[list["Board"]]: """Get all boards in an organisation @@ -137,9 +137,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, -) -> Optional[list["Board"]]: +) -> list["Board"] | None: """Get all boards in an organisation Args: diff --git a/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py b/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py index c3699c7..968f133 100644 --- a/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py +++ b/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast from uuid import UUID import httpx @@ -13,8 +13,8 @@ def _get_kwargs( id: UUID, *, - metadata_name: Union[Unset, str] = UNSET, - metadata_value: Union[Unset, str] = UNSET, + metadata_name: Unset | str = UNSET, + metadata_value: Unset | str = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -33,9 +33,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, list["Device"]]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | list["Device"] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -55,8 +53,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, list["Device"]]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any | list["Device"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -68,10 +66,10 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], - metadata_name: Union[Unset, str] = UNSET, - metadata_value: Union[Unset, str] = UNSET, -) -> Response[Union[Any, list["Device"]]]: + client: AuthenticatedClient | Client, + metadata_name: Unset | str = UNSET, + metadata_value: Unset | str = UNSET, +) -> Response[Any | list["Device"]]: """Get devices by board id and optional metadata field Args: @@ -103,10 +101,10 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], - metadata_name: Union[Unset, str] = UNSET, - metadata_value: Union[Unset, str] = UNSET, -) -> Optional[Union[Any, list["Device"]]]: + client: AuthenticatedClient | Client, + metadata_name: Unset | str = UNSET, + metadata_value: Unset | str = UNSET, +) -> Any | list["Device"] | None: """Get devices by board id and optional metadata field Args: @@ -133,10 +131,10 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], - metadata_name: Union[Unset, str] = UNSET, - metadata_value: Union[Unset, str] = UNSET, -) -> Response[Union[Any, list["Device"]]]: + client: AuthenticatedClient | Client, + metadata_name: Unset | str = UNSET, + metadata_value: Unset | str = UNSET, +) -> Response[Any | list["Device"]]: """Get devices by board id and optional metadata field Args: @@ -166,10 +164,10 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], - metadata_name: Union[Unset, str] = UNSET, - metadata_value: Union[Unset, str] = UNSET, -) -> Optional[Union[Any, list["Device"]]]: + client: AuthenticatedClient | Client, + metadata_name: Unset | str = UNSET, + metadata_value: Unset | str = UNSET, +) -> Any | list["Device"] | None: """Get devices by board id and optional metadata field Args: diff --git a/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py b/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py index 0e0a612..7a708b0 100644 --- a/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py +++ b/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -21,9 +21,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[COAPFileStats, Error]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> COAPFileStats | Error | None: if response.status_code == 200: response_200 = COAPFileStats.from_dict(response.json()) @@ -43,8 +41,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[COAPFileStats, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[COAPFileStats | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,8 +54,8 @@ def _build_response( def sync_detailed( filename: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[COAPFileStats, Error]]: + client: AuthenticatedClient | Client, +) -> Response[COAPFileStats | Error]: """Get statistics for a file on the COAP server Args: @@ -85,8 +83,8 @@ def sync_detailed( def sync( filename: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[COAPFileStats, Error]]: + client: AuthenticatedClient | Client, +) -> COAPFileStats | Error | None: """Get statistics for a file on the COAP server Args: @@ -109,8 +107,8 @@ def sync( async def asyncio_detailed( filename: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[COAPFileStats, Error]]: + client: AuthenticatedClient | Client, +) -> Response[COAPFileStats | Error]: """Get statistics for a file on the COAP server Args: @@ -136,8 +134,8 @@ async def asyncio_detailed( async def asyncio( filename: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[COAPFileStats, Error]]: + client: AuthenticatedClient | Client, +) -> COAPFileStats | Error | None: """Get statistics for a file on the COAP server Args: diff --git a/src/infuse_iot/api_client/api/coap/get_coap_files.py b/src/infuse_iot/api_client/api/coap/get_coap_files.py index 822e567..7fa7f6c 100644 --- a/src/infuse_iot/api_client/api/coap/get_coap_files.py +++ b/src/infuse_iot/api_client/api/coap/get_coap_files.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -12,7 +12,7 @@ def _get_kwargs( *, - regex: Union[Unset, str] = UNSET, + regex: Unset | str = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -29,9 +29,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[COAPFilesList, Error]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> COAPFilesList | Error | None: if response.status_code == 200: response_200 = COAPFilesList.from_dict(response.json()) @@ -51,8 +49,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[COAPFilesList, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[COAPFilesList | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -63,9 +61,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], - regex: Union[Unset, str] = UNSET, -) -> Response[Union[COAPFilesList, Error]]: + client: AuthenticatedClient | Client, + regex: Unset | str = UNSET, +) -> Response[COAPFilesList | Error]: """Get a list of files on the COAP server Args: @@ -92,9 +90,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], - regex: Union[Unset, str] = UNSET, -) -> Optional[Union[COAPFilesList, Error]]: + client: AuthenticatedClient | Client, + regex: Unset | str = UNSET, +) -> COAPFilesList | Error | None: """Get a list of files on the COAP server Args: @@ -116,9 +114,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], - regex: Union[Unset, str] = UNSET, -) -> Response[Union[COAPFilesList, Error]]: + client: AuthenticatedClient | Client, + regex: Unset | str = UNSET, +) -> Response[COAPFilesList | Error]: """Get a list of files on the COAP server Args: @@ -143,9 +141,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], - regex: Union[Unset, str] = UNSET, -) -> Optional[Union[COAPFilesList, Error]]: + client: AuthenticatedClient | Client, + regex: Unset | str = UNSET, +) -> COAPFilesList | Error | None: """Get a list of files on the COAP server Args: diff --git a/src/infuse_iot/api_client/api/default/get_health.py b/src/infuse_iot/api_client/api/default/get_health.py index 9112e61..d53c3ca 100644 --- a/src/infuse_iot/api_client/api/default/get_health.py +++ b/src/infuse_iot/api_client/api/default/get_health.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -18,7 +18,7 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[HealthCheck]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> HealthCheck | None: if response.status_code == 200: response_200 = HealthCheck.from_dict(response.json()) @@ -29,7 +29,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[HealthCheck]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[HealthCheck]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -40,7 +40,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, ) -> Response[HealthCheck]: """Health check endpoint @@ -63,8 +63,8 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[HealthCheck]: + client: AuthenticatedClient | Client, +) -> HealthCheck | None: """Health check endpoint Raises: @@ -82,7 +82,7 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, ) -> Response[HealthCheck]: """Health check endpoint @@ -103,8 +103,8 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[HealthCheck]: + client: AuthenticatedClient | Client, +) -> HealthCheck | None: """Health check endpoint Raises: diff --git a/src/infuse_iot/api_client/api/defs/add_kv_definitions.py b/src/infuse_iot/api_client/api/defs/add_kv_definitions.py index 4c9a817..00c5344 100644 --- a/src/infuse_iot/api_client/api/defs/add_kv_definitions.py +++ b/src/infuse_iot/api_client/api/defs/add_kv_definitions.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -32,8 +32,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsKVResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsKVResponse | Error | None: if response.status_code == 201: response_201 = DefinitionsKVResponse.from_dict(response.json()) @@ -53,8 +53,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsKVResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsKVResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -65,9 +65,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsKV, -) -> Response[Union[DefinitionsKVResponse, Error]]: +) -> Response[DefinitionsKVResponse | Error]: """Add new version of key-value definitions Args: @@ -94,9 +94,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsKV, -) -> Optional[Union[DefinitionsKVResponse, Error]]: +) -> DefinitionsKVResponse | Error | None: """Add new version of key-value definitions Args: @@ -118,9 +118,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsKV, -) -> Response[Union[DefinitionsKVResponse, Error]]: +) -> Response[DefinitionsKVResponse | Error]: """Add new version of key-value definitions Args: @@ -145,9 +145,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsKV, -) -> Optional[Union[DefinitionsKVResponse, Error]]: +) -> DefinitionsKVResponse | Error | None: """Add new version of key-value definitions Args: diff --git a/src/infuse_iot/api_client/api/defs/add_rpc_definitions.py b/src/infuse_iot/api_client/api/defs/add_rpc_definitions.py index 34f8aaf..5c0d5a4 100644 --- a/src/infuse_iot/api_client/api/defs/add_rpc_definitions.py +++ b/src/infuse_iot/api_client/api/defs/add_rpc_definitions.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -32,8 +32,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsRPCResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsRPCResponse | Error | None: if response.status_code == 201: response_201 = DefinitionsRPCResponse.from_dict(response.json()) @@ -53,8 +53,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsRPCResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsRPCResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -65,9 +65,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsRPC, -) -> Response[Union[DefinitionsRPCResponse, Error]]: +) -> Response[DefinitionsRPCResponse | Error]: """Add new version of RPC definitions Args: @@ -94,9 +94,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsRPC, -) -> Optional[Union[DefinitionsRPCResponse, Error]]: +) -> DefinitionsRPCResponse | Error | None: """Add new version of RPC definitions Args: @@ -118,9 +118,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsRPC, -) -> Response[Union[DefinitionsRPCResponse, Error]]: +) -> Response[DefinitionsRPCResponse | Error]: """Add new version of RPC definitions Args: @@ -145,9 +145,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsRPC, -) -> Optional[Union[DefinitionsRPCResponse, Error]]: +) -> DefinitionsRPCResponse | Error | None: """Add new version of RPC definitions Args: diff --git a/src/infuse_iot/api_client/api/defs/add_tdf_definitions.py b/src/infuse_iot/api_client/api/defs/add_tdf_definitions.py index 31595d0..542c7c9 100644 --- a/src/infuse_iot/api_client/api/defs/add_tdf_definitions.py +++ b/src/infuse_iot/api_client/api/defs/add_tdf_definitions.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -32,8 +32,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsTDFResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsTDFResponse | Error | None: if response.status_code == 201: response_201 = DefinitionsTDFResponse.from_dict(response.json()) @@ -53,8 +53,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsTDFResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsTDFResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -65,9 +65,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsTDF, -) -> Response[Union[DefinitionsTDFResponse, Error]]: +) -> Response[DefinitionsTDFResponse | Error]: """Add new version of TDF definitions Args: @@ -94,9 +94,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsTDF, -) -> Optional[Union[DefinitionsTDFResponse, Error]]: +) -> DefinitionsTDFResponse | Error | None: """Add new version of TDF definitions Args: @@ -118,9 +118,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsTDF, -) -> Response[Union[DefinitionsTDFResponse, Error]]: +) -> Response[DefinitionsTDFResponse | Error]: """Add new version of TDF definitions Args: @@ -145,9 +145,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DefinitionsTDF, -) -> Optional[Union[DefinitionsTDFResponse, Error]]: +) -> DefinitionsTDFResponse | Error | None: """Add new version of TDF definitions Args: diff --git a/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py b/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py index b0f24e2..baf0d75 100644 --- a/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py +++ b/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -22,8 +22,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsKVResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsKVResponse | Error | None: if response.status_code == 200: response_200 = DefinitionsKVResponse.from_dict(response.json()) @@ -43,8 +43,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsKVResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsKVResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,8 +56,8 @@ def _build_response( def sync_detailed( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsKVResponse | Error]: """Get key-value definitions by version Args: @@ -85,8 +85,8 @@ def sync_detailed( def sync( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsKVResponse | Error | None: """Get key-value definitions by version Args: @@ -109,8 +109,8 @@ def sync( async def asyncio_detailed( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsKVResponse | Error]: """Get key-value definitions by version Args: @@ -136,8 +136,8 @@ async def asyncio_detailed( async def asyncio( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsKVResponse | Error | None: """Get key-value definitions by version Args: diff --git a/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py b/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py index 96d497a..a24f0a7 100644 --- a/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py +++ b/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -20,8 +20,8 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsKVResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsKVResponse | Error | None: if response.status_code == 200: response_200 = DefinitionsKVResponse.from_dict(response.json()) @@ -41,8 +41,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsKVResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsKVResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,8 +53,8 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsKVResponse | Error]: """Get the latest KV definitions Raises: @@ -76,8 +76,8 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsKVResponse | Error | None: """Get the latest KV definitions Raises: @@ -95,8 +95,8 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsKVResponse | Error]: """Get the latest KV definitions Raises: @@ -116,8 +116,8 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsKVResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsKVResponse | Error | None: """Get the latest KV definitions Raises: diff --git a/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py b/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py index 9eb7c84..7a2bd10 100644 --- a/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py +++ b/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -20,8 +20,8 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsRPCResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsRPCResponse | Error | None: if response.status_code == 200: response_200 = DefinitionsRPCResponse.from_dict(response.json()) @@ -41,8 +41,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsRPCResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsRPCResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,8 +53,8 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsRPCResponse | Error]: """Get the latest RPC definitions Raises: @@ -76,8 +76,8 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsRPCResponse | Error | None: """Get the latest RPC definitions Raises: @@ -95,8 +95,8 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsRPCResponse | Error]: """Get the latest RPC definitions Raises: @@ -116,8 +116,8 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsRPCResponse | Error | None: """Get the latest RPC definitions Raises: diff --git a/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py b/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py index 309f87b..ddad953 100644 --- a/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py +++ b/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -20,8 +20,8 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsTDFResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsTDFResponse | Error | None: if response.status_code == 200: response_200 = DefinitionsTDFResponse.from_dict(response.json()) @@ -41,8 +41,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsTDFResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsTDFResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,8 +53,8 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsTDFResponse | Error]: """Get the latest TDF definitions Raises: @@ -76,8 +76,8 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsTDFResponse | Error | None: """Get the latest TDF definitions Raises: @@ -95,8 +95,8 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsTDFResponse | Error]: """Get the latest TDF definitions Raises: @@ -116,8 +116,8 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsTDFResponse | Error | None: """Get the latest TDF definitions Raises: diff --git a/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py b/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py index 70ac46f..b540ffd 100644 --- a/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py +++ b/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -22,8 +22,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsRPCResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsRPCResponse | Error | None: if response.status_code == 200: response_200 = DefinitionsRPCResponse.from_dict(response.json()) @@ -43,8 +43,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsRPCResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsRPCResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,8 +56,8 @@ def _build_response( def sync_detailed( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsRPCResponse | Error]: """Get RPC definitions by version Args: @@ -85,8 +85,8 @@ def sync_detailed( def sync( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsRPCResponse | Error | None: """Get RPC definitions by version Args: @@ -109,8 +109,8 @@ def sync( async def asyncio_detailed( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsRPCResponse | Error]: """Get RPC definitions by version Args: @@ -136,8 +136,8 @@ async def asyncio_detailed( async def asyncio( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsRPCResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsRPCResponse | Error | None: """Get RPC definitions by version Args: diff --git a/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py b/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py index 5e4f46b..a73ec7f 100644 --- a/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py +++ b/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -22,8 +22,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[DefinitionsTDFResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DefinitionsTDFResponse | Error | None: if response.status_code == 200: response_200 = DefinitionsTDFResponse.from_dict(response.json()) @@ -43,8 +43,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[DefinitionsTDFResponse, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DefinitionsTDFResponse | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -56,8 +56,8 @@ def _build_response( def sync_detailed( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsTDFResponse | Error]: """Get TDF definitions by version Args: @@ -85,8 +85,8 @@ def sync_detailed( def sync( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsTDFResponse | Error | None: """Get TDF definitions by version Args: @@ -109,8 +109,8 @@ def sync( async def asyncio_detailed( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> Response[DefinitionsTDFResponse | Error]: """Get TDF definitions by version Args: @@ -136,8 +136,8 @@ async def asyncio_detailed( async def asyncio( version: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[DefinitionsTDFResponse, Error]]: + client: AuthenticatedClient | Client, +) -> DefinitionsTDFResponse | Error | None: """Get TDF definitions by version Args: diff --git a/src/infuse_iot/api_client/api/device/cancel_pending_device_kv_entry_updates_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/cancel_pending_device_kv_entry_updates_by_device_id_and_key_id.py new file mode 100644 index 0000000..a971008 --- /dev/null +++ b/src/infuse_iot/api_client/api/device/cancel_pending_device_kv_entry_updates_by_device_id_and_key_id.py @@ -0,0 +1,166 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_kv_entry_update import DeviceKVEntryUpdate +from ...types import Response + + +def _get_kwargs( + device_id: str, + key_id: int, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "delete", + "url": f"/device/deviceId/{device_id}/kv/entries/{key_id}/updates", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | DeviceKVEntryUpdate | None: + if response.status_code == 200: + response_200 = DeviceKVEntryUpdate.from_dict(response.json()) + + return response_200 + if response.status_code == 204: + response_204 = cast(Any, None) + return response_204 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any | DeviceKVEntryUpdate]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceKVEntryUpdate]: + """Cancel pending KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, DeviceKVEntryUpdate]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Any | DeviceKVEntryUpdate | None: + """Cancel pending KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, DeviceKVEntryUpdate] + """ + + return sync_detailed( + device_id=device_id, + key_id=key_id, + client=client, + ).parsed + + +async def asyncio_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceKVEntryUpdate]: + """Cancel pending KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, DeviceKVEntryUpdate]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Any | DeviceKVEntryUpdate | None: + """Cancel pending KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, DeviceKVEntryUpdate] + """ + + return ( + await asyncio_detailed( + device_id=device_id, + key_id=key_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/device/create_device.py b/src/infuse_iot/api_client/api/device/create_device.py index c958b3a..e2ca71a 100644 --- a/src/infuse_iot/api_client/api/device/create_device.py +++ b/src/infuse_iot/api_client/api/device/create_device.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -30,9 +30,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Device]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: if response.status_code == 201: response_201 = Device.from_dict(response.json()) @@ -49,9 +47,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Device]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,9 +58,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDevice, -) -> Response[Union[Any, Device]]: +) -> Response[Any | Device]: """Create a new device Args: @@ -91,9 +87,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDevice, -) -> Optional[Union[Any, Device]]: +) -> Any | Device | None: """Create a new device Args: @@ -115,9 +111,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDevice, -) -> Response[Union[Any, Device]]: +) -> Response[Any | Device]: """Create a new device Args: @@ -142,9 +138,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDevice, -) -> Optional[Union[Any, Device]]: +) -> Any | Device | None: """Create a new device Args: diff --git a/src/infuse_iot/api_client/api/device/create_device_kv_entry_update_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/create_device_kv_entry_update_by_device_id_and_key_id.py new file mode 100644 index 0000000..461943f --- /dev/null +++ b/src/infuse_iot/api_client/api/device/create_device_kv_entry_update_by_device_id_and_key_id.py @@ -0,0 +1,203 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_kv_entry import DeviceKVEntry +from ...models.device_kv_entry_update import DeviceKVEntryUpdate +from ...models.new_device_kv_entry_update import NewDeviceKVEntryUpdate +from ...types import Response + + +def _get_kwargs( + device_id: str, + key_id: int, + *, + body: NewDeviceKVEntryUpdate, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": f"/device/deviceId/{device_id}/kv/entries/{key_id}/updates", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | DeviceKVEntry | DeviceKVEntryUpdate | None: + if response.status_code == 200: + response_200 = DeviceKVEntry.from_dict(response.json()) + + return response_200 + if response.status_code == 201: + response_201 = DeviceKVEntryUpdate.from_dict(response.json()) + + return response_201 + if response.status_code == 400: + response_400 = cast(Any, None) + return response_400 + if response.status_code == 403: + response_403 = cast(Any, None) + return response_403 + if response.status_code == 404: + response_404 = cast(Any, None) + return response_404 + if response.status_code == 409: + response_409 = cast(Any, None) + return response_409 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any | DeviceKVEntry | DeviceKVEntryUpdate]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + body: NewDeviceKVEntryUpdate, +) -> Response[Any | DeviceKVEntry | DeviceKVEntryUpdate]: + """Create a KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + body (NewDeviceKVEntryUpdate): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, DeviceKVEntry, DeviceKVEntryUpdate]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + body: NewDeviceKVEntryUpdate, +) -> Any | DeviceKVEntry | DeviceKVEntryUpdate | None: + """Create a KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + body (NewDeviceKVEntryUpdate): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, DeviceKVEntry, DeviceKVEntryUpdate] + """ + + return sync_detailed( + device_id=device_id, + key_id=key_id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + body: NewDeviceKVEntryUpdate, +) -> Response[Any | DeviceKVEntry | DeviceKVEntryUpdate]: + """Create a KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + body (NewDeviceKVEntryUpdate): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, DeviceKVEntry, DeviceKVEntryUpdate]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + body: NewDeviceKVEntryUpdate, +) -> Any | DeviceKVEntry | DeviceKVEntryUpdate | None: + """Create a KV entry update by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + body (NewDeviceKVEntryUpdate): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, DeviceKVEntry, DeviceKVEntryUpdate] + """ + + return ( + await asyncio_detailed( + device_id=device_id, + key_id=key_id, + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/device/get_device_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_by_device_id.py index b9d8cf5..f0b08e5 100644 --- a/src/infuse_iot/api_client/api/device/get_device_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_device_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -20,9 +20,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Device]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) @@ -36,9 +34,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Device]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,8 +46,8 @@ def _build_response( def sync_detailed( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Device]: """Get a device by DeviceID Args: @@ -79,8 +75,8 @@ def sync_detailed( def sync( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Any | Device | None: """Get a device by DeviceID Args: @@ -103,8 +99,8 @@ def sync( async def asyncio_detailed( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Device]: """Get a device by DeviceID Args: @@ -130,8 +126,8 @@ async def asyncio_detailed( async def asyncio( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Any | Device | None: """Get a device by DeviceID Args: diff --git a/src/infuse_iot/api_client/api/device/get_device_by_id.py b/src/infuse_iot/api_client/api/device/get_device_by_id.py index 97854e1..b1f0246 100644 --- a/src/infuse_iot/api_client/api/device/get_device_by_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast from uuid import UUID import httpx @@ -21,9 +21,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Device]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) @@ -37,9 +35,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Device]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,8 +47,8 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Device]: """Get a device by ID Args: @@ -80,8 +76,8 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Any | Device | None: """Get a device by ID Args: @@ -104,8 +100,8 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Device]: """Get a device by ID Args: @@ -131,8 +127,8 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Any | Device | None: """Get a device by ID Args: diff --git a/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py b/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py index 2e476e6..a0ab2b1 100644 --- a/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -21,9 +21,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Device]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) @@ -37,9 +35,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Device]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,8 +48,8 @@ def sync_detailed( soc: str, mcu_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Device]: """Get a device by SoC and MCU ID Args: @@ -84,8 +80,8 @@ def sync( soc: str, mcu_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Any | Device | None: """Get a device by SoC and MCU ID Args: @@ -111,8 +107,8 @@ async def asyncio_detailed( soc: str, mcu_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Device]: """Get a device by SoC and MCU ID Args: @@ -141,8 +137,8 @@ async def asyncio( soc: str, mcu_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Device]]: + client: AuthenticatedClient | Client, +) -> Any | Device | None: """Get a device by SoC and MCU ID Args: diff --git a/src/infuse_iot/api_client/api/device/get_device_kv_entries_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_kv_entries_by_device_id.py new file mode 100644 index 0000000..70e69ff --- /dev/null +++ b/src/infuse_iot/api_client/api/device/get_device_kv_entries_by_device_id.py @@ -0,0 +1,158 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_kv_entry import DeviceKVEntry +from ...types import Response + + +def _get_kwargs( + device_id: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/device/deviceId/{device_id}/kv/entries", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | list["DeviceKVEntry"] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = DeviceKVEntry.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if response.status_code == 404: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any | list["DeviceKVEntry"]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + device_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | list["DeviceKVEntry"]]: + """Get KV entries by DeviceID + + Args: + device_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, list['DeviceKVEntry']]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + device_id: str, + *, + client: AuthenticatedClient | Client, +) -> Any | list["DeviceKVEntry"] | None: + """Get KV entries by DeviceID + + Args: + device_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, list['DeviceKVEntry']] + """ + + return sync_detailed( + device_id=device_id, + client=client, + ).parsed + + +async def asyncio_detailed( + device_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | list["DeviceKVEntry"]]: + """Get KV entries by DeviceID + + Args: + device_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, list['DeviceKVEntry']]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + device_id: str, + *, + client: AuthenticatedClient | Client, +) -> Any | list["DeviceKVEntry"] | None: + """Get KV entries by DeviceID + + Args: + device_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, list['DeviceKVEntry']] + """ + + return ( + await asyncio_detailed( + device_id=device_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/device/get_device_kv_entry_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/get_device_kv_entry_by_device_id_and_key_id.py new file mode 100644 index 0000000..acef74b --- /dev/null +++ b/src/infuse_iot/api_client/api/device/get_device_kv_entry_by_device_id_and_key_id.py @@ -0,0 +1,162 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_kv_entry import DeviceKVEntry +from ...types import Response + + +def _get_kwargs( + device_id: str, + key_id: int, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/device/deviceId/{device_id}/kv/entries/{key_id}", + } + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceKVEntry | None: + if response.status_code == 200: + response_200 = DeviceKVEntry.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceKVEntry]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceKVEntry]: + """Get a KV entry by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, DeviceKVEntry]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Any | DeviceKVEntry | None: + """Get a KV entry by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, DeviceKVEntry] + """ + + return sync_detailed( + device_id=device_id, + key_id=key_id, + client=client, + ).parsed + + +async def asyncio_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceKVEntry]: + """Get a KV entry by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, DeviceKVEntry]] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, +) -> Any | DeviceKVEntry | None: + """Get a KV entry by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, DeviceKVEntry] + """ + + return ( + await asyncio_detailed( + device_id=device_id, + key_id=key_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/device/get_device_kv_entry_updates_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/get_device_kv_entry_updates_by_device_id_and_key_id.py new file mode 100644 index 0000000..c7682df --- /dev/null +++ b/src/infuse_iot/api_client/api/device/get_device_kv_entry_updates_by_device_id_and_key_id.py @@ -0,0 +1,224 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_entry_update_status import DeviceEntryUpdateStatus +from ...models.device_kv_entry_update import DeviceKVEntryUpdate +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + device_id: str, + key_id: int, + *, + status: Unset | DeviceEntryUpdateStatus = UNSET, + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + json_status: Unset | str = UNSET + if not isinstance(status, Unset): + json_status = status.value + + params["status"] = json_status + + params["limit"] = limit + + params["offset"] = offset + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/device/deviceId/{device_id}/kv/entries/{key_id}/updates", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list["DeviceKVEntryUpdate"] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = DeviceKVEntryUpdate.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list["DeviceKVEntryUpdate"]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + status: Unset | DeviceEntryUpdateStatus = UNSET, + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> Response[list["DeviceKVEntryUpdate"]]: + """Get KV entry updates by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + status (Union[Unset, DeviceEntryUpdateStatus]): Status of device KV entry update + limit (Union[Unset, int]): Default: 100. + offset (Union[Unset, int]): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list['DeviceKVEntryUpdate']] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + status=status, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + status: Unset | DeviceEntryUpdateStatus = UNSET, + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> list["DeviceKVEntryUpdate"] | None: + """Get KV entry updates by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + status (Union[Unset, DeviceEntryUpdateStatus]): Status of device KV entry update + limit (Union[Unset, int]): Default: 100. + offset (Union[Unset, int]): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list['DeviceKVEntryUpdate'] + """ + + return sync_detailed( + device_id=device_id, + key_id=key_id, + client=client, + status=status, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + status: Unset | DeviceEntryUpdateStatus = UNSET, + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> Response[list["DeviceKVEntryUpdate"]]: + """Get KV entry updates by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + status (Union[Unset, DeviceEntryUpdateStatus]): Status of device KV entry update + limit (Union[Unset, int]): Default: 100. + offset (Union[Unset, int]): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list['DeviceKVEntryUpdate']] + """ + + kwargs = _get_kwargs( + device_id=device_id, + key_id=key_id, + status=status, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + device_id: str, + key_id: int, + *, + client: AuthenticatedClient | Client, + status: Unset | DeviceEntryUpdateStatus = UNSET, + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> list["DeviceKVEntryUpdate"] | None: + """Get KV entry updates by DeviceID and Key ID + + Args: + device_id (str): + key_id (int): + status (Union[Unset, DeviceEntryUpdateStatus]): Status of device KV entry update + limit (Union[Unset, int]): Default: 100. + offset (Union[Unset, int]): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list['DeviceKVEntryUpdate'] + """ + + return ( + await asyncio_detailed( + device_id=device_id, + key_id=key_id, + client=client, + status=status, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py index 0a58dcc..de2c8ee 100644 --- a/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -20,9 +20,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, UplinkRoute]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | UplinkRoute | None: if response.status_code == 200: response_200 = UplinkRoute.from_dict(response.json()) @@ -36,9 +34,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, UplinkRoute]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | UplinkRoute]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,8 +46,8 @@ def _build_response( def sync_detailed( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, UplinkRoute]]: + client: AuthenticatedClient | Client, +) -> Response[Any | UplinkRoute]: """Get last route by DeviceID Args: @@ -79,8 +75,8 @@ def sync_detailed( def sync( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, UplinkRoute]]: + client: AuthenticatedClient | Client, +) -> Any | UplinkRoute | None: """Get last route by DeviceID Args: @@ -103,8 +99,8 @@ def sync( async def asyncio_detailed( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, UplinkRoute]]: + client: AuthenticatedClient | Client, +) -> Response[Any | UplinkRoute]: """Get last route by DeviceID Args: @@ -130,8 +126,8 @@ async def asyncio_detailed( async def asyncio( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, UplinkRoute]]: + client: AuthenticatedClient | Client, +) -> Any | UplinkRoute | None: """Get last route by DeviceID Args: diff --git a/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py b/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py index 5da2a95..01b0b29 100644 --- a/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py +++ b/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -22,8 +22,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, DeviceLoggerState]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | DeviceLoggerState | None: if response.status_code == 200: response_200 = DeviceLoggerState.from_dict(response.json()) @@ -38,8 +38,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, DeviceLoggerState]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any | DeviceLoggerState]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,8 +52,8 @@ def sync_detailed( device_id: str, index: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, DeviceLoggerState]]: + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceLoggerState]: """Get logger state by DeviceID and index Args: @@ -84,8 +84,8 @@ def sync( device_id: str, index: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, DeviceLoggerState]]: + client: AuthenticatedClient | Client, +) -> Any | DeviceLoggerState | None: """Get logger state by DeviceID and index Args: @@ -111,8 +111,8 @@ async def asyncio_detailed( device_id: str, index: int, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, DeviceLoggerState]]: + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceLoggerState]: """Get logger state by DeviceID and index Args: @@ -141,8 +141,8 @@ async def asyncio( device_id: str, index: int, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, DeviceLoggerState]]: + client: AuthenticatedClient | Client, +) -> Any | DeviceLoggerState | None: """Get logger state by DeviceID and index Args: diff --git a/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py index 4d9b882..f7a7187 100644 --- a/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -20,9 +20,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, DeviceState]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceState | None: if response.status_code == 200: response_200 = DeviceState.from_dict(response.json()) @@ -36,9 +34,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, DeviceState]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceState]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -50,8 +46,8 @@ def _build_response( def sync_detailed( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceState]: """Get device state by DeviceID Args: @@ -79,8 +75,8 @@ def sync_detailed( def sync( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Any | DeviceState | None: """Get device state by DeviceID Args: @@ -103,8 +99,8 @@ def sync( async def asyncio_detailed( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceState]: """Get device state by DeviceID Args: @@ -130,8 +126,8 @@ async def asyncio_detailed( async def asyncio( device_id: str, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Any | DeviceState | None: """Get device state by DeviceID Args: diff --git a/src/infuse_iot/api_client/api/device/get_device_state_by_id.py b/src/infuse_iot/api_client/api/device/get_device_state_by_id.py index 90bbe34..6bd521d 100644 --- a/src/infuse_iot/api_client/api/device/get_device_state_by_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_state_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast from uuid import UUID import httpx @@ -21,9 +21,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, DeviceState]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceState | None: if response.status_code == 200: response_200 = DeviceState.from_dict(response.json()) @@ -37,9 +35,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, DeviceState]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceState]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,8 +47,8 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceState]: """Get device state by ID Args: @@ -80,8 +76,8 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Any | DeviceState | None: """Get device state by ID Args: @@ -104,8 +100,8 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Response[Any | DeviceState]: """Get device state by ID Args: @@ -131,8 +127,8 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, DeviceState]]: + client: AuthenticatedClient | Client, +) -> Any | DeviceState | None: """Get device state by ID Args: diff --git a/src/infuse_iot/api_client/api/device/get_devices.py b/src/infuse_iot/api_client/api/device/get_devices.py index b56f74c..2f4b0da 100644 --- a/src/infuse_iot/api_client/api/device/get_devices.py +++ b/src/infuse_iot/api_client/api/device/get_devices.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any from uuid import UUID import httpx @@ -13,8 +13,8 @@ def _get_kwargs( *, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, + limit: Unset | int = 100, + offset: Unset | int = 0, ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -36,9 +36,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[list["Device"]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list["Device"] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -54,9 +52,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[list["Device"]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list["Device"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -67,10 +63,10 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, + limit: Unset | int = 100, + offset: Unset | int = 0, ) -> Response[list["Device"]]: """Get all devices in an organisation @@ -102,11 +98,11 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, -) -> Optional[list["Device"]]: + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> list["Device"] | None: """Get all devices in an organisation Args: @@ -132,10 +128,10 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, + limit: Unset | int = 100, + offset: Unset | int = 0, ) -> Response[list["Device"]]: """Get all devices in an organisation @@ -165,11 +161,11 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, -) -> Optional[list["Device"]]: + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> list["Device"] | None: """Get all devices in an organisation Args: diff --git a/src/infuse_iot/api_client/api/device/get_devices_and_states.py b/src/infuse_iot/api_client/api/device/get_devices_and_states.py index 6ce7512..7d66e4c 100644 --- a/src/infuse_iot/api_client/api/device/get_devices_and_states.py +++ b/src/infuse_iot/api_client/api/device/get_devices_and_states.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any from uuid import UUID import httpx @@ -13,8 +13,8 @@ def _get_kwargs( *, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, + limit: Unset | int = 100, + offset: Unset | int = 0, ) -> dict[str, Any]: params: dict[str, Any] = {} @@ -36,9 +36,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[list["DeviceAndState"]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list["DeviceAndState"] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -55,7 +53,7 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response + *, client: AuthenticatedClient | Client, response: httpx.Response ) -> Response[list["DeviceAndState"]]: return Response( status_code=HTTPStatus(response.status_code), @@ -67,10 +65,10 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, + limit: Unset | int = 100, + offset: Unset | int = 0, ) -> Response[list["DeviceAndState"]]: """Get all devices and their states in an organisation @@ -102,11 +100,11 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, -) -> Optional[list["DeviceAndState"]]: + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> list["DeviceAndState"] | None: """Get all devices and their states in an organisation Args: @@ -132,10 +130,10 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, + limit: Unset | int = 100, + offset: Unset | int = 0, ) -> Response[list["DeviceAndState"]]: """Get all devices and their states in an organisation @@ -165,11 +163,11 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, organisation_id: UUID, - limit: Union[Unset, int] = 100, - offset: Union[Unset, int] = 0, -) -> Optional[list["DeviceAndState"]]: + limit: Unset | int = 100, + offset: Unset | int = 0, +) -> list["DeviceAndState"] | None: """Get all devices and their states in an organisation Args: diff --git a/src/infuse_iot/api_client/api/device/get_last_routes_for_devices.py b/src/infuse_iot/api_client/api/device/get_last_routes_for_devices.py index 2ee3a9c..2b51399 100644 --- a/src/infuse_iot/api_client/api/device/get_last_routes_for_devices.py +++ b/src/infuse_iot/api_client/api/device/get_last_routes_for_devices.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -31,8 +31,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[list["UplinkRouteAndDeviceId"]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list["UplinkRouteAndDeviceId"] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -49,7 +49,7 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response + *, client: AuthenticatedClient | Client, response: httpx.Response ) -> Response[list["UplinkRouteAndDeviceId"]]: return Response( status_code=HTTPStatus(response.status_code), @@ -61,7 +61,7 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: GetLastRoutesForDevicesBody, ) -> Response[list["UplinkRouteAndDeviceId"]]: """Get last routes for a group of devices @@ -90,9 +90,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: GetLastRoutesForDevicesBody, -) -> Optional[list["UplinkRouteAndDeviceId"]]: +) -> list["UplinkRouteAndDeviceId"] | None: """Get last routes for a group of devices Args: @@ -114,7 +114,7 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: GetLastRoutesForDevicesBody, ) -> Response[list["UplinkRouteAndDeviceId"]]: """Get last routes for a group of devices @@ -141,9 +141,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: GetLastRoutesForDevicesBody, -) -> Optional[list["UplinkRouteAndDeviceId"]]: +) -> list["UplinkRouteAndDeviceId"] | None: """Get last routes for a group of devices Args: diff --git a/src/infuse_iot/api_client/api/device/update_device_by_id.py b/src/infuse_iot/api_client/api/device/update_device_by_id.py index 60346bc..2c5bc78 100644 --- a/src/infuse_iot/api_client/api/device/update_device_by_id.py +++ b/src/infuse_iot/api_client/api/device/update_device_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast from uuid import UUID import httpx @@ -32,9 +32,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Device]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) @@ -48,9 +46,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Device]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,9 +58,9 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Response[Union[Any, Device]]: +) -> Response[Any | Device]: """Update a device by ID Args: @@ -94,9 +90,9 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Optional[Union[Any, Device]]: +) -> Any | Device | None: """Update a device by ID Args: @@ -121,9 +117,9 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Response[Union[Any, Device]]: +) -> Response[Any | Device]: """Update a device by ID Args: @@ -151,9 +147,9 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Optional[Union[Any, Device]]: +) -> Any | Device | None: """Update a device by ID Args: diff --git a/src/infuse_iot/api_client/api/device/update_device_state_by_id.py b/src/infuse_iot/api_client/api/device/update_device_state_by_id.py index f011c5c..fe366d1 100644 --- a/src/infuse_iot/api_client/api/device/update_device_state_by_id.py +++ b/src/infuse_iot/api_client/api/device/update_device_state_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast from uuid import UUID import httpx @@ -32,9 +32,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, DeviceState]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceState | None: if response.status_code == 200: response_200 = DeviceState.from_dict(response.json()) @@ -48,9 +46,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, DeviceState]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceState]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,9 +58,9 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Response[Union[Any, DeviceState]]: +) -> Response[Any | DeviceState]: """Update device state by ID Args: @@ -94,9 +90,9 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Optional[Union[Any, DeviceState]]: +) -> Any | DeviceState | None: """Update device state by ID Args: @@ -121,9 +117,9 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Response[Union[Any, DeviceState]]: +) -> Response[Any | DeviceState]: """Update device state by ID Args: @@ -151,9 +147,9 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Optional[Union[Any, DeviceState]]: +) -> Any | DeviceState | None: """Update device state by ID Args: diff --git a/src/infuse_iot/api_client/api/key/derive_device_key.py b/src/infuse_iot/api_client/api/key/derive_device_key.py index 98d3f49..f5d0077 100644 --- a/src/infuse_iot/api_client/api/key/derive_device_key.py +++ b/src/infuse_iot/api_client/api/key/derive_device_key.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -31,9 +31,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Error, Key]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | Key | None: if response.status_code == 200: response_200 = Key.from_dict(response.json()) @@ -48,9 +46,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Error, Key]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | Key]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -61,9 +57,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeriveDeviceKeyBody, -) -> Response[Union[Error, Key]]: +) -> Response[Error | Key]: """Derive a device key for encryption Generate a derived key to use for device level encrpytion, if security state is provided, it will be @@ -93,9 +89,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeriveDeviceKeyBody, -) -> Optional[Union[Error, Key]]: +) -> Error | Key | None: """Derive a device key for encryption Generate a derived key to use for device level encrpytion, if security state is provided, it will be @@ -120,9 +116,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeriveDeviceKeyBody, -) -> Response[Union[Error, Key]]: +) -> Response[Error | Key]: """Derive a device key for encryption Generate a derived key to use for device level encrpytion, if security state is provided, it will be @@ -150,9 +146,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: DeriveDeviceKeyBody, -) -> Optional[Union[Error, Key]]: +) -> Error | Key | None: """Derive a device key for encryption Generate a derived key to use for device level encrpytion, if security state is provided, it will be diff --git a/src/infuse_iot/api_client/api/key/get_public_key.py b/src/infuse_iot/api_client/api/key/get_public_key.py index 4bf9a56..d3c6221 100644 --- a/src/infuse_iot/api_client/api/key/get_public_key.py +++ b/src/infuse_iot/api_client/api/key/get_public_key.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -18,7 +18,7 @@ def _get_kwargs() -> dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Key]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Key | None: if response.status_code == 200: response_200 = Key.from_dict(response.json()) @@ -29,7 +29,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Key]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Key]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -40,7 +40,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, ) -> Response[Key]: """Get the current public key of the cloud @@ -63,8 +63,8 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Key]: + client: AuthenticatedClient | Client, +) -> Key | None: """Get the current public key of the cloud Raises: @@ -82,7 +82,7 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, ) -> Response[Key]: """Get the current public key of the cloud @@ -103,8 +103,8 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Key]: + client: AuthenticatedClient | Client, +) -> Key | None: """Get the current public key of the cloud Raises: diff --git a/src/infuse_iot/api_client/api/key/get_shared_secret.py b/src/infuse_iot/api_client/api/key/get_shared_secret.py index 59082fc..3f4b07a 100644 --- a/src/infuse_iot/api_client/api/key/get_shared_secret.py +++ b/src/infuse_iot/api_client/api/key/get_shared_secret.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -29,7 +29,7 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Key]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Key | None: if response.status_code == 200: response_200 = Key.from_dict(response.json()) @@ -40,7 +40,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Key]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Key]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,7 +51,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: Key, ) -> Response[Key]: """Generate a shared secret key from a device's public key @@ -80,9 +80,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: Key, -) -> Optional[Key]: +) -> Key | None: """Generate a shared secret key from a device's public key Args: @@ -104,7 +104,7 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: Key, ) -> Response[Key]: """Generate a shared secret key from a device's public key @@ -131,9 +131,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: Key, -) -> Optional[Key]: +) -> Key | None: """Generate a shared secret key from a device's public key Args: diff --git a/src/infuse_iot/api_client/api/mqtt/__init__.py b/src/infuse_iot/api_client/api/mqtt/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/infuse_iot/api_client/api/mqtt/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/infuse_iot/api_client/api/mqtt/generate_mqtt_token.py b/src/infuse_iot/api_client/api/mqtt/generate_mqtt_token.py new file mode 100644 index 0000000..81afd5f --- /dev/null +++ b/src/infuse_iot/api_client/api/mqtt/generate_mqtt_token.py @@ -0,0 +1,169 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.error import Error +from ...models.generate_mqtt_token_body import GenerateMQTTTokenBody +from ...models.generated_mqtt_token import GeneratedMQTTToken +from ...types import Response + + +def _get_kwargs( + *, + body: GenerateMQTTTokenBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/mqtt/token", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Error | GeneratedMQTTToken | None: + if response.status_code == 200: + response_200 = GeneratedMQTTToken.from_dict(response.json()) + + return response_200 + if response.status_code == 400: + response_400 = Error.from_dict(response.json()) + + return response_400 + if response.status_code == 500: + response_500 = Error.from_dict(response.json()) + + return response_500 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | GeneratedMQTTToken]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: GenerateMQTTTokenBody, +) -> Response[Error | GeneratedMQTTToken]: + """Generate an MQTT token + + Args: + body (GenerateMQTTTokenBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Error, GeneratedMQTTToken]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + body: GenerateMQTTTokenBody, +) -> Error | GeneratedMQTTToken | None: + """Generate an MQTT token + + Args: + body (GenerateMQTTTokenBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Error, GeneratedMQTTToken] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: GenerateMQTTTokenBody, +) -> Response[Error | GeneratedMQTTToken]: + """Generate an MQTT token + + Args: + body (GenerateMQTTTokenBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Error, GeneratedMQTTToken]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + body: GenerateMQTTTokenBody, +) -> Error | GeneratedMQTTToken | None: + """Generate an MQTT token + + Args: + body (GenerateMQTTTokenBody): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Error, GeneratedMQTTToken] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/organisation/create_organisation.py b/src/infuse_iot/api_client/api/organisation/create_organisation.py index 67cef74..261c620 100644 --- a/src/infuse_iot/api_client/api/organisation/create_organisation.py +++ b/src/infuse_iot/api_client/api/organisation/create_organisation.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast import httpx @@ -30,9 +30,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Organisation]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Organisation | None: if response.status_code == 201: response_201 = Organisation.from_dict(response.json()) @@ -46,9 +44,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Organisation]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Organisation]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,9 +55,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Response[Union[Any, Organisation]]: +) -> Response[Any | Organisation]: """Create a new organisation Args: @@ -88,9 +84,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Optional[Union[Any, Organisation]]: +) -> Any | Organisation | None: """Create a new organisation Args: @@ -112,9 +108,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Response[Union[Any, Organisation]]: +) -> Response[Any | Organisation]: """Create a new organisation Args: @@ -139,9 +135,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Optional[Union[Any, Organisation]]: +) -> Any | Organisation | None: """Create a new organisation Args: diff --git a/src/infuse_iot/api_client/api/organisation/get_all_organisations.py b/src/infuse_iot/api_client/api/organisation/get_all_organisations.py index 2f9b14a..a789a8c 100644 --- a/src/infuse_iot/api_client/api/organisation/get_all_organisations.py +++ b/src/infuse_iot/api_client/api/organisation/get_all_organisations.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -20,8 +20,8 @@ def _get_kwargs() -> dict[str, Any]: def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Error, list["Organisation"]]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Error | list["Organisation"] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -42,8 +42,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Error, list["Organisation"]]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | list["Organisation"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -54,8 +54,8 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Error, list["Organisation"]]]: + client: AuthenticatedClient | Client, +) -> Response[Error | list["Organisation"]]: """Get all organisations that user has access to Raises: @@ -77,8 +77,8 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Error, list["Organisation"]]]: + client: AuthenticatedClient | Client, +) -> Error | list["Organisation"] | None: """Get all organisations that user has access to Raises: @@ -96,8 +96,8 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Error, list["Organisation"]]]: + client: AuthenticatedClient | Client, +) -> Response[Error | list["Organisation"]]: """Get all organisations that user has access to Raises: @@ -117,8 +117,8 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Error, list["Organisation"]]]: + client: AuthenticatedClient | Client, +) -> Error | list["Organisation"] | None: """Get all organisations that user has access to Raises: diff --git a/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py b/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py index 1231f35..854be22 100644 --- a/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py +++ b/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union, cast +from typing import Any, cast from uuid import UUID import httpx @@ -21,9 +21,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, Organisation]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Organisation | None: if response.status_code == 200: response_200 = Organisation.from_dict(response.json()) @@ -37,9 +35,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, Organisation]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Organisation]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -51,8 +47,8 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Organisation]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Organisation]: """Get an organisation by ID Args: @@ -80,8 +76,8 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Organisation]]: + client: AuthenticatedClient | Client, +) -> Any | Organisation | None: """Get an organisation by ID Args: @@ -104,8 +100,8 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Any, Organisation]]: + client: AuthenticatedClient | Client, +) -> Response[Any | Organisation]: """Get an organisation by ID Args: @@ -131,8 +127,8 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Any, Organisation]]: + client: AuthenticatedClient | Client, +) -> Any | Organisation | None: """Get an organisation by ID Args: diff --git a/src/infuse_iot/api_client/api/organisation/get_organisation_by_name.py b/src/infuse_iot/api_client/api/organisation/get_organisation_by_name.py new file mode 100644 index 0000000..2bca963 --- /dev/null +++ b/src/infuse_iot/api_client/api/organisation/get_organisation_by_name.py @@ -0,0 +1,149 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.organisation import Organisation +from ...types import Response + + +def _get_kwargs( + name: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/organisation/name/{name}", + } + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Organisation | None: + if response.status_code == 200: + response_200 = Organisation.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = cast(Any, None) + return response_404 + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Organisation]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + name: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | Organisation]: + """Get an organisation by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, Organisation]] + """ + + kwargs = _get_kwargs( + name=name, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + name: str, + *, + client: AuthenticatedClient | Client, +) -> Any | Organisation | None: + """Get an organisation by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, Organisation] + """ + + return sync_detailed( + name=name, + client=client, + ).parsed + + +async def asyncio_detailed( + name: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | Organisation]: + """Get an organisation by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Union[Any, Organisation]] + """ + + kwargs = _get_kwargs( + name=name, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + name: str, + *, + client: AuthenticatedClient | Client, +) -> Any | Organisation | None: + """Get an organisation by name + + Args: + name (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Union[Any, Organisation] + """ + + return ( + await asyncio_detailed( + name=name, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/rpc/get_rp_cs.py b/src/infuse_iot/api_client/api/rpc/get_rp_cs.py index bf6af14..e708d8d 100644 --- a/src/infuse_iot/api_client/api/rpc/get_rp_cs.py +++ b/src/infuse_iot/api_client/api/rpc/get_rp_cs.py @@ -1,6 +1,6 @@ import datetime from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any from uuid import UUID import httpx @@ -15,36 +15,36 @@ def _get_kwargs( *, - organisation_id: Union[Unset, UUID] = UNSET, - device_id: Union[Unset, str] = UNSET, - status: Union[Unset, DownlinkMessageStatus] = UNSET, - start_time: Union[Unset, datetime.datetime] = UNSET, - end_time: Union[Unset, datetime.datetime] = UNSET, - limit: Union[Unset, int] = 10, - rpc_command_id: Union[Unset, int] = UNSET, - show_expired: Union[Unset, bool] = True, + organisation_id: Unset | UUID = UNSET, + device_id: Unset | str = UNSET, + status: Unset | DownlinkMessageStatus = UNSET, + start_time: Unset | datetime.datetime = UNSET, + end_time: Unset | datetime.datetime = UNSET, + limit: Unset | int = 10, + rpc_command_id: Unset | int = UNSET, + show_expired: Unset | bool = True, ) -> dict[str, Any]: params: dict[str, Any] = {} - json_organisation_id: Union[Unset, str] = UNSET + json_organisation_id: Unset | str = UNSET if not isinstance(organisation_id, Unset): json_organisation_id = str(organisation_id) params["organisationId"] = json_organisation_id params["deviceId"] = device_id - json_status: Union[Unset, str] = UNSET + json_status: Unset | str = UNSET if not isinstance(status, Unset): json_status = status.value params["status"] = json_status - json_start_time: Union[Unset, str] = UNSET + json_start_time: Unset | str = UNSET if not isinstance(start_time, Unset): json_start_time = start_time.isoformat() params["startTime"] = json_start_time - json_end_time: Union[Unset, str] = UNSET + json_end_time: Unset | str = UNSET if not isinstance(end_time, Unset): json_end_time = end_time.isoformat() params["endTime"] = json_end_time @@ -67,8 +67,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Error, list["RpcMessage"]]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Error | list["RpcMessage"] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -89,8 +89,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Error, list["RpcMessage"]]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | list["RpcMessage"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -101,16 +101,16 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], - organisation_id: Union[Unset, UUID] = UNSET, - device_id: Union[Unset, str] = UNSET, - status: Union[Unset, DownlinkMessageStatus] = UNSET, - start_time: Union[Unset, datetime.datetime] = UNSET, - end_time: Union[Unset, datetime.datetime] = UNSET, - limit: Union[Unset, int] = 10, - rpc_command_id: Union[Unset, int] = UNSET, - show_expired: Union[Unset, bool] = True, -) -> Response[Union[Error, list["RpcMessage"]]]: + client: AuthenticatedClient | Client, + organisation_id: Unset | UUID = UNSET, + device_id: Unset | str = UNSET, + status: Unset | DownlinkMessageStatus = UNSET, + start_time: Unset | datetime.datetime = UNSET, + end_time: Unset | datetime.datetime = UNSET, + limit: Unset | int = 10, + rpc_command_id: Unset | int = UNSET, + show_expired: Unset | bool = True, +) -> Response[Error | list["RpcMessage"]]: """Get RPC messages Args: @@ -154,16 +154,16 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], - organisation_id: Union[Unset, UUID] = UNSET, - device_id: Union[Unset, str] = UNSET, - status: Union[Unset, DownlinkMessageStatus] = UNSET, - start_time: Union[Unset, datetime.datetime] = UNSET, - end_time: Union[Unset, datetime.datetime] = UNSET, - limit: Union[Unset, int] = 10, - rpc_command_id: Union[Unset, int] = UNSET, - show_expired: Union[Unset, bool] = True, -) -> Optional[Union[Error, list["RpcMessage"]]]: + client: AuthenticatedClient | Client, + organisation_id: Unset | UUID = UNSET, + device_id: Unset | str = UNSET, + status: Unset | DownlinkMessageStatus = UNSET, + start_time: Unset | datetime.datetime = UNSET, + end_time: Unset | datetime.datetime = UNSET, + limit: Unset | int = 10, + rpc_command_id: Unset | int = UNSET, + show_expired: Unset | bool = True, +) -> Error | list["RpcMessage"] | None: """Get RPC messages Args: @@ -202,16 +202,16 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], - organisation_id: Union[Unset, UUID] = UNSET, - device_id: Union[Unset, str] = UNSET, - status: Union[Unset, DownlinkMessageStatus] = UNSET, - start_time: Union[Unset, datetime.datetime] = UNSET, - end_time: Union[Unset, datetime.datetime] = UNSET, - limit: Union[Unset, int] = 10, - rpc_command_id: Union[Unset, int] = UNSET, - show_expired: Union[Unset, bool] = True, -) -> Response[Union[Error, list["RpcMessage"]]]: + client: AuthenticatedClient | Client, + organisation_id: Unset | UUID = UNSET, + device_id: Unset | str = UNSET, + status: Unset | DownlinkMessageStatus = UNSET, + start_time: Unset | datetime.datetime = UNSET, + end_time: Unset | datetime.datetime = UNSET, + limit: Unset | int = 10, + rpc_command_id: Unset | int = UNSET, + show_expired: Unset | bool = True, +) -> Response[Error | list["RpcMessage"]]: """Get RPC messages Args: @@ -253,16 +253,16 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], - organisation_id: Union[Unset, UUID] = UNSET, - device_id: Union[Unset, str] = UNSET, - status: Union[Unset, DownlinkMessageStatus] = UNSET, - start_time: Union[Unset, datetime.datetime] = UNSET, - end_time: Union[Unset, datetime.datetime] = UNSET, - limit: Union[Unset, int] = 10, - rpc_command_id: Union[Unset, int] = UNSET, - show_expired: Union[Unset, bool] = True, -) -> Optional[Union[Error, list["RpcMessage"]]]: + client: AuthenticatedClient | Client, + organisation_id: Unset | UUID = UNSET, + device_id: Unset | str = UNSET, + status: Unset | DownlinkMessageStatus = UNSET, + start_time: Unset | datetime.datetime = UNSET, + end_time: Unset | datetime.datetime = UNSET, + limit: Unset | int = 10, + rpc_command_id: Unset | int = UNSET, + show_expired: Unset | bool = True, +) -> Error | list["RpcMessage"] | None: """Get RPC messages Args: diff --git a/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py b/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py index e8e8c60..7a812d5 100644 --- a/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py +++ b/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any from uuid import UUID import httpx @@ -22,9 +22,7 @@ def _get_kwargs( return _kwargs -def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Error, RpcMessage]]: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | RpcMessage | None: if response.status_code == 200: response_200 = RpcMessage.from_dict(response.json()) @@ -43,9 +41,7 @@ def _parse_response( return None -def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Error, RpcMessage]]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | RpcMessage]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -57,8 +53,8 @@ def _build_response( def sync_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Error, RpcMessage]]: + client: AuthenticatedClient | Client, +) -> Response[Error | RpcMessage]: """Get an RPC message by ID Args: @@ -86,8 +82,8 @@ def sync_detailed( def sync( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Error, RpcMessage]]: + client: AuthenticatedClient | Client, +) -> Error | RpcMessage | None: """Get an RPC message by ID Args: @@ -110,8 +106,8 @@ def sync( async def asyncio_detailed( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Response[Union[Error, RpcMessage]]: + client: AuthenticatedClient | Client, +) -> Response[Error | RpcMessage]: """Get an RPC message by ID Args: @@ -137,8 +133,8 @@ async def asyncio_detailed( async def asyncio( id: UUID, *, - client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Error, RpcMessage]]: + client: AuthenticatedClient | Client, +) -> Error | RpcMessage | None: """Get an RPC message by ID Args: diff --git a/src/infuse_iot/api_client/api/rpc/send_rpc.py b/src/infuse_iot/api_client/api/rpc/send_rpc.py index 61db3a3..9cfea59 100644 --- a/src/infuse_iot/api_client/api/rpc/send_rpc.py +++ b/src/infuse_iot/api_client/api/rpc/send_rpc.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Optional, Union +from typing import Any import httpx @@ -32,8 +32,8 @@ def _get_kwargs( def _parse_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[CreatedRpcMessage, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CreatedRpcMessage | Error | None: if response.status_code == 201: response_201 = CreatedRpcMessage.from_dict(response.json()) @@ -57,8 +57,8 @@ def _parse_response( def _build_response( - *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[CreatedRpcMessage, Error]]: + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CreatedRpcMessage | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -69,9 +69,9 @@ def _build_response( def sync_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewRPCMessage, -) -> Response[Union[CreatedRpcMessage, Error]]: +) -> Response[CreatedRpcMessage | Error]: """Send an RPC to a device Args: @@ -98,9 +98,9 @@ def sync_detailed( def sync( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewRPCMessage, -) -> Optional[Union[CreatedRpcMessage, Error]]: +) -> CreatedRpcMessage | Error | None: """Send an RPC to a device Args: @@ -122,9 +122,9 @@ def sync( async def asyncio_detailed( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewRPCMessage, -) -> Response[Union[CreatedRpcMessage, Error]]: +) -> Response[CreatedRpcMessage | Error]: """Send an RPC to a device Args: @@ -149,9 +149,9 @@ async def asyncio_detailed( async def asyncio( *, - client: Union[AuthenticatedClient, Client], + client: AuthenticatedClient | Client, body: NewRPCMessage, -) -> Optional[Union[CreatedRpcMessage, Error]]: +) -> CreatedRpcMessage | Error | None: """Send an RPC to a device Args: diff --git a/src/infuse_iot/api_client/client.py b/src/infuse_iot/api_client/client.py index e80446f..3f312fb 100644 --- a/src/infuse_iot/api_client/client.py +++ b/src/infuse_iot/api_client/client.py @@ -1,5 +1,5 @@ import ssl -from typing import Any, Optional, Union +from typing import Any import httpx from attrs import define, evolve, field @@ -38,12 +38,12 @@ class Client: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") - _client: Optional[httpx.Client] = field(default=None, init=False) - _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) def with_headers(self, headers: dict[str, str]) -> "Client": """Get a new client matching this one with additional headers""" @@ -168,12 +168,12 @@ class AuthenticatedClient: _base_url: str = field(alias="base_url") _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") - _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") - _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") - _client: Optional[httpx.Client] = field(default=None, init=False) - _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) token: str prefix: str = "Bearer" diff --git a/src/infuse_iot/api_client/models/__init__.py b/src/infuse_iot/api_client/models/__init__.py index 58f54e5..497db47 100644 --- a/src/infuse_iot/api_client/models/__init__.py +++ b/src/infuse_iot/api_client/models/__init__.py @@ -1,6 +1,9 @@ """Contains all the data models used in inputs/outputs""" from .algorithm import Algorithm +from .api_key_org_user_type import APIKeyOrgUserType +from .api_key_resource_name import APIKeyResourceName +from .api_key_resource_perm import APIKeyResourcePerm from .application_version import ApplicationVersion from .board import Board from .bt_le_route import BtLeRoute @@ -39,7 +42,11 @@ from .derive_device_key_body import DeriveDeviceKeyBody from .device import Device from .device_and_state import DeviceAndState +from .device_entry_update_status import DeviceEntryUpdateStatus from .device_id_field import DeviceIdField +from .device_kv_entry import DeviceKVEntry +from .device_kv_entry_decoded import DeviceKVEntryDecoded +from .device_kv_entry_update import DeviceKVEntryUpdate from .device_logger_state import DeviceLoggerState from .device_metadata import DeviceMetadata from .device_metadata_update import DeviceMetadataUpdate @@ -52,6 +59,11 @@ from .error import Error from .forwarded_downlink_route import ForwardedDownlinkRoute from .forwarded_uplink_route import ForwardedUplinkRoute +from .generate_api_key_body import GenerateAPIKeyBody +from .generate_api_key_body_resource_perms import GenerateAPIKeyBodyResourcePerms +from .generate_mqtt_token_body import GenerateMQTTTokenBody +from .generated_api_key import GeneratedAPIKey +from .generated_mqtt_token import GeneratedMQTTToken from .get_last_routes_for_devices_body import GetLastRoutesForDevicesBody from .health_check import HealthCheck from .interface_data import InterfaceData @@ -60,6 +72,8 @@ from .metadata_field import MetadataField from .new_board import NewBoard from .new_device import NewDevice +from .new_device_kv_entry_update import NewDeviceKVEntryUpdate +from .new_device_kv_entry_update_decoded import NewDeviceKVEntryUpdateDecoded from .new_device_state import NewDeviceState from .new_organisation import NewOrganisation from .new_rpc_message import NewRPCMessage @@ -79,6 +93,9 @@ __all__ = ( "Algorithm", + "APIKeyOrgUserType", + "APIKeyResourceName", + "APIKeyResourcePerm", "ApplicationVersion", "Board", "BtLeRoute", @@ -117,7 +134,11 @@ "DeriveDeviceKeyBody", "Device", "DeviceAndState", + "DeviceEntryUpdateStatus", "DeviceIdField", + "DeviceKVEntry", + "DeviceKVEntryDecoded", + "DeviceKVEntryUpdate", "DeviceLoggerState", "DeviceMetadata", "DeviceMetadataUpdate", @@ -130,6 +151,11 @@ "Error", "ForwardedDownlinkRoute", "ForwardedUplinkRoute", + "GenerateAPIKeyBody", + "GenerateAPIKeyBodyResourcePerms", + "GeneratedAPIKey", + "GeneratedMQTTToken", + "GenerateMQTTTokenBody", "GetLastRoutesForDevicesBody", "HealthCheck", "InterfaceData", @@ -138,6 +164,8 @@ "MetadataField", "NewBoard", "NewDevice", + "NewDeviceKVEntryUpdate", + "NewDeviceKVEntryUpdateDecoded", "NewDeviceState", "NewOrganisation", "NewRPCMessage", diff --git a/src/infuse_iot/api_client/models/api_key_org_user_type.py b/src/infuse_iot/api_client/models/api_key_org_user_type.py new file mode 100644 index 0000000..f1e0a02 --- /dev/null +++ b/src/infuse_iot/api_client/models/api_key_org_user_type.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class APIKeyOrgUserType(str, Enum): + ADMIN = "admin" + STANDARD = "standard" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/api_key_resource_name.py b/src/infuse_iot/api_client/models/api_key_resource_name.py new file mode 100644 index 0000000..8a1ac9f --- /dev/null +++ b/src/infuse_iot/api_client/models/api_key_resource_name.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class APIKeyResourceName(str, Enum): + BOARD = "board" + DEVICE = "device" + NETWORK = "network" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/api_key_resource_perm.py b/src/infuse_iot/api_client/models/api_key_resource_perm.py new file mode 100644 index 0000000..6bf9c78 --- /dev/null +++ b/src/infuse_iot/api_client/models/api_key_resource_perm.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class APIKeyResourcePerm(str, Enum): + ADMIN = "admin" + CREATE = "create" + DELETE = "delete" + UPDATE = "update" + VIEW = "view" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/board.py b/src/infuse_iot/api_client/models/board.py index 8012728..2f014f0 100644 --- a/src/infuse_iot/api_client/models/board.py +++ b/src/infuse_iot/api_client/models/board.py @@ -1,6 +1,6 @@ import datetime from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -38,7 +38,7 @@ class Board: description: str soc: str organisation_id: UUID - metadata_fields: Union[Unset, list["MetadataField"]] = UNSET + metadata_fields: Unset | list["MetadataField"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -56,7 +56,7 @@ def to_dict(self) -> dict[str, Any]: organisation_id = str(self.organisation_id) - metadata_fields: Union[Unset, list[dict[str, Any]]] = UNSET + metadata_fields: Unset | list[dict[str, Any]] = UNSET if not isinstance(self.metadata_fields, Unset): metadata_fields = [] for componentsschemas_board_metadata_fields_item_data in self.metadata_fields: diff --git a/src/infuse_iot/api_client/models/definitions_field_conversion.py b/src/infuse_iot/api_client/models/definitions_field_conversion.py index d9ec9ef..a2eabcd 100644 --- a/src/infuse_iot/api_client/models/definitions_field_conversion.py +++ b/src/infuse_iot/api_client/models/definitions_field_conversion.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import Any, TypeVar, Union +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,9 +20,9 @@ class DefinitionsFieldConversion: int_ (Union[Unset, DefinitionsFieldConversionInt]): Byte array value should be treated as an integer """ - m: Union[Unset, float] = UNSET - c: Union[Unset, float] = UNSET - int_: Union[Unset, DefinitionsFieldConversionInt] = UNSET + m: Unset | float = UNSET + c: Unset | float = UNSET + int_: Unset | DefinitionsFieldConversionInt = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -30,7 +30,7 @@ def to_dict(self) -> dict[str, Any]: c = self.c - int_: Union[Unset, str] = UNSET + int_: Unset | str = UNSET if not isinstance(self.int_, Unset): int_ = self.int_.value @@ -54,7 +54,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: c = d.pop("c", UNSET) _int_ = d.pop("int", UNSET) - int_: Union[Unset, DefinitionsFieldConversionInt] + int_: Unset | DefinitionsFieldConversionInt if isinstance(_int_, Unset): int_ = UNSET else: diff --git a/src/infuse_iot/api_client/models/definitions_field_definition.py b/src/infuse_iot/api_client/models/definitions_field_definition.py index 4bf80f1..ef14a30 100644 --- a/src/infuse_iot/api_client/models/definitions_field_definition.py +++ b/src/infuse_iot/api_client/models/definitions_field_definition.py @@ -22,14 +22,17 @@ class DefinitionsFieldDefinition: type_ (str): Field type description (Union[Unset, str]): Field description num (Union[Unset, int]): If field is array, the number of elements (0 for variable length) + counted_by (Union[Unset, str]): If field is array, the name of the field that contains the number of elements + (overrides num) display (Union[Unset, DefinitionsFieldDisplay]): Display settings for a field conversion (Union[Unset, DefinitionsFieldConversion]): Conversion formula for a field (m * + c) """ name: str type_: str - description: Union[Unset, str] = UNSET - num: Union[Unset, int] = UNSET + description: Unset | str = UNSET + num: Unset | int = UNSET + counted_by: Unset | str = UNSET display: Union[Unset, "DefinitionsFieldDisplay"] = UNSET conversion: Union[Unset, "DefinitionsFieldConversion"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -43,11 +46,13 @@ def to_dict(self) -> dict[str, Any]: num = self.num - display: Union[Unset, dict[str, Any]] = UNSET + counted_by = self.counted_by + + display: Unset | dict[str, Any] = UNSET if not isinstance(self.display, Unset): display = self.display.to_dict() - conversion: Union[Unset, dict[str, Any]] = UNSET + conversion: Unset | dict[str, Any] = UNSET if not isinstance(self.conversion, Unset): conversion = self.conversion.to_dict() @@ -63,6 +68,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["description"] = description if num is not UNSET: field_dict["num"] = num + if counted_by is not UNSET: + field_dict["counted_by"] = counted_by if display is not UNSET: field_dict["display"] = display if conversion is not UNSET: @@ -84,15 +91,17 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: num = d.pop("num", UNSET) + counted_by = d.pop("counted_by", UNSET) + _display = d.pop("display", UNSET) - display: Union[Unset, DefinitionsFieldDisplay] + display: Unset | DefinitionsFieldDisplay if isinstance(_display, Unset): display = UNSET else: display = DefinitionsFieldDisplay.from_dict(_display) _conversion = d.pop("conversion", UNSET) - conversion: Union[Unset, DefinitionsFieldConversion] + conversion: Unset | DefinitionsFieldConversion if isinstance(_conversion, Unset): conversion = UNSET else: @@ -103,6 +112,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: type_=type_, description=description, num=num, + counted_by=counted_by, display=display, conversion=conversion, ) diff --git a/src/infuse_iot/api_client/models/definitions_field_display.py b/src/infuse_iot/api_client/models/definitions_field_display.py index 3b6951f..c8640f9 100644 --- a/src/infuse_iot/api_client/models/definitions_field_display.py +++ b/src/infuse_iot/api_client/models/definitions_field_display.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import Any, TypeVar, Union +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,13 +20,13 @@ class DefinitionsFieldDisplay: postfix (Union[Unset, str]): """ - fmt: Union[Unset, DefinitionsFieldDisplayFmt] = UNSET - digits: Union[Unset, int] = UNSET - postfix: Union[Unset, str] = UNSET + fmt: Unset | DefinitionsFieldDisplayFmt = UNSET + digits: Unset | int = UNSET + postfix: Unset | str = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - fmt: Union[Unset, str] = UNSET + fmt: Unset | str = UNSET if not isinstance(self.fmt, Unset): fmt = self.fmt.value @@ -50,7 +50,7 @@ def to_dict(self) -> dict[str, Any]: def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) _fmt = d.pop("fmt", UNSET) - fmt: Union[Unset, DefinitionsFieldDisplayFmt] + fmt: Unset | DefinitionsFieldDisplayFmt if isinstance(_fmt, Unset): fmt = UNSET else: diff --git a/src/infuse_iot/api_client/models/definitions_kv_definition.py b/src/infuse_iot/api_client/models/definitions_kv_definition.py index f3898c9..df29bc4 100644 --- a/src/infuse_iot/api_client/models/definitions_kv_definition.py +++ b/src/infuse_iot/api_client/models/definitions_kv_definition.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -31,12 +31,12 @@ class DefinitionsKVDefinition: name: str description: str fields: list["DefinitionsFieldDefinition"] - reflect: Union[Unset, bool] = UNSET - read_only: Union[Unset, bool] = UNSET - write_only: Union[Unset, bool] = UNSET - default: Union[Unset, str] = UNSET - depends_on: Union[Unset, str] = UNSET - range_: Union[Unset, int] = UNSET + reflect: Unset | bool = UNSET + read_only: Unset | bool = UNSET + write_only: Unset | bool = UNSET + default: Unset | str = UNSET + depends_on: Unset | str = UNSET + range_: Unset | int = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: diff --git a/src/infuse_iot/api_client/models/definitions_rpc_command.py b/src/infuse_iot/api_client/models/definitions_rpc_command.py index 8bc9636..04acd3a 100644 --- a/src/infuse_iot/api_client/models/definitions_rpc_command.py +++ b/src/infuse_iot/api_client/models/definitions_rpc_command.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,22 +20,22 @@ class DefinitionsRPCCommand: Attributes: name (str): description (str): - default (str): default_auth (DefinitionsRPCCommandDefaultAuth): request_params (list['DefinitionsFieldDefinition']): response_params (list['DefinitionsFieldDefinition']): depends_on (Union[Unset, str]): + default (Union[Unset, str]): rpc_data (Union[Unset, bool]): Whether the command is an RPC data command """ name: str description: str - default: str default_auth: DefinitionsRPCCommandDefaultAuth request_params: list["DefinitionsFieldDefinition"] response_params: list["DefinitionsFieldDefinition"] - depends_on: Union[Unset, str] = UNSET - rpc_data: Union[Unset, bool] = UNSET + depends_on: Unset | str = UNSET + default: Unset | str = UNSET + rpc_data: Unset | bool = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -43,8 +43,6 @@ def to_dict(self) -> dict[str, Any]: description = self.description - default = self.default - default_auth = self.default_auth.value request_params = [] @@ -59,6 +57,8 @@ def to_dict(self) -> dict[str, Any]: depends_on = self.depends_on + default = self.default + rpc_data = self.rpc_data field_dict: dict[str, Any] = {} @@ -67,7 +67,6 @@ def to_dict(self) -> dict[str, Any]: { "name": name, "description": description, - "default": default, "default_auth": default_auth, "request_params": request_params, "response_params": response_params, @@ -75,6 +74,8 @@ def to_dict(self) -> dict[str, Any]: ) if depends_on is not UNSET: field_dict["depends_on"] = depends_on + if default is not UNSET: + field_dict["default"] = default if rpc_data is not UNSET: field_dict["rpc_data"] = rpc_data @@ -89,8 +90,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: description = d.pop("description") - default = d.pop("default") - default_auth = DefinitionsRPCCommandDefaultAuth(d.pop("default_auth")) request_params = [] @@ -109,16 +108,18 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: depends_on = d.pop("depends_on", UNSET) + default = d.pop("default", UNSET) + rpc_data = d.pop("rpc_data", UNSET) definitions_rpc_command = cls( name=name, description=description, - default=default, default_auth=default_auth, request_params=request_params, response_params=response_params, depends_on=depends_on, + default=default, rpc_data=rpc_data, ) diff --git a/src/infuse_iot/api_client/models/derive_device_key_body.py b/src/infuse_iot/api_client/models/derive_device_key_body.py index 769123a..5f8bce0 100644 --- a/src/infuse_iot/api_client/models/derive_device_key_body.py +++ b/src/infuse_iot/api_client/models/derive_device_key_body.py @@ -33,7 +33,7 @@ def to_dict(self) -> dict[str, Any]: interface = self.interface.value - security_state: Union[Unset, dict[str, Any]] = UNSET + security_state: Unset | dict[str, Any] = UNSET if not isinstance(self.security_state, Unset): security_state = self.security_state.to_dict() @@ -60,7 +60,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: interface = KeyInterface(d.pop("interface")) _security_state = d.pop("securityState", UNSET) - security_state: Union[Unset, SecurityState] + security_state: Unset | SecurityState if isinstance(_security_state, Unset): security_state = UNSET else: diff --git a/src/infuse_iot/api_client/models/device.py b/src/infuse_iot/api_client/models/device.py index 393cf4b..da6b068 100644 --- a/src/infuse_iot/api_client/models/device.py +++ b/src/infuse_iot/api_client/models/device.py @@ -39,7 +39,7 @@ class Device: mcu_id: str board_id: UUID organisation_id: UUID - device_id: Union[Unset, str] = UNSET + device_id: Unset | str = UNSET metadata: Union[Unset, "DeviceMetadata"] = UNSET initial_device_state: Union[Unset, "NewDeviceState"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -59,11 +59,11 @@ def to_dict(self) -> dict[str, Any]: device_id = self.device_id - metadata: Union[Unset, dict[str, Any]] = UNSET + metadata: Unset | dict[str, Any] = UNSET if not isinstance(self.metadata, Unset): metadata = self.metadata.to_dict() - initial_device_state: Union[Unset, dict[str, Any]] = UNSET + initial_device_state: Unset | dict[str, Any] = UNSET if not isinstance(self.initial_device_state, Unset): initial_device_state = self.initial_device_state.to_dict() @@ -109,14 +109,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: device_id = d.pop("deviceId", UNSET) _metadata = d.pop("metadata", UNSET) - metadata: Union[Unset, DeviceMetadata] + metadata: Unset | DeviceMetadata if isinstance(_metadata, Unset): metadata = UNSET else: metadata = DeviceMetadata.from_dict(_metadata) _initial_device_state = d.pop("initialDeviceState", UNSET) - initial_device_state: Union[Unset, NewDeviceState] + initial_device_state: Unset | NewDeviceState if isinstance(_initial_device_state, Unset): initial_device_state = UNSET else: diff --git a/src/infuse_iot/api_client/models/device_and_state.py b/src/infuse_iot/api_client/models/device_and_state.py index 4fe039b..4e1acdb 100644 --- a/src/infuse_iot/api_client/models/device_and_state.py +++ b/src/infuse_iot/api_client/models/device_and_state.py @@ -42,7 +42,7 @@ class DeviceAndState: board_id: UUID organisation_id: UUID state: "DeviceState" - device_id: Union[Unset, str] = UNSET + device_id: Unset | str = UNSET metadata: Union[Unset, "DeviceMetadata"] = UNSET initial_device_state: Union[Unset, "NewDeviceState"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -64,11 +64,11 @@ def to_dict(self) -> dict[str, Any]: device_id = self.device_id - metadata: Union[Unset, dict[str, Any]] = UNSET + metadata: Unset | dict[str, Any] = UNSET if not isinstance(self.metadata, Unset): metadata = self.metadata.to_dict() - initial_device_state: Union[Unset, dict[str, Any]] = UNSET + initial_device_state: Unset | dict[str, Any] = UNSET if not isinstance(self.initial_device_state, Unset): initial_device_state = self.initial_device_state.to_dict() @@ -118,14 +118,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: device_id = d.pop("deviceId", UNSET) _metadata = d.pop("metadata", UNSET) - metadata: Union[Unset, DeviceMetadata] + metadata: Unset | DeviceMetadata if isinstance(_metadata, Unset): metadata = UNSET else: metadata = DeviceMetadata.from_dict(_metadata) _initial_device_state = d.pop("initialDeviceState", UNSET) - initial_device_state: Union[Unset, NewDeviceState] + initial_device_state: Unset | NewDeviceState if isinstance(_initial_device_state, Unset): initial_device_state = UNSET else: diff --git a/src/infuse_iot/api_client/models/device_entry_update_status.py b/src/infuse_iot/api_client/models/device_entry_update_status.py new file mode 100644 index 0000000..d584787 --- /dev/null +++ b/src/infuse_iot/api_client/models/device_entry_update_status.py @@ -0,0 +1,11 @@ +from enum import Enum + + +class DeviceEntryUpdateStatus(str, Enum): + CANCELLED = "cancelled" + FAILED = "failed" + PENDING = "pending" + SUCCESS = "success" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/device_id_field.py b/src/infuse_iot/api_client/models/device_id_field.py index 740be2d..9f92d32 100644 --- a/src/infuse_iot/api_client/models/device_id_field.py +++ b/src/infuse_iot/api_client/models/device_id_field.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import Any, TypeVar, Union +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -17,7 +17,7 @@ class DeviceIdField: d291d4d66bf0a955. """ - device_id: Union[Unset, str] = UNSET + device_id: Unset | str = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: diff --git a/src/infuse_iot/api_client/models/device_kv_entry.py b/src/infuse_iot/api_client/models/device_kv_entry.py new file mode 100644 index 0000000..e540b02 --- /dev/null +++ b/src/infuse_iot/api_client/models/device_kv_entry.py @@ -0,0 +1,127 @@ +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.device_kv_entry_decoded import DeviceKVEntryDecoded + + +T = TypeVar("T", bound="DeviceKVEntry") + + +@_attrs_define +class DeviceKVEntry: + """ + Attributes: + key_id (int): Key id + crc (int): CRC32 of entry value + created_at (datetime.datetime): + updated_at (datetime.datetime): + key_name (Union[Unset, str]): Key name - if definition known + data (Union[Unset, str]): Raw entry data as a base64 encoded string - if not write_only + decoded (Union[Unset, DeviceKVEntryDecoded]): Decoded entry value - if not write_only and definition known + """ + + key_id: int + crc: int + created_at: datetime.datetime + updated_at: datetime.datetime + key_name: Unset | str = UNSET + data: Unset | str = UNSET + decoded: Union[Unset, "DeviceKVEntryDecoded"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + key_id = self.key_id + + crc = self.crc + + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() + + key_name = self.key_name + + data = self.data + + decoded: Unset | dict[str, Any] = UNSET + if not isinstance(self.decoded, Unset): + decoded = self.decoded.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "keyId": key_id, + "crc": crc, + "createdAt": created_at, + "updatedAt": updated_at, + } + ) + if key_name is not UNSET: + field_dict["keyName"] = key_name + if data is not UNSET: + field_dict["data"] = data + if decoded is not UNSET: + field_dict["decoded"] = decoded + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.device_kv_entry_decoded import DeviceKVEntryDecoded + + d = dict(src_dict) + key_id = d.pop("keyId") + + crc = d.pop("crc") + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + key_name = d.pop("keyName", UNSET) + + data = d.pop("data", UNSET) + + _decoded = d.pop("decoded", UNSET) + decoded: Unset | DeviceKVEntryDecoded + if isinstance(_decoded, Unset): + decoded = UNSET + else: + decoded = DeviceKVEntryDecoded.from_dict(_decoded) + + device_kv_entry = cls( + key_id=key_id, + crc=crc, + created_at=created_at, + updated_at=updated_at, + key_name=key_name, + data=data, + decoded=decoded, + ) + + device_kv_entry.additional_properties = d + return device_kv_entry + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/device_kv_entry_decoded.py b/src/infuse_iot/api_client/models/device_kv_entry_decoded.py new file mode 100644 index 0000000..4ca61b7 --- /dev/null +++ b/src/infuse_iot/api_client/models/device_kv_entry_decoded.py @@ -0,0 +1,44 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="DeviceKVEntryDecoded") + + +@_attrs_define +class DeviceKVEntryDecoded: + """Decoded entry value - if not write_only and definition known""" + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + device_kv_entry_decoded = cls() + + device_kv_entry_decoded.additional_properties = d + return device_kv_entry_decoded + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/device_kv_entry_update.py b/src/infuse_iot/api_client/models/device_kv_entry_update.py new file mode 100644 index 0000000..90a847a --- /dev/null +++ b/src/infuse_iot/api_client/models/device_kv_entry_update.py @@ -0,0 +1,161 @@ +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.device_entry_update_status import DeviceEntryUpdateStatus +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.new_device_kv_entry_update_decoded import NewDeviceKVEntryUpdateDecoded + + +T = TypeVar("T", bound="DeviceKVEntryUpdate") + + +@_attrs_define +class DeviceKVEntryUpdate: + """ + Attributes: + id (UUID): ID of update + key_id (int): Key id + crc (int): CRC32 of entry update value + status (DeviceEntryUpdateStatus): Status of device KV entry update + created_at (datetime.datetime): + updated_at (datetime.datetime): + data (Union[Unset, str]): Raw entry data as a base64 encoded string (must provide either data or decoded) + decoded (Union[Unset, NewDeviceKVEntryUpdateDecoded]): Decoded entry value (must provide either data or decoded) + last_error (Union[Unset, str]): Last error message if update failed + last_attempt_at (Union[Unset, datetime.datetime]): Time of last attempt + """ + + id: UUID + key_id: int + crc: int + status: DeviceEntryUpdateStatus + created_at: datetime.datetime + updated_at: datetime.datetime + data: Unset | str = UNSET + decoded: Union[Unset, "NewDeviceKVEntryUpdateDecoded"] = UNSET + last_error: Unset | str = UNSET + last_attempt_at: Unset | datetime.datetime = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = str(self.id) + + key_id = self.key_id + + crc = self.crc + + status = self.status.value + + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() + + data = self.data + + decoded: Unset | dict[str, Any] = UNSET + if not isinstance(self.decoded, Unset): + decoded = self.decoded.to_dict() + + last_error = self.last_error + + last_attempt_at: Unset | str = UNSET + if not isinstance(self.last_attempt_at, Unset): + last_attempt_at = self.last_attempt_at.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "keyId": key_id, + "crc": crc, + "status": status, + "createdAt": created_at, + "updatedAt": updated_at, + } + ) + if data is not UNSET: + field_dict["data"] = data + if decoded is not UNSET: + field_dict["decoded"] = decoded + if last_error is not UNSET: + field_dict["lastError"] = last_error + if last_attempt_at is not UNSET: + field_dict["lastAttemptAt"] = last_attempt_at + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.new_device_kv_entry_update_decoded import NewDeviceKVEntryUpdateDecoded + + d = dict(src_dict) + id = UUID(d.pop("id")) + + key_id = d.pop("keyId") + + crc = d.pop("crc") + + status = DeviceEntryUpdateStatus(d.pop("status")) + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + data = d.pop("data", UNSET) + + _decoded = d.pop("decoded", UNSET) + decoded: Unset | NewDeviceKVEntryUpdateDecoded + if isinstance(_decoded, Unset): + decoded = UNSET + else: + decoded = NewDeviceKVEntryUpdateDecoded.from_dict(_decoded) + + last_error = d.pop("lastError", UNSET) + + _last_attempt_at = d.pop("lastAttemptAt", UNSET) + last_attempt_at: Unset | datetime.datetime + if isinstance(_last_attempt_at, Unset): + last_attempt_at = UNSET + else: + last_attempt_at = isoparse(_last_attempt_at) + + device_kv_entry_update = cls( + id=id, + key_id=key_id, + crc=crc, + status=status, + created_at=created_at, + updated_at=updated_at, + data=data, + decoded=decoded, + last_error=last_error, + last_attempt_at=last_attempt_at, + ) + + device_kv_entry_update.additional_properties = d + return device_kv_entry_update + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/device_logger_state.py b/src/infuse_iot/api_client/models/device_logger_state.py index 4ad7697..6917b62 100644 --- a/src/infuse_iot/api_client/models/device_logger_state.py +++ b/src/infuse_iot/api_client/models/device_logger_state.py @@ -1,6 +1,6 @@ import datetime from collections.abc import Mapping -from typing import Any, TypeVar, Union +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -22,17 +22,17 @@ class DeviceLoggerState: last_downloaded_time (Union[Unset, datetime.datetime]): Last time logger state was downloaded """ - last_reported_block: Union[Unset, int] = UNSET - last_reported_time: Union[Unset, datetime.datetime] = UNSET - last_downloaded_block: Union[Unset, int] = UNSET - last_downloaded_wrap_count: Union[Unset, int] = UNSET - last_downloaded_time: Union[Unset, datetime.datetime] = UNSET + last_reported_block: Unset | int = UNSET + last_reported_time: Unset | datetime.datetime = UNSET + last_downloaded_block: Unset | int = UNSET + last_downloaded_wrap_count: Unset | int = UNSET + last_downloaded_time: Unset | datetime.datetime = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: last_reported_block = self.last_reported_block - last_reported_time: Union[Unset, str] = UNSET + last_reported_time: Unset | str = UNSET if not isinstance(self.last_reported_time, Unset): last_reported_time = self.last_reported_time.isoformat() @@ -40,7 +40,7 @@ def to_dict(self) -> dict[str, Any]: last_downloaded_wrap_count = self.last_downloaded_wrap_count - last_downloaded_time: Union[Unset, str] = UNSET + last_downloaded_time: Unset | str = UNSET if not isinstance(self.last_downloaded_time, Unset): last_downloaded_time = self.last_downloaded_time.isoformat() @@ -66,7 +66,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: last_reported_block = d.pop("lastReportedBlock", UNSET) _last_reported_time = d.pop("lastReportedTime", UNSET) - last_reported_time: Union[Unset, datetime.datetime] + last_reported_time: Unset | datetime.datetime if isinstance(_last_reported_time, Unset): last_reported_time = UNSET else: @@ -77,7 +77,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: last_downloaded_wrap_count = d.pop("lastDownloadedWrapCount", UNSET) _last_downloaded_time = d.pop("lastDownloadedTime", UNSET) - last_downloaded_time: Union[Unset, datetime.datetime] + last_downloaded_time: Unset | datetime.datetime if isinstance(_last_downloaded_time, Unset): last_downloaded_time = UNSET else: diff --git a/src/infuse_iot/api_client/models/device_state.py b/src/infuse_iot/api_client/models/device_state.py index 4708151..b2d07ca 100644 --- a/src/infuse_iot/api_client/models/device_state.py +++ b/src/infuse_iot/api_client/models/device_state.py @@ -32,11 +32,11 @@ class DeviceState: created_at: datetime.datetime updated_at: datetime.datetime - application_id: Union[Unset, int] = UNSET + application_id: Unset | int = UNSET application_version: Union[Unset, "ApplicationVersion"] = UNSET - algorithms: Union[Unset, list["Algorithm"]] = UNSET - last_route_interface: Union[Unset, RouteType] = UNSET - last_route_udp_address: Union[Unset, str] = UNSET + algorithms: Unset | list["Algorithm"] = UNSET + last_route_interface: Unset | RouteType = UNSET + last_route_udp_address: Unset | str = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -46,18 +46,18 @@ def to_dict(self) -> dict[str, Any]: application_id = self.application_id - application_version: Union[Unset, dict[str, Any]] = UNSET + application_version: Unset | dict[str, Any] = UNSET if not isinstance(self.application_version, Unset): application_version = self.application_version.to_dict() - algorithms: Union[Unset, list[dict[str, Any]]] = UNSET + algorithms: Unset | list[dict[str, Any]] = UNSET if not isinstance(self.algorithms, Unset): algorithms = [] for algorithms_item_data in self.algorithms: algorithms_item = algorithms_item_data.to_dict() algorithms.append(algorithms_item) - last_route_interface: Union[Unset, str] = UNSET + last_route_interface: Unset | str = UNSET if not isinstance(self.last_route_interface, Unset): last_route_interface = self.last_route_interface.value @@ -97,7 +97,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: application_id = d.pop("applicationId", UNSET) _application_version = d.pop("applicationVersion", UNSET) - application_version: Union[Unset, ApplicationVersion] + application_version: Unset | ApplicationVersion if isinstance(_application_version, Unset): application_version = UNSET else: @@ -111,7 +111,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: algorithms.append(algorithms_item) _last_route_interface = d.pop("lastRouteInterface", UNSET) - last_route_interface: Union[Unset, RouteType] + last_route_interface: Unset | RouteType if isinstance(_last_route_interface, Unset): last_route_interface = UNSET else: diff --git a/src/infuse_iot/api_client/models/device_update.py b/src/infuse_iot/api_client/models/device_update.py index f78f352..b878b0d 100644 --- a/src/infuse_iot/api_client/models/device_update.py +++ b/src/infuse_iot/api_client/models/device_update.py @@ -24,7 +24,7 @@ class DeviceUpdate: additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - metadata: Union[Unset, dict[str, Any]] = UNSET + metadata: Unset | dict[str, Any] = UNSET if not isinstance(self.metadata, Unset): metadata = self.metadata.to_dict() @@ -42,7 +42,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) _metadata = d.pop("metadata", UNSET) - metadata: Union[Unset, DeviceMetadataUpdate] + metadata: Unset | DeviceMetadataUpdate if isinstance(_metadata, Unset): metadata = UNSET else: diff --git a/src/infuse_iot/api_client/models/downlink_message.py b/src/infuse_iot/api_client/models/downlink_message.py index 966860b..31cf046 100644 --- a/src/infuse_iot/api_client/models/downlink_message.py +++ b/src/infuse_iot/api_client/models/downlink_message.py @@ -47,10 +47,10 @@ class DownlinkMessage: rpc_req: "RpcReq" status: DownlinkMessageStatus rpc_rsp: Union[Unset, "RpcRsp"] = UNSET - send_wait_timeout_ms: Union[Unset, int] = UNSET - sent_at: Union[Unset, datetime.datetime] = UNSET - expires_at: Union[Unset, datetime.datetime] = UNSET - completed_at: Union[Unset, datetime.datetime] = UNSET + send_wait_timeout_ms: Unset | int = UNSET + sent_at: Unset | datetime.datetime = UNSET + expires_at: Unset | datetime.datetime = UNSET + completed_at: Unset | datetime.datetime = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -70,21 +70,21 @@ def to_dict(self) -> dict[str, Any]: status = self.status.value - rpc_rsp: Union[Unset, dict[str, Any]] = UNSET + rpc_rsp: Unset | dict[str, Any] = UNSET if not isinstance(self.rpc_rsp, Unset): rpc_rsp = self.rpc_rsp.to_dict() send_wait_timeout_ms = self.send_wait_timeout_ms - sent_at: Union[Unset, str] = UNSET + sent_at: Unset | str = UNSET if not isinstance(self.sent_at, Unset): sent_at = self.sent_at.isoformat() - expires_at: Union[Unset, str] = UNSET + expires_at: Unset | str = UNSET if not isinstance(self.expires_at, Unset): expires_at = self.expires_at.isoformat() - completed_at: Union[Unset, str] = UNSET + completed_at: Unset | str = UNSET if not isinstance(self.completed_at, Unset): completed_at = self.completed_at.isoformat() @@ -138,7 +138,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: status = DownlinkMessageStatus(d.pop("status")) _rpc_rsp = d.pop("rpcRsp", UNSET) - rpc_rsp: Union[Unset, RpcRsp] + rpc_rsp: Unset | RpcRsp if isinstance(_rpc_rsp, Unset): rpc_rsp = UNSET else: @@ -147,21 +147,21 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: send_wait_timeout_ms = d.pop("sendWaitTimeoutMs", UNSET) _sent_at = d.pop("sentAt", UNSET) - sent_at: Union[Unset, datetime.datetime] + sent_at: Unset | datetime.datetime if isinstance(_sent_at, Unset): sent_at = UNSET else: sent_at = isoparse(_sent_at) _expires_at = d.pop("expiresAt", UNSET) - expires_at: Union[Unset, datetime.datetime] + expires_at: Unset | datetime.datetime if isinstance(_expires_at, Unset): expires_at = UNSET else: expires_at = isoparse(_expires_at) _completed_at = d.pop("completedAt", UNSET) - completed_at: Union[Unset, datetime.datetime] + completed_at: Unset | datetime.datetime if isinstance(_completed_at, Unset): completed_at = UNSET else: diff --git a/src/infuse_iot/api_client/models/downlink_route.py b/src/infuse_iot/api_client/models/downlink_route.py index 53487a4..eb8ec3c 100644 --- a/src/infuse_iot/api_client/models/downlink_route.py +++ b/src/infuse_iot/api_client/models/downlink_route.py @@ -44,23 +44,23 @@ def to_dict(self) -> dict[str, Any]: interface_data = self.interface_data.to_dict() - udp: Union[Unset, dict[str, Any]] = UNSET + udp: Unset | dict[str, Any] = UNSET if not isinstance(self.udp, Unset): udp = self.udp.to_dict() - bt_adv: Union[Unset, dict[str, Any]] = UNSET + bt_adv: Unset | dict[str, Any] = UNSET if not isinstance(self.bt_adv, Unset): bt_adv = self.bt_adv.to_dict() - bt_peripheral: Union[Unset, dict[str, Any]] = UNSET + bt_peripheral: Unset | dict[str, Any] = UNSET if not isinstance(self.bt_peripheral, Unset): bt_peripheral = self.bt_peripheral.to_dict() - bt_central: Union[Unset, dict[str, Any]] = UNSET + bt_central: Unset | dict[str, Any] = UNSET if not isinstance(self.bt_central, Unset): bt_central = self.bt_central.to_dict() - forwarded: Union[Unset, dict[str, Any]] = UNSET + forwarded: Unset | dict[str, Any] = UNSET if not isinstance(self.forwarded, Unset): forwarded = self.forwarded.to_dict() @@ -98,35 +98,35 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: interface_data = InterfaceData.from_dict(d.pop("interfaceData")) _udp = d.pop("udp", UNSET) - udp: Union[Unset, UdpDownlinkRoute] + udp: Unset | UdpDownlinkRoute if isinstance(_udp, Unset): udp = UNSET else: udp = UdpDownlinkRoute.from_dict(_udp) _bt_adv = d.pop("btAdv", UNSET) - bt_adv: Union[Unset, BtLeRoute] + bt_adv: Unset | BtLeRoute if isinstance(_bt_adv, Unset): bt_adv = UNSET else: bt_adv = BtLeRoute.from_dict(_bt_adv) _bt_peripheral = d.pop("btPeripheral", UNSET) - bt_peripheral: Union[Unset, BtLeRoute] + bt_peripheral: Unset | BtLeRoute if isinstance(_bt_peripheral, Unset): bt_peripheral = UNSET else: bt_peripheral = BtLeRoute.from_dict(_bt_peripheral) _bt_central = d.pop("btCentral", UNSET) - bt_central: Union[Unset, BtLeRoute] + bt_central: Unset | BtLeRoute if isinstance(_bt_central, Unset): bt_central = UNSET else: bt_central = BtLeRoute.from_dict(_bt_central) _forwarded = d.pop("forwarded", UNSET) - forwarded: Union[Unset, ForwardedDownlinkRoute] + forwarded: Unset | ForwardedDownlinkRoute if isinstance(_forwarded, Unset): forwarded = UNSET else: diff --git a/src/infuse_iot/api_client/models/generate_api_key_body.py b/src/infuse_iot/api_client/models/generate_api_key_body.py new file mode 100644 index 0000000..6f03921 --- /dev/null +++ b/src/infuse_iot/api_client/models/generate_api_key_body.py @@ -0,0 +1,84 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.api_key_org_user_type import APIKeyOrgUserType + +if TYPE_CHECKING: + from ..models.generate_api_key_body_resource_perms import GenerateAPIKeyBodyResourcePerms + + +T = TypeVar("T", bound="GenerateAPIKeyBody") + + +@_attrs_define +class GenerateAPIKeyBody: + """ + Attributes: + organisation_id (UUID): ID of the organisation Example: 123e4567-e89b-12d3-a456-426614174000. + user_type (APIKeyOrgUserType): The type of user in the organization. + resource_perms (GenerateAPIKeyBodyResourcePerms): + """ + + organisation_id: UUID + user_type: APIKeyOrgUserType + resource_perms: "GenerateAPIKeyBodyResourcePerms" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + organisation_id = str(self.organisation_id) + + user_type = self.user_type.value + + resource_perms = self.resource_perms.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "organisationId": organisation_id, + "userType": user_type, + "resourcePerms": resource_perms, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.generate_api_key_body_resource_perms import GenerateAPIKeyBodyResourcePerms + + d = dict(src_dict) + organisation_id = UUID(d.pop("organisationId")) + + user_type = APIKeyOrgUserType(d.pop("userType")) + + resource_perms = GenerateAPIKeyBodyResourcePerms.from_dict(d.pop("resourcePerms")) + + generate_api_key_body = cls( + organisation_id=organisation_id, + user_type=user_type, + resource_perms=resource_perms, + ) + + generate_api_key_body.additional_properties = d + return generate_api_key_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/generate_api_key_body_resource_perms.py b/src/infuse_iot/api_client/models/generate_api_key_body_resource_perms.py new file mode 100644 index 0000000..f876ef6 --- /dev/null +++ b/src/infuse_iot/api_client/models/generate_api_key_body_resource_perms.py @@ -0,0 +1,61 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.api_key_resource_perm import APIKeyResourcePerm + +T = TypeVar("T", bound="GenerateAPIKeyBodyResourcePerms") + + +@_attrs_define +class GenerateAPIKeyBodyResourcePerms: + """ """ + + additional_properties: dict[str, list[APIKeyResourcePerm]] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + for prop_name, prop in self.additional_properties.items(): + field_dict[prop_name] = [] + for additional_property_item_data in prop: + additional_property_item = additional_property_item_data.value + field_dict[prop_name].append(additional_property_item) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + generate_api_key_body_resource_perms = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = [] + _additional_property = prop_dict + for additional_property_item_data in _additional_property: + additional_property_item = APIKeyResourcePerm(additional_property_item_data) + + additional_property.append(additional_property_item) + + additional_properties[prop_name] = additional_property + + generate_api_key_body_resource_perms.additional_properties = additional_properties + return generate_api_key_body_resource_perms + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> list[APIKeyResourcePerm]: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: list[APIKeyResourcePerm]) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/generate_mqtt_token_body.py b/src/infuse_iot/api_client/models/generate_mqtt_token_body.py new file mode 100644 index 0000000..d7d2821 --- /dev/null +++ b/src/infuse_iot/api_client/models/generate_mqtt_token_body.py @@ -0,0 +1,68 @@ +from collections.abc import Mapping +from typing import Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="GenerateMQTTTokenBody") + + +@_attrs_define +class GenerateMQTTTokenBody: + """ + Attributes: + organisation_id (UUID): ID of organisation to scope the token to + ttl_seconds (int): Default: 3600. + """ + + organisation_id: UUID + ttl_seconds: int = 3600 + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + organisation_id = str(self.organisation_id) + + ttl_seconds = self.ttl_seconds + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "organisationId": organisation_id, + "ttlSeconds": ttl_seconds, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + organisation_id = UUID(d.pop("organisationId")) + + ttl_seconds = d.pop("ttlSeconds") + + generate_mqtt_token_body = cls( + organisation_id=organisation_id, + ttl_seconds=ttl_seconds, + ) + + generate_mqtt_token_body.additional_properties = d + return generate_mqtt_token_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/generated_api_key.py b/src/infuse_iot/api_client/models/generated_api_key.py new file mode 100644 index 0000000..deed412 --- /dev/null +++ b/src/infuse_iot/api_client/models/generated_api_key.py @@ -0,0 +1,59 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="GeneratedAPIKey") + + +@_attrs_define +class GeneratedAPIKey: + """ + Attributes: + key (str): Generated API Key Example: Bearer abcdefghijklmnopqrstuvwxyz1234567890. + """ + + key: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + key = self.key + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "key": key, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + key = d.pop("key") + + generated_api_key = cls( + key=key, + ) + + generated_api_key.additional_properties = d + return generated_api_key + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/generated_mqtt_token.py b/src/infuse_iot/api_client/models/generated_mqtt_token.py new file mode 100644 index 0000000..3d318d4 --- /dev/null +++ b/src/infuse_iot/api_client/models/generated_mqtt_token.py @@ -0,0 +1,77 @@ +import datetime +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +T = TypeVar("T", bound="GeneratedMQTTToken") + + +@_attrs_define +class GeneratedMQTTToken: + """ + Attributes: + token (str): Generated MQTT token + issued_at (datetime.datetime): Issue time of token + expires_at (datetime.datetime): Expiry time of token + """ + + token: str + issued_at: datetime.datetime + expires_at: datetime.datetime + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + token = self.token + + issued_at = self.issued_at.isoformat() + + expires_at = self.expires_at.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "token": token, + "issuedAt": issued_at, + "expiresAt": expires_at, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + token = d.pop("token") + + issued_at = isoparse(d.pop("issuedAt")) + + expires_at = isoparse(d.pop("expiresAt")) + + generated_mqtt_token = cls( + token=token, + issued_at=issued_at, + expires_at=expires_at, + ) + + generated_mqtt_token.additional_properties = d + return generated_mqtt_token + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/interface_data.py b/src/infuse_iot/api_client/models/interface_data.py index bef430e..c0c4754 100644 --- a/src/infuse_iot/api_client/models/interface_data.py +++ b/src/infuse_iot/api_client/models/interface_data.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import Any, TypeVar, Union +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,7 +16,7 @@ class InterfaceData: sequence (Union[Unset, int]): Sequence number of packet """ - sequence: Union[Unset, int] = UNSET + sequence: Unset | int = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: diff --git a/src/infuse_iot/api_client/models/new_board.py b/src/infuse_iot/api_client/models/new_board.py index 44ec7bd..9c55258 100644 --- a/src/infuse_iot/api_client/models/new_board.py +++ b/src/infuse_iot/api_client/models/new_board.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -30,7 +30,7 @@ class NewBoard: description: str soc: str organisation_id: UUID - metadata_fields: Union[Unset, list["MetadataField"]] = UNSET + metadata_fields: Unset | list["MetadataField"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -42,7 +42,7 @@ def to_dict(self) -> dict[str, Any]: organisation_id = str(self.organisation_id) - metadata_fields: Union[Unset, list[dict[str, Any]]] = UNSET + metadata_fields: Unset | list[dict[str, Any]] = UNSET if not isinstance(self.metadata_fields, Unset): metadata_fields = [] for componentsschemas_board_metadata_fields_item_data in self.metadata_fields: diff --git a/src/infuse_iot/api_client/models/new_device.py b/src/infuse_iot/api_client/models/new_device.py index 4981247..d081e03 100644 --- a/src/infuse_iot/api_client/models/new_device.py +++ b/src/infuse_iot/api_client/models/new_device.py @@ -31,7 +31,7 @@ class NewDevice: mcu_id: str board_id: UUID organisation_id: UUID - device_id: Union[Unset, str] = UNSET + device_id: Unset | str = UNSET metadata: Union[Unset, "DeviceMetadata"] = UNSET initial_device_state: Union[Unset, "NewDeviceState"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -45,11 +45,11 @@ def to_dict(self) -> dict[str, Any]: device_id = self.device_id - metadata: Union[Unset, dict[str, Any]] = UNSET + metadata: Unset | dict[str, Any] = UNSET if not isinstance(self.metadata, Unset): metadata = self.metadata.to_dict() - initial_device_state: Union[Unset, dict[str, Any]] = UNSET + initial_device_state: Unset | dict[str, Any] = UNSET if not isinstance(self.initial_device_state, Unset): initial_device_state = self.initial_device_state.to_dict() @@ -86,14 +86,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: device_id = d.pop("deviceId", UNSET) _metadata = d.pop("metadata", UNSET) - metadata: Union[Unset, DeviceMetadata] + metadata: Unset | DeviceMetadata if isinstance(_metadata, Unset): metadata = UNSET else: metadata = DeviceMetadata.from_dict(_metadata) _initial_device_state = d.pop("initialDeviceState", UNSET) - initial_device_state: Union[Unset, NewDeviceState] + initial_device_state: Unset | NewDeviceState if isinstance(_initial_device_state, Unset): initial_device_state = UNSET else: diff --git a/src/infuse_iot/api_client/models/new_device_kv_entry_update.py b/src/infuse_iot/api_client/models/new_device_kv_entry_update.py new file mode 100644 index 0000000..1b89dfc --- /dev/null +++ b/src/infuse_iot/api_client/models/new_device_kv_entry_update.py @@ -0,0 +1,81 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.new_device_kv_entry_update_decoded import NewDeviceKVEntryUpdateDecoded + + +T = TypeVar("T", bound="NewDeviceKVEntryUpdate") + + +@_attrs_define +class NewDeviceKVEntryUpdate: + """ + Attributes: + data (Union[Unset, str]): Raw entry data as a base64 encoded string (must provide either data or decoded) + decoded (Union[Unset, NewDeviceKVEntryUpdateDecoded]): Decoded entry value (must provide either data or decoded) + """ + + data: Unset | str = UNSET + decoded: Union[Unset, "NewDeviceKVEntryUpdateDecoded"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + data = self.data + + decoded: Unset | dict[str, Any] = UNSET + if not isinstance(self.decoded, Unset): + decoded = self.decoded.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if data is not UNSET: + field_dict["data"] = data + if decoded is not UNSET: + field_dict["decoded"] = decoded + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.new_device_kv_entry_update_decoded import NewDeviceKVEntryUpdateDecoded + + d = dict(src_dict) + data = d.pop("data", UNSET) + + _decoded = d.pop("decoded", UNSET) + decoded: Unset | NewDeviceKVEntryUpdateDecoded + if isinstance(_decoded, Unset): + decoded = UNSET + else: + decoded = NewDeviceKVEntryUpdateDecoded.from_dict(_decoded) + + new_device_kv_entry_update = cls( + data=data, + decoded=decoded, + ) + + new_device_kv_entry_update.additional_properties = d + return new_device_kv_entry_update + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/new_device_kv_entry_update_decoded.py b/src/infuse_iot/api_client/models/new_device_kv_entry_update_decoded.py new file mode 100644 index 0000000..47eeed8 --- /dev/null +++ b/src/infuse_iot/api_client/models/new_device_kv_entry_update_decoded.py @@ -0,0 +1,44 @@ +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="NewDeviceKVEntryUpdateDecoded") + + +@_attrs_define +class NewDeviceKVEntryUpdateDecoded: + """Decoded entry value (must provide either data or decoded)""" + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + new_device_kv_entry_update_decoded = cls() + + new_device_kv_entry_update_decoded.additional_properties = d + return new_device_kv_entry_update_decoded + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/new_device_state.py b/src/infuse_iot/api_client/models/new_device_state.py index 80f28f3..6b53f1b 100644 --- a/src/infuse_iot/api_client/models/new_device_state.py +++ b/src/infuse_iot/api_client/models/new_device_state.py @@ -23,19 +23,19 @@ class NewDeviceState: algorithms (Union[Unset, list['Algorithm']]): Last announced algorithms """ - application_id: Union[Unset, int] = UNSET + application_id: Unset | int = UNSET application_version: Union[Unset, "ApplicationVersion"] = UNSET - algorithms: Union[Unset, list["Algorithm"]] = UNSET + algorithms: Unset | list["Algorithm"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: application_id = self.application_id - application_version: Union[Unset, dict[str, Any]] = UNSET + application_version: Unset | dict[str, Any] = UNSET if not isinstance(self.application_version, Unset): application_version = self.application_version.to_dict() - algorithms: Union[Unset, list[dict[str, Any]]] = UNSET + algorithms: Unset | list[dict[str, Any]] = UNSET if not isinstance(self.algorithms, Unset): algorithms = [] for algorithms_item_data in self.algorithms: @@ -63,7 +63,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: application_id = d.pop("applicationId", UNSET) _application_version = d.pop("applicationVersion", UNSET) - application_version: Union[Unset, ApplicationVersion] + application_version: Unset | ApplicationVersion if isinstance(_application_version, Unset): application_version = UNSET else: diff --git a/src/infuse_iot/api_client/models/new_rpc_message.py b/src/infuse_iot/api_client/models/new_rpc_message.py index 1c4817e..5f560ad 100644 --- a/src/infuse_iot/api_client/models/new_rpc_message.py +++ b/src/infuse_iot/api_client/models/new_rpc_message.py @@ -1,5 +1,5 @@ from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -25,7 +25,7 @@ class NewRPCMessage: device_id: str rpc: "NewRPCReq" - send_wait_timeout_ms: Union[Unset, int] = 60000 + send_wait_timeout_ms: Unset | int = 60000 additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: diff --git a/src/infuse_iot/api_client/models/new_rpc_req.py b/src/infuse_iot/api_client/models/new_rpc_req.py index 7bd9efd..1dd0083 100644 --- a/src/infuse_iot/api_client/models/new_rpc_req.py +++ b/src/infuse_iot/api_client/models/new_rpc_req.py @@ -28,10 +28,10 @@ class NewRPCReq: data_header (Union[Unset, RPCReqDataHeader]): """ - command_id: Union[Unset, int] = UNSET - command_name: Union[Unset, str] = UNSET + command_id: Unset | int = UNSET + command_name: Unset | str = UNSET params: Union[Unset, "RPCParams"] = UNSET - params_encoded: Union[Unset, str] = UNSET + params_encoded: Unset | str = UNSET data_header: Union[Unset, "RPCReqDataHeader"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -40,13 +40,13 @@ def to_dict(self) -> dict[str, Any]: command_name = self.command_name - params: Union[Unset, dict[str, Any]] = UNSET + params: Unset | dict[str, Any] = UNSET if not isinstance(self.params, Unset): params = self.params.to_dict() params_encoded = self.params_encoded - data_header: Union[Unset, dict[str, Any]] = UNSET + data_header: Unset | dict[str, Any] = UNSET if not isinstance(self.data_header, Unset): data_header = self.data_header.to_dict() @@ -77,7 +77,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: command_name = d.pop("commandName", UNSET) _params = d.pop("params", UNSET) - params: Union[Unset, RPCParams] + params: Unset | RPCParams if isinstance(_params, Unset): params = UNSET else: @@ -86,7 +86,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: params_encoded = d.pop("paramsEncoded", UNSET) _data_header = d.pop("dataHeader", UNSET) - data_header: Union[Unset, RPCReqDataHeader] + data_header: Unset | RPCReqDataHeader if isinstance(_data_header, Unset): data_header = UNSET else: diff --git a/src/infuse_iot/api_client/models/rpc_req.py b/src/infuse_iot/api_client/models/rpc_req.py index a677d0a..14daae6 100644 --- a/src/infuse_iot/api_client/models/rpc_req.py +++ b/src/infuse_iot/api_client/models/rpc_req.py @@ -32,7 +32,7 @@ class RpcReq: request_id: int command_id: int params: Union[Unset, "RPCParams"] = UNSET - params_encoded: Union[Unset, str] = UNSET + params_encoded: Unset | str = UNSET data_header: Union[Unset, "RPCReqDataHeader"] = UNSET route: Union[Unset, "DownlinkRoute"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -42,17 +42,17 @@ def to_dict(self) -> dict[str, Any]: command_id = self.command_id - params: Union[Unset, dict[str, Any]] = UNSET + params: Unset | dict[str, Any] = UNSET if not isinstance(self.params, Unset): params = self.params.to_dict() params_encoded = self.params_encoded - data_header: Union[Unset, dict[str, Any]] = UNSET + data_header: Unset | dict[str, Any] = UNSET if not isinstance(self.data_header, Unset): data_header = self.data_header.to_dict() - route: Union[Unset, dict[str, Any]] = UNSET + route: Unset | dict[str, Any] = UNSET if not isinstance(self.route, Unset): route = self.route.to_dict() @@ -87,7 +87,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: command_id = d.pop("commandId") _params = d.pop("params", UNSET) - params: Union[Unset, RPCParams] + params: Unset | RPCParams if isinstance(_params, Unset): params = UNSET else: @@ -96,14 +96,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: params_encoded = d.pop("paramsEncoded", UNSET) _data_header = d.pop("dataHeader", UNSET) - data_header: Union[Unset, RPCReqDataHeader] + data_header: Unset | RPCReqDataHeader if isinstance(_data_header, Unset): data_header = UNSET else: data_header = RPCReqDataHeader.from_dict(_data_header) _route = d.pop("route", UNSET) - route: Union[Unset, DownlinkRoute] + route: Unset | DownlinkRoute if isinstance(_route, Unset): route = UNSET else: diff --git a/src/infuse_iot/api_client/models/rpc_rsp.py b/src/infuse_iot/api_client/models/rpc_rsp.py index e139cec..65eb0c9 100644 --- a/src/infuse_iot/api_client/models/rpc_rsp.py +++ b/src/infuse_iot/api_client/models/rpc_rsp.py @@ -30,7 +30,7 @@ class RpcRsp: route: "UplinkRoute" return_code: int params: Union[Unset, "RPCParams"] = UNSET - params_encoded: Union[Unset, str] = UNSET + params_encoded: Unset | str = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -38,7 +38,7 @@ def to_dict(self) -> dict[str, Any]: return_code = self.return_code - params: Union[Unset, dict[str, Any]] = UNSET + params: Unset | dict[str, Any] = UNSET if not isinstance(self.params, Unset): params = self.params.to_dict() @@ -70,7 +70,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: return_code = d.pop("returnCode") _params = d.pop("params", UNSET) - params: Union[Unset, RPCParams] + params: Unset | RPCParams if isinstance(_params, Unset): params = UNSET else: diff --git a/src/infuse_iot/api_client/models/uplink_route.py b/src/infuse_iot/api_client/models/uplink_route.py index 4b66857..f2be48f 100644 --- a/src/infuse_iot/api_client/models/uplink_route.py +++ b/src/infuse_iot/api_client/models/uplink_route.py @@ -44,23 +44,23 @@ def to_dict(self) -> dict[str, Any]: interface_data = self.interface_data.to_dict() - udp: Union[Unset, dict[str, Any]] = UNSET + udp: Unset | dict[str, Any] = UNSET if not isinstance(self.udp, Unset): udp = self.udp.to_dict() - bt_adv: Union[Unset, dict[str, Any]] = UNSET + bt_adv: Unset | dict[str, Any] = UNSET if not isinstance(self.bt_adv, Unset): bt_adv = self.bt_adv.to_dict() - bt_peripheral: Union[Unset, dict[str, Any]] = UNSET + bt_peripheral: Unset | dict[str, Any] = UNSET if not isinstance(self.bt_peripheral, Unset): bt_peripheral = self.bt_peripheral.to_dict() - bt_central: Union[Unset, dict[str, Any]] = UNSET + bt_central: Unset | dict[str, Any] = UNSET if not isinstance(self.bt_central, Unset): bt_central = self.bt_central.to_dict() - forwarded: Union[Unset, dict[str, Any]] = UNSET + forwarded: Unset | dict[str, Any] = UNSET if not isinstance(self.forwarded, Unset): forwarded = self.forwarded.to_dict() @@ -98,35 +98,35 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: interface_data = InterfaceData.from_dict(d.pop("interfaceData")) _udp = d.pop("udp", UNSET) - udp: Union[Unset, UdpUplinkRoute] + udp: Unset | UdpUplinkRoute if isinstance(_udp, Unset): udp = UNSET else: udp = UdpUplinkRoute.from_dict(_udp) _bt_adv = d.pop("btAdv", UNSET) - bt_adv: Union[Unset, BtLeRoute] + bt_adv: Unset | BtLeRoute if isinstance(_bt_adv, Unset): bt_adv = UNSET else: bt_adv = BtLeRoute.from_dict(_bt_adv) _bt_peripheral = d.pop("btPeripheral", UNSET) - bt_peripheral: Union[Unset, BtLeRoute] + bt_peripheral: Unset | BtLeRoute if isinstance(_bt_peripheral, Unset): bt_peripheral = UNSET else: bt_peripheral = BtLeRoute.from_dict(_bt_peripheral) _bt_central = d.pop("btCentral", UNSET) - bt_central: Union[Unset, BtLeRoute] + bt_central: Unset | BtLeRoute if isinstance(_bt_central, Unset): bt_central = UNSET else: bt_central = BtLeRoute.from_dict(_bt_central) _forwarded = d.pop("forwarded", UNSET) - forwarded: Union[Unset, ForwardedUplinkRoute] + forwarded: Unset | ForwardedUplinkRoute if isinstance(_forwarded, Unset): forwarded = UNSET else: diff --git a/src/infuse_iot/api_client/py.typed b/src/infuse_iot/api_client/py.typed deleted file mode 100644 index 1aad327..0000000 --- a/src/infuse_iot/api_client/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561 \ No newline at end of file diff --git a/src/infuse_iot/api_client/types.py b/src/infuse_iot/api_client/types.py index b9ed58b..ca68df1 100644 --- a/src/infuse_iot/api_client/types.py +++ b/src/infuse_iot/api_client/types.py @@ -2,7 +2,7 @@ from collections.abc import MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, Optional, TypeVar +from typing import BinaryIO, Generic, Literal, TypeVar from attrs import define @@ -14,7 +14,7 @@ def __bool__(self) -> Literal[False]: UNSET: Unset = Unset() -FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] +FileJsonType = tuple[str | None, BinaryIO, str | None] @define @@ -22,8 +22,8 @@ class File: """Contains information for file uploads""" payload: BinaryIO - file_name: Optional[str] = None - mime_type: Optional[str] = None + file_name: str | None = None + mime_type: str | None = None def to_tuple(self) -> FileJsonType: """Return a tuple representation that httpx will accept for multipart/form-data""" @@ -40,7 +40,7 @@ class Response(Generic[T]): status_code: HTTPStatus content: bytes headers: MutableMapping[str, str] - parsed: Optional[T] + parsed: T | None __all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"] diff --git a/src/infuse_iot/tools/cloud.py b/src/infuse_iot/tools/cloud.py index 737dfd6..3f7972d 100644 --- a/src/infuse_iot/tools/cloud.py +++ b/src/infuse_iot/tools/cloud.py @@ -21,6 +21,7 @@ from infuse_iot.api_client.api.coap import get_coap_files from infuse_iot.api_client.api.device import ( get_device_by_device_id, + get_device_kv_entries_by_device_id, get_device_last_route_by_device_id, get_device_state_by_id, ) @@ -30,6 +31,7 @@ get_organisation_by_id, ) from infuse_iot.api_client.models import COAPFilesList, Error, NewBoard, NewOrganisation +from infuse_iot.api_client.types import Unset from infuse_iot.commands import InfuseCommand from infuse_iot.credentials import get_api_key @@ -167,6 +169,9 @@ def add_parser(cls, parser): info_parser = tool_parser.add_parser("info") info_parser.set_defaults(command_fn=cls.info) info_parser.add_argument("--id", type=str, help="Infuse-IoT device ID") + info_parser = tool_parser.add_parser("kv_state") + info_parser.set_defaults(command_fn=cls.kv_state) + info_parser.add_argument("--id", type=str, help="Infuse-IoT device ID") def run(self): with self.client() as client: @@ -217,6 +222,36 @@ def info(self, client: Client): print(tabulate(table)) + def _kv_display(self, table: list[tuple[str, Any]], name_base: str, dictionary: dict): + for name, value in dictionary.items(): + if isinstance(value, dict): + self._kv_display(table, f"{name_base}.{name}", value) + else: + table.append((f"{name_base}.{name}", value)) + + def kv_state(self, client: Client): + id_int = int(self.args.id, 0) + id_str = f"{id_int:016x}" + + kv_state = get_device_kv_entries_by_device_id.sync(client=client, device_id=id_str) + if kv_state is None: + print(f"Unable to query KV state for {id_str}") + return + + table: list[tuple[str, Any]] = [] + for element in kv_state: + key = element.key_name if isinstance(element.key_name, str) else str(element.key_id) + + if isinstance(element.data, Unset): + table.append((key, "Not set")) + else: + if isinstance(element.decoded, Unset): + table.append((key, element.data)) + else: + self._kv_display(table, key, element.decoded.additional_properties) + + print(tabulate(table)) + class Coap(CloudSubCommand): @classmethod