diff --git a/src/infuse_iot/api_client/api/board/__init__.py b/src/infuse_iot/api_client/api/board/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/infuse_iot/api_client/api/default/create_board.py b/src/infuse_iot/api_client/api/board/create_board.py similarity index 95% rename from src/infuse_iot/api_client/api/default/create_board.py rename to src/infuse_iot/api_client/api/board/create_board.py index f909ba4..22d44fd 100644 --- a/src/infuse_iot/api_client/api/default/create_board.py +++ b/src/infuse_iot/api_client/api/board/create_board.py @@ -33,14 +33,14 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Board]]: - if response.status_code == HTTPStatus.CREATED: + if response.status_code == 201: response_201 = Board.from_dict(response.json()) return response_201 - if response.status_code == HTTPStatus.CONFLICT: + if response.status_code == 409: response_409 = cast(Any, None) return response_409 - if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + if response.status_code == 422: response_422 = cast(Any, None) return response_422 if client.raise_on_unexpected_status: diff --git a/src/infuse_iot/api_client/api/default/get_board_by_id.py b/src/infuse_iot/api_client/api/board/get_board_by_id.py similarity index 93% rename from src/infuse_iot/api_client/api/default/get_board_by_id.py rename to src/infuse_iot/api_client/api/board/get_board_by_id.py index f321070..88ea7ca 100644 --- a/src/infuse_iot/api_client/api/default/get_board_by_id.py +++ b/src/infuse_iot/api_client/api/board/get_board_by_id.py @@ -1,5 +1,6 @@ from http import HTTPStatus from typing import Any, Dict, Optional, Union, cast +from uuid import UUID import httpx @@ -10,7 +11,7 @@ def _get_kwargs( - id: str, + id: UUID, ) -> Dict[str, Any]: _kwargs: Dict[str, Any] = { "method": "get", @@ -23,11 +24,11 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Board]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Board.from_dict(response.json()) return response_200 - if response.status_code == HTTPStatus.NOT_FOUND: + if response.status_code == 404: response_404 = cast(Any, None) return response_404 if client.raise_on_unexpected_status: @@ -48,14 +49,14 @@ def _build_response( def sync_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Response[Union[Any, Board]]: """Get a board by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -77,14 +78,14 @@ def sync_detailed( def sync( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Optional[Union[Any, Board]]: """Get a board by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -101,14 +102,14 @@ def sync( async def asyncio_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Response[Union[Any, Board]]: """Get a board by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -128,14 +129,14 @@ async def asyncio_detailed( async def asyncio( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Optional[Union[Any, Board]]: """Get a board by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/src/infuse_iot/api_client/api/default/get_boards.py b/src/infuse_iot/api_client/api/board/get_boards.py similarity index 90% rename from src/infuse_iot/api_client/api/default/get_boards.py rename to src/infuse_iot/api_client/api/board/get_boards.py index 835dcdc..47cf156 100644 --- a/src/infuse_iot/api_client/api/default/get_boards.py +++ b/src/infuse_iot/api_client/api/board/get_boards.py @@ -1,5 +1,6 @@ from http import HTTPStatus from typing import Any, Dict, List, Optional, Union +from uuid import UUID import httpx @@ -11,11 +12,12 @@ def _get_kwargs( *, - organisation_id: str, + organisation_id: UUID, ) -> Dict[str, Any]: params: Dict[str, Any] = {} - params["organisationId"] = organisation_id + 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} @@ -29,7 +31,7 @@ def _get_kwargs( def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List["Board"]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = [] _response_200 = response.json() for response_200_item_data in _response_200: @@ -56,12 +58,12 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Response[List["Board"]]: """Get all boards in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -85,12 +87,12 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Optional[List["Board"]]: """Get all boards in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -109,12 +111,12 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Response[List["Board"]]: """Get all boards in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -136,12 +138,12 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Optional[List["Board"]]: """Get all boards in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/src/infuse_iot/api_client/api/default/get_devices_by_board_id.py b/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py similarity index 95% rename from src/infuse_iot/api_client/api/default/get_devices_by_board_id.py rename to src/infuse_iot/api_client/api/board/get_devices_by_board_id.py index 687fc16..8b6ebde 100644 --- a/src/infuse_iot/api_client/api/default/get_devices_by_board_id.py +++ b/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py @@ -1,5 +1,6 @@ from http import HTTPStatus from typing import Any, Dict, List, Optional, Union, cast +from uuid import UUID import httpx @@ -10,7 +11,7 @@ def _get_kwargs( - id: str, + id: UUID, *, metadata_name: Union[Unset, str] = UNSET, metadata_value: Union[Unset, str] = UNSET, @@ -35,7 +36,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, List["Device"]]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = [] _response_200 = response.json() for response_200_item_data in _response_200: @@ -44,7 +45,7 @@ def _parse_response( response_200.append(response_200_item) return response_200 - if response.status_code == HTTPStatus.NOT_FOUND: + if response.status_code == 404: response_404 = cast(Any, None) return response_404 if client.raise_on_unexpected_status: @@ -65,7 +66,7 @@ def _build_response( def sync_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, @@ -74,7 +75,7 @@ def sync_detailed( """Get devices by board id and optional metadata field Args: - id (str): + id (UUID): metadata_name (Union[Unset, str]): metadata_value (Union[Unset, str]): @@ -100,7 +101,7 @@ def sync_detailed( def sync( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, @@ -109,7 +110,7 @@ def sync( """Get devices by board id and optional metadata field Args: - id (str): + id (UUID): metadata_name (Union[Unset, str]): metadata_value (Union[Unset, str]): @@ -130,7 +131,7 @@ def sync( async def asyncio_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, @@ -139,7 +140,7 @@ async def asyncio_detailed( """Get devices by board id and optional metadata field Args: - id (str): + id (UUID): metadata_name (Union[Unset, str]): metadata_value (Union[Unset, str]): @@ -163,7 +164,7 @@ async def asyncio_detailed( async def asyncio( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], metadata_name: Union[Unset, str] = UNSET, @@ -172,7 +173,7 @@ async def asyncio( """Get devices by board id and optional metadata field Args: - id (str): + id (UUID): metadata_name (Union[Unset, str]): metadata_value (Union[Unset, str]): 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 7328f10..c29d46e 100644 --- a/src/infuse_iot/api_client/api/default/get_health.py +++ b/src/infuse_iot/api_client/api/default/get_health.py @@ -19,7 +19,7 @@ def _get_kwargs() -> Dict[str, Any]: def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[HealthCheck]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = HealthCheck.from_dict(response.json()) return response_200 diff --git a/src/infuse_iot/api_client/api/device/__init__.py b/src/infuse_iot/api_client/api/device/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/infuse_iot/api_client/api/default/create_device.py b/src/infuse_iot/api_client/api/device/create_device.py similarity index 95% rename from src/infuse_iot/api_client/api/default/create_device.py rename to src/infuse_iot/api_client/api/device/create_device.py index 266e090..5ece19c 100644 --- a/src/infuse_iot/api_client/api/default/create_device.py +++ b/src/infuse_iot/api_client/api/device/create_device.py @@ -33,14 +33,14 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Device]]: - if response.status_code == HTTPStatus.CREATED: + if response.status_code == 201: response_201 = Device.from_dict(response.json()) return response_201 - if response.status_code == HTTPStatus.CONFLICT: + if response.status_code == 409: response_409 = cast(Any, None) return response_409 - if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY: + if response.status_code == 422: response_422 = cast(Any, None) return response_422 if client.raise_on_unexpected_status: diff --git a/src/infuse_iot/api_client/api/default/get_device_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_by_device_id.py similarity index 97% rename from src/infuse_iot/api_client/api/default/get_device_by_device_id.py rename to src/infuse_iot/api_client/api/device/get_device_by_device_id.py index e6ee0a6..cecbaaf 100644 --- a/src/infuse_iot/api_client/api/default/get_device_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_device_id.py @@ -23,11 +23,11 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Device]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Device.from_dict(response.json()) return response_200 - if response.status_code == HTTPStatus.NOT_FOUND: + if response.status_code == 404: response_404 = cast(Any, None) return response_404 if client.raise_on_unexpected_status: diff --git a/src/infuse_iot/api_client/api/default/get_device_by_id.py b/src/infuse_iot/api_client/api/device/get_device_by_id.py similarity index 93% rename from src/infuse_iot/api_client/api/default/get_device_by_id.py rename to src/infuse_iot/api_client/api/device/get_device_by_id.py index 84ba3e4..1fbe505 100644 --- a/src/infuse_iot/api_client/api/default/get_device_by_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_id.py @@ -1,5 +1,6 @@ from http import HTTPStatus from typing import Any, Dict, Optional, Union, cast +from uuid import UUID import httpx @@ -10,7 +11,7 @@ def _get_kwargs( - id: str, + id: UUID, ) -> Dict[str, Any]: _kwargs: Dict[str, Any] = { "method": "get", @@ -23,11 +24,11 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Device]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Device.from_dict(response.json()) return response_200 - if response.status_code == HTTPStatus.NOT_FOUND: + if response.status_code == 404: response_404 = cast(Any, None) return response_404 if client.raise_on_unexpected_status: @@ -48,14 +49,14 @@ def _build_response( def sync_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Response[Union[Any, Device]]: """Get a device by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -77,14 +78,14 @@ def sync_detailed( def sync( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Optional[Union[Any, Device]]: """Get a device by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -101,14 +102,14 @@ def sync( async def asyncio_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Response[Union[Any, Device]]: """Get a device by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -128,14 +129,14 @@ async def asyncio_detailed( async def asyncio( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Optional[Union[Any, Device]]: """Get a device by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/src/infuse_iot/api_client/api/default/get_device_by_soc_and_mcu_id.py b/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py similarity index 97% rename from src/infuse_iot/api_client/api/default/get_device_by_soc_and_mcu_id.py rename to src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py index a7075fe..c7c14e4 100644 --- a/src/infuse_iot/api_client/api/default/get_device_by_soc_and_mcu_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py @@ -24,11 +24,11 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Device]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Device.from_dict(response.json()) return response_200 - if response.status_code == HTTPStatus.NOT_FOUND: + if response.status_code == 404: response_404 = cast(Any, None) return response_404 if client.raise_on_unexpected_status: 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 new file mode 100644 index 0000000..f69ee86 --- /dev/null +++ b/src/infuse_iot/api_client/api/device/get_device_state_by_id.py @@ -0,0 +1,154 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union, cast +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.device_state import DeviceState +from ...types import Response + + +def _get_kwargs( + id: UUID, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/device/id/{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( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, DeviceState]]: + """Get device state by ID + + Args: + id (UUID): + + 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, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Any, DeviceState]]: + """Get device state by ID + + Args: + id (UUID): + + 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, + ).parsed + + +async def asyncio_detailed( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Any, DeviceState]]: + """Get device state by ID + + Args: + id (UUID): + + 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, + ) + + 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], +) -> Optional[Union[Any, DeviceState]]: + """Get device state by ID + + Args: + id (UUID): + + 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, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/default/get_devices.py b/src/infuse_iot/api_client/api/device/get_devices.py similarity index 90% rename from src/infuse_iot/api_client/api/default/get_devices.py rename to src/infuse_iot/api_client/api/device/get_devices.py index 260a721..7e719b1 100644 --- a/src/infuse_iot/api_client/api/default/get_devices.py +++ b/src/infuse_iot/api_client/api/device/get_devices.py @@ -1,5 +1,6 @@ from http import HTTPStatus from typing import Any, Dict, List, Optional, Union +from uuid import UUID import httpx @@ -11,11 +12,12 @@ def _get_kwargs( *, - organisation_id: str, + organisation_id: UUID, ) -> Dict[str, Any]: params: Dict[str, Any] = {} - params["organisationId"] = organisation_id + 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} @@ -31,7 +33,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[List["Device"]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = [] _response_200 = response.json() for response_200_item_data in _response_200: @@ -60,12 +62,12 @@ def _build_response( def sync_detailed( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Response[List["Device"]]: """Get all devices in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -89,12 +91,12 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Optional[List["Device"]]: """Get all devices in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -113,12 +115,12 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Response[List["Device"]]: """Get all devices in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -140,12 +142,12 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], - organisation_id: str, + organisation_id: UUID, ) -> Optional[List["Device"]]: """Get all devices in an organisation Args: - organisation_id (str): + organisation_id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/src/infuse_iot/api_client/api/key/__init__.py b/src/infuse_iot/api_client/api/key/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/infuse_iot/api_client/api/default/get_public_key.py b/src/infuse_iot/api_client/api/key/get_public_key.py similarity index 98% rename from src/infuse_iot/api_client/api/default/get_public_key.py rename to src/infuse_iot/api_client/api/key/get_public_key.py index e41b079..d52cef5 100644 --- a/src/infuse_iot/api_client/api/default/get_public_key.py +++ b/src/infuse_iot/api_client/api/key/get_public_key.py @@ -19,7 +19,7 @@ def _get_kwargs() -> Dict[str, Any]: def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Key]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Key.from_dict(response.json()) return response_200 diff --git a/src/infuse_iot/api_client/api/default/get_shared_secret.py b/src/infuse_iot/api_client/api/key/get_shared_secret.py similarity index 98% rename from src/infuse_iot/api_client/api/default/get_shared_secret.py rename to src/infuse_iot/api_client/api/key/get_shared_secret.py index 6259e76..1591091 100644 --- a/src/infuse_iot/api_client/api/default/get_shared_secret.py +++ b/src/infuse_iot/api_client/api/key/get_shared_secret.py @@ -30,7 +30,7 @@ def _get_kwargs( def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Key]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Key.from_dict(response.json()) return response_200 diff --git a/src/infuse_iot/api_client/api/organisation/__init__.py b/src/infuse_iot/api_client/api/organisation/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/infuse_iot/api_client/api/default/create_organisation.py b/src/infuse_iot/api_client/api/organisation/create_organisation.py similarity index 97% rename from src/infuse_iot/api_client/api/default/create_organisation.py rename to src/infuse_iot/api_client/api/organisation/create_organisation.py index f8863b6..63bf36f 100644 --- a/src/infuse_iot/api_client/api/default/create_organisation.py +++ b/src/infuse_iot/api_client/api/organisation/create_organisation.py @@ -33,11 +33,11 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Organisation]]: - if response.status_code == HTTPStatus.CREATED: + if response.status_code == 201: response_201 = Organisation.from_dict(response.json()) return response_201 - if response.status_code == HTTPStatus.CONFLICT: + if response.status_code == 409: response_409 = cast(Any, None) return response_409 if client.raise_on_unexpected_status: diff --git a/src/infuse_iot/api_client/api/default/get_all_organisations.py b/src/infuse_iot/api_client/api/organisation/get_all_organisations.py similarity index 97% rename from src/infuse_iot/api_client/api/default/get_all_organisations.py rename to src/infuse_iot/api_client/api/organisation/get_all_organisations.py index 0765228..22f3cbd 100644 --- a/src/infuse_iot/api_client/api/default/get_all_organisations.py +++ b/src/infuse_iot/api_client/api/organisation/get_all_organisations.py @@ -22,7 +22,7 @@ def _get_kwargs() -> Dict[str, Any]: def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Error, List["Organisation"]]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = [] _response_200 = response.json() for response_200_item_data in _response_200: @@ -31,7 +31,7 @@ def _parse_response( response_200.append(response_200_item) return response_200 - if response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR: + if response.status_code == 500: response_500 = Error.from_dict(response.json()) return response_500 diff --git a/src/infuse_iot/api_client/api/default/get_organisation_by_id.py b/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py similarity index 93% rename from src/infuse_iot/api_client/api/default/get_organisation_by_id.py rename to src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py index b1a68e4..2856fff 100644 --- a/src/infuse_iot/api_client/api/default/get_organisation_by_id.py +++ b/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py @@ -1,5 +1,6 @@ from http import HTTPStatus from typing import Any, Dict, Optional, Union, cast +from uuid import UUID import httpx @@ -10,7 +11,7 @@ def _get_kwargs( - id: str, + id: UUID, ) -> Dict[str, Any]: _kwargs: Dict[str, Any] = { "method": "get", @@ -23,11 +24,11 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[Union[Any, Organisation]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Organisation.from_dict(response.json()) return response_200 - if response.status_code == HTTPStatus.NOT_FOUND: + if response.status_code == 404: response_404 = cast(Any, None) return response_404 if client.raise_on_unexpected_status: @@ -48,14 +49,14 @@ def _build_response( def sync_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Response[Union[Any, Organisation]]: """Get an organisation by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -77,14 +78,14 @@ def sync_detailed( def sync( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Optional[Union[Any, Organisation]]: """Get an organisation by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -101,14 +102,14 @@ def sync( async def asyncio_detailed( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Response[Union[Any, Organisation]]: """Get an organisation by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -128,14 +129,14 @@ async def asyncio_detailed( async def asyncio( - id: str, + id: UUID, *, client: Union[AuthenticatedClient, Client], ) -> Optional[Union[Any, Organisation]]: """Get an organisation by ID Args: - id (str): + id (UUID): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/src/infuse_iot/api_client/api/rpc/__init__.py b/src/infuse_iot/api_client/api/rpc/__init__.py new file mode 100644 index 0000000..e69de29 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 new file mode 100644 index 0000000..edf8172 --- /dev/null +++ b/src/infuse_iot/api_client/api/rpc/get_rp_cs.py @@ -0,0 +1,271 @@ +import datetime +from http import HTTPStatus +from typing import Any, Dict, List, Optional, Union +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.downlink_message_status import DownlinkMessageStatus +from ...models.error import Error +from ...models.rpc_message import RpcMessage +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + organisation_id: Union[Unset, UUID] = UNSET, + device_id: Union[Unset, str] = UNSET, + status: Union[Unset, DownlinkMessageStatus] = UNSET, + start_time: Union[Unset, datetime.datetime] = UNSET, + end_time: Union[Unset, datetime.datetime] = UNSET, + limit: Union[Unset, int] = 10, +) -> Dict[str, Any]: + params: Dict[str, Any] = {} + + json_organisation_id: Union[Unset, str] = UNSET + if not isinstance(organisation_id, Unset): + json_organisation_id = str(organisation_id) + params["organisationId"] = json_organisation_id + + params["deviceId"] = device_id + + json_status: Union[Unset, str] = UNSET + if not isinstance(status, Unset): + json_status = status.value + + params["status"] = json_status + + json_start_time: Union[Unset, str] = UNSET + if not isinstance(start_time, Unset): + json_start_time = start_time.isoformat() + params["startTime"] = json_start_time + + json_end_time: Union[Unset, str] = UNSET + if not isinstance(end_time, Unset): + json_end_time = end_time.isoformat() + params["endTime"] = json_end_time + + params["limit"] = limit + + 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": "/rpc", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Error, List["RpcMessage"]]]: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = RpcMessage.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + 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[Error, List["RpcMessage"]]]: + 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: Union[Unset, UUID] = UNSET, + device_id: Union[Unset, str] = UNSET, + status: Union[Unset, DownlinkMessageStatus] = UNSET, + start_time: Union[Unset, datetime.datetime] = UNSET, + end_time: Union[Unset, datetime.datetime] = UNSET, + limit: Union[Unset, int] = 10, +) -> Response[Union[Error, List["RpcMessage"]]]: + """Get RPC messages + + Args: + organisation_id (Union[Unset, UUID]): ID of organisation + device_id (Union[Unset, str]): 8 byte DeviceID as a hex string (if not provided will be + auto-generated) Example: d291d4d66bf0a955. + status (Union[Unset, DownlinkMessageStatus]): Status of downlink message + start_time (Union[Unset, datetime.datetime]): The start time of the query (only return + items on or after this time) + 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. + + 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']]] + """ + + kwargs = _get_kwargs( + organisation_id=organisation_id, + device_id=device_id, + status=status, + start_time=start_time, + end_time=end_time, + limit=limit, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: Union[AuthenticatedClient, Client], + organisation_id: Union[Unset, UUID] = UNSET, + device_id: Union[Unset, str] = UNSET, + status: Union[Unset, DownlinkMessageStatus] = UNSET, + start_time: Union[Unset, datetime.datetime] = UNSET, + end_time: Union[Unset, datetime.datetime] = UNSET, + limit: Union[Unset, int] = 10, +) -> Optional[Union[Error, List["RpcMessage"]]]: + """Get RPC messages + + Args: + organisation_id (Union[Unset, UUID]): ID of organisation + device_id (Union[Unset, str]): 8 byte DeviceID as a hex string (if not provided will be + auto-generated) Example: d291d4d66bf0a955. + status (Union[Unset, DownlinkMessageStatus]): Status of downlink message + start_time (Union[Unset, datetime.datetime]): The start time of the query (only return + items on or after this time) + 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. + + 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']] + """ + + return sync_detailed( + client=client, + organisation_id=organisation_id, + device_id=device_id, + status=status, + start_time=start_time, + end_time=end_time, + limit=limit, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + organisation_id: Union[Unset, UUID] = UNSET, + device_id: Union[Unset, str] = UNSET, + status: Union[Unset, DownlinkMessageStatus] = UNSET, + start_time: Union[Unset, datetime.datetime] = UNSET, + end_time: Union[Unset, datetime.datetime] = UNSET, + limit: Union[Unset, int] = 10, +) -> Response[Union[Error, List["RpcMessage"]]]: + """Get RPC messages + + Args: + organisation_id (Union[Unset, UUID]): ID of organisation + device_id (Union[Unset, str]): 8 byte DeviceID as a hex string (if not provided will be + auto-generated) Example: d291d4d66bf0a955. + status (Union[Unset, DownlinkMessageStatus]): Status of downlink message + start_time (Union[Unset, datetime.datetime]): The start time of the query (only return + items on or after this time) + 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. + + 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']]] + """ + + kwargs = _get_kwargs( + organisation_id=organisation_id, + device_id=device_id, + status=status, + start_time=start_time, + end_time=end_time, + limit=limit, + ) + + 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: Union[Unset, UUID] = UNSET, + device_id: Union[Unset, str] = UNSET, + status: Union[Unset, DownlinkMessageStatus] = UNSET, + start_time: Union[Unset, datetime.datetime] = UNSET, + end_time: Union[Unset, datetime.datetime] = UNSET, + limit: Union[Unset, int] = 10, +) -> Optional[Union[Error, List["RpcMessage"]]]: + """Get RPC messages + + Args: + organisation_id (Union[Unset, UUID]): ID of organisation + device_id (Union[Unset, str]): 8 byte DeviceID as a hex string (if not provided will be + auto-generated) Example: d291d4d66bf0a955. + status (Union[Unset, DownlinkMessageStatus]): Status of downlink message + start_time (Union[Unset, datetime.datetime]): The start time of the query (only return + items on or after this time) + 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. + + 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']] + """ + + return ( + await asyncio_detailed( + client=client, + organisation_id=organisation_id, + device_id=device_id, + status=status, + start_time=start_time, + end_time=end_time, + limit=limit, + ) + ).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 new file mode 100644 index 0000000..fccbc3b --- /dev/null +++ b/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.error import Error +from ...models.rpc_message import RpcMessage +from ...types import Response + + +def _get_kwargs( + id: UUID, +) -> Dict[str, Any]: + _kwargs: Dict[str, Any] = { + "method": "get", + "url": f"/rpc/{id}", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[Union[Error, RpcMessage]]: + if response.status_code == 200: + response_200 = RpcMessage.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[Error, RpcMessage]]: + 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], +) -> Response[Union[Error, RpcMessage]]: + """Get an RPC message by ID + + Args: + id (UUID): + + 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, RpcMessage]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], +) -> Optional[Union[Error, RpcMessage]]: + """Get an RPC message by ID + + Args: + id (UUID): + + 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, RpcMessage] + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: UUID, + *, + client: Union[AuthenticatedClient, Client], +) -> Response[Union[Error, RpcMessage]]: + """Get an RPC message by ID + + Args: + id (UUID): + + 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, RpcMessage]] + """ + + kwargs = _get_kwargs( + id=id, + ) + + 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], +) -> Optional[Union[Error, RpcMessage]]: + """Get an RPC message by ID + + Args: + id (UUID): + + 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, RpcMessage] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/rpc/send_rpc.py b/src/infuse_iot/api_client/api/rpc/send_rpc.py new file mode 100644 index 0000000..2ac9880 --- /dev/null +++ b/src/infuse_iot/api_client/api/rpc/send_rpc.py @@ -0,0 +1,173 @@ +from http import HTTPStatus +from typing import Any, Dict, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.created_rpc_message import CreatedRpcMessage +from ...models.error import Error +from ...models.new_rpc_message import NewRPCMessage +from ...types import Response + + +def _get_kwargs( + *, + body: NewRPCMessage, +) -> Dict[str, Any]: + headers: Dict[str, Any] = {} + + _kwargs: Dict[str, Any] = { + "method": "post", + "url": "/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[CreatedRpcMessage, Error]]: + if response.status_code == 201: + response_201 = CreatedRpcMessage.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 == 403: + response_403 = Error.from_dict(response.json()) + + return response_403 + 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[CreatedRpcMessage, 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: NewRPCMessage, +) -> Response[Union[CreatedRpcMessage, Error]]: + """Send an RPC to a device + + Args: + body (NewRPCMessage): + + 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[CreatedRpcMessage, 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: NewRPCMessage, +) -> Optional[Union[CreatedRpcMessage, Error]]: + """Send an RPC to a device + + Args: + body (NewRPCMessage): + + 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[CreatedRpcMessage, Error] + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: Union[AuthenticatedClient, Client], + body: NewRPCMessage, +) -> Response[Union[CreatedRpcMessage, Error]]: + """Send an RPC to a device + + Args: + body (NewRPCMessage): + + 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[CreatedRpcMessage, 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: NewRPCMessage, +) -> Optional[Union[CreatedRpcMessage, Error]]: + """Send an RPC to a device + + Args: + body (NewRPCMessage): + + 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[CreatedRpcMessage, Error] + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/client.py b/src/infuse_iot/api_client/client.py index 63a2493..0f6d15e 100644 --- a/src/infuse_iot/api_client/client.py +++ b/src/infuse_iot/api_client/client.py @@ -70,7 +70,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": return evolve(self, timeout=timeout) def set_httpx_client(self, client: httpx.Client) -> "Client": - """Manually the underlying httpx.Client + """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. """ @@ -204,7 +204,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": return evolve(self, timeout=timeout) def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": - """Manually the underlying httpx.Client + """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. """ diff --git a/src/infuse_iot/api_client/models/__init__.py b/src/infuse_iot/api_client/models/__init__.py index a89386d..548522b 100644 --- a/src/infuse_iot/api_client/models/__init__.py +++ b/src/infuse_iot/api_client/models/__init__.py @@ -1,35 +1,69 @@ """Contains all the data models used in inputs/outputs""" +from .application_version import ApplicationVersion from .board import Board 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 .device import Device from .device_id_field import DeviceIdField +from .device_state import DeviceState +from .downlink_message import DownlinkMessage +from .downlink_message_status import DownlinkMessageStatus +from .downlink_route import DownlinkRoute from .error import Error from .health_check import HealthCheck +from .interface_data import InterfaceData from .key import Key from .metadata_field import MetadataField from .new_board import NewBoard from .new_device import NewDevice from .new_device_metadata import NewDeviceMetadata from .new_organisation import NewOrganisation +from .new_rpc_message import NewRPCMessage +from .new_rpc_req import NewRPCReq from .organisation import Organisation +from .route_type import RouteType +from .rpc_message import RpcMessage +from .rpc_params import RPCParams +from .rpc_req import RpcReq +from .rpc_rsp import RpcRsp +from .udp_downlink_route import UdpDownlinkRoute +from .udp_uplink_route import UdpUplinkRoute +from .uplink_route import UplinkRoute __all__ = ( + "ApplicationVersion", "Board", "CreatedBoardProperties", "CreatedDeviceProperties", "CreatedOrganisationProperties", + "CreatedRpcMessage", "Device", "DeviceIdField", + "DeviceState", + "DownlinkMessage", + "DownlinkMessageStatus", + "DownlinkRoute", "Error", "HealthCheck", + "InterfaceData", "Key", "MetadataField", "NewBoard", "NewDevice", "NewDeviceMetadata", "NewOrganisation", + "NewRPCMessage", + "NewRPCReq", "Organisation", + "RouteType", + "RpcMessage", + "RPCParams", + "RpcReq", + "RpcRsp", + "UdpDownlinkRoute", + "UdpUplinkRoute", + "UplinkRoute", ) diff --git a/src/infuse_iot/api_client/models/application_version.py b/src/infuse_iot/api_client/models/application_version.py new file mode 100644 index 0000000..2b76458 --- /dev/null +++ b/src/infuse_iot/api_client/models/application_version.py @@ -0,0 +1,83 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ApplicationVersion") + + +@_attrs_define +class ApplicationVersion: + """Application version + + Attributes: + major (int): Major version number + minor (int): Minor version number + revision (int): Revision number + build_num (int): Build number + """ + + major: int + minor: int + revision: int + build_num: int + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + major = self.major + + minor = self.minor + + revision = self.revision + + build_num = self.build_num + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "major": major, + "minor": minor, + "revision": revision, + "buildNum": build_num, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + major = d.pop("major") + + minor = d.pop("minor") + + revision = d.pop("revision") + + build_num = d.pop("buildNum") + + application_version = cls( + major=major, + minor=minor, + revision=revision, + build_num=build_num, + ) + + application_version.additional_properties = d + return application_version + + @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/board.py b/src/infuse_iot/api_client/models/board.py index fff26b8..c7faccd 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,29 +19,29 @@ class Board: """ Attributes: - id (str): Generated UUID for board + id (UUID): Generated UUID for board created_at (datetime.datetime): updated_at (datetime.datetime): name (str): Name of board Example: Board Name. description (str): Description of board Example: Extended description of board. soc (str): System on Chip (SoC) of board Example: nRF9151. - organisation_id (str): ID of organisation for board to exist in + organisation_id (UUID): ID of organisation for board to exist in metadata_fields (Union[Unset, List['MetadataField']]): Metadata fields for board Example: [{'name': 'Field Name', 'required': True, 'unique': False}]. """ - id: str + id: UUID created_at: datetime.datetime updated_at: datetime.datetime name: str description: str soc: str - organisation_id: str + organisation_id: UUID 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]: - id = self.id + id = str(self.id) created_at = self.created_at.isoformat() @@ -52,7 +53,7 @@ def to_dict(self) -> Dict[str, Any]: soc = self.soc - organisation_id = self.organisation_id + organisation_id = str(self.organisation_id) metadata_fields: Union[Unset, List[Dict[str, Any]]] = UNSET if not isinstance(self.metadata_fields, Unset): @@ -86,7 +87,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: from ..models.metadata_field import MetadataField d = src_dict.copy() - id = d.pop("id") + id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -98,7 +99,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: soc = d.pop("soc") - organisation_id = d.pop("organisationId") + organisation_id = UUID(d.pop("organisationId")) metadata_fields = [] _metadata_fields = d.pop("metadataFields", UNSET) 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 0af0a6b..2f5a25c 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,18 +13,18 @@ class CreatedBoardProperties: """ Attributes: - id (str): Generated UUID for board + id (UUID): Generated UUID for board created_at (datetime.datetime): updated_at (datetime.datetime): """ - id: str + id: UUID created_at: datetime.datetime updated_at: datetime.datetime additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: - id = self.id + id = str(self.id) created_at = self.created_at.isoformat() @@ -44,7 +45,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - id = d.pop("id") + id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) 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 bc85981..a46d4d4 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,18 +13,18 @@ class CreatedDeviceProperties: """ Attributes: - id (str): Generated UUID for organisation + id (UUID): Generated UUID for organisation created_at (datetime.datetime): updated_at (datetime.datetime): """ - id: str + id: UUID created_at: datetime.datetime updated_at: datetime.datetime additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: - id = self.id + id = str(self.id) created_at = self.created_at.isoformat() @@ -44,7 +45,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - id = d.pop("id") + id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) 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 c0765e1..4e36ea0 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,18 +13,18 @@ class CreatedOrganisationProperties: """ Attributes: - id (str): Generated UUID for organisation + id (UUID): Generated UUID for organisation created_at (datetime.datetime): updated_at (datetime.datetime): """ - id: str + id: UUID created_at: datetime.datetime updated_at: datetime.datetime additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: - id = self.id + id = str(self.id) created_at = self.created_at.isoformat() @@ -44,7 +45,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - id = d.pop("id") + id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) diff --git a/src/infuse_iot/api_client/models/created_rpc_message.py b/src/infuse_iot/api_client/models/created_rpc_message.py new file mode 100644 index 0000000..e3cc989 --- /dev/null +++ b/src/infuse_iot/api_client/models/created_rpc_message.py @@ -0,0 +1,78 @@ +import datetime +from typing import Any, Dict, List, Type, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +T = TypeVar("T", bound="CreatedRpcMessage") + + +@_attrs_define +class CreatedRpcMessage: + """ + Attributes: + created_at (datetime.datetime): The time the RPC message was created + id (UUID): The ID of the RPC message Example: 5f4b1b2b-3b4d-4b5e-8c6f-7d8e9f0a1b2c. + downlink_message_id (UUID): The ID of the corresponding downlink message sent to the device Example: + 7527bf1c-9868-4afd-b07d-16dc7eb7bed3. + """ + + created_at: datetime.datetime + id: UUID + downlink_message_id: UUID + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + 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.update(self.additional_properties) + field_dict.update( + { + "createdAt": created_at, + "id": id, + "downlinkMessageId": downlink_message_id, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + created_at = isoparse(d.pop("createdAt")) + + id = UUID(d.pop("id")) + + downlink_message_id = UUID(d.pop("downlinkMessageId")) + + created_rpc_message = cls( + created_at=created_at, + id=id, + downlink_message_id=downlink_message_id, + ) + + created_rpc_message.additional_properties = d + return created_rpc_message + + @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.py b/src/infuse_iot/api_client/models/device.py index 958a99f..8791d3d 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,29 +19,29 @@ class Device: """ Attributes: - id (str): Generated UUID for organisation + 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 (str): ID of board of device - organisation_id (str): ID of organisation for board to exist in + board_id (UUID): ID of board of 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'}. """ - id: str + id: UUID created_at: datetime.datetime updated_at: datetime.datetime mcu_id: str - board_id: str - organisation_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) def to_dict(self) -> Dict[str, Any]: - id = self.id + id = str(self.id) created_at = self.created_at.isoformat() @@ -48,9 +49,9 @@ def to_dict(self) -> Dict[str, Any]: mcu_id = self.mcu_id - board_id = self.board_id + board_id = str(self.board_id) - organisation_id = self.organisation_id + organisation_id = str(self.organisation_id) device_id = self.device_id @@ -82,7 +83,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: from ..models.new_device_metadata import NewDeviceMetadata d = src_dict.copy() - id = d.pop("id") + id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) @@ -90,9 +91,9 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: mcu_id = d.pop("mcuId") - board_id = d.pop("boardId") + board_id = UUID(d.pop("boardId")) - organisation_id = d.pop("organisationId") + organisation_id = UUID(d.pop("organisationId")) device_id = d.pop("deviceId", UNSET) diff --git a/src/infuse_iot/api_client/models/device_state.py b/src/infuse_iot/api_client/models/device_state.py new file mode 100644 index 0000000..184aab4 --- /dev/null +++ b/src/infuse_iot/api_client/models/device_state.py @@ -0,0 +1,140 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.route_type import RouteType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.application_version import ApplicationVersion + + +T = TypeVar("T", bound="DeviceState") + + +@_attrs_define +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 + application_id (Union[Unset, int]): Last announced application ID + application_version (Union[Unset, ApplicationVersion]): Application version + """ + + 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 + application_id: Union[Unset, int] = UNSET + application_version: Union[Unset, "ApplicationVersion"] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + 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() + + updated_at: Union[Unset, str] = UNSET + if not isinstance(self.updated_at, Unset): + updated_at = self.updated_at.isoformat() + + last_route_interface: Union[Unset, str] = UNSET + if not isinstance(self.last_route_interface, Unset): + last_route_interface = self.last_route_interface.value + + 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.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 + if application_id is not UNSET: + field_dict["applicationId"] = application_id + if application_version is not UNSET: + field_dict["applicationVersion"] = application_version + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + 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) + + _updated_at = d.pop("updatedAt", UNSET) + updated_at: Union[Unset, datetime.datetime] + if isinstance(_updated_at, Unset): + updated_at = UNSET + else: + updated_at = isoparse(_updated_at) + + _last_route_interface = d.pop("lastRouteInterface", UNSET) + last_route_interface: Union[Unset, RouteType] + if isinstance(_last_route_interface, Unset): + last_route_interface = UNSET + else: + last_route_interface = RouteType(_last_route_interface) + + 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, + ) + + device_state.additional_properties = d + return 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/downlink_message.py b/src/infuse_iot/api_client/models/downlink_message.py new file mode 100644 index 0000000..545ae09 --- /dev/null +++ b/src/infuse_iot/api_client/models/downlink_message.py @@ -0,0 +1,202 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +from ..models.downlink_message_status import DownlinkMessageStatus +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.rpc_req import RpcReq + from ..models.rpc_rsp import RpcRsp + + +T = TypeVar("T", bound="DownlinkMessage") + + +@_attrs_define +class DownlinkMessage: + """ + Attributes: + id (UUID): The ID of the downlink message Example: 7527bf1c-9868-4afd-b07d-16dc7eb7bed3. + created_at (datetime.datetime): The time the downlink message was created + updated_at (datetime.datetime): The time the downlink message was last updated + device_id (UUID): The ID of the device the message is for Example: 5f4b1b2b-3b4d-4b5e-8c6f-7d8e9f0a1b2c. + payload_type (int): The type of payload + auth (int): The auth level of the message + rpc_req (RpcReq): + status (DownlinkMessageStatus): Status of downlink message + rpc_rsp (Union[Unset, RpcRsp]): + send_wait_timeout_ms (Union[Unset, int]): Maximum time to wait (in milliseconds) for the device to send a packet + before expiring. If 0 or not set, the RPC was sent immediately using the device's last route. + sent_at (Union[Unset, datetime.datetime]): The time the downlink message was sent + expires_at (Union[Unset, datetime.datetime]): The time the downlink message expires + completed_at (Union[Unset, datetime.datetime]): The time the downlink message was completed + """ + + id: UUID + created_at: datetime.datetime + updated_at: datetime.datetime + device_id: UUID + payload_type: int + auth: int + rpc_req: "RpcReq" + status: DownlinkMessageStatus + rpc_rsp: Union[Unset, "RpcRsp"] = UNSET + send_wait_timeout_ms: Union[Unset, int] = UNSET + sent_at: Union[Unset, datetime.datetime] = UNSET + expires_at: Union[Unset, datetime.datetime] = UNSET + completed_at: Union[Unset, datetime.datetime] = UNSET + 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() + + device_id = str(self.device_id) + + payload_type = self.payload_type + + auth = self.auth + + rpc_req = self.rpc_req.to_dict() + + status = self.status.value + + rpc_rsp: Union[Unset, Dict[str, Any]] = UNSET + if not isinstance(self.rpc_rsp, Unset): + rpc_rsp = self.rpc_rsp.to_dict() + + send_wait_timeout_ms = self.send_wait_timeout_ms + + sent_at: Union[Unset, str] = UNSET + if not isinstance(self.sent_at, Unset): + sent_at = self.sent_at.isoformat() + + expires_at: Union[Unset, str] = UNSET + if not isinstance(self.expires_at, Unset): + expires_at = self.expires_at.isoformat() + + completed_at: Union[Unset, str] = UNSET + if not isinstance(self.completed_at, Unset): + completed_at = self.completed_at.isoformat() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "createdAt": created_at, + "updatedAt": updated_at, + "deviceId": device_id, + "payloadType": payload_type, + "auth": auth, + "rpcReq": rpc_req, + "status": status, + } + ) + if rpc_rsp is not UNSET: + field_dict["rpcRsp"] = rpc_rsp + if send_wait_timeout_ms is not UNSET: + field_dict["sendWaitTimeoutMs"] = send_wait_timeout_ms + if sent_at is not UNSET: + field_dict["sentAt"] = sent_at + if expires_at is not UNSET: + field_dict["expiresAt"] = expires_at + if completed_at is not UNSET: + field_dict["completedAt"] = completed_at + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.rpc_req import RpcReq + from ..models.rpc_rsp import RpcRsp + + d = src_dict.copy() + id = UUID(d.pop("id")) + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + device_id = UUID(d.pop("deviceId")) + + payload_type = d.pop("payloadType") + + auth = d.pop("auth") + + rpc_req = RpcReq.from_dict(d.pop("rpcReq")) + + status = DownlinkMessageStatus(d.pop("status")) + + _rpc_rsp = d.pop("rpcRsp", UNSET) + rpc_rsp: Union[Unset, RpcRsp] + if isinstance(_rpc_rsp, Unset): + rpc_rsp = UNSET + else: + rpc_rsp = RpcRsp.from_dict(_rpc_rsp) + + send_wait_timeout_ms = d.pop("sendWaitTimeoutMs", UNSET) + + _sent_at = d.pop("sentAt", UNSET) + sent_at: Union[Unset, datetime.datetime] + if isinstance(_sent_at, Unset): + sent_at = UNSET + else: + sent_at = isoparse(_sent_at) + + _expires_at = d.pop("expiresAt", UNSET) + expires_at: Union[Unset, datetime.datetime] + if isinstance(_expires_at, Unset): + expires_at = UNSET + else: + expires_at = isoparse(_expires_at) + + _completed_at = d.pop("completedAt", UNSET) + completed_at: Union[Unset, datetime.datetime] + if isinstance(_completed_at, Unset): + completed_at = UNSET + else: + completed_at = isoparse(_completed_at) + + downlink_message = cls( + id=id, + created_at=created_at, + updated_at=updated_at, + device_id=device_id, + payload_type=payload_type, + auth=auth, + rpc_req=rpc_req, + status=status, + rpc_rsp=rpc_rsp, + send_wait_timeout_ms=send_wait_timeout_ms, + sent_at=sent_at, + expires_at=expires_at, + completed_at=completed_at, + ) + + downlink_message.additional_properties = d + return downlink_message + + @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_status.py b/src/infuse_iot/api_client/models/downlink_message_status.py new file mode 100644 index 0000000..69c28e0 --- /dev/null +++ b/src/infuse_iot/api_client/models/downlink_message_status.py @@ -0,0 +1,10 @@ +from enum import Enum + + +class DownlinkMessageStatus(str, Enum): + COMPLETED = "completed" + SENT = "sent" + WAITING = "waiting" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/downlink_route.py b/src/infuse_iot/api_client/models/downlink_route.py new file mode 100644 index 0000000..c5b7995 --- /dev/null +++ b/src/infuse_iot/api_client/models/downlink_route.py @@ -0,0 +1,93 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.route_type import RouteType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.interface_data import InterfaceData + from ..models.udp_downlink_route import UdpDownlinkRoute + + +T = TypeVar("T", bound="DownlinkRoute") + + +@_attrs_define +class DownlinkRoute: + """ + Attributes: + interface (RouteType): Interface of route + interface_data (InterfaceData): + udp (Union[Unset, UdpDownlinkRoute]): + """ + + interface: RouteType + interface_data: "InterfaceData" + udp: Union[Unset, "UdpDownlinkRoute"] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + 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 + if not isinstance(self.udp, Unset): + udp = self.udp.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "interface": interface, + "interfaceData": interface_data, + } + ) + if udp is not UNSET: + field_dict["udp"] = udp + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.interface_data import InterfaceData + from ..models.udp_downlink_route import UdpDownlinkRoute + + d = src_dict.copy() + interface = RouteType(d.pop("interface")) + + interface_data = InterfaceData.from_dict(d.pop("interfaceData")) + + _udp = d.pop("udp", UNSET) + udp: Union[Unset, UdpDownlinkRoute] + if isinstance(_udp, Unset): + udp = UNSET + else: + udp = UdpDownlinkRoute.from_dict(_udp) + + downlink_route = cls( + interface=interface, + interface_data=interface_data, + udp=udp, + ) + + downlink_route.additional_properties = d + return downlink_route + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/interface_data.py b/src/infuse_iot/api_client/models/interface_data.py new file mode 100644 index 0000000..bdf4e56 --- /dev/null +++ b/src/infuse_iot/api_client/models/interface_data.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="InterfaceData") + + +@_attrs_define +class InterfaceData: + """ + Attributes: + sequence (Union[Unset, int]): Sequence number of packet + """ + + sequence: Union[Unset, int] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + sequence = self.sequence + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if sequence is not UNSET: + field_dict["sequence"] = sequence + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + sequence = d.pop("sequence", UNSET) + + interface_data = cls( + sequence=sequence, + ) + + interface_data.additional_properties = d + return interface_data + + @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_board.py b/src/infuse_iot/api_client/models/new_board.py index 76d8d5e..4755c32 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -19,7 +20,7 @@ class NewBoard: name (str): Name of board Example: Board Name. description (str): Description of board Example: Extended description of board. soc (str): System on Chip (SoC) of board Example: nRF9151. - organisation_id (str): ID of organisation for board to exist in + organisation_id (UUID): ID of organisation for board to exist in metadata_fields (Union[Unset, List['MetadataField']]): Metadata fields for board Example: [{'name': 'Field Name', 'required': True, 'unique': False}]. """ @@ -27,7 +28,7 @@ class NewBoard: name: str description: str soc: str - organisation_id: str + organisation_id: UUID metadata_fields: Union[Unset, List["MetadataField"]] = UNSET additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -38,7 +39,7 @@ def to_dict(self) -> Dict[str, Any]: soc = self.soc - organisation_id = self.organisation_id + organisation_id = str(self.organisation_id) metadata_fields: Union[Unset, List[Dict[str, Any]]] = UNSET if not isinstance(self.metadata_fields, Unset): @@ -75,7 +76,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: soc = d.pop("soc") - organisation_id = d.pop("organisationId") + organisation_id = UUID(d.pop("organisationId")) metadata_fields = [] _metadata_fields = d.pop("metadataFields", UNSET) diff --git a/src/infuse_iot/api_client/models/new_device.py b/src/infuse_iot/api_client/models/new_device.py index e5b58c7..f773d9d 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -17,16 +18,16 @@ class NewDevice: """ Attributes: mcu_id (str): Device's MCU ID as a hex string Example: 0011223344556677. - board_id (str): ID of board of device - organisation_id (str): ID of organisation for board to exist in + board_id (UUID): ID of board of 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'}. """ mcu_id: str - board_id: str - organisation_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) @@ -34,9 +35,9 @@ class NewDevice: def to_dict(self) -> Dict[str, Any]: mcu_id = self.mcu_id - board_id = self.board_id + board_id = str(self.board_id) - organisation_id = self.organisation_id + organisation_id = str(self.organisation_id) device_id = self.device_id @@ -67,9 +68,9 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() mcu_id = d.pop("mcuId") - board_id = d.pop("boardId") + board_id = UUID(d.pop("boardId")) - organisation_id = d.pop("organisationId") + organisation_id = UUID(d.pop("organisationId")) device_id = d.pop("deviceId", UNSET) diff --git a/src/infuse_iot/api_client/models/new_rpc_message.py b/src/infuse_iot/api_client/models/new_rpc_message.py new file mode 100644 index 0000000..d9df4a2 --- /dev/null +++ b/src/infuse_iot/api_client/models/new_rpc_message.py @@ -0,0 +1,84 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.new_rpc_req import NewRPCReq + + +T = TypeVar("T", bound="NewRPCMessage") + + +@_attrs_define +class NewRPCMessage: + """ + Attributes: + device_id (str): The ID of the device to send the RPC to as a hex string Example: d291d4d66bf0a955. + rpc (NewRPCReq): + send_wait_timeout_ms (Union[Unset, int]): Maximum time to wait (in milliseconds) for the device to send a + packet. If 0 or not set, the RPC is sent immediately using the device's last route. Default: 60000. + """ + + device_id: str + rpc: "NewRPCReq" + send_wait_timeout_ms: Union[Unset, int] = 60000 + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + 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.update(self.additional_properties) + field_dict.update( + { + "deviceId": device_id, + "rpc": rpc, + } + ) + if send_wait_timeout_ms is not UNSET: + field_dict["sendWaitTimeoutMs"] = send_wait_timeout_ms + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.new_rpc_req import NewRPCReq + + d = src_dict.copy() + device_id = d.pop("deviceId") + + rpc = NewRPCReq.from_dict(d.pop("rpc")) + + send_wait_timeout_ms = d.pop("sendWaitTimeoutMs", UNSET) + + new_rpc_message = cls( + device_id=device_id, + rpc=rpc, + send_wait_timeout_ms=send_wait_timeout_ms, + ) + + new_rpc_message.additional_properties = d + return new_rpc_message + + @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_rpc_req.py b/src/infuse_iot/api_client/models/new_rpc_req.py new file mode 100644 index 0000000..5e538d4 --- /dev/null +++ b/src/infuse_iot/api_client/models/new_rpc_req.py @@ -0,0 +1,92 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, 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.rpc_params import RPCParams + + +T = TypeVar("T", bound="NewRPCReq") + + +@_attrs_define +class NewRPCReq: + """ + Attributes: + command_id (Union[Unset, int]): ID of RPC command (must provide either commandId or commandName) Example: 3. + command_name (Union[Unset, str]): Name of RPC command (must provide either commandId or commandName) Example: + time_get. + params (Union[Unset, RPCParams]): RPC request or response params (must be a JSON object with string or embedded + json values - numbers sent as decimal strings) Example: {'primitive_vaue': '1000', 'struct_value': {'field': + 'value'}}. + """ + + 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) + + def to_dict(self) -> Dict[str, Any]: + command_id = self.command_id + + command_name = self.command_name + + 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.update(self.additional_properties) + field_dict.update({}) + if command_id is not UNSET: + field_dict["commandId"] = command_id + if command_name is not UNSET: + field_dict["commandName"] = command_name + if params is not UNSET: + field_dict["params"] = params + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.rpc_params import RPCParams + + d = src_dict.copy() + command_id = d.pop("commandId", UNSET) + + command_name = d.pop("commandName", UNSET) + + _params = d.pop("params", UNSET) + params: Union[Unset, RPCParams] + if isinstance(_params, Unset): + params = UNSET + else: + params = RPCParams.from_dict(_params) + + new_rpc_req = cls( + command_id=command_id, + command_name=command_name, + params=params, + ) + + new_rpc_req.additional_properties = d + return new_rpc_req + + @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/organisation.py b/src/infuse_iot/api_client/models/organisation.py index a5ad91d..533c691 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 uuid import UUID from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,20 +13,20 @@ class Organisation: """ Attributes: - id (str): Generated UUID for organisation + id (UUID): Generated UUID for organisation created_at (datetime.datetime): updated_at (datetime.datetime): name (str): Name of organisation Example: Organisation Name. """ - id: str + id: UUID created_at: datetime.datetime updated_at: datetime.datetime name: str additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: - id = self.id + id = str(self.id) created_at = self.created_at.isoformat() @@ -49,7 +50,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: d = src_dict.copy() - id = d.pop("id") + id = UUID(d.pop("id")) created_at = isoparse(d.pop("createdAt")) diff --git a/src/infuse_iot/api_client/models/route_type.py b/src/infuse_iot/api_client/models/route_type.py new file mode 100644 index 0000000..af7db05 --- /dev/null +++ b/src/infuse_iot/api_client/models/route_type.py @@ -0,0 +1,8 @@ +from enum import Enum + + +class RouteType(str, Enum): + UDP = "udp" + + def __str__(self) -> str: + return str(self.value) diff --git a/src/infuse_iot/api_client/models/rpc_message.py b/src/infuse_iot/api_client/models/rpc_message.py new file mode 100644 index 0000000..7911f66 --- /dev/null +++ b/src/infuse_iot/api_client/models/rpc_message.py @@ -0,0 +1,102 @@ +import datetime +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.device import Device + from ..models.downlink_message import DownlinkMessage + + +T = TypeVar("T", bound="RpcMessage") + + +@_attrs_define +class RpcMessage: + """ + Attributes: + created_at (datetime.datetime): The time the RPC message was created + id (UUID): The ID of the RPC message Example: 5f4b1b2b-3b4d-4b5e-8c6f-7d8e9f0a1b2c. + downlink_message_id (UUID): The ID of the corresponding downlink message sent to the device Example: + 7527bf1c-9868-4afd-b07d-16dc7eb7bed3. + device (Device): + downlink_message (DownlinkMessage): + """ + + created_at: datetime.datetime + id: UUID + downlink_message_id: UUID + device: "Device" + downlink_message: "DownlinkMessage" + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + 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) + + device = self.device.to_dict() + + downlink_message = self.downlink_message.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "createdAt": created_at, + "id": id, + "downlinkMessageId": downlink_message_id, + "device": device, + "downlinkMessage": downlink_message, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.device import Device + from ..models.downlink_message import DownlinkMessage + + d = src_dict.copy() + created_at = isoparse(d.pop("createdAt")) + + id = UUID(d.pop("id")) + + downlink_message_id = UUID(d.pop("downlinkMessageId")) + + device = Device.from_dict(d.pop("device")) + + downlink_message = DownlinkMessage.from_dict(d.pop("downlinkMessage")) + + rpc_message = cls( + created_at=created_at, + id=id, + downlink_message_id=downlink_message_id, + device=device, + downlink_message=downlink_message, + ) + + rpc_message.additional_properties = d + return rpc_message + + @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/rpc_params.py b/src/infuse_iot/api_client/models/rpc_params.py new file mode 100644 index 0000000..1bfbfb7 --- /dev/null +++ b/src/infuse_iot/api_client/models/rpc_params.py @@ -0,0 +1,49 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RPCParams") + + +@_attrs_define +class RPCParams: + """RPC request or response params (must be a JSON object with string or embedded json values - numbers sent as decimal + strings) + + Example: + {'primitive_vaue': '1000', 'struct_value': {'field': 'value'}} + + """ + + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + rpc_params = cls() + + rpc_params.additional_properties = d + return rpc_params + + @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/rpc_req.py b/src/infuse_iot/api_client/models/rpc_req.py new file mode 100644 index 0000000..874278b --- /dev/null +++ b/src/infuse_iot/api_client/models/rpc_req.py @@ -0,0 +1,110 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, 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.downlink_route import DownlinkRoute + from ..models.rpc_params import RPCParams + + +T = TypeVar("T", bound="RpcReq") + + +@_attrs_define +class RpcReq: + """ + Attributes: + request_id (int): The unique ID of the RPC request + command_id (int): ID of RPC command + params (Union[Unset, RPCParams]): RPC request or response params (must be a JSON object with string or embedded + json values - numbers sent as decimal strings) Example: {'primitive_vaue': '1000', 'struct_value': {'field': + 'value'}}. + route (Union[Unset, DownlinkRoute]): + """ + + request_id: int + command_id: int + params: Union[Unset, "RPCParams"] = UNSET + route: Union[Unset, "DownlinkRoute"] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + request_id = self.request_id + + command_id = self.command_id + + 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 + if not isinstance(self.route, Unset): + route = self.route.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "requestId": request_id, + "commandId": command_id, + } + ) + if params is not UNSET: + field_dict["params"] = params + if route is not UNSET: + field_dict["route"] = route + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.downlink_route import DownlinkRoute + from ..models.rpc_params import RPCParams + + d = src_dict.copy() + request_id = d.pop("requestId") + + command_id = d.pop("commandId") + + _params = d.pop("params", UNSET) + params: Union[Unset, RPCParams] + if isinstance(_params, Unset): + params = UNSET + else: + params = RPCParams.from_dict(_params) + + _route = d.pop("route", UNSET) + route: Union[Unset, DownlinkRoute] + if isinstance(_route, Unset): + route = UNSET + else: + route = DownlinkRoute.from_dict(_route) + + rpc_req = cls( + request_id=request_id, + command_id=command_id, + params=params, + route=route, + ) + + rpc_req.additional_properties = d + return rpc_req + + @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/rpc_rsp.py b/src/infuse_iot/api_client/models/rpc_rsp.py new file mode 100644 index 0000000..f85ecee --- /dev/null +++ b/src/infuse_iot/api_client/models/rpc_rsp.py @@ -0,0 +1,94 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, 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.rpc_params import RPCParams + from ..models.uplink_route import UplinkRoute + + +T = TypeVar("T", bound="RpcRsp") + + +@_attrs_define +class RpcRsp: + """ + Attributes: + route (UplinkRoute): + return_code (int): Return code of RPC + params (Union[Unset, RPCParams]): RPC request or response params (must be a JSON object with string or embedded + json values - numbers sent as decimal strings) Example: {'primitive_vaue': '1000', 'struct_value': {'field': + 'value'}}. + """ + + route: "UplinkRoute" + return_code: int + params: Union[Unset, "RPCParams"] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + route = self.route.to_dict() + + return_code = self.return_code + + 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.update(self.additional_properties) + field_dict.update( + { + "route": route, + "returnCode": return_code, + } + ) + if params is not UNSET: + field_dict["params"] = params + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.rpc_params import RPCParams + from ..models.uplink_route import UplinkRoute + + d = src_dict.copy() + route = UplinkRoute.from_dict(d.pop("route")) + + return_code = d.pop("returnCode") + + _params = d.pop("params", UNSET) + params: Union[Unset, RPCParams] + if isinstance(_params, Unset): + params = UNSET + else: + params = RPCParams.from_dict(_params) + + rpc_rsp = cls( + route=route, + return_code=return_code, + params=params, + ) + + rpc_rsp.additional_properties = d + return rpc_rsp + + @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/udp_downlink_route.py b/src/infuse_iot/api_client/models/udp_downlink_route.py new file mode 100644 index 0000000..57ac54c --- /dev/null +++ b/src/infuse_iot/api_client/models/udp_downlink_route.py @@ -0,0 +1,58 @@ +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="UdpDownlinkRoute") + + +@_attrs_define +class UdpDownlinkRoute: + """ + Attributes: + address (str): UDP address of device + """ + + address: str + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + address = self.address + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "address": address, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + address = d.pop("address") + + udp_downlink_route = cls( + address=address, + ) + + udp_downlink_route.additional_properties = d + return udp_downlink_route + + @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/udp_uplink_route.py b/src/infuse_iot/api_client/models/udp_uplink_route.py new file mode 100644 index 0000000..d5f33ed --- /dev/null +++ b/src/infuse_iot/api_client/models/udp_uplink_route.py @@ -0,0 +1,68 @@ +import datetime +from typing import Any, Dict, List, Type, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +T = TypeVar("T", bound="UdpUplinkRoute") + + +@_attrs_define +class UdpUplinkRoute: + """ + Attributes: + address (str): UDP address of device + time (datetime.datetime): Time packet was received by UDP server + """ + + address: str + time: datetime.datetime + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + address = self.address + + time = self.time.isoformat() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "address": address, + "time": time, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + address = d.pop("address") + + time = isoparse(d.pop("time")) + + udp_uplink_route = cls( + address=address, + time=time, + ) + + udp_uplink_route.additional_properties = d + return udp_uplink_route + + @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/uplink_route.py b/src/infuse_iot/api_client/models/uplink_route.py new file mode 100644 index 0000000..5cee4d6 --- /dev/null +++ b/src/infuse_iot/api_client/models/uplink_route.py @@ -0,0 +1,93 @@ +from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..models.route_type import RouteType +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.interface_data import InterfaceData + from ..models.udp_uplink_route import UdpUplinkRoute + + +T = TypeVar("T", bound="UplinkRoute") + + +@_attrs_define +class UplinkRoute: + """ + Attributes: + interface (RouteType): Interface of route + interface_data (InterfaceData): + udp (Union[Unset, UdpUplinkRoute]): + """ + + interface: RouteType + interface_data: "InterfaceData" + udp: Union[Unset, "UdpUplinkRoute"] = UNSET + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + + 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 + if not isinstance(self.udp, Unset): + udp = self.udp.to_dict() + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "interface": interface, + "interfaceData": interface_data, + } + ) + if udp is not UNSET: + field_dict["udp"] = udp + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + from ..models.interface_data import InterfaceData + from ..models.udp_uplink_route import UdpUplinkRoute + + d = src_dict.copy() + interface = RouteType(d.pop("interface")) + + interface_data = InterfaceData.from_dict(d.pop("interfaceData")) + + _udp = d.pop("udp", UNSET) + udp: Union[Unset, UdpUplinkRoute] + if isinstance(_udp, Unset): + udp = UNSET + else: + udp = UdpUplinkRoute.from_dict(_udp) + + uplink_route = cls( + interface=interface, + interface_data=interface_data, + udp=udp, + ) + + uplink_route.additional_properties = d + return uplink_route + + @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/types.py b/src/infuse_iot/api_client/types.py index 21fac10..27e9a71 100644 --- a/src/infuse_iot/api_client/types.py +++ b/src/infuse_iot/api_client/types.py @@ -1,7 +1,8 @@ """Contains some shared types for properties""" +from collections.abc import MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, Optional, Tuple, TypeVar from attrs import define diff --git a/src/infuse_iot/database.py b/src/infuse_iot/database.py index 745a06f..ee7934e 100644 --- a/src/infuse_iot/database.py +++ b/src/infuse_iot/database.py @@ -4,7 +4,7 @@ import binascii from infuse_iot.api_client import Client -from infuse_iot.api_client.api.default import get_shared_secret +from infuse_iot.api_client.api.key import get_shared_secret from infuse_iot.api_client.models import Key from infuse_iot.credentials import get_api_key, load_network from infuse_iot.epacket.interface import Address as InterfaceAddress @@ -98,9 +98,7 @@ def observe_security_state(self, address: int, cloud_key: bytes, device_key: byt self.devices[address].network_id = network_id self.devices[address].public_key = device_key - client = Client(base_url="https://api.dev.infuse-iot.com").with_headers( - {"x-api-key": f"Bearer {get_api_key()}"} - ) + client = Client(base_url="https://api.infuse-iot.com").with_headers({"x-api-key": f"Bearer {get_api_key()}"}) with client as client: body = Key(base64.b64encode(device_key).decode("utf-8")) diff --git a/src/infuse_iot/generated/rpc_definitions.py b/src/infuse_iot/generated/rpc_definitions.py index 0fe609f..01157a7 100644 --- a/src/infuse_iot/generated/rpc_definitions.py +++ b/src/infuse_iot/generated/rpc_definitions.py @@ -152,6 +152,7 @@ class rpc_enum_file_action(enum.IntEnum): APP_IMG = 1 BT_CTLR_IMG = 2 APP_CPATCH = 11 + BT_CTLR_CPATCH = 12 NRF91_MODEM_DIFF = 20 @@ -205,7 +206,8 @@ class request(ctypes.LittleEndianStructure): _pack_ = 1 class response(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 @@ -217,7 +219,8 @@ class time_get: COMMAND_ID = 3 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): @@ -243,7 +246,8 @@ class request(ctypes.LittleEndianStructure): _pack_ = 1 class response(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 @@ -342,7 +346,8 @@ class application_info: COMMAND_ID = 9 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): @@ -367,7 +372,8 @@ class wifi_scan: COMMAND_ID = 10 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): @@ -386,7 +392,8 @@ class wifi_state: COMMAND_ID = 11 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): @@ -405,7 +412,8 @@ class last_reboot: COMMAND_ID = 12 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): @@ -502,7 +510,8 @@ class lte_state: COMMAND_ID = 21 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): @@ -602,7 +611,8 @@ class request(ctypes.LittleEndianStructure): _pack_ = 1 class response(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 @@ -638,11 +648,13 @@ class data_sender: COMMAND_ID = 32765 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 @@ -654,7 +666,8 @@ class data_receiver: COMMAND_ID = 32766 class request(ctypes.LittleEndianStructure): - _fields_ = [] + _fields_ = [ + ] _pack_ = 1 class response(ctypes.LittleEndianStructure): @@ -683,3 +696,4 @@ class response(ctypes.LittleEndianStructure): ("array", 0 * ctypes.c_uint8), ] _pack_ = 1 + diff --git a/src/infuse_iot/rpc_wrappers/file_write_basic.py b/src/infuse_iot/rpc_wrappers/file_write_basic.py index 691fce5..0263059 100644 --- a/src/infuse_iot/rpc_wrappers/file_write_basic.py +++ b/src/infuse_iot/rpc_wrappers/file_write_basic.py @@ -46,7 +46,7 @@ def add_parser(cls, parser): dest="action", action="store_const", const=rpc_enum_file_action.APP_CPATCH, - help="Write complete image file and perform DFU", + help="Write diff image file and perform DFU", ) group.add_argument( "--bt-ctlr-dfu", @@ -55,6 +55,13 @@ def add_parser(cls, parser): const=rpc_enum_file_action.BT_CTLR_IMG, help="Write Bluetooth controller image file and perform DFU", ) + group.add_argument( + "--bt-ctlr-cpatch", + dest="action", + action="store_const", + const=rpc_enum_file_action.BT_CTLR_CPATCH, + help="Write Bluetooth controller diff file and perform DFU", + ) group.add_argument( "--nrf91-modem", dest="action", diff --git a/src/infuse_iot/tools/cloud.py b/src/infuse_iot/tools/cloud.py index e5c578a..74565a6 100644 --- a/src/infuse_iot/tools/cloud.py +++ b/src/infuse_iot/tools/cloud.py @@ -12,11 +12,13 @@ from tabulate import tabulate from infuse_iot.api_client import Client -from infuse_iot.api_client.api.default import ( +from infuse_iot.api_client.api.board import ( create_board, + get_boards, +) +from infuse_iot.api_client.api.organisation import ( create_organisation, get_all_organisations, - get_boards, ) from infuse_iot.api_client.models import Error, NewBoard, NewOrganisation from infuse_iot.commands import InfuseCommand @@ -32,7 +34,7 @@ def run(self): def client(self): """Get API client object ready to use""" - return Client(base_url="https://api.dev.infuse-iot.com").with_headers({"x-api-key": f"Bearer {get_api_key()}"}) + return Client(base_url="https://api.infuse-iot.com").with_headers({"x-api-key": f"Bearer {get_api_key()}"}) class Organisations(CloudSubCommand): diff --git a/src/infuse_iot/tools/localhost/index.html b/src/infuse_iot/tools/localhost/index.html index 4174098..c77cfb9 100644 --- a/src/infuse_iot/tools/localhost/index.html +++ b/src/infuse_iot/tools/localhost/index.html @@ -12,6 +12,14 @@ .tabulator { font-family: monospace; } + + #tdf-show { + vertical-align: top; + } + + #app-show { + vertical-align: top; + }
@@ -21,18 +29,20 @@