diff --git a/src/infuse_iot/api_client/api/board/__init__.py b/src/infuse_iot/api_client/api/board/__init__.py index e69de29..2d7c0b2 100644 --- a/src/infuse_iot/api_client/api/board/__init__.py +++ b/src/infuse_iot/api_client/api/board/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 22d44fd..70eca07 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: NewBoard, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/board", } 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 88ea7ca..0ea48f8 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast from uuid import UUID import httpx @@ -12,8 +12,8 @@ def _get_kwargs( id: UUID, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/board/id/{id}", } 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 47cf156..f655c14 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, Dict, List, Optional, Union +from typing import Any, Optional, Union from uuid import UUID import httpx @@ -13,15 +13,15 @@ def _get_kwargs( *, organisation_id: UUID, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id = str(organisation_id) params["organisationId"] = json_organisation_id params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/board", "params": params, @@ -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: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list["Board"]]: 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: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list["Board"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +59,7 @@ def sync_detailed( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Response[List["Board"]]: +) -> Response[list["Board"]]: """Get all boards in an organisation Args: @@ -70,7 +70,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List['Board']] + Response[list['Board']] """ kwargs = _get_kwargs( @@ -88,7 +88,7 @@ def sync( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Optional[List["Board"]]: +) -> Optional[list["Board"]]: """Get all boards in an organisation Args: @@ -99,7 +99,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List['Board'] + list['Board'] """ return sync_detailed( @@ -112,7 +112,7 @@ async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Response[List["Board"]]: +) -> Response[list["Board"]]: """Get all boards in an organisation Args: @@ -123,7 +123,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List['Board']] + Response[list['Board']] """ kwargs = _get_kwargs( @@ -139,7 +139,7 @@ async def asyncio( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Optional[List["Board"]]: +) -> Optional[list["Board"]]: """Get all boards in an organisation Args: @@ -150,7 +150,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List['Board'] + list['Board'] """ return ( 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 8b6ebde..c3699c7 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, Dict, List, Optional, Union, cast +from typing import Any, Optional, Union, cast from uuid import UUID import httpx @@ -15,8 +15,8 @@ def _get_kwargs( *, metadata_name: Union[Unset, str] = UNSET, metadata_value: Union[Unset, str] = UNSET, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["metadataName"] = metadata_name @@ -24,7 +24,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": f"/board/id/{id}/devices", "params": params, @@ -35,7 +35,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Any, List["Device"]]]: +) -> Optional[Union[Any, list["Device"]]]: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -56,7 +56,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Any, List["Device"]]]: +) -> Response[Union[Any, list["Device"]]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -71,7 +71,7 @@ def sync_detailed( client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, metadata_value: Union[Unset, str] = UNSET, -) -> Response[Union[Any, List["Device"]]]: +) -> Response[Union[Any, list["Device"]]]: """Get devices by board id and optional metadata field Args: @@ -84,7 +84,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, List['Device']]] + Response[Union[Any, list['Device']]] """ kwargs = _get_kwargs( @@ -106,7 +106,7 @@ def sync( client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, metadata_value: Union[Unset, str] = UNSET, -) -> Optional[Union[Any, List["Device"]]]: +) -> Optional[Union[Any, list["Device"]]]: """Get devices by board id and optional metadata field Args: @@ -119,7 +119,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Any, List['Device']] + Union[Any, list['Device']] """ return sync_detailed( @@ -136,7 +136,7 @@ async def asyncio_detailed( client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, metadata_value: Union[Unset, str] = UNSET, -) -> Response[Union[Any, List["Device"]]]: +) -> Response[Union[Any, list["Device"]]]: """Get devices by board id and optional metadata field Args: @@ -149,7 +149,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Any, List['Device']]] + Response[Union[Any, list['Device']]] """ kwargs = _get_kwargs( @@ -169,7 +169,7 @@ async def asyncio( client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, metadata_value: Union[Unset, str] = UNSET, -) -> Optional[Union[Any, List["Device"]]]: +) -> Optional[Union[Any, list["Device"]]]: """Get devices by board id and optional metadata field Args: @@ -182,7 +182,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Any, List['Device']] + Union[Any, list['Device']] """ return ( diff --git a/src/infuse_iot/api_client/api/coap/__init__.py b/src/infuse_iot/api_client/api/coap/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/infuse_iot/api_client/api/coap/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 new file mode 100644 index 0000000..0e0a612 --- /dev/null +++ b/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py @@ -0,0 +1,159 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.coap_file_stats import COAPFileStats +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + filename: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/coap/file/{filename}/stats", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[COAPFileStats, Error]]: + if response.status_code == 200: + response_200 = COAPFileStats.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[COAPFileStats, Error]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + filename: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[COAPFileStats, Error]]: + """Get statistics for a file on the COAP server + + Args: + filename (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[COAPFileStats, Error]] + """ + + kwargs = _get_kwargs( + filename=filename, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + filename: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[COAPFileStats, Error]]: + """Get statistics for a file on the COAP server + + Args: + filename (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[COAPFileStats, Error] + """ + + return sync_detailed( + filename=filename, + client=client, + ).parsed + + +async def asyncio_detailed( + filename: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[COAPFileStats, Error]]: + """Get statistics for a file on the COAP server + + Args: + filename (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[COAPFileStats, Error]] + """ + + kwargs = _get_kwargs( + filename=filename, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + filename: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[COAPFileStats, Error]]: + """Get statistics for a file on the COAP server + + Args: + filename (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[COAPFileStats, Error] + """ + + return ( + await asyncio_detailed( + filename=filename, + client=client, + ) + ).parsed 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 new file mode 100644 index 0000000..822e567 --- /dev/null +++ b/src/infuse_iot/api_client/api/coap/get_coap_files.py @@ -0,0 +1,167 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.coap_files_list import COAPFilesList +from ...models.error import Error +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + regex: Union[Unset, str] = UNSET, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + params["regex"] = regex + + 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": "/coap/files", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[COAPFilesList, Error]]: + if response.status_code == 200: + response_200 = COAPFilesList.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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[COAPFilesList, Error]]: + 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: Union[AuthenticatedClient, Client], + regex: Union[Unset, str] = UNSET, +) -> Response[Union[COAPFilesList, Error]]: + """Get a list of files on the COAP server + + Args: + regex (Union[Unset, 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[COAPFilesList, Error]] + """ + + kwargs = _get_kwargs( + regex=regex, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + regex: Union[Unset, str] = UNSET, +) -> Optional[Union[COAPFilesList, Error]]: + """Get a list of files on the COAP server + + Args: + regex (Union[Unset, 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[COAPFilesList, Error] + """ + + return sync_detailed( + client=client, + regex=regex, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + regex: Union[Unset, str] = UNSET, +) -> Response[Union[COAPFilesList, Error]]: + """Get a list of files on the COAP server + + Args: + regex (Union[Unset, 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[COAPFilesList, Error]] + """ + + kwargs = _get_kwargs( + regex=regex, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + regex: Union[Unset, str] = UNSET, +) -> Optional[Union[COAPFilesList, Error]]: + """Get a list of files on the COAP server + + Args: + regex (Union[Unset, 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[COAPFilesList, Error] + """ + + return ( + await asyncio_detailed( + client=client, + regex=regex, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/default/__init__.py b/src/infuse_iot/api_client/api/default/__init__.py index e69de29..2d7c0b2 100644 --- a/src/infuse_iot/api_client/api/default/__init__.py +++ b/src/infuse_iot/api_client/api/default/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 c29d46e..9112e61 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, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -9,8 +9,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/health", } diff --git a/src/infuse_iot/api_client/api/defs/__init__.py b/src/infuse_iot/api_client/api/defs/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 new file mode 100644 index 0000000..4c9a817 --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/add_kv_definitions.py @@ -0,0 +1,169 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_kv import DefinitionsKV +from ...models.definitions_kv_response import DefinitionsKVResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + *, + body: DefinitionsKV, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/defs/kv", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsKVResponse, Error]]: + if response.status_code == 201: + response_201 = DefinitionsKVResponse.from_dict(response.json()) + + return response_201 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsKVResponse, Error]]: + 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: Union[AuthenticatedClient, Client], + body: DefinitionsKV, +) -> Response[Union[DefinitionsKVResponse, Error]]: + """Add new version of key-value definitions + + Args: + body (DefinitionsKV): + + 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[DefinitionsKVResponse, Error]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: DefinitionsKV, +) -> Optional[Union[DefinitionsKVResponse, Error]]: + """Add new version of key-value definitions + + Args: + body (DefinitionsKV): + + 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[DefinitionsKVResponse, Error] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: DefinitionsKV, +) -> Response[Union[DefinitionsKVResponse, Error]]: + """Add new version of key-value definitions + + Args: + body (DefinitionsKV): + + 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[DefinitionsKVResponse, Error]] + """ + + 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: Union[AuthenticatedClient, Client], + body: DefinitionsKV, +) -> Optional[Union[DefinitionsKVResponse, Error]]: + """Add new version of key-value definitions + + Args: + body (DefinitionsKV): + + 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[DefinitionsKVResponse, Error] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed 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 new file mode 100644 index 0000000..34f8aaf --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/add_rpc_definitions.py @@ -0,0 +1,169 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_rpc import DefinitionsRPC +from ...models.definitions_rpc_response import DefinitionsRPCResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + *, + body: DefinitionsRPC, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/defs/rpc", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + if response.status_code == 201: + response_201 = DefinitionsRPCResponse.from_dict(response.json()) + + return response_201 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsRPCResponse, Error]]: + 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: Union[AuthenticatedClient, Client], + body: DefinitionsRPC, +) -> Response[Union[DefinitionsRPCResponse, Error]]: + """Add new version of RPC definitions + + Args: + body (DefinitionsRPC): + + 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[DefinitionsRPCResponse, Error]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: DefinitionsRPC, +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + """Add new version of RPC definitions + + Args: + body (DefinitionsRPC): + + 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[DefinitionsRPCResponse, Error] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: DefinitionsRPC, +) -> Response[Union[DefinitionsRPCResponse, Error]]: + """Add new version of RPC definitions + + Args: + body (DefinitionsRPC): + + 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[DefinitionsRPCResponse, Error]] + """ + + 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: Union[AuthenticatedClient, Client], + body: DefinitionsRPC, +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + """Add new version of RPC definitions + + Args: + body (DefinitionsRPC): + + 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[DefinitionsRPCResponse, Error] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed 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 new file mode 100644 index 0000000..31595d0 --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/add_tdf_definitions.py @@ -0,0 +1,169 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_tdf import DefinitionsTDF +from ...models.definitions_tdf_response import DefinitionsTDFResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + *, + body: DefinitionsTDF, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/defs/tdf", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + if response.status_code == 201: + response_201 = DefinitionsTDFResponse.from_dict(response.json()) + + return response_201 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsTDFResponse, Error]]: + 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: Union[AuthenticatedClient, Client], + body: DefinitionsTDF, +) -> Response[Union[DefinitionsTDFResponse, Error]]: + """Add new version of TDF definitions + + Args: + body (DefinitionsTDF): + + 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[DefinitionsTDFResponse, Error]] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + body: DefinitionsTDF, +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + """Add new version of TDF definitions + + Args: + body (DefinitionsTDF): + + 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[DefinitionsTDFResponse, Error] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: DefinitionsTDF, +) -> Response[Union[DefinitionsTDFResponse, Error]]: + """Add new version of TDF definitions + + Args: + body (DefinitionsTDF): + + 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[DefinitionsTDFResponse, Error]] + """ + + 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: Union[AuthenticatedClient, Client], + body: DefinitionsTDF, +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + """Add new version of TDF definitions + + Args: + body (DefinitionsTDF): + + 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[DefinitionsTDFResponse, Error] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed 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 new file mode 100644 index 0000000..b0f24e2 --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py @@ -0,0 +1,159 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_kv_response import DefinitionsKVResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + version: int, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/defs/kv/{version}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsKVResponse, Error]]: + if response.status_code == 200: + response_200 = DefinitionsKVResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsKVResponse, Error]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsKVResponse, Error]]: + """Get key-value definitions by version + + Args: + version (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[DefinitionsKVResponse, Error]] + """ + + kwargs = _get_kwargs( + version=version, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsKVResponse, Error]]: + """Get key-value definitions by version + + Args: + version (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[DefinitionsKVResponse, Error] + """ + + return sync_detailed( + version=version, + client=client, + ).parsed + + +async def asyncio_detailed( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsKVResponse, Error]]: + """Get key-value definitions by version + + Args: + version (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[DefinitionsKVResponse, Error]] + """ + + kwargs = _get_kwargs( + version=version, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsKVResponse, Error]]: + """Get key-value definitions by version + + Args: + version (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[DefinitionsKVResponse, Error] + """ + + return ( + await asyncio_detailed( + version=version, + client=client, + ) + ).parsed 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 new file mode 100644 index 0000000..96d497a --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py @@ -0,0 +1,135 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_kv_response import DefinitionsKVResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/defs/kv", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsKVResponse, Error]]: + if response.status_code == 200: + response_200 = DefinitionsKVResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsKVResponse, Error]]: + 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: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsKVResponse, Error]]: + """Get the latest KV definitions + + 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[DefinitionsKVResponse, Error]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsKVResponse, Error]]: + """Get the latest KV definitions + + 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[DefinitionsKVResponse, Error] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsKVResponse, Error]]: + """Get the latest KV definitions + + 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[DefinitionsKVResponse, Error]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsKVResponse, Error]]: + """Get the latest KV definitions + + 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[DefinitionsKVResponse, Error] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed 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 new file mode 100644 index 0000000..9eb7c84 --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py @@ -0,0 +1,135 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_rpc_response import DefinitionsRPCResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/defs/rpc", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + if response.status_code == 200: + response_200 = DefinitionsRPCResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsRPCResponse, Error]]: + 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: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsRPCResponse, Error]]: + """Get the latest RPC definitions + + 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[DefinitionsRPCResponse, Error]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + """Get the latest RPC definitions + + 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[DefinitionsRPCResponse, Error] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsRPCResponse, Error]]: + """Get the latest RPC definitions + + 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[DefinitionsRPCResponse, Error]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + """Get the latest RPC definitions + + 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[DefinitionsRPCResponse, Error] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed 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 new file mode 100644 index 0000000..309f87b --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py @@ -0,0 +1,135 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_tdf_response import DefinitionsTDFResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/defs/tdf", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + if response.status_code == 200: + response_200 = DefinitionsTDFResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsTDFResponse, Error]]: + 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: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsTDFResponse, Error]]: + """Get the latest TDF definitions + + 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[DefinitionsTDFResponse, Error]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + """Get the latest TDF definitions + + 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[DefinitionsTDFResponse, Error] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsTDFResponse, Error]]: + """Get the latest TDF definitions + + 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[DefinitionsTDFResponse, Error]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + """Get the latest TDF definitions + + 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[DefinitionsTDFResponse, Error] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed 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 new file mode 100644 index 0000000..70ac46f --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py @@ -0,0 +1,159 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_rpc_response import DefinitionsRPCResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + version: int, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/defs/rpc/{version}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + if response.status_code == 200: + response_200 = DefinitionsRPCResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsRPCResponse, Error]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsRPCResponse, Error]]: + """Get RPC definitions by version + + Args: + version (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[DefinitionsRPCResponse, Error]] + """ + + kwargs = _get_kwargs( + version=version, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + """Get RPC definitions by version + + Args: + version (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[DefinitionsRPCResponse, Error] + """ + + return sync_detailed( + version=version, + client=client, + ).parsed + + +async def asyncio_detailed( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsRPCResponse, Error]]: + """Get RPC definitions by version + + Args: + version (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[DefinitionsRPCResponse, Error]] + """ + + kwargs = _get_kwargs( + version=version, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsRPCResponse, Error]]: + """Get RPC definitions by version + + Args: + version (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[DefinitionsRPCResponse, Error] + """ + + return ( + await asyncio_detailed( + version=version, + client=client, + ) + ).parsed 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 new file mode 100644 index 0000000..5e4f46b --- /dev/null +++ b/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py @@ -0,0 +1,159 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.definitions_tdf_response import DefinitionsTDFResponse +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + version: int, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/defs/tdf/{version}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + if response.status_code == 200: + response_200 = DefinitionsTDFResponse.from_dict(response.json()) + + return response_200 + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + 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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[DefinitionsTDFResponse, Error]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsTDFResponse, Error]]: + """Get TDF definitions by version + + Args: + version (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[DefinitionsTDFResponse, Error]] + """ + + kwargs = _get_kwargs( + version=version, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + """Get TDF definitions by version + + Args: + version (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[DefinitionsTDFResponse, Error] + """ + + return sync_detailed( + version=version, + client=client, + ).parsed + + +async def asyncio_detailed( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[DefinitionsTDFResponse, Error]]: + """Get TDF definitions by version + + Args: + version (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[DefinitionsTDFResponse, Error]] + """ + + kwargs = _get_kwargs( + version=version, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + version: int, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[DefinitionsTDFResponse, Error]]: + """Get TDF definitions by version + + Args: + version (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[DefinitionsTDFResponse, Error] + """ + + return ( + await asyncio_detailed( + version=version, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/device/__init__.py b/src/infuse_iot/api_client/api/device/__init__.py index e69de29..2d7c0b2 100644 --- a/src/infuse_iot/api_client/api/device/__init__.py +++ b/src/infuse_iot/api_client/api/device/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 5ece19c..c958b3a 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: NewDevice, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/device", } 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 cecbaaf..b9d8cf5 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -11,8 +11,8 @@ def _get_kwargs( device_id: str, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/device/deviceId/{device_id}", } 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 1fbe505..97854e1 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast from uuid import UUID import httpx @@ -12,8 +12,8 @@ def _get_kwargs( id: UUID, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/device/id/{id}", } 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 c7c14e4..2e476e6 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -12,8 +12,8 @@ def _get_kwargs( soc: str, mcu_id: str, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/device/soc/{soc}/mcuId/{mcu_id}", } 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 new file mode 100644 index 0000000..4d9b882 --- /dev/null +++ b/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py @@ -0,0 +1,153 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_state import DeviceState +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}/state", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, DeviceState]]: + if response.status_code == 200: + response_200 = DeviceState.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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, DeviceState]]: + 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: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, DeviceState]]: + """Get device state 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, DeviceState]] + """ + + 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: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, DeviceState]]: + """Get device state 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, DeviceState] + """ + + return sync_detailed( + device_id=device_id, + client=client, + ).parsed + + +async def asyncio_detailed( + device_id: str, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, DeviceState]]: + """Get device state 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, DeviceState]] + """ + + 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: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, DeviceState]]: + """Get device state 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, DeviceState] + """ + + return ( + await asyncio_detailed( + device_id=device_id, + client=client, + ) + ).parsed 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 f69ee86..90bbe34 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast from uuid import UUID import httpx @@ -12,8 +12,8 @@ def _get_kwargs( id: UUID, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/device/id/{id}/state", } 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 7e719b1..b56f74c 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, Dict, List, Optional, Union +from typing import Any, Optional, Union from uuid import UUID import httpx @@ -7,21 +7,27 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device import Device -from ...types import UNSET, Response +from ...types import UNSET, Response, Unset def _get_kwargs( *, organisation_id: UUID, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id = str(organisation_id) params["organisationId"] = json_organisation_id + 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] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/device", "params": params, @@ -32,7 +38,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[List["Device"]]: +) -> Optional[list["Device"]]: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -50,7 +56,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[List["Device"]]: +) -> Response[list["Device"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -63,22 +69,28 @@ def sync_detailed( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Response[List["Device"]]: + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Response[list["Device"]]: """Get all devices in an organisation Args: organisation_id (UUID): + 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['Device']] + Response[list['Device']] """ kwargs = _get_kwargs( organisation_id=organisation_id, + limit=limit, + offset=offset, ) response = client.get_httpx_client().request( @@ -92,23 +104,29 @@ def sync( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Optional[List["Device"]]: + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Optional[list["Device"]]: """Get all devices in an organisation Args: organisation_id (UUID): + 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['Device'] + list['Device'] """ return sync_detailed( client=client, organisation_id=organisation_id, + limit=limit, + offset=offset, ).parsed @@ -116,22 +134,28 @@ async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Response[List["Device"]]: + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Response[list["Device"]]: """Get all devices in an organisation Args: organisation_id (UUID): + 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['Device']] + Response[list['Device']] """ kwargs = _get_kwargs( organisation_id=organisation_id, + limit=limit, + offset=offset, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -143,23 +167,29 @@ async def asyncio( *, client: Union[AuthenticatedClient, Client], organisation_id: UUID, -) -> Optional[List["Device"]]: + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Optional[list["Device"]]: """Get all devices in an organisation Args: organisation_id (UUID): + 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['Device'] + list['Device'] """ return ( await asyncio_detailed( client=client, organisation_id=organisation_id, + limit=limit, + offset=offset, ) ).parsed 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 new file mode 100644 index 0000000..6ce7512 --- /dev/null +++ b/src/infuse_iot/api_client/api/device/get_devices_and_states.py @@ -0,0 +1,195 @@ +from http import HTTPStatus +from typing import Any, Optional, Union +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_and_state import DeviceAndState +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + organisation_id: UUID, + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> dict[str, Any]: + params: dict[str, Any] = {} + + json_organisation_id = str(organisation_id) + params["organisationId"] = json_organisation_id + + 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": "/device-and-state", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[list["DeviceAndState"]]: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = DeviceAndState.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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[list["DeviceAndState"]]: + 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: Union[AuthenticatedClient, Client], + organisation_id: UUID, + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Response[list["DeviceAndState"]]: + """Get all devices and their states in an organisation + + Args: + organisation_id (UUID): + 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['DeviceAndState']] + """ + + kwargs = _get_kwargs( + organisation_id=organisation_id, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + organisation_id: UUID, + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Optional[list["DeviceAndState"]]: + """Get all devices and their states in an organisation + + Args: + organisation_id (UUID): + 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['DeviceAndState'] + """ + + return sync_detailed( + client=client, + organisation_id=organisation_id, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + organisation_id: UUID, + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Response[list["DeviceAndState"]]: + """Get all devices and their states in an organisation + + Args: + organisation_id (UUID): + 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['DeviceAndState']] + """ + + kwargs = _get_kwargs( + organisation_id=organisation_id, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: Union[AuthenticatedClient, Client], + organisation_id: UUID, + limit: Union[Unset, int] = 100, + offset: Union[Unset, int] = 0, +) -> Optional[list["DeviceAndState"]]: + """Get all devices and their states in an organisation + + Args: + organisation_id (UUID): + 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['DeviceAndState'] + """ + + return ( + await asyncio_detailed( + client=client, + organisation_id=organisation_id, + limit=limit, + offset=offset, + ) + ).parsed 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 new file mode 100644 index 0000000..60346bc --- /dev/null +++ b/src/infuse_iot/api_client/api/device/update_device_by_id.py @@ -0,0 +1,177 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device import Device +from ...models.device_update import DeviceUpdate +from ...types import Response + + +def _get_kwargs( + id: UUID, + *, + body: DeviceUpdate, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": f"/device/id/{id}", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, Device]]: + if response.status_code == 200: + response_200 = Device.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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, Device]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: DeviceUpdate, +) -> Response[Union[Any, Device]]: + """Update a device by ID + + Args: + id (UUID): + body (DeviceUpdate): + + 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, Device]] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: DeviceUpdate, +) -> Optional[Union[Any, Device]]: + """Update a device by ID + + Args: + id (UUID): + body (DeviceUpdate): + + 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, Device] + """ + + return sync_detailed( + id=id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: DeviceUpdate, +) -> Response[Union[Any, Device]]: + """Update a device by ID + + Args: + id (UUID): + body (DeviceUpdate): + + 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, Device]] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: DeviceUpdate, +) -> Optional[Union[Any, Device]]: + """Update a device by ID + + Args: + id (UUID): + body (DeviceUpdate): + + 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, Device] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + body=body, + ) + ).parsed 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 new file mode 100644 index 0000000..f011c5c --- /dev/null +++ b/src/infuse_iot/api_client/api/device/update_device_state_by_id.py @@ -0,0 +1,177 @@ +from http import HTTPStatus +from typing import Any, Optional, Union, cast +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_state import DeviceState +from ...models.new_device_state import NewDeviceState +from ...types import Response + + +def _get_kwargs( + id: UUID, + *, + body: NewDeviceState, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": f"/device/id/{id}/state", + } + + _body = body.to_dict() + + _kwargs["json"] = _body + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Any, DeviceState]]: + if response.status_code == 200: + response_200 = DeviceState.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: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[Union[Any, DeviceState]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: NewDeviceState, +) -> Response[Union[Any, DeviceState]]: + """Update device state by ID + + Args: + id (UUID): + body (NewDeviceState): + + 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, DeviceState]] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: NewDeviceState, +) -> Optional[Union[Any, DeviceState]]: + """Update device state by ID + + Args: + id (UUID): + body (NewDeviceState): + + 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, DeviceState] + """ + + return sync_detailed( + id=id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: NewDeviceState, +) -> Response[Union[Any, DeviceState]]: + """Update device state by ID + + Args: + id (UUID): + body (NewDeviceState): + + 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, DeviceState]] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], + body: NewDeviceState, +) -> Optional[Union[Any, DeviceState]]: + """Update device state by ID + + Args: + id (UUID): + body (NewDeviceState): + + 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, DeviceState] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/key/__init__.py b/src/infuse_iot/api_client/api/key/__init__.py index e69de29..2d7c0b2 100644 --- a/src/infuse_iot/api_client/api/key/__init__.py +++ b/src/infuse_iot/api_client/api/key/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 d52cef5..4bf9a56 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, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -9,8 +9,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/key/publicKey", } 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 1591091..59082fc 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, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: Key, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/key/sharedSecret", } diff --git a/src/infuse_iot/api_client/api/organisation/__init__.py b/src/infuse_iot/api_client/api/organisation/__init__.py index e69de29..2d7c0b2 100644 --- a/src/infuse_iot/api_client/api/organisation/__init__.py +++ b/src/infuse_iot/api_client/api/organisation/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 63bf36f..67cef74 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: NewOrganisation, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/organisation", } 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 22f3cbd..2f9b14a 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, Dict, List, Optional, Union +from typing import Any, Optional, Union import httpx @@ -10,8 +10,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/organisation", } @@ -21,7 +21,7 @@ def _get_kwargs() -> Dict[str, Any]: def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Error, List["Organisation"]]]: +) -> Optional[Union[Error, list["Organisation"]]]: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -43,7 +43,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Error, List["Organisation"]]]: +) -> Response[Union[Error, list["Organisation"]]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -55,7 +55,7 @@ def _build_response( def sync_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[Union[Error, List["Organisation"]]]: +) -> Response[Union[Error, list["Organisation"]]]: """Get all organisations that user has access to Raises: @@ -63,7 +63,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Error, List['Organisation']]] + Response[Union[Error, list['Organisation']]] """ kwargs = _get_kwargs() @@ -78,7 +78,7 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Error, List["Organisation"]]]: +) -> Optional[Union[Error, list["Organisation"]]]: """Get all organisations that user has access to Raises: @@ -86,7 +86,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Error, List['Organisation']] + Union[Error, list['Organisation']] """ return sync_detailed( @@ -97,7 +97,7 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[Union[Error, List["Organisation"]]]: +) -> Response[Union[Error, list["Organisation"]]]: """Get all organisations that user has access to Raises: @@ -105,7 +105,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[Error, List['Organisation']]] + Response[Union[Error, list['Organisation']]] """ kwargs = _get_kwargs() @@ -118,7 +118,7 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], -) -> Optional[Union[Error, List["Organisation"]]]: +) -> Optional[Union[Error, list["Organisation"]]]: """Get all organisations that user has access to Raises: @@ -126,7 +126,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[Error, List['Organisation']] + Union[Error, list['Organisation']] """ return ( 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 2856fff..1231f35 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, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast from uuid import UUID import httpx @@ -12,8 +12,8 @@ def _get_kwargs( id: UUID, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/organisation/id/{id}", } diff --git a/src/infuse_iot/api_client/api/rpc/__init__.py b/src/infuse_iot/api_client/api/rpc/__init__.py index e69de29..2d7c0b2 100644 --- a/src/infuse_iot/api_client/api/rpc/__init__.py +++ b/src/infuse_iot/api_client/api/rpc/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" 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 edf8172..bf6af14 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, Dict, List, Optional, Union +from typing import Any, Optional, Union from uuid import UUID import httpx @@ -21,8 +21,10 @@ def _get_kwargs( start_time: Union[Unset, datetime.datetime] = UNSET, end_time: Union[Unset, datetime.datetime] = UNSET, limit: Union[Unset, int] = 10, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} + rpc_command_id: Union[Unset, int] = UNSET, + show_expired: Union[Unset, bool] = True, +) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id: Union[Unset, str] = UNSET if not isinstance(organisation_id, Unset): @@ -49,9 +51,13 @@ def _get_kwargs( params["limit"] = limit + params["rpcCommandId"] = rpc_command_id + + params["showExpired"] = show_expired + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/rpc", "params": params, @@ -62,7 +68,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[Error, List["RpcMessage"]]]: +) -> Optional[Union[Error, list["RpcMessage"]]]: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -84,7 +90,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[Error, List["RpcMessage"]]]: +) -> Response[Union[Error, list["RpcMessage"]]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -102,7 +108,9 @@ def sync_detailed( start_time: Union[Unset, datetime.datetime] = UNSET, end_time: Union[Unset, datetime.datetime] = UNSET, limit: Union[Unset, int] = 10, -) -> Response[Union[Error, List["RpcMessage"]]]: + rpc_command_id: Union[Unset, int] = UNSET, + show_expired: Union[Unset, bool] = True, +) -> Response[Union[Error, list["RpcMessage"]]]: """Get RPC messages Args: @@ -115,13 +123,15 @@ def sync_detailed( end_time (Union[Unset, datetime.datetime]): The end time of the query (only return items on or before this time) limit (Union[Unset, int]): Maximum number of items to return Default: 10. + rpc_command_id (Union[Unset, int]): ID of RPC command + show_expired (Union[Unset, bool]): Whether to show expired RPC messages Default: True. 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, List['RpcMessage']]] + Response[Union[Error, list['RpcMessage']]] """ kwargs = _get_kwargs( @@ -131,6 +141,8 @@ def sync_detailed( start_time=start_time, end_time=end_time, limit=limit, + rpc_command_id=rpc_command_id, + show_expired=show_expired, ) response = client.get_httpx_client().request( @@ -149,7 +161,9 @@ def sync( start_time: Union[Unset, datetime.datetime] = UNSET, end_time: Union[Unset, datetime.datetime] = UNSET, limit: Union[Unset, int] = 10, -) -> Optional[Union[Error, List["RpcMessage"]]]: + rpc_command_id: Union[Unset, int] = UNSET, + show_expired: Union[Unset, bool] = True, +) -> Optional[Union[Error, list["RpcMessage"]]]: """Get RPC messages Args: @@ -162,13 +176,15 @@ def sync( end_time (Union[Unset, datetime.datetime]): The end time of the query (only return items on or before this time) limit (Union[Unset, int]): Maximum number of items to return Default: 10. + rpc_command_id (Union[Unset, int]): ID of RPC command + show_expired (Union[Unset, bool]): Whether to show expired RPC messages Default: True. 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, List['RpcMessage']] + Union[Error, list['RpcMessage']] """ return sync_detailed( @@ -179,6 +195,8 @@ def sync( start_time=start_time, end_time=end_time, limit=limit, + rpc_command_id=rpc_command_id, + show_expired=show_expired, ).parsed @@ -191,7 +209,9 @@ async def asyncio_detailed( start_time: Union[Unset, datetime.datetime] = UNSET, end_time: Union[Unset, datetime.datetime] = UNSET, limit: Union[Unset, int] = 10, -) -> Response[Union[Error, List["RpcMessage"]]]: + rpc_command_id: Union[Unset, int] = UNSET, + show_expired: Union[Unset, bool] = True, +) -> Response[Union[Error, list["RpcMessage"]]]: """Get RPC messages Args: @@ -204,13 +224,15 @@ async def asyncio_detailed( end_time (Union[Unset, datetime.datetime]): The end time of the query (only return items on or before this time) limit (Union[Unset, int]): Maximum number of items to return Default: 10. + rpc_command_id (Union[Unset, int]): ID of RPC command + show_expired (Union[Unset, bool]): Whether to show expired RPC messages Default: True. 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, List['RpcMessage']]] + Response[Union[Error, list['RpcMessage']]] """ kwargs = _get_kwargs( @@ -220,6 +242,8 @@ async def asyncio_detailed( start_time=start_time, end_time=end_time, limit=limit, + rpc_command_id=rpc_command_id, + show_expired=show_expired, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -236,7 +260,9 @@ async def asyncio( start_time: Union[Unset, datetime.datetime] = UNSET, end_time: Union[Unset, datetime.datetime] = UNSET, limit: Union[Unset, int] = 10, -) -> Optional[Union[Error, List["RpcMessage"]]]: + rpc_command_id: Union[Unset, int] = UNSET, + show_expired: Union[Unset, bool] = True, +) -> Optional[Union[Error, list["RpcMessage"]]]: """Get RPC messages Args: @@ -249,13 +275,15 @@ async def asyncio( end_time (Union[Unset, datetime.datetime]): The end time of the query (only return items on or before this time) limit (Union[Unset, int]): Maximum number of items to return Default: 10. + rpc_command_id (Union[Unset, int]): ID of RPC command + show_expired (Union[Unset, bool]): Whether to show expired RPC messages Default: True. 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, List['RpcMessage']] + Union[Error, list['RpcMessage']] """ return ( @@ -267,5 +295,7 @@ async def asyncio( start_time=start_time, end_time=end_time, limit=limit, + rpc_command_id=rpc_command_id, + show_expired=show_expired, ) ).parsed 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 fccbc3b..e8e8c60 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, Dict, Optional, Union +from typing import Any, Optional, Union from uuid import UUID import httpx @@ -13,8 +13,8 @@ def _get_kwargs( id: UUID, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/rpc/{id}", } 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 2ac9880..61db3a3 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, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -14,10 +14,10 @@ def _get_kwargs( *, body: NewRPCMessage, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/rpc", } diff --git a/src/infuse_iot/api_client/client.py b/src/infuse_iot/api_client/client.py index 0f6d15e..e80446f 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, Dict, Optional, Union +from typing import Any, Optional, Union import httpx from attrs import define, evolve, field @@ -36,16 +36,16 @@ class Client: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _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") + _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") _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") + _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) - def with_headers(self, headers: Dict[str, str]) -> "Client": + def with_headers(self, headers: dict[str, str]) -> "Client": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -53,7 +53,7 @@ def with_headers(self, headers: Dict[str, str]) -> "Client": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "Client": + def with_cookies(self, cookies: dict[str, str]) -> "Client": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) @@ -166,12 +166,12 @@ class AuthenticatedClient: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _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") + _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") _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") + _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) @@ -179,7 +179,7 @@ class AuthenticatedClient: prefix: str = "Bearer" auth_header_name: str = "Authorization" - def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -187,7 +187,7 @@ def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) diff --git a/src/infuse_iot/api_client/models/__init__.py b/src/infuse_iot/api_client/models/__init__.py index 548522b..1a80510 100644 --- a/src/infuse_iot/api_client/models/__init__.py +++ b/src/infuse_iot/api_client/models/__init__.py @@ -1,14 +1,47 @@ """Contains all the data models used in inputs/outputs""" +from .algorithm import Algorithm from .application_version import ApplicationVersion from .board import Board +from .coap_file_stats import COAPFileStats +from .coap_files_list import COAPFilesList from .created_board_properties import CreatedBoardProperties from .created_device_properties import CreatedDeviceProperties from .created_organisation_properties import CreatedOrganisationProperties from .created_rpc_message import CreatedRpcMessage +from .definitions_enum_definition import DefinitionsEnumDefinition +from .definitions_enum_value import DefinitionsEnumValue +from .definitions_field_conversion import DefinitionsFieldConversion +from .definitions_field_conversion_int import DefinitionsFieldConversionInt +from .definitions_field_definition import DefinitionsFieldDefinition +from .definitions_field_display import DefinitionsFieldDisplay +from .definitions_field_display_fmt import DefinitionsFieldDisplayFmt +from .definitions_kv import DefinitionsKV +from .definitions_kv_definition import DefinitionsKVDefinition +from .definitions_kv_definitions import DefinitionsKVDefinitions +from .definitions_kv_response import DefinitionsKVResponse +from .definitions_kv_structs import DefinitionsKVStructs +from .definitions_rpc import DefinitionsRPC +from .definitions_rpc_command import DefinitionsRPCCommand +from .definitions_rpc_command_default_auth import DefinitionsRPCCommandDefaultAuth +from .definitions_rpc_commands import DefinitionsRPCCommands +from .definitions_rpc_enums import DefinitionsRPCEnums +from .definitions_rpc_response import DefinitionsRPCResponse +from .definitions_rpc_structs import DefinitionsRPCStructs +from .definitions_struct_definition import DefinitionsStructDefinition +from .definitions_tdf import DefinitionsTDF +from .definitions_tdf_definition import DefinitionsTDFDefinition +from .definitions_tdf_definitions import DefinitionsTDFDefinitions +from .definitions_tdf_response import DefinitionsTDFResponse +from .definitions_tdf_structs import DefinitionsTDFStructs from .device import Device +from .device_and_state import DeviceAndState from .device_id_field import DeviceIdField +from .device_metadata import DeviceMetadata +from .device_metadata_update import DeviceMetadataUpdate +from .device_metadata_update_operation import DeviceMetadataUpdateOperation from .device_state import DeviceState +from .device_update import DeviceUpdate from .downlink_message import DownlinkMessage from .downlink_message_status import DownlinkMessageStatus from .downlink_route import DownlinkRoute @@ -19,7 +52,7 @@ from .metadata_field import MetadataField from .new_board import NewBoard from .new_device import NewDevice -from .new_device_metadata import NewDeviceMetadata +from .new_device_state import NewDeviceState from .new_organisation import NewOrganisation from .new_rpc_message import NewRPCMessage from .new_rpc_req import NewRPCReq @@ -34,15 +67,48 @@ from .uplink_route import UplinkRoute __all__ = ( + "Algorithm", "ApplicationVersion", "Board", + "COAPFilesList", + "COAPFileStats", "CreatedBoardProperties", "CreatedDeviceProperties", "CreatedOrganisationProperties", "CreatedRpcMessage", + "DefinitionsEnumDefinition", + "DefinitionsEnumValue", + "DefinitionsFieldConversion", + "DefinitionsFieldConversionInt", + "DefinitionsFieldDefinition", + "DefinitionsFieldDisplay", + "DefinitionsFieldDisplayFmt", + "DefinitionsKV", + "DefinitionsKVDefinition", + "DefinitionsKVDefinitions", + "DefinitionsKVResponse", + "DefinitionsKVStructs", + "DefinitionsRPC", + "DefinitionsRPCCommand", + "DefinitionsRPCCommandDefaultAuth", + "DefinitionsRPCCommands", + "DefinitionsRPCEnums", + "DefinitionsRPCResponse", + "DefinitionsRPCStructs", + "DefinitionsStructDefinition", + "DefinitionsTDF", + "DefinitionsTDFDefinition", + "DefinitionsTDFDefinitions", + "DefinitionsTDFResponse", + "DefinitionsTDFStructs", "Device", + "DeviceAndState", "DeviceIdField", + "DeviceMetadata", + "DeviceMetadataUpdate", + "DeviceMetadataUpdateOperation", "DeviceState", + "DeviceUpdate", "DownlinkMessage", "DownlinkMessageStatus", "DownlinkRoute", @@ -53,7 +119,7 @@ "MetadataField", "NewBoard", "NewDevice", - "NewDeviceMetadata", + "NewDeviceState", "NewOrganisation", "NewRPCMessage", "NewRPCReq", diff --git a/src/infuse_iot/api_client/models/algorithm.py b/src/infuse_iot/api_client/models/algorithm.py new file mode 100644 index 0000000..fd48f4a --- /dev/null +++ b/src/infuse_iot/api_client/models/algorithm.py @@ -0,0 +1,67 @@ +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="Algorithm") + + +@_attrs_define +class Algorithm: + """ + Attributes: + id (int): ID of algorithm + version (int): Version of algorithm + """ + + id: int + version: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + version = self.version + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "version": version, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id") + + version = d.pop("version") + + algorithm = cls( + id=id, + version=version, + ) + + algorithm.additional_properties = d + return algorithm + + @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/application_version.py b/src/infuse_iot/api_client/models/application_version.py index 2b76458..52215c1 100644 --- a/src/infuse_iot/api_client/models/application_version.py +++ b/src/infuse_iot/api_client/models/application_version.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -21,9 +22,9 @@ class ApplicationVersion: minor: int revision: int build_num: int - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: major = self.major minor = self.minor @@ -32,7 +33,7 @@ def to_dict(self) -> Dict[str, Any]: build_num = self.build_num - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -46,8 +47,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) major = d.pop("major") minor = d.pop("minor") @@ -67,7 +68,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return application_version @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/board.py b/src/infuse_iot/api_client/models/board.py index c7faccd..8012728 100644 --- a/src/infuse_iot/api_client/models/board.py +++ b/src/infuse_iot/api_client/models/board.py @@ -1,5 +1,6 @@ import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define @@ -26,7 +27,7 @@ class Board: description (str): Description of board Example: Extended description of board. soc (str): System on Chip (SoC) of board Example: nRF9151. organisation_id (UUID): ID of organisation for board to exist in - metadata_fields (Union[Unset, List['MetadataField']]): Metadata fields for board Example: [{'name': 'Field + metadata_fields (Union[Unset, list['MetadataField']]): Metadata fields for board Example: [{'name': 'Field Name', 'required': True, 'unique': False}]. """ @@ -37,10 +38,10 @@ class Board: description: str soc: str organisation_id: UUID - metadata_fields: Union[Unset, List["MetadataField"]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + metadata_fields: Union[Unset, list["MetadataField"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: id = str(self.id) created_at = self.created_at.isoformat() @@ -55,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: Union[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: @@ -64,7 +65,7 @@ def to_dict(self) -> Dict[str, Any]: ) metadata_fields.append(componentsschemas_board_metadata_fields_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -83,10 +84,10 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.metadata_field import MetadataField - d = src_dict.copy() + d = dict(src_dict) id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -125,7 +126,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return board @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/coap_file_stats.py b/src/infuse_iot/api_client/models/coap_file_stats.py new file mode 100644 index 0000000..51a0a2c --- /dev/null +++ b/src/infuse_iot/api_client/models/coap_file_stats.py @@ -0,0 +1,75 @@ +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="COAPFileStats") + + +@_attrs_define +class COAPFileStats: + """ + Attributes: + name (str): + len_ (int): + crc (int): + """ + + name: str + len_: int + crc: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + len_ = self.len_ + + crc = self.crc + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "name": name, + "len": len_, + "crc": crc, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + name = d.pop("name") + + len_ = d.pop("len") + + crc = d.pop("crc") + + coap_file_stats = cls( + name=name, + len_=len_, + crc=crc, + ) + + coap_file_stats.additional_properties = d + return coap_file_stats + + @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/coap_files_list.py b/src/infuse_iot/api_client/models/coap_files_list.py new file mode 100644 index 0000000..13dd5be --- /dev/null +++ b/src/infuse_iot/api_client/models/coap_files_list.py @@ -0,0 +1,59 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="COAPFilesList") + + +@_attrs_define +class COAPFilesList: + """ + Attributes: + filenames (list[str]): + """ + + filenames: list[str] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + filenames = self.filenames + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "filenames": filenames, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + filenames = cast(list[str], d.pop("filenames")) + + coap_files_list = cls( + filenames=filenames, + ) + + coap_files_list.additional_properties = d + return coap_files_list + + @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/created_board_properties.py b/src/infuse_iot/api_client/models/created_board_properties.py index 2f5a25c..e2679b1 100644 --- a/src/infuse_iot/api_client/models/created_board_properties.py +++ b/src/infuse_iot/api_client/models/created_board_properties.py @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -21,16 +22,16 @@ class CreatedBoardProperties: id: UUID created_at: datetime.datetime updated_at: datetime.datetime - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: id = str(self.id) created_at = self.created_at.isoformat() updated_at = self.updated_at.isoformat() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -43,8 +44,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -61,7 +62,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return created_board_properties @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/created_device_properties.py b/src/infuse_iot/api_client/models/created_device_properties.py index a46d4d4..9fbbf2a 100644 --- a/src/infuse_iot/api_client/models/created_device_properties.py +++ b/src/infuse_iot/api_client/models/created_device_properties.py @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -21,16 +22,16 @@ class CreatedDeviceProperties: id: UUID created_at: datetime.datetime updated_at: datetime.datetime - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: id = str(self.id) created_at = self.created_at.isoformat() updated_at = self.updated_at.isoformat() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -43,8 +44,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -61,7 +62,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return created_device_properties @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/created_organisation_properties.py b/src/infuse_iot/api_client/models/created_organisation_properties.py index 4e36ea0..fd62550 100644 --- a/src/infuse_iot/api_client/models/created_organisation_properties.py +++ b/src/infuse_iot/api_client/models/created_organisation_properties.py @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -21,16 +22,16 @@ class CreatedOrganisationProperties: id: UUID created_at: datetime.datetime updated_at: datetime.datetime - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: id = str(self.id) created_at = self.created_at.isoformat() updated_at = self.updated_at.isoformat() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -43,8 +44,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -61,7 +62,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return created_organisation_properties @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/created_rpc_message.py b/src/infuse_iot/api_client/models/created_rpc_message.py index e3cc989..edd95fc 100644 --- a/src/infuse_iot/api_client/models/created_rpc_message.py +++ b/src/infuse_iot/api_client/models/created_rpc_message.py @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -22,16 +23,16 @@ class CreatedRpcMessage: created_at: datetime.datetime id: UUID downlink_message_id: UUID - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: created_at = self.created_at.isoformat() id = str(self.id) downlink_message_id = str(self.downlink_message_id) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -44,8 +45,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) created_at = isoparse(d.pop("createdAt")) id = UUID(d.pop("id")) @@ -62,7 +63,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return created_rpc_message @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/definitions_enum_definition.py b/src/infuse_iot/api_client/models/definitions_enum_definition.py new file mode 100644 index 0000000..b41ad5b --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_enum_definition.py @@ -0,0 +1,89 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_enum_value import DefinitionsEnumValue + + +T = TypeVar("T", bound="DefinitionsEnumDefinition") + + +@_attrs_define +class DefinitionsEnumDefinition: + """ + Attributes: + description (str): + type_ (str): + values (list['DefinitionsEnumValue']): + """ + + description: str + type_: str + values: list["DefinitionsEnumValue"] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + description = self.description + + type_ = self.type_ + + values = [] + for values_item_data in self.values: + values_item = values_item_data.to_dict() + values.append(values_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "description": description, + "type": type_, + "values": values, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_enum_value import DefinitionsEnumValue + + d = dict(src_dict) + description = d.pop("description") + + type_ = d.pop("type") + + values = [] + _values = d.pop("values") + for values_item_data in _values: + values_item = DefinitionsEnumValue.from_dict(values_item_data) + + values.append(values_item) + + definitions_enum_definition = cls( + description=description, + type_=type_, + values=values, + ) + + definitions_enum_definition.additional_properties = d + return definitions_enum_definition + + @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/definitions_enum_value.py b/src/infuse_iot/api_client/models/definitions_enum_value.py new file mode 100644 index 0000000..8d425e3 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_enum_value.py @@ -0,0 +1,75 @@ +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="DefinitionsEnumValue") + + +@_attrs_define +class DefinitionsEnumValue: + """ + Attributes: + name (str): + value (int): + description (str): + """ + + name: str + value: int + description: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + value = self.value + + description = self.description + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "name": name, + "value": value, + "description": description, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + name = d.pop("name") + + value = d.pop("value") + + description = d.pop("description") + + definitions_enum_value = cls( + name=name, + value=value, + description=description, + ) + + definitions_enum_value.additional_properties = d + return definitions_enum_value + + @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/definitions_field_conversion.py b/src/infuse_iot/api_client/models/definitions_field_conversion.py new file mode 100644 index 0000000..d9ec9ef --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_field_conversion.py @@ -0,0 +1,86 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.definitions_field_conversion_int import DefinitionsFieldConversionInt +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DefinitionsFieldConversion") + + +@_attrs_define +class DefinitionsFieldConversion: + """Conversion formula for a field (m * + c) + + Attributes: + m (Union[Unset, float]): + c (Union[Unset, float]): + 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 + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + m = self.m + + c = self.c + + int_: Union[Unset, str] = UNSET + if not isinstance(self.int_, Unset): + int_ = self.int_.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if m is not UNSET: + field_dict["m"] = m + if c is not UNSET: + field_dict["c"] = c + if int_ is not UNSET: + field_dict["int"] = int_ + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + m = d.pop("m", UNSET) + + c = d.pop("c", UNSET) + + _int_ = d.pop("int", UNSET) + int_: Union[Unset, DefinitionsFieldConversionInt] + if isinstance(_int_, Unset): + int_ = UNSET + else: + int_ = DefinitionsFieldConversionInt(_int_) + + definitions_field_conversion = cls( + m=m, + c=c, + int_=int_, + ) + + definitions_field_conversion.additional_properties = d + return definitions_field_conversion + + @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/definitions_field_conversion_int.py b/src/infuse_iot/api_client/models/definitions_field_conversion_int.py new file mode 100644 index 0000000..b0d7313 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_field_conversion_int.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class DefinitionsFieldConversionInt(str, Enum): + BIG = "big" + LITTLE = "little" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/definitions_field_definition.py b/src/infuse_iot/api_client/models/definitions_field_definition.py new file mode 100644 index 0000000..4bf80f1 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_field_definition.py @@ -0,0 +1,127 @@ +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.definitions_field_conversion import DefinitionsFieldConversion + from ..models.definitions_field_display import DefinitionsFieldDisplay + + +T = TypeVar("T", bound="DefinitionsFieldDefinition") + + +@_attrs_define +class DefinitionsFieldDefinition: + """ + Attributes: + name (str): Field name + 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) + 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 + display: Union[Unset, "DefinitionsFieldDisplay"] = UNSET + conversion: Union[Unset, "DefinitionsFieldConversion"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + type_ = self.type_ + + description = self.description + + num = self.num + + display: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.display, Unset): + display = self.display.to_dict() + + conversion: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.conversion, Unset): + conversion = self.conversion.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "name": name, + "type": type_, + } + ) + if description is not UNSET: + field_dict["description"] = description + if num is not UNSET: + field_dict["num"] = num + if display is not UNSET: + field_dict["display"] = display + if conversion is not UNSET: + field_dict["conversion"] = conversion + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_field_conversion import DefinitionsFieldConversion + from ..models.definitions_field_display import DefinitionsFieldDisplay + + d = dict(src_dict) + name = d.pop("name") + + type_ = d.pop("type") + + description = d.pop("description", UNSET) + + num = d.pop("num", UNSET) + + _display = d.pop("display", UNSET) + display: Union[Unset, DefinitionsFieldDisplay] + if isinstance(_display, Unset): + display = UNSET + else: + display = DefinitionsFieldDisplay.from_dict(_display) + + _conversion = d.pop("conversion", UNSET) + conversion: Union[Unset, DefinitionsFieldConversion] + if isinstance(_conversion, Unset): + conversion = UNSET + else: + conversion = DefinitionsFieldConversion.from_dict(_conversion) + + definitions_field_definition = cls( + name=name, + type_=type_, + description=description, + num=num, + display=display, + conversion=conversion, + ) + + definitions_field_definition.additional_properties = d + return definitions_field_definition + + @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/definitions_field_display.py b/src/infuse_iot/api_client/models/definitions_field_display.py new file mode 100644 index 0000000..3b6951f --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_field_display.py @@ -0,0 +1,86 @@ +from collections.abc import Mapping +from typing import Any, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.definitions_field_display_fmt import DefinitionsFieldDisplayFmt +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DefinitionsFieldDisplay") + + +@_attrs_define +class DefinitionsFieldDisplay: + """Display settings for a field + + Attributes: + fmt (Union[Unset, DefinitionsFieldDisplayFmt]): Format string for field + digits (Union[Unset, int]): + postfix (Union[Unset, str]): + """ + + fmt: Union[Unset, DefinitionsFieldDisplayFmt] = UNSET + digits: Union[Unset, int] = UNSET + postfix: Union[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 + if not isinstance(self.fmt, Unset): + fmt = self.fmt.value + + digits = self.digits + + postfix = self.postfix + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if fmt is not UNSET: + field_dict["fmt"] = fmt + if digits is not UNSET: + field_dict["digits"] = digits + if postfix is not UNSET: + field_dict["postfix"] = postfix + + return field_dict + + @classmethod + 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] + if isinstance(_fmt, Unset): + fmt = UNSET + else: + fmt = DefinitionsFieldDisplayFmt(_fmt) + + digits = d.pop("digits", UNSET) + + postfix = d.pop("postfix", UNSET) + + definitions_field_display = cls( + fmt=fmt, + digits=digits, + postfix=postfix, + ) + + definitions_field_display.additional_properties = d + return definitions_field_display + + @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/definitions_field_display_fmt.py b/src/infuse_iot/api_client/models/definitions_field_display_fmt.py new file mode 100644 index 0000000..cbd687e --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_field_display_fmt.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class DefinitionsFieldDisplayFmt(str, Enum): + FLOAT = "float" + HEX = "hex" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/definitions_kv.py b/src/infuse_iot/api_client/models/definitions_kv.py new file mode 100644 index 0000000..41be149 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_kv.py @@ -0,0 +1,75 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_kv_definitions import DefinitionsKVDefinitions + from ..models.definitions_kv_structs import DefinitionsKVStructs + + +T = TypeVar("T", bound="DefinitionsKV") + + +@_attrs_define +class DefinitionsKV: + """ + Attributes: + structs (DefinitionsKVStructs): + definitions (DefinitionsKVDefinitions): + """ + + structs: "DefinitionsKVStructs" + definitions: "DefinitionsKVDefinitions" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + structs = self.structs.to_dict() + + definitions = self.definitions.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "structs": structs, + "definitions": definitions, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_kv_definitions import DefinitionsKVDefinitions + from ..models.definitions_kv_structs import DefinitionsKVStructs + + d = dict(src_dict) + structs = DefinitionsKVStructs.from_dict(d.pop("structs")) + + definitions = DefinitionsKVDefinitions.from_dict(d.pop("definitions")) + + definitions_kv = cls( + structs=structs, + definitions=definitions, + ) + + definitions_kv.additional_properties = d + return definitions_kv + + @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/definitions_kv_definition.py b/src/infuse_iot/api_client/models/definitions_kv_definition.py new file mode 100644 index 0000000..f3898c9 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_kv_definition.py @@ -0,0 +1,145 @@ +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.definitions_field_definition import DefinitionsFieldDefinition + + +T = TypeVar("T", bound="DefinitionsKVDefinition") + + +@_attrs_define +class DefinitionsKVDefinition: + """ + Attributes: + name (str): + description (str): + fields (list['DefinitionsFieldDefinition']): + reflect (Union[Unset, bool]): + read_only (Union[Unset, bool]): + write_only (Union[Unset, bool]): + default (Union[Unset, str]): + depends_on (Union[Unset, str]): + range_ (Union[Unset, int]): + """ + + 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 + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + description = self.description + + fields = [] + for fields_item_data in self.fields: + fields_item = fields_item_data.to_dict() + fields.append(fields_item) + + reflect = self.reflect + + read_only = self.read_only + + write_only = self.write_only + + default = self.default + + depends_on = self.depends_on + + range_ = self.range_ + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "name": name, + "description": description, + "fields": fields, + } + ) + if reflect is not UNSET: + field_dict["reflect"] = reflect + if read_only is not UNSET: + field_dict["read_only"] = read_only + if write_only is not UNSET: + field_dict["write_only"] = write_only + if default is not UNSET: + field_dict["default"] = default + if depends_on is not UNSET: + field_dict["depends_on"] = depends_on + if range_ is not UNSET: + field_dict["range"] = range_ + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_field_definition import DefinitionsFieldDefinition + + d = dict(src_dict) + name = d.pop("name") + + description = d.pop("description") + + fields = [] + _fields = d.pop("fields") + for fields_item_data in _fields: + fields_item = DefinitionsFieldDefinition.from_dict(fields_item_data) + + fields.append(fields_item) + + reflect = d.pop("reflect", UNSET) + + read_only = d.pop("read_only", UNSET) + + write_only = d.pop("write_only", UNSET) + + default = d.pop("default", UNSET) + + depends_on = d.pop("depends_on", UNSET) + + range_ = d.pop("range", UNSET) + + definitions_kv_definition = cls( + name=name, + description=description, + fields=fields, + reflect=reflect, + read_only=read_only, + write_only=write_only, + default=default, + depends_on=depends_on, + range_=range_, + ) + + definitions_kv_definition.additional_properties = d + return definitions_kv_definition + + @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/definitions_kv_definitions.py b/src/infuse_iot/api_client/models/definitions_kv_definitions.py new file mode 100644 index 0000000..57d02cd --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_kv_definitions.py @@ -0,0 +1,57 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_kv_definition import DefinitionsKVDefinition + + +T = TypeVar("T", bound="DefinitionsKVDefinitions") + + +@_attrs_define +class DefinitionsKVDefinitions: + """ """ + + additional_properties: dict[str, "DefinitionsKVDefinition"] = _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] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_kv_definition import DefinitionsKVDefinition + + d = dict(src_dict) + definitions_kv_definitions = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = DefinitionsKVDefinition.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + definitions_kv_definitions.additional_properties = additional_properties + return definitions_kv_definitions + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "DefinitionsKVDefinition": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "DefinitionsKVDefinition") -> 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/definitions_kv_response.py b/src/infuse_iot/api_client/models/definitions_kv_response.py new file mode 100644 index 0000000..e8b1cb5 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_kv_response.py @@ -0,0 +1,83 @@ +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.definitions_kv import DefinitionsKV + + +T = TypeVar("T", bound="DefinitionsKVResponse") + + +@_attrs_define +class DefinitionsKVResponse: + """ + Attributes: + created_at (datetime.datetime): + version (int): + definitions (DefinitionsKV): + """ + + created_at: datetime.datetime + version: int + definitions: "DefinitionsKV" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + created_at = self.created_at.isoformat() + + version = self.version + + definitions = self.definitions.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "createdAt": created_at, + "version": version, + "definitions": definitions, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_kv import DefinitionsKV + + d = dict(src_dict) + created_at = isoparse(d.pop("createdAt")) + + version = d.pop("version") + + definitions = DefinitionsKV.from_dict(d.pop("definitions")) + + definitions_kv_response = cls( + created_at=created_at, + version=version, + definitions=definitions, + ) + + definitions_kv_response.additional_properties = d + return definitions_kv_response + + @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/definitions_kv_structs.py b/src/infuse_iot/api_client/models/definitions_kv_structs.py new file mode 100644 index 0000000..7464fa1 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_kv_structs.py @@ -0,0 +1,57 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_struct_definition import DefinitionsStructDefinition + + +T = TypeVar("T", bound="DefinitionsKVStructs") + + +@_attrs_define +class DefinitionsKVStructs: + """ """ + + additional_properties: dict[str, "DefinitionsStructDefinition"] = _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] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_struct_definition import DefinitionsStructDefinition + + d = dict(src_dict) + definitions_kv_structs = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = DefinitionsStructDefinition.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + definitions_kv_structs.additional_properties = additional_properties + return definitions_kv_structs + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "DefinitionsStructDefinition": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "DefinitionsStructDefinition") -> 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/definitions_rpc.py b/src/infuse_iot/api_client/models/definitions_rpc.py new file mode 100644 index 0000000..91076f2 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_rpc.py @@ -0,0 +1,85 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_rpc_commands import DefinitionsRPCCommands + from ..models.definitions_rpc_enums import DefinitionsRPCEnums + from ..models.definitions_rpc_structs import DefinitionsRPCStructs + + +T = TypeVar("T", bound="DefinitionsRPC") + + +@_attrs_define +class DefinitionsRPC: + """ + Attributes: + commands (DefinitionsRPCCommands): + structs (DefinitionsRPCStructs): + enums (DefinitionsRPCEnums): + """ + + commands: "DefinitionsRPCCommands" + structs: "DefinitionsRPCStructs" + enums: "DefinitionsRPCEnums" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + commands = self.commands.to_dict() + + structs = self.structs.to_dict() + + enums = self.enums.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "commands": commands, + "structs": structs, + "enums": enums, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_rpc_commands import DefinitionsRPCCommands + from ..models.definitions_rpc_enums import DefinitionsRPCEnums + from ..models.definitions_rpc_structs import DefinitionsRPCStructs + + d = dict(src_dict) + commands = DefinitionsRPCCommands.from_dict(d.pop("commands")) + + structs = DefinitionsRPCStructs.from_dict(d.pop("structs")) + + enums = DefinitionsRPCEnums.from_dict(d.pop("enums")) + + definitions_rpc = cls( + commands=commands, + structs=structs, + enums=enums, + ) + + definitions_rpc.additional_properties = d + return definitions_rpc + + @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/definitions_rpc_command.py b/src/infuse_iot/api_client/models/definitions_rpc_command.py new file mode 100644 index 0000000..8bc9636 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_rpc_command.py @@ -0,0 +1,142 @@ +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 ..models.definitions_rpc_command_default_auth import DefinitionsRPCCommandDefaultAuth +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.definitions_field_definition import DefinitionsFieldDefinition + + +T = TypeVar("T", bound="DefinitionsRPCCommand") + + +@_attrs_define +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]): + 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 + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + description = self.description + + default = self.default + + default_auth = self.default_auth.value + + request_params = [] + for request_params_item_data in self.request_params: + request_params_item = request_params_item_data.to_dict() + request_params.append(request_params_item) + + response_params = [] + for response_params_item_data in self.response_params: + response_params_item = response_params_item_data.to_dict() + response_params.append(response_params_item) + + depends_on = self.depends_on + + rpc_data = self.rpc_data + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "name": name, + "description": description, + "default": default, + "default_auth": default_auth, + "request_params": request_params, + "response_params": response_params, + } + ) + if depends_on is not UNSET: + field_dict["depends_on"] = depends_on + if rpc_data is not UNSET: + field_dict["rpc_data"] = rpc_data + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_field_definition import DefinitionsFieldDefinition + + d = dict(src_dict) + name = d.pop("name") + + description = d.pop("description") + + default = d.pop("default") + + default_auth = DefinitionsRPCCommandDefaultAuth(d.pop("default_auth")) + + request_params = [] + _request_params = d.pop("request_params") + for request_params_item_data in _request_params: + request_params_item = DefinitionsFieldDefinition.from_dict(request_params_item_data) + + request_params.append(request_params_item) + + response_params = [] + _response_params = d.pop("response_params") + for response_params_item_data in _response_params: + response_params_item = DefinitionsFieldDefinition.from_dict(response_params_item_data) + + response_params.append(response_params_item) + + depends_on = d.pop("depends_on", 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, + rpc_data=rpc_data, + ) + + definitions_rpc_command.additional_properties = d + return definitions_rpc_command + + @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/definitions_rpc_command_default_auth.py b/src/infuse_iot/api_client/models/definitions_rpc_command_default_auth.py new file mode 100644 index 0000000..6474ec7 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_rpc_command_default_auth.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class DefinitionsRPCCommandDefaultAuth(str, Enum): + EPACKET_AUTH_DEVICE = "EPACKET_AUTH_DEVICE" + EPACKET_AUTH_NETWORK = "EPACKET_AUTH_NETWORK" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/definitions_rpc_commands.py b/src/infuse_iot/api_client/models/definitions_rpc_commands.py new file mode 100644 index 0000000..9a300f7 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_rpc_commands.py @@ -0,0 +1,57 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_rpc_command import DefinitionsRPCCommand + + +T = TypeVar("T", bound="DefinitionsRPCCommands") + + +@_attrs_define +class DefinitionsRPCCommands: + """ """ + + additional_properties: dict[str, "DefinitionsRPCCommand"] = _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] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_rpc_command import DefinitionsRPCCommand + + d = dict(src_dict) + definitions_rpc_commands = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = DefinitionsRPCCommand.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + definitions_rpc_commands.additional_properties = additional_properties + return definitions_rpc_commands + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "DefinitionsRPCCommand": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "DefinitionsRPCCommand") -> 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/definitions_rpc_enums.py b/src/infuse_iot/api_client/models/definitions_rpc_enums.py new file mode 100644 index 0000000..aff6ec2 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_rpc_enums.py @@ -0,0 +1,57 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_enum_definition import DefinitionsEnumDefinition + + +T = TypeVar("T", bound="DefinitionsRPCEnums") + + +@_attrs_define +class DefinitionsRPCEnums: + """ """ + + additional_properties: dict[str, "DefinitionsEnumDefinition"] = _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] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_enum_definition import DefinitionsEnumDefinition + + d = dict(src_dict) + definitions_rpc_enums = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = DefinitionsEnumDefinition.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + definitions_rpc_enums.additional_properties = additional_properties + return definitions_rpc_enums + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "DefinitionsEnumDefinition": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "DefinitionsEnumDefinition") -> 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/definitions_rpc_response.py b/src/infuse_iot/api_client/models/definitions_rpc_response.py new file mode 100644 index 0000000..a3b58dc --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_rpc_response.py @@ -0,0 +1,83 @@ +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.definitions_rpc import DefinitionsRPC + + +T = TypeVar("T", bound="DefinitionsRPCResponse") + + +@_attrs_define +class DefinitionsRPCResponse: + """ + Attributes: + created_at (datetime.datetime): + version (int): + definitions (DefinitionsRPC): + """ + + created_at: datetime.datetime + version: int + definitions: "DefinitionsRPC" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + created_at = self.created_at.isoformat() + + version = self.version + + definitions = self.definitions.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "createdAt": created_at, + "version": version, + "definitions": definitions, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_rpc import DefinitionsRPC + + d = dict(src_dict) + created_at = isoparse(d.pop("createdAt")) + + version = d.pop("version") + + definitions = DefinitionsRPC.from_dict(d.pop("definitions")) + + definitions_rpc_response = cls( + created_at=created_at, + version=version, + definitions=definitions, + ) + + definitions_rpc_response.additional_properties = d + return definitions_rpc_response + + @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/definitions_rpc_structs.py b/src/infuse_iot/api_client/models/definitions_rpc_structs.py new file mode 100644 index 0000000..35e36c7 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_rpc_structs.py @@ -0,0 +1,57 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_struct_definition import DefinitionsStructDefinition + + +T = TypeVar("T", bound="DefinitionsRPCStructs") + + +@_attrs_define +class DefinitionsRPCStructs: + """ """ + + additional_properties: dict[str, "DefinitionsStructDefinition"] = _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] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_struct_definition import DefinitionsStructDefinition + + d = dict(src_dict) + definitions_rpc_structs = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = DefinitionsStructDefinition.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + definitions_rpc_structs.additional_properties = additional_properties + return definitions_rpc_structs + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "DefinitionsStructDefinition": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "DefinitionsStructDefinition") -> 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/definitions_struct_definition.py b/src/infuse_iot/api_client/models/definitions_struct_definition.py new file mode 100644 index 0000000..8065ffe --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_struct_definition.py @@ -0,0 +1,81 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_field_definition import DefinitionsFieldDefinition + + +T = TypeVar("T", bound="DefinitionsStructDefinition") + + +@_attrs_define +class DefinitionsStructDefinition: + """ + Attributes: + description (str): + fields (list['DefinitionsFieldDefinition']): + """ + + description: str + fields: list["DefinitionsFieldDefinition"] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + description = self.description + + fields = [] + for fields_item_data in self.fields: + fields_item = fields_item_data.to_dict() + fields.append(fields_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "description": description, + "fields": fields, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_field_definition import DefinitionsFieldDefinition + + d = dict(src_dict) + description = d.pop("description") + + fields = [] + _fields = d.pop("fields") + for fields_item_data in _fields: + fields_item = DefinitionsFieldDefinition.from_dict(fields_item_data) + + fields.append(fields_item) + + definitions_struct_definition = cls( + description=description, + fields=fields, + ) + + definitions_struct_definition.additional_properties = d + return definitions_struct_definition + + @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/definitions_tdf.py b/src/infuse_iot/api_client/models/definitions_tdf.py new file mode 100644 index 0000000..27f994b --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_tdf.py @@ -0,0 +1,75 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_tdf_definitions import DefinitionsTDFDefinitions + from ..models.definitions_tdf_structs import DefinitionsTDFStructs + + +T = TypeVar("T", bound="DefinitionsTDF") + + +@_attrs_define +class DefinitionsTDF: + """ + Attributes: + structs (DefinitionsTDFStructs): + definitions (DefinitionsTDFDefinitions): + """ + + structs: "DefinitionsTDFStructs" + definitions: "DefinitionsTDFDefinitions" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + structs = self.structs.to_dict() + + definitions = self.definitions.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "structs": structs, + "definitions": definitions, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_tdf_definitions import DefinitionsTDFDefinitions + from ..models.definitions_tdf_structs import DefinitionsTDFStructs + + d = dict(src_dict) + structs = DefinitionsTDFStructs.from_dict(d.pop("structs")) + + definitions = DefinitionsTDFDefinitions.from_dict(d.pop("definitions")) + + definitions_tdf = cls( + structs=structs, + definitions=definitions, + ) + + definitions_tdf.additional_properties = d + return definitions_tdf + + @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/definitions_tdf_definition.py b/src/infuse_iot/api_client/models/definitions_tdf_definition.py new file mode 100644 index 0000000..92322e9 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_tdf_definition.py @@ -0,0 +1,89 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_field_definition import DefinitionsFieldDefinition + + +T = TypeVar("T", bound="DefinitionsTDFDefinition") + + +@_attrs_define +class DefinitionsTDFDefinition: + """ + Attributes: + name (str): + description (str): + fields (list['DefinitionsFieldDefinition']): + """ + + name: str + description: str + fields: list["DefinitionsFieldDefinition"] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + description = self.description + + fields = [] + for fields_item_data in self.fields: + fields_item = fields_item_data.to_dict() + fields.append(fields_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "name": name, + "description": description, + "fields": fields, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_field_definition import DefinitionsFieldDefinition + + d = dict(src_dict) + name = d.pop("name") + + description = d.pop("description") + + fields = [] + _fields = d.pop("fields") + for fields_item_data in _fields: + fields_item = DefinitionsFieldDefinition.from_dict(fields_item_data) + + fields.append(fields_item) + + definitions_tdf_definition = cls( + name=name, + description=description, + fields=fields, + ) + + definitions_tdf_definition.additional_properties = d + return definitions_tdf_definition + + @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/definitions_tdf_definitions.py b/src/infuse_iot/api_client/models/definitions_tdf_definitions.py new file mode 100644 index 0000000..c96f728 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_tdf_definitions.py @@ -0,0 +1,57 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_tdf_definition import DefinitionsTDFDefinition + + +T = TypeVar("T", bound="DefinitionsTDFDefinitions") + + +@_attrs_define +class DefinitionsTDFDefinitions: + """ """ + + additional_properties: dict[str, "DefinitionsTDFDefinition"] = _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] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_tdf_definition import DefinitionsTDFDefinition + + d = dict(src_dict) + definitions_tdf_definitions = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = DefinitionsTDFDefinition.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + definitions_tdf_definitions.additional_properties = additional_properties + return definitions_tdf_definitions + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "DefinitionsTDFDefinition": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "DefinitionsTDFDefinition") -> 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/definitions_tdf_response.py b/src/infuse_iot/api_client/models/definitions_tdf_response.py new file mode 100644 index 0000000..133a397 --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_tdf_response.py @@ -0,0 +1,83 @@ +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.definitions_tdf import DefinitionsTDF + + +T = TypeVar("T", bound="DefinitionsTDFResponse") + + +@_attrs_define +class DefinitionsTDFResponse: + """ + Attributes: + created_at (datetime.datetime): + version (int): + definitions (DefinitionsTDF): + """ + + created_at: datetime.datetime + version: int + definitions: "DefinitionsTDF" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + created_at = self.created_at.isoformat() + + version = self.version + + definitions = self.definitions.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "createdAt": created_at, + "version": version, + "definitions": definitions, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_tdf import DefinitionsTDF + + d = dict(src_dict) + created_at = isoparse(d.pop("createdAt")) + + version = d.pop("version") + + definitions = DefinitionsTDF.from_dict(d.pop("definitions")) + + definitions_tdf_response = cls( + created_at=created_at, + version=version, + definitions=definitions, + ) + + definitions_tdf_response.additional_properties = d + return definitions_tdf_response + + @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/definitions_tdf_structs.py b/src/infuse_iot/api_client/models/definitions_tdf_structs.py new file mode 100644 index 0000000..11804bb --- /dev/null +++ b/src/infuse_iot/api_client/models/definitions_tdf_structs.py @@ -0,0 +1,57 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.definitions_struct_definition import DefinitionsStructDefinition + + +T = TypeVar("T", bound="DefinitionsTDFStructs") + + +@_attrs_define +class DefinitionsTDFStructs: + """ """ + + additional_properties: dict[str, "DefinitionsStructDefinition"] = _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] = prop.to_dict() + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.definitions_struct_definition import DefinitionsStructDefinition + + d = dict(src_dict) + definitions_tdf_structs = cls() + + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = DefinitionsStructDefinition.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + definitions_tdf_structs.additional_properties = additional_properties + return definitions_tdf_structs + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> "DefinitionsStructDefinition": + return self.additional_properties[key] + + def __setitem__(self, key: str, value: "DefinitionsStructDefinition") -> 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.py b/src/infuse_iot/api_client/models/device.py index 8791d3d..393cf4b 100644 --- a/src/infuse_iot/api_client/models/device.py +++ b/src/infuse_iot/api_client/models/device.py @@ -1,5 +1,6 @@ import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define @@ -9,7 +10,8 @@ from ..types import UNSET, Unset if TYPE_CHECKING: - from ..models.new_device_metadata import NewDeviceMetadata + from ..models.device_metadata import DeviceMetadata + from ..models.new_device_state import NewDeviceState T = TypeVar("T", bound="Device") @@ -27,7 +29,8 @@ class Device: organisation_id (UUID): ID of organisation for board to exist in device_id (Union[Unset, str]): 8 byte DeviceID as a hex string (if not provided will be auto-generated) Example: d291d4d66bf0a955. - metadata (Union[Unset, NewDeviceMetadata]): Metadata fields for device Example: {'Field Name': 'Field Value'}. + metadata (Union[Unset, DeviceMetadata]): Metadata fields for device Example: {'Field Name': 'Field Value'}. + initial_device_state (Union[Unset, NewDeviceState]): """ id: UUID @@ -37,10 +40,11 @@ class Device: board_id: UUID organisation_id: UUID device_id: Union[Unset, str] = UNSET - metadata: Union[Unset, "NewDeviceMetadata"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + metadata: Union[Unset, "DeviceMetadata"] = UNSET + initial_device_state: Union[Unset, "NewDeviceState"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: id = str(self.id) created_at = self.created_at.isoformat() @@ -55,11 +59,15 @@ def to_dict(self) -> Dict[str, Any]: device_id = self.device_id - metadata: Union[Unset, Dict[str, Any]] = UNSET + metadata: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.metadata, Unset): metadata = self.metadata.to_dict() - field_dict: Dict[str, Any] = {} + initial_device_state: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.initial_device_state, Unset): + initial_device_state = self.initial_device_state.to_dict() + + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -75,14 +83,17 @@ def to_dict(self) -> Dict[str, Any]: field_dict["deviceId"] = device_id if metadata is not UNSET: field_dict["metadata"] = metadata + if initial_device_state is not UNSET: + field_dict["initialDeviceState"] = initial_device_state return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - from ..models.new_device_metadata import NewDeviceMetadata + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.device_metadata import DeviceMetadata + from ..models.new_device_state import NewDeviceState - d = src_dict.copy() + d = dict(src_dict) id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -98,11 +109,18 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: device_id = d.pop("deviceId", UNSET) _metadata = d.pop("metadata", UNSET) - metadata: Union[Unset, NewDeviceMetadata] + metadata: Union[Unset, DeviceMetadata] if isinstance(_metadata, Unset): metadata = UNSET else: - metadata = NewDeviceMetadata.from_dict(_metadata) + metadata = DeviceMetadata.from_dict(_metadata) + + _initial_device_state = d.pop("initialDeviceState", UNSET) + initial_device_state: Union[Unset, NewDeviceState] + if isinstance(_initial_device_state, Unset): + initial_device_state = UNSET + else: + initial_device_state = NewDeviceState.from_dict(_initial_device_state) device = cls( id=id, @@ -113,13 +131,14 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: organisation_id=organisation_id, device_id=device_id, metadata=metadata, + initial_device_state=initial_device_state, ) device.additional_properties = d return device @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/device_and_state.py b/src/infuse_iot/api_client/models/device_and_state.py new file mode 100644 index 0000000..4fe039b --- /dev/null +++ b/src/infuse_iot/api_client/models/device_and_state.py @@ -0,0 +1,164 @@ +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 ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.device_metadata import DeviceMetadata + from ..models.device_state import DeviceState + from ..models.new_device_state import NewDeviceState + + +T = TypeVar("T", bound="DeviceAndState") + + +@_attrs_define +class DeviceAndState: + """ + Attributes: + id (UUID): Generated UUID for organisation + created_at (datetime.datetime): + updated_at (datetime.datetime): + mcu_id (str): Device's MCU ID as a hex string Example: 0011223344556677. + board_id (UUID): ID of board of device + organisation_id (UUID): ID of organisation for board to exist in + state (DeviceState): + device_id (Union[Unset, str]): 8 byte DeviceID as a hex string (if not provided will be auto-generated) Example: + d291d4d66bf0a955. + metadata (Union[Unset, DeviceMetadata]): Metadata fields for device Example: {'Field Name': 'Field Value'}. + initial_device_state (Union[Unset, NewDeviceState]): + """ + + id: UUID + created_at: datetime.datetime + updated_at: datetime.datetime + mcu_id: str + board_id: UUID + organisation_id: UUID + state: "DeviceState" + device_id: Union[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) + + def to_dict(self) -> dict[str, Any]: + id = str(self.id) + + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() + + mcu_id = self.mcu_id + + board_id = str(self.board_id) + + organisation_id = str(self.organisation_id) + + state = self.state.to_dict() + + device_id = self.device_id + + metadata: Union[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 + if not isinstance(self.initial_device_state, Unset): + initial_device_state = self.initial_device_state.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "createdAt": created_at, + "updatedAt": updated_at, + "mcuId": mcu_id, + "boardId": board_id, + "organisationId": organisation_id, + "state": state, + } + ) + if device_id is not UNSET: + field_dict["deviceId"] = device_id + if metadata is not UNSET: + field_dict["metadata"] = metadata + if initial_device_state is not UNSET: + field_dict["initialDeviceState"] = initial_device_state + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.device_metadata import DeviceMetadata + from ..models.device_state import DeviceState + from ..models.new_device_state import NewDeviceState + + d = dict(src_dict) + id = UUID(d.pop("id")) + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + mcu_id = d.pop("mcuId") + + board_id = UUID(d.pop("boardId")) + + organisation_id = UUID(d.pop("organisationId")) + + state = DeviceState.from_dict(d.pop("state")) + + device_id = d.pop("deviceId", UNSET) + + _metadata = d.pop("metadata", UNSET) + metadata: Union[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] + if isinstance(_initial_device_state, Unset): + initial_device_state = UNSET + else: + initial_device_state = NewDeviceState.from_dict(_initial_device_state) + + device_and_state = cls( + id=id, + created_at=created_at, + updated_at=updated_at, + mcu_id=mcu_id, + board_id=board_id, + organisation_id=organisation_id, + state=state, + device_id=device_id, + metadata=metadata, + initial_device_state=initial_device_state, + ) + + device_and_state.additional_properties = d + return device_and_state + + @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_id_field.py b/src/infuse_iot/api_client/models/device_id_field.py index e4129eb..740be2d 100644 --- a/src/infuse_iot/api_client/models/device_id_field.py +++ b/src/infuse_iot/api_client/models/device_id_field.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from collections.abc import Mapping +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -17,12 +18,12 @@ class DeviceIdField: """ device_id: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: device_id = self.device_id - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if device_id is not UNSET: @@ -31,8 +32,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) device_id = d.pop("deviceId", UNSET) device_id_field = cls( @@ -43,7 +44,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return device_id_field @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/new_device_metadata.py b/src/infuse_iot/api_client/models/device_metadata.py similarity index 59% rename from src/infuse_iot/api_client/models/new_device_metadata.py rename to src/infuse_iot/api_client/models/device_metadata.py index e34d494..efccd02 100644 --- a/src/infuse_iot/api_client/models/new_device_metadata.py +++ b/src/infuse_iot/api_client/models/device_metadata.py @@ -1,13 +1,14 @@ -from typing import Any, Dict, List, Type, TypeVar +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="NewDeviceMetadata") +T = TypeVar("T", bound="DeviceMetadata") @_attrs_define -class NewDeviceMetadata: +class DeviceMetadata: """Metadata fields for device Example: @@ -15,24 +16,24 @@ class NewDeviceMetadata: """ - additional_properties: Dict[str, str] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + 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: Dict[str, Any]) -> T: - d = src_dict.copy() - new_device_metadata = cls() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + device_metadata = cls() - new_device_metadata.additional_properties = d - return new_device_metadata + device_metadata.additional_properties = d + return device_metadata @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> str: diff --git a/src/infuse_iot/api_client/models/device_metadata_update.py b/src/infuse_iot/api_client/models/device_metadata_update.py new file mode 100644 index 0000000..0305991 --- /dev/null +++ b/src/infuse_iot/api_client/models/device_metadata_update.py @@ -0,0 +1,77 @@ +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.device_metadata_update_operation import DeviceMetadataUpdateOperation + +if TYPE_CHECKING: + from ..models.device_metadata import DeviceMetadata + + +T = TypeVar("T", bound="DeviceMetadataUpdate") + + +@_attrs_define +class DeviceMetadataUpdate: + """Metadata update + + Attributes: + operation (DeviceMetadataUpdateOperation): Operation to perform on metadata, patch to update/add provided + fields, replace to replace all metadata with provided fields + value (DeviceMetadata): Metadata fields for device Example: {'Field Name': 'Field Value'}. + """ + + operation: DeviceMetadataUpdateOperation + value: "DeviceMetadata" + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + operation = self.operation.value + + value = self.value.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "operation": operation, + "value": value, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.device_metadata import DeviceMetadata + + d = dict(src_dict) + operation = DeviceMetadataUpdateOperation(d.pop("operation")) + + value = DeviceMetadata.from_dict(d.pop("value")) + + device_metadata_update = cls( + operation=operation, + value=value, + ) + + device_metadata_update.additional_properties = d + return device_metadata_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_metadata_update_operation.py b/src/infuse_iot/api_client/models/device_metadata_update_operation.py new file mode 100644 index 0000000..e12725b --- /dev/null +++ b/src/infuse_iot/api_client/models/device_metadata_update_operation.py @@ -0,0 +1,9 @@ +from enum import Enum + + +class DeviceMetadataUpdateOperation(str, Enum): + PATCH = "patch" + REPLACE = "replace" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/device_state.py b/src/infuse_iot/api_client/models/device_state.py index 184aab4..4708151 100644 --- a/src/infuse_iot/api_client/models/device_state.py +++ b/src/infuse_iot/api_client/models/device_state.py @@ -1,5 +1,6 @@ import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +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 @@ -9,6 +10,7 @@ from ..types import UNSET, Unset if TYPE_CHECKING: + from ..models.algorithm import Algorithm from ..models.application_version import ApplicationVersion @@ -19,30 +21,41 @@ class DeviceState: """ Attributes: - created_at (Union[Unset, datetime.datetime]): - updated_at (Union[Unset, datetime.datetime]): - last_route_interface (Union[Unset, RouteType]): Interface of route - last_route_udp_address (Union[Unset, str]): UDP address of last packet sent by device + created_at (datetime.datetime): + updated_at (datetime.datetime): application_id (Union[Unset, int]): Last announced application ID application_version (Union[Unset, ApplicationVersion]): Application version + algorithms (Union[Unset, list['Algorithm']]): Last announced algorithms + last_route_interface (Union[Unset, RouteType]): Interface of route + last_route_udp_address (Union[Unset, str]): UDP address of last packet sent by device """ - created_at: Union[Unset, datetime.datetime] = UNSET - updated_at: Union[Unset, datetime.datetime] = UNSET - last_route_interface: Union[Unset, RouteType] = UNSET - last_route_udp_address: Union[Unset, str] = UNSET + created_at: datetime.datetime + updated_at: datetime.datetime application_id: Union[Unset, int] = UNSET application_version: Union[Unset, "ApplicationVersion"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + algorithms: Union[Unset, list["Algorithm"]] = UNSET + last_route_interface: Union[Unset, RouteType] = UNSET + last_route_udp_address: Union[Unset, str] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() - def to_dict(self) -> Dict[str, Any]: - created_at: Union[Unset, str] = UNSET - if not isinstance(self.created_at, Unset): - created_at = self.created_at.isoformat() + application_id = self.application_id + + application_version: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.application_version, Unset): + application_version = self.application_version.to_dict() - updated_at: Union[Unset, str] = UNSET - if not isinstance(self.updated_at, Unset): - updated_at = self.updated_at.isoformat() + algorithms: Union[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 if not isinstance(self.last_route_interface, Unset): @@ -50,48 +63,52 @@ def to_dict(self) -> Dict[str, Any]: last_route_udp_address = self.last_route_udp_address - application_id = self.application_id - - application_version: Union[Unset, Dict[str, Any]] = UNSET - if not isinstance(self.application_version, Unset): - application_version = self.application_version.to_dict() - - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) - field_dict.update({}) - if created_at is not UNSET: - field_dict["createdAt"] = created_at - if updated_at is not UNSET: - field_dict["updatedAt"] = updated_at - if last_route_interface is not UNSET: - field_dict["lastRouteInterface"] = last_route_interface - if last_route_udp_address is not UNSET: - field_dict["lastRouteUdpAddress"] = last_route_udp_address + field_dict.update( + { + "createdAt": created_at, + "updatedAt": updated_at, + } + ) if application_id is not UNSET: field_dict["applicationId"] = application_id if application_version is not UNSET: field_dict["applicationVersion"] = application_version + if algorithms is not UNSET: + field_dict["algorithms"] = algorithms + if last_route_interface is not UNSET: + field_dict["lastRouteInterface"] = last_route_interface + if last_route_udp_address is not UNSET: + field_dict["lastRouteUdpAddress"] = last_route_udp_address return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.algorithm import Algorithm from ..models.application_version import ApplicationVersion - d = src_dict.copy() - _created_at = d.pop("createdAt", UNSET) - created_at: Union[Unset, datetime.datetime] - if isinstance(_created_at, Unset): - created_at = UNSET - else: - created_at = isoparse(_created_at) + d = dict(src_dict) + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) - _updated_at = d.pop("updatedAt", UNSET) - updated_at: Union[Unset, datetime.datetime] - if isinstance(_updated_at, Unset): - updated_at = UNSET + application_id = d.pop("applicationId", UNSET) + + _application_version = d.pop("applicationVersion", UNSET) + application_version: Union[Unset, ApplicationVersion] + if isinstance(_application_version, Unset): + application_version = UNSET else: - updated_at = isoparse(_updated_at) + application_version = ApplicationVersion.from_dict(_application_version) + + algorithms = [] + _algorithms = d.pop("algorithms", UNSET) + for algorithms_item_data in _algorithms or []: + algorithms_item = Algorithm.from_dict(algorithms_item_data) + + algorithms.append(algorithms_item) _last_route_interface = d.pop("lastRouteInterface", UNSET) last_route_interface: Union[Unset, RouteType] @@ -102,29 +119,21 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: last_route_udp_address = d.pop("lastRouteUdpAddress", UNSET) - application_id = d.pop("applicationId", UNSET) - - _application_version = d.pop("applicationVersion", UNSET) - application_version: Union[Unset, ApplicationVersion] - if isinstance(_application_version, Unset): - application_version = UNSET - else: - application_version = ApplicationVersion.from_dict(_application_version) - device_state = cls( created_at=created_at, updated_at=updated_at, - last_route_interface=last_route_interface, - last_route_udp_address=last_route_udp_address, application_id=application_id, application_version=application_version, + algorithms=algorithms, + last_route_interface=last_route_interface, + last_route_udp_address=last_route_udp_address, ) device_state.additional_properties = d return device_state @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/device_update.py b/src/infuse_iot/api_client/models/device_update.py new file mode 100644 index 0000000..f78f352 --- /dev/null +++ b/src/infuse_iot/api_client/models/device_update.py @@ -0,0 +1,72 @@ +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.device_metadata_update import DeviceMetadataUpdate + + +T = TypeVar("T", bound="DeviceUpdate") + + +@_attrs_define +class DeviceUpdate: + """ + Attributes: + metadata (Union[Unset, DeviceMetadataUpdate]): Metadata update + """ + + metadata: Union[Unset, "DeviceMetadataUpdate"] = UNSET + 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 + if not isinstance(self.metadata, Unset): + metadata = self.metadata.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if metadata is not UNSET: + field_dict["metadata"] = metadata + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.device_metadata_update import DeviceMetadataUpdate + + d = dict(src_dict) + _metadata = d.pop("metadata", UNSET) + metadata: Union[Unset, DeviceMetadataUpdate] + if isinstance(_metadata, Unset): + metadata = UNSET + else: + metadata = DeviceMetadataUpdate.from_dict(_metadata) + + device_update = cls( + metadata=metadata, + ) + + device_update.additional_properties = d + return device_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/downlink_message.py b/src/infuse_iot/api_client/models/downlink_message.py index 545ae09..966860b 100644 --- a/src/infuse_iot/api_client/models/downlink_message.py +++ b/src/infuse_iot/api_client/models/downlink_message.py @@ -1,5 +1,6 @@ import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define @@ -50,9 +51,9 @@ class DownlinkMessage: sent_at: Union[Unset, datetime.datetime] = UNSET expires_at: Union[Unset, datetime.datetime] = UNSET completed_at: Union[Unset, datetime.datetime] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: id = str(self.id) created_at = self.created_at.isoformat() @@ -69,7 +70,7 @@ def to_dict(self) -> Dict[str, Any]: status = self.status.value - rpc_rsp: Union[Unset, Dict[str, Any]] = UNSET + rpc_rsp: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.rpc_rsp, Unset): rpc_rsp = self.rpc_rsp.to_dict() @@ -87,7 +88,7 @@ def to_dict(self) -> Dict[str, Any]: if not isinstance(self.completed_at, Unset): completed_at = self.completed_at.isoformat() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -115,11 +116,11 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.rpc_req import RpcReq from ..models.rpc_rsp import RpcRsp - d = src_dict.copy() + d = dict(src_dict) id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -186,7 +187,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return downlink_message @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/downlink_route.py b/src/infuse_iot/api_client/models/downlink_route.py index c5b7995..b4a3a9c 100644 --- a/src/infuse_iot/api_client/models/downlink_route.py +++ b/src/infuse_iot/api_client/models/downlink_route.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +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 @@ -26,18 +27,18 @@ class DownlinkRoute: interface: RouteType interface_data: "InterfaceData" udp: Union[Unset, "UdpDownlinkRoute"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: interface = self.interface.value interface_data = self.interface_data.to_dict() - udp: Union[Unset, Dict[str, Any]] = UNSET + udp: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.udp, Unset): udp = self.udp.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -51,11 +52,11 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.interface_data import InterfaceData from ..models.udp_downlink_route import UdpDownlinkRoute - d = src_dict.copy() + d = dict(src_dict) interface = RouteType(d.pop("interface")) interface_data = InterfaceData.from_dict(d.pop("interfaceData")) @@ -77,7 +78,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return downlink_route @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/error.py b/src/infuse_iot/api_client/models/error.py index 212fe76..5ca3dbd 100644 --- a/src/infuse_iot/api_client/models/error.py +++ b/src/infuse_iot/api_client/models/error.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,14 +17,14 @@ class Error: code: int message: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: code = self.code message = self.message - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -35,8 +36,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) code = d.pop("code") message = d.pop("message") @@ -50,7 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return error @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/health_check.py b/src/infuse_iot/api_client/models/health_check.py index ef7d1d2..dba1920 100644 --- a/src/infuse_iot/api_client/models/health_check.py +++ b/src/infuse_iot/api_client/models/health_check.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,12 +15,12 @@ class HealthCheck: """ health: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: health = self.health - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -30,8 +31,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) health = d.pop("health") health_check = cls( @@ -42,7 +43,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return health_check @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/interface_data.py b/src/infuse_iot/api_client/models/interface_data.py index bdf4e56..bef430e 100644 --- a/src/infuse_iot/api_client/models/interface_data.py +++ b/src/infuse_iot/api_client/models/interface_data.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from collections.abc import Mapping +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +17,12 @@ class InterfaceData: """ sequence: Union[Unset, int] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: sequence = self.sequence - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if sequence is not UNSET: @@ -30,8 +31,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) sequence = d.pop("sequence", UNSET) interface_data = cls( @@ -42,7 +43,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return interface_data @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/key.py b/src/infuse_iot/api_client/models/key.py index ccba541..9d94cc0 100644 --- a/src/infuse_iot/api_client/models/key.py +++ b/src/infuse_iot/api_client/models/key.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,12 +15,12 @@ class Key: """ key: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: key = self.key - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -30,8 +31,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) key = d.pop("key") key = cls( @@ -42,7 +43,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return key @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/metadata_field.py b/src/infuse_iot/api_client/models/metadata_field.py index 8143960..eb12c0d 100644 --- a/src/infuse_iot/api_client/models/metadata_field.py +++ b/src/infuse_iot/api_client/models/metadata_field.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,16 +19,16 @@ class MetadataField: name: str required: bool unique: bool - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: name = self.name required = self.required unique = self.unique - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -40,8 +41,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) name = d.pop("name") required = d.pop("required") @@ -58,7 +59,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return metadata_field @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: 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 4755c32..44ec7bd 100644 --- a/src/infuse_iot/api_client/models/new_board.py +++ b/src/infuse_iot/api_client/models/new_board.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define @@ -21,7 +22,7 @@ class NewBoard: description (str): Description of board Example: Extended description of board. soc (str): System on Chip (SoC) of board Example: nRF9151. organisation_id (UUID): ID of organisation for board to exist in - metadata_fields (Union[Unset, List['MetadataField']]): Metadata fields for board Example: [{'name': 'Field + metadata_fields (Union[Unset, list['MetadataField']]): Metadata fields for board Example: [{'name': 'Field Name', 'required': True, 'unique': False}]. """ @@ -29,10 +30,10 @@ class NewBoard: description: str soc: str organisation_id: UUID - metadata_fields: Union[Unset, List["MetadataField"]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + metadata_fields: Union[Unset, list["MetadataField"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: name = self.name description = self.description @@ -41,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: Union[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: @@ -50,7 +51,7 @@ def to_dict(self) -> Dict[str, Any]: ) metadata_fields.append(componentsschemas_board_metadata_fields_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -66,10 +67,10 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.metadata_field import MetadataField - d = src_dict.copy() + d = dict(src_dict) name = d.pop("name") description = d.pop("description") @@ -99,7 +100,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return new_board @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/new_device.py b/src/infuse_iot/api_client/models/new_device.py index f773d9d..4981247 100644 --- a/src/infuse_iot/api_client/models/new_device.py +++ b/src/infuse_iot/api_client/models/new_device.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, Union from uuid import UUID from attrs import define as _attrs_define @@ -7,7 +8,8 @@ from ..types import UNSET, Unset if TYPE_CHECKING: - from ..models.new_device_metadata import NewDeviceMetadata + from ..models.device_metadata import DeviceMetadata + from ..models.new_device_state import NewDeviceState T = TypeVar("T", bound="NewDevice") @@ -22,17 +24,19 @@ class NewDevice: organisation_id (UUID): ID of organisation for board to exist in device_id (Union[Unset, str]): 8 byte DeviceID as a hex string (if not provided will be auto-generated) Example: d291d4d66bf0a955. - metadata (Union[Unset, NewDeviceMetadata]): Metadata fields for device Example: {'Field Name': 'Field Value'}. + metadata (Union[Unset, DeviceMetadata]): Metadata fields for device Example: {'Field Name': 'Field Value'}. + initial_device_state (Union[Unset, NewDeviceState]): """ mcu_id: str board_id: UUID organisation_id: UUID device_id: Union[Unset, str] = UNSET - metadata: Union[Unset, "NewDeviceMetadata"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + metadata: Union[Unset, "DeviceMetadata"] = UNSET + initial_device_state: Union[Unset, "NewDeviceState"] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: mcu_id = self.mcu_id board_id = str(self.board_id) @@ -41,11 +45,15 @@ def to_dict(self) -> Dict[str, Any]: device_id = self.device_id - metadata: Union[Unset, Dict[str, Any]] = UNSET + metadata: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.metadata, Unset): metadata = self.metadata.to_dict() - field_dict: Dict[str, Any] = {} + initial_device_state: Union[Unset, dict[str, Any]] = UNSET + if not isinstance(self.initial_device_state, Unset): + initial_device_state = self.initial_device_state.to_dict() + + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -58,14 +66,17 @@ def to_dict(self) -> Dict[str, Any]: field_dict["deviceId"] = device_id if metadata is not UNSET: field_dict["metadata"] = metadata + if initial_device_state is not UNSET: + field_dict["initialDeviceState"] = initial_device_state return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - from ..models.new_device_metadata import NewDeviceMetadata + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.device_metadata import DeviceMetadata + from ..models.new_device_state import NewDeviceState - d = src_dict.copy() + d = dict(src_dict) mcu_id = d.pop("mcuId") board_id = UUID(d.pop("boardId")) @@ -75,11 +86,18 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: device_id = d.pop("deviceId", UNSET) _metadata = d.pop("metadata", UNSET) - metadata: Union[Unset, NewDeviceMetadata] + metadata: Union[Unset, DeviceMetadata] if isinstance(_metadata, Unset): metadata = UNSET else: - metadata = NewDeviceMetadata.from_dict(_metadata) + metadata = DeviceMetadata.from_dict(_metadata) + + _initial_device_state = d.pop("initialDeviceState", UNSET) + initial_device_state: Union[Unset, NewDeviceState] + if isinstance(_initial_device_state, Unset): + initial_device_state = UNSET + else: + initial_device_state = NewDeviceState.from_dict(_initial_device_state) new_device = cls( mcu_id=mcu_id, @@ -87,13 +105,14 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: organisation_id=organisation_id, device_id=device_id, metadata=metadata, + initial_device_state=initial_device_state, ) new_device.additional_properties = d return new_device @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/new_device_state.py b/src/infuse_iot/api_client/models/new_device_state.py new file mode 100644 index 0000000..80f28f3 --- /dev/null +++ b/src/infuse_iot/api_client/models/new_device_state.py @@ -0,0 +1,102 @@ +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.algorithm import Algorithm + from ..models.application_version import ApplicationVersion + + +T = TypeVar("T", bound="NewDeviceState") + + +@_attrs_define +class NewDeviceState: + """ + Attributes: + application_id (Union[Unset, int]): Last announced application ID + application_version (Union[Unset, ApplicationVersion]): Application version + algorithms (Union[Unset, list['Algorithm']]): Last announced algorithms + """ + + application_id: Union[Unset, int] = UNSET + application_version: Union[Unset, "ApplicationVersion"] = UNSET + algorithms: Union[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 + if not isinstance(self.application_version, Unset): + application_version = self.application_version.to_dict() + + algorithms: Union[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) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if application_id is not UNSET: + field_dict["applicationId"] = application_id + if application_version is not UNSET: + field_dict["applicationVersion"] = application_version + if algorithms is not UNSET: + field_dict["algorithms"] = algorithms + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.algorithm import Algorithm + from ..models.application_version import ApplicationVersion + + d = dict(src_dict) + application_id = d.pop("applicationId", UNSET) + + _application_version = d.pop("applicationVersion", UNSET) + application_version: Union[Unset, ApplicationVersion] + if isinstance(_application_version, Unset): + application_version = UNSET + else: + application_version = ApplicationVersion.from_dict(_application_version) + + algorithms = [] + _algorithms = d.pop("algorithms", UNSET) + for algorithms_item_data in _algorithms or []: + algorithms_item = Algorithm.from_dict(algorithms_item_data) + + algorithms.append(algorithms_item) + + new_device_state = cls( + application_id=application_id, + application_version=application_version, + algorithms=algorithms, + ) + + new_device_state.additional_properties = d + return new_device_state + + @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_organisation.py b/src/infuse_iot/api_client/models/new_organisation.py index c9897c4..b6fffc2 100644 --- a/src/infuse_iot/api_client/models/new_organisation.py +++ b/src/infuse_iot/api_client/models/new_organisation.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,12 +15,12 @@ class NewOrganisation: """ name: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: name = self.name - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -30,8 +31,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) name = d.pop("name") new_organisation = cls( @@ -42,7 +43,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return new_organisation @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: 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 d9df4a2..1c4817e 100644 --- a/src/infuse_iot/api_client/models/new_rpc_message.py +++ b/src/infuse_iot/api_client/models/new_rpc_message.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +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 @@ -25,16 +26,16 @@ class NewRPCMessage: device_id: str rpc: "NewRPCReq" send_wait_timeout_ms: Union[Unset, int] = 60000 - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: device_id = self.device_id rpc = self.rpc.to_dict() send_wait_timeout_ms = self.send_wait_timeout_ms - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -48,10 +49,10 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.new_rpc_req import NewRPCReq - d = src_dict.copy() + d = dict(src_dict) device_id = d.pop("deviceId") rpc = NewRPCReq.from_dict(d.pop("rpc")) @@ -68,7 +69,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return new_rpc_message @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: 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 5e538d4..dbe9d95 100644 --- a/src/infuse_iot/api_client/models/new_rpc_req.py +++ b/src/infuse_iot/api_client/models/new_rpc_req.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +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 @@ -27,18 +28,18 @@ class NewRPCReq: command_id: Union[Unset, int] = UNSET command_name: Union[Unset, str] = UNSET params: Union[Unset, "RPCParams"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: command_id = self.command_id command_name = self.command_name - params: Union[Unset, Dict[str, Any]] = UNSET + params: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.params, Unset): params = self.params.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if command_id is not UNSET: @@ -51,10 +52,10 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.rpc_params import RPCParams - d = src_dict.copy() + d = dict(src_dict) command_id = d.pop("commandId", UNSET) command_name = d.pop("commandName", UNSET) @@ -76,7 +77,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return new_rpc_req @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/organisation.py b/src/infuse_iot/api_client/models/organisation.py index 533c691..b0890b3 100644 --- a/src/infuse_iot/api_client/models/organisation.py +++ b/src/infuse_iot/api_client/models/organisation.py @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -23,9 +24,9 @@ class Organisation: created_at: datetime.datetime updated_at: datetime.datetime name: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: id = str(self.id) created_at = self.created_at.isoformat() @@ -34,7 +35,7 @@ def to_dict(self) -> Dict[str, Any]: name = self.name - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -48,8 +49,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -69,7 +70,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return organisation @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/rpc_message.py b/src/infuse_iot/api_client/models/rpc_message.py index 7911f66..4cd7d0c 100644 --- a/src/infuse_iot/api_client/models/rpc_message.py +++ b/src/infuse_iot/api_client/models/rpc_message.py @@ -1,5 +1,6 @@ import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar from uuid import UUID from attrs import define as _attrs_define @@ -31,9 +32,9 @@ class RpcMessage: downlink_message_id: UUID device: "Device" downlink_message: "DownlinkMessage" - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: created_at = self.created_at.isoformat() id = str(self.id) @@ -44,7 +45,7 @@ def to_dict(self) -> Dict[str, Any]: downlink_message = self.downlink_message.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -59,11 +60,11 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.device import Device from ..models.downlink_message import DownlinkMessage - d = src_dict.copy() + d = dict(src_dict) created_at = isoparse(d.pop("createdAt")) id = UUID(d.pop("id")) @@ -86,7 +87,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return rpc_message @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/rpc_params.py b/src/infuse_iot/api_client/models/rpc_params.py index 1bfbfb7..9121b1d 100644 --- a/src/infuse_iot/api_client/models/rpc_params.py +++ b/src/infuse_iot/api_client/models/rpc_params.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,24 +17,24 @@ class RPCParams: """ - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + 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: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) rpc_params = cls() rpc_params.additional_properties = d return rpc_params @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/rpc_req.py b/src/infuse_iot/api_client/models/rpc_req.py index 874278b..6d49853 100644 --- a/src/infuse_iot/api_client/models/rpc_req.py +++ b/src/infuse_iot/api_client/models/rpc_req.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +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 @@ -29,22 +30,22 @@ class RpcReq: command_id: int params: Union[Unset, "RPCParams"] = UNSET route: Union[Unset, "DownlinkRoute"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: request_id = self.request_id command_id = self.command_id - params: Union[Unset, Dict[str, Any]] = UNSET + params: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.params, Unset): params = self.params.to_dict() - route: Union[Unset, Dict[str, Any]] = UNSET + route: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.route, Unset): route = self.route.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -60,11 +61,11 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.downlink_route import DownlinkRoute from ..models.rpc_params import RPCParams - d = src_dict.copy() + d = dict(src_dict) request_id = d.pop("requestId") command_id = d.pop("commandId") @@ -94,7 +95,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return rpc_req @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/rpc_rsp.py b/src/infuse_iot/api_client/models/rpc_rsp.py index f85ecee..ba8f387 100644 --- a/src/infuse_iot/api_client/models/rpc_rsp.py +++ b/src/infuse_iot/api_client/models/rpc_rsp.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +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 @@ -27,18 +28,18 @@ class RpcRsp: route: "UplinkRoute" return_code: int params: Union[Unset, "RPCParams"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: route = self.route.to_dict() return_code = self.return_code - params: Union[Unset, Dict[str, Any]] = UNSET + params: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.params, Unset): params = self.params.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -52,11 +53,11 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.rpc_params import RPCParams from ..models.uplink_route import UplinkRoute - d = src_dict.copy() + d = dict(src_dict) route = UplinkRoute.from_dict(d.pop("route")) return_code = d.pop("returnCode") @@ -78,7 +79,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return rpc_rsp @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/udp_downlink_route.py b/src/infuse_iot/api_client/models/udp_downlink_route.py index 57ac54c..e9a7f89 100644 --- a/src/infuse_iot/api_client/models/udp_downlink_route.py +++ b/src/infuse_iot/api_client/models/udp_downlink_route.py @@ -1,4 +1,5 @@ -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,12 +15,12 @@ class UdpDownlinkRoute: """ address: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: address = self.address - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -30,8 +31,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) address = d.pop("address") udp_downlink_route = cls( @@ -42,7 +43,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return udp_downlink_route @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/udp_uplink_route.py b/src/infuse_iot/api_client/models/udp_uplink_route.py index d5f33ed..4bb1d5f 100644 --- a/src/infuse_iot/api_client/models/udp_uplink_route.py +++ b/src/infuse_iot/api_client/models/udp_uplink_route.py @@ -1,5 +1,6 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar +from collections.abc import Mapping +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +19,14 @@ class UdpUplinkRoute: address: str time: datetime.datetime - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: address = self.address time = self.time.isoformat() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -37,8 +38,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) address = d.pop("address") time = isoparse(d.pop("time")) @@ -52,7 +53,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return udp_uplink_route @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/models/uplink_route.py b/src/infuse_iot/api_client/models/uplink_route.py index 5cee4d6..d07785a 100644 --- a/src/infuse_iot/api_client/models/uplink_route.py +++ b/src/infuse_iot/api_client/models/uplink_route.py @@ -1,4 +1,5 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +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 @@ -26,18 +27,18 @@ class UplinkRoute: interface: RouteType interface_data: "InterfaceData" udp: Union[Unset, "UdpUplinkRoute"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: interface = self.interface.value interface_data = self.interface_data.to_dict() - udp: Union[Unset, Dict[str, Any]] = UNSET + udp: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.udp, Unset): udp = self.udp.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -51,11 +52,11 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.interface_data import InterfaceData from ..models.udp_uplink_route import UdpUplinkRoute - d = src_dict.copy() + d = dict(src_dict) interface = RouteType(d.pop("interface")) interface_data = InterfaceData.from_dict(d.pop("interfaceData")) @@ -77,7 +78,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return uplink_route @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/src/infuse_iot/api_client/types.py b/src/infuse_iot/api_client/types.py index 27e9a71..b9ed58b 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, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, Optional, 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[Optional[str], BinaryIO, Optional[str]] @define @@ -43,4 +43,4 @@ class Response(Generic[T]): parsed: Optional[T] -__all__ = ["File", "Response", "FileJsonType", "Unset", "UNSET"] +__all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"] diff --git a/src/infuse_iot/generated/kv_definitions.py b/src/infuse_iot/generated/kv_definitions.py index 7276193..32af070 100644 --- a/src/infuse_iot/generated/kv_definitions.py +++ b/src/infuse_iot/generated/kv_definitions.py @@ -38,7 +38,7 @@ class kv_string(VLACompatLittleEndianStruct): _pack_ = 1 def __str__(self) -> str: - return bytes(self.value).decode('utf-8') + return bytes(self.value).decode("utf-8") class kv_mcuboot_img_sem_ver(VLACompatLittleEndianStruct): """MCUboot semantic versioning struct""" @@ -125,8 +125,7 @@ class wifi_ssid(VLACompatLittleEndianStruct): NAME = "WIFI_SSID" BASE_ID = 20 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("ssid", structs.kv_string) _pack_ = 1 @@ -136,8 +135,7 @@ class wifi_psk(VLACompatLittleEndianStruct): NAME = "WIFI_PSK" BASE_ID = 21 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("psk", structs.kv_string) _pack_ = 1 @@ -147,8 +145,7 @@ class ntp_server_url(VLACompatLittleEndianStruct): NAME = "NTP_SERVER_URL" BASE_ID = 30 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("url", structs.kv_string) _pack_ = 1 @@ -158,8 +155,7 @@ class epacket_udp_url(VLACompatLittleEndianStruct): NAME = "EPACKET_UDP_URL" BASE_ID = 31 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("server", structs.kv_string) _pack_ = 1 @@ -180,8 +176,7 @@ class lte_modem_model(VLACompatLittleEndianStruct): NAME = "LTE_MODEM_MODEL" BASE_ID = 40 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("model", structs.kv_string) _pack_ = 1 @@ -191,8 +186,7 @@ class lte_modem_firmware_revision(VLACompatLittleEndianStruct): NAME = "LTE_MODEM_FIRMWARE_REVISION" BASE_ID = 41 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("revision", structs.kv_string) _pack_ = 1 @@ -202,8 +196,7 @@ class lte_modem_esn(VLACompatLittleEndianStruct): NAME = "LTE_MODEM_ESN" BASE_ID = 42 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("esn", structs.kv_string) _pack_ = 1 @@ -224,8 +217,7 @@ class lte_sim_uicc(VLACompatLittleEndianStruct): NAME = "LTE_SIM_UICC" BASE_ID = 44 RANGE = 1 - _fields_ = [ - ] + _fields_ = [] vla_field = ("uicc", structs.kv_string) _pack_ = 1 diff --git a/src/infuse_iot/generated/rpc_definitions.py b/src/infuse_iot/generated/rpc_definitions.py index 45c1ae6..a5c1d2d 100644 --- a/src/infuse_iot/generated/rpc_definitions.py +++ b/src/infuse_iot/generated/rpc_definitions.py @@ -251,8 +251,7 @@ class request(VLACompatLittleEndianStruct): _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 @@ -264,8 +263,7 @@ class time_get: COMMAND_ID = 3 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): @@ -291,8 +289,7 @@ class request(VLACompatLittleEndianStruct): _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 @@ -311,8 +308,7 @@ class request(VLACompatLittleEndianStruct): _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] vla_field = ("rc", 0 * ctypes.c_int16) _pack_ = 1 @@ -332,8 +328,7 @@ class request(VLACompatLittleEndianStruct): _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] vla_field = ("values", 0 * rpc_struct_kv_store_value) _pack_ = 1 @@ -391,8 +386,7 @@ class application_info: COMMAND_ID = 9 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): @@ -417,8 +411,7 @@ class wifi_scan: COMMAND_ID = 10 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): @@ -437,8 +430,7 @@ class wifi_state: COMMAND_ID = 11 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): @@ -457,8 +449,7 @@ class last_reboot: COMMAND_ID = 12 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): @@ -584,8 +575,7 @@ class request(VLACompatLittleEndianStruct): _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 @@ -597,14 +587,12 @@ class lte_at_cmd: COMMAND_ID = 20 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] vla_field = ("cmd", 0 * ctypes.c_char) _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] vla_field = ("rsp", 0 * ctypes.c_char) _pack_ = 1 @@ -617,8 +605,7 @@ class lte_state: COMMAND_ID = 21 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): @@ -752,8 +739,7 @@ class request(VLACompatLittleEndianStruct): _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 @@ -812,13 +798,11 @@ class data_sender: COMMAND_ID = 32765 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 @@ -830,8 +814,7 @@ class data_receiver: COMMAND_ID = 32766 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] _pack_ = 1 class response(VLACompatLittleEndianStruct): @@ -850,14 +833,11 @@ class echo: COMMAND_ID = 32767 class request(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] vla_field = ("array", 0 * ctypes.c_uint8) _pack_ = 1 class response(VLACompatLittleEndianStruct): - _fields_ = [ - ] + _fields_ = [] vla_field = ("array", 0 * ctypes.c_uint8) _pack_ = 1 - diff --git a/src/infuse_iot/generated/tdf_definitions.py b/src/infuse_iot/generated/tdf_definitions.py index 08143e8..fe20c4d 100644 --- a/src/infuse_iot/generated/tdf_definitions.py +++ b/src/infuse_iot/generated/tdf_definitions.py @@ -176,7 +176,7 @@ class tdf_struct_bt_addr_le(TdfStructBase): @property def val(self): - return int.from_bytes(self._val, byteorder='little') + return int.from_bytes(self._val, byteorder="little") class tdf_struct_eui48(TdfStructBase): """IEEE EUI-48 address""" @@ -194,7 +194,7 @@ class tdf_struct_eui48(TdfStructBase): @property def val(self): - return int.from_bytes(self._val, byteorder='little') + return int.from_bytes(self._val, byteorder="little") class readings: diff --git a/src/infuse_iot/tools/cloud.py b/src/infuse_iot/tools/cloud.py index d234c88..c8eeba8 100644 --- a/src/infuse_iot/tools/cloud.py +++ b/src/infuse_iot/tools/cloud.py @@ -18,9 +18,7 @@ get_board_by_id, get_boards, ) -from infuse_iot.api_client.api.device import ( - get_device_by_device_id, -) +from infuse_iot.api_client.api.device import get_device_by_device_id, get_device_state_by_id from infuse_iot.api_client.api.organisation import ( create_organisation, get_all_organisations, @@ -181,6 +179,7 @@ def info(self, client): org = get_organisation_by_id.sync(client=client, id=info.organisation_id) board = get_board_by_id.sync(client=client, id=info.board_id) + state = get_device_state_by_id.sync(client=client, id=info.id) table: list[tuple[str, Any]] = [ ("UUID", info.id), @@ -191,6 +190,18 @@ def info(self, client): ("Updated", info.updated_at), *metadata, ] + if state is not None: + v = state.application_version + v_str = f"{v.major}.{v.minor}.{v.revision}+{v.build_num:08x}" if v else "Unknown" + + table += [ + ("~~~State~~~", ""), + ("Updated", state.updated_at), + ("Application ID", f"0x{state.application_id:08x}"), + ("Version", v_str), + ("Last Heard", state.last_route_interface), + ] + print(tabulate(table)) diff --git a/src/infuse_iot/tools/provision.py b/src/infuse_iot/tools/provision.py index 51064ba..c84f860 100644 --- a/src/infuse_iot/tools/provision.py +++ b/src/infuse_iot/tools/provision.py @@ -21,7 +21,7 @@ get_device_by_soc_and_mcu_id, ) from infuse_iot.api_client.api.organisation import get_all_organisations -from infuse_iot.api_client.models import Board, Error, NewDevice, NewDeviceMetadata +from infuse_iot.api_client.models import Board, DeviceMetadata, Error, NewDevice from infuse_iot.commands import InfuseCommand from infuse_iot.credentials import get_api_key from infuse_iot.util.soc import nrf, soc, stm @@ -119,7 +119,7 @@ def create_device(self, client: Client, soc_name: str, hardware_id_str: str): mcu_id=hardware_id_str, organisation_id=self._org, board_id=self._board, - metadata=NewDeviceMetadata.from_dict(self._metadata), + metadata=DeviceMetadata.from_dict(self._metadata), ) if self._id: new_board.device_id = f"{self._id:016x}" @@ -138,7 +138,7 @@ def run(self): raise NotImplementedError(f"Unhandled vendor '{self._vendor}'") hardware_id = interface.unique_device_id() - hardware_id_str = f"{hardware_id:0{2*interface.unique_device_id_len}x}" + hardware_id_str = f"{hardware_id:0{2 * interface.unique_device_id_len}x}" client = Client(base_url="https://api.infuse-iot.com").with_headers({"x-api-key": f"Bearer {get_api_key()}"}) diff --git a/src/infuse_iot/tools/serial_throughput.py b/src/infuse_iot/tools/serial_throughput.py index 793738e..9b364bc 100644 --- a/src/infuse_iot/tools/serial_throughput.py +++ b/src/infuse_iot/tools/serial_throughput.py @@ -77,7 +77,7 @@ def run_send_test(self, num, size, queue_size): if responses != num: print(f"\tOnly received {responses}/{num} responses") msg = f"\t{num} packets with {size:3d} bytes payload complete in {duration:.2f} seconds" - msg += f" ({int(8*throughput):6d} bps)" + msg += f" ({int(8 * throughput):6d} bps)" print(msg) def run(self):