From 260ad7949652f16fd47b653f640bfdc2ff410dfd Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 2 Jun 2026 15:52:09 +1000 Subject: [PATCH 1/5] api_client: regenerate client Regenerate the API client from the OpenAPI schema as of 03/06/2026. Signed-off-by: Jordan Yates --- .../api_client/api/application/__init__.py | 1 + .../api/application/create_application.py | 194 +++++++++++ .../api/application/create_release.py | 220 ++++++++++++ .../api/application/create_release_diff.py | 229 +++++++++++++ ...plication_id_and_release_id_and_diff_id.py | 208 ++++++++++++ ...on_id_and_application_id_and_release_id.py | 203 +++++++++++ ...n_by_organisation_id_and_application_id.py | 182 ++++++++++ .../get_applications_by_organisation_id.py | 208 ++++++++++++ ...plication_id_and_release_id_and_diff_id.py | 214 ++++++++++++ ...on_id_and_application_id_and_release_id.py | 256 ++++++++++++++ ...on_id_and_application_id_and_release_id.py | 200 +++++++++++ ...s_by_organisation_id_and_application_id.py | 320 ++++++++++++++++++ .../api_client/api/board/create_board.py | 34 +- .../api_client/api/board/get_board_by_id.py | 27 +- .../api_client/api/board/get_boards.py | 1 + .../api/board/get_devices_by_board_id.py | 29 +- .../api/coap/get_coap_file_stats.py | 1 + .../api_client/api/coap/get_coap_files.py | 1 + .../api_client/api/default/get_health.py | 1 + .../api/defs/get_kv_definitions_by_version.py | 1 + .../api/defs/get_latest_kv_definitions.py | 1 + .../api/defs/get_latest_rpc_definitions.py | 1 + .../api/defs/get_latest_tdf_definitions.py | 1 + .../defs/get_rpc_definitions_by_version.py | 1 + .../defs/get_tdf_definitions_by_version.py | 1 + ...v_entry_updates_by_device_id_and_key_id.py | 1 + .../api_client/api/device/create_device.py | 34 +- ...kv_entry_update_by_device_id_and_key_id.py | 35 +- .../api/device/get_device_by_device_id.py | 27 +- .../api_client/api/device/get_device_by_id.py | 27 +- .../device/get_device_by_soc_and_mcu_id.py | 27 +- .../get_device_kv_entries_by_device_id.py | 27 +- ...device_kv_entry_by_device_id_and_key_id.py | 29 +- ...v_entry_updates_by_device_id_and_key_id.py | 1 + .../get_device_last_route_by_device_id.py | 27 +- ...ice_logger_state_by_device_id_and_index.py | 27 +- .../get_device_logger_states_by_device_id.py | 27 +- .../device/get_device_state_by_device_id.py | 27 +- .../api/device/get_device_state_by_id.py | 27 +- .../api_client/api/device/get_devices.py | 1 + .../api/device/get_devices_and_states.py | 1 + .../api/device/update_device_by_id.py | 26 +- ...ice_logger_state_by_device_id_and_index.py | 26 +- .../api/device/update_device_state_by_id.py | 26 +- .../api_client/api/key/get_public_key.py | 1 + .../api_client/api/network/create_network.py | 34 +- .../api_client/api/network/get_networks.py | 1 + .../api/organisation/create_organisation.py | 28 +- .../api/organisation/get_all_organisations.py | 1 + .../organisation/get_organisation_by_id.py | 29 +- .../organisation/get_organisation_by_name.py | 29 +- .../api_client/api/rpc/get_rp_cs.py | 1 + .../api_client/api/rpc/get_rpc_by_id.py | 1 + src/infuse_iot/api_client/models/__init__.py | 18 + .../api_client/models/application.py | 104 ++++++ .../models/application_diff_file_stats.py | 77 +++++ .../api_client/models/application_release.py | 144 ++++++++ .../models/application_release_diff.py | 109 ++++++ .../models/application_release_file_stats.py | 85 +++++ .../models/application_release_version.py | 85 +++++ src/infuse_iot/api_client/models/board.py | 8 + .../api_client/models/create_release_body.py | 146 ++++++++ .../models/create_release_diff_body.py | 85 +++++ .../models/definitions_kv_definitions.py | 1 + .../models/definitions_kv_structs.py | 1 + .../models/definitions_rpc_commands.py | 1 + .../models/definitions_rpc_enums.py | 1 + .../models/definitions_rpc_structs.py | 1 + .../models/definitions_tdf_definitions.py | 1 + .../models/definitions_tdf_structs.py | 1 + .../models/device_kv_entry_decoded.py | 1 + .../models/device_kv_entry_update.py | 20 +- .../api_client/models/device_metadata.py | 1 + .../api_client/models/device_state.py | 52 ++- .../generate_api_key_body_resource_perms.py | 1 + .../api_client/models/new_application.py | 77 +++++ src/infuse_iot/api_client/models/new_board.py | 9 + .../new_device_kv_entry_update_decoded.py | 1 + .../api_client/models/rpc_params.py | 1 + 79 files changed, 3834 insertions(+), 280 deletions(-) create mode 100644 src/infuse_iot/api_client/api/application/__init__.py create mode 100644 src/infuse_iot/api_client/api/application/create_application.py create mode 100644 src/infuse_iot/api_client/api/application/create_release.py create mode 100644 src/infuse_iot/api_client/api/application/create_release_diff.py create mode 100644 src/infuse_iot/api_client/api/application/delete_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py create mode 100644 src/infuse_iot/api_client/api/application/delete_release_by_organisation_id_and_application_id_and_release_id.py create mode 100644 src/infuse_iot/api_client/api/application/get_application_by_organisation_id_and_application_id.py create mode 100644 src/infuse_iot/api_client/api/application/get_applications_by_organisation_id.py create mode 100644 src/infuse_iot/api_client/api/application/get_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py create mode 100644 src/infuse_iot/api_client/api/application/get_diffs_by_organisation_id_and_application_id_and_release_id.py create mode 100644 src/infuse_iot/api_client/api/application/get_release_by_organisation_id_and_application_id_and_release_id.py create mode 100644 src/infuse_iot/api_client/api/application/get_releases_by_organisation_id_and_application_id.py create mode 100644 src/infuse_iot/api_client/models/application.py create mode 100644 src/infuse_iot/api_client/models/application_diff_file_stats.py create mode 100644 src/infuse_iot/api_client/models/application_release.py create mode 100644 src/infuse_iot/api_client/models/application_release_diff.py create mode 100644 src/infuse_iot/api_client/models/application_release_file_stats.py create mode 100644 src/infuse_iot/api_client/models/application_release_version.py create mode 100644 src/infuse_iot/api_client/models/create_release_body.py create mode 100644 src/infuse_iot/api_client/models/create_release_diff_body.py create mode 100644 src/infuse_iot/api_client/models/new_application.py diff --git a/src/infuse_iot/api_client/api/application/__init__.py b/src/infuse_iot/api_client/api/application/__init__.py new file mode 100644 index 00000000..2d7c0b23 --- /dev/null +++ b/src/infuse_iot/api_client/api/application/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/infuse_iot/api_client/api/application/create_application.py b/src/infuse_iot/api_client/api/application/create_application.py new file mode 100644 index 00000000..cd02e6ae --- /dev/null +++ b/src/infuse_iot/api_client/api/application/create_application.py @@ -0,0 +1,194 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application import Application +from ...models.error import Error +from ...models.new_application import NewApplication +from ...types import Response + + +def _get_kwargs( + id: UUID, + *, + body: NewApplication, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/organisation/id/{id}/applications".format( + id=quote(str(id), safe=""), + ), + } + + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Application | Error | None: + if response.status_code == 201: + response_201 = Application.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 == 409: + response_409 = Error.from_dict(response.json()) + + return response_409 + + if response.status_code == 422: + response_422 = Error.from_dict(response.json()) + + return response_422 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Application | 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( + id: UUID, + *, + client: AuthenticatedClient | Client, + body: NewApplication, +) -> Response[Application | Error]: + """Create a new application in an organisation + + Args: + id (UUID): + body (NewApplication): + + 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[Application | Error] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + *, + client: AuthenticatedClient | Client, + body: NewApplication, +) -> Application | Error | None: + """Create a new application in an organisation + + Args: + id (UUID): + body (NewApplication): + + 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: + Application | Error + """ + + return sync_detailed( + id=id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + id: UUID, + *, + client: AuthenticatedClient | Client, + body: NewApplication, +) -> Response[Application | Error]: + """Create a new application in an organisation + + Args: + id (UUID): + body (NewApplication): + + 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[Application | Error] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + *, + client: AuthenticatedClient | Client, + body: NewApplication, +) -> Application | Error | None: + """Create a new application in an organisation + + Args: + id (UUID): + body (NewApplication): + + 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: + Application | Error + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/create_release.py b/src/infuse_iot/api_client/api/application/create_release.py new file mode 100644 index 00000000..d3330cd1 --- /dev/null +++ b/src/infuse_iot/api_client/api/application/create_release.py @@ -0,0 +1,220 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_release import ApplicationRelease +from ...models.create_release_body import CreateReleaseBody +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + id: UUID, + application_id: int, + *, + body: CreateReleaseBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/organisation/id/{id}/applications/{application_id}/releases".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + ), + } + + _kwargs["files"] = body.to_multipart() + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ApplicationRelease | Error | None: + if response.status_code == 201: + response_201 = ApplicationRelease.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 == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = Error.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = Error.from_dict(response.json()) + + return response_413 + + if response.status_code == 422: + response_422 = Error.from_dict(response.json()) + + return response_422 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ApplicationRelease | 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( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseBody, +) -> Response[ApplicationRelease | Error]: + """Create a new release for an application + + Args: + id (UUID): + application_id (int): + body (CreateReleaseBody): + + 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[ApplicationRelease | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseBody, +) -> ApplicationRelease | Error | None: + """Create a new release for an application + + Args: + id (UUID): + application_id (int): + body (CreateReleaseBody): + + 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: + ApplicationRelease | Error + """ + + return sync_detailed( + id=id, + application_id=application_id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseBody, +) -> Response[ApplicationRelease | Error]: + """Create a new release for an application + + Args: + id (UUID): + application_id (int): + body (CreateReleaseBody): + + 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[ApplicationRelease | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseBody, +) -> ApplicationRelease | Error | None: + """Create a new release for an application + + Args: + id (UUID): + application_id (int): + body (CreateReleaseBody): + + 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: + ApplicationRelease | Error + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/create_release_diff.py b/src/infuse_iot/api_client/api/application/create_release_diff.py new file mode 100644 index 00000000..0ff938fe --- /dev/null +++ b/src/infuse_iot/api_client/api/application/create_release_diff.py @@ -0,0 +1,229 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_release_diff import ApplicationReleaseDiff +from ...models.create_release_diff_body import CreateReleaseDiffBody +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + id: UUID, + application_id: int, + release_id: str, + *, + body: CreateReleaseDiffBody, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/organisation/id/{id}/applications/{application_id}/releases/{release_id}/diffs".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + release_id=quote(str(release_id), safe=""), + ), + } + + _kwargs["files"] = body.to_multipart() + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ApplicationReleaseDiff | Error | None: + if response.status_code == 201: + response_201 = ApplicationReleaseDiff.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 == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = Error.from_dict(response.json()) + + return response_409 + + if response.status_code == 413: + response_413 = Error.from_dict(response.json()) + + return response_413 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ApplicationReleaseDiff | 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( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseDiffBody, +) -> Response[ApplicationReleaseDiff | Error]: + """Create a new diff for an application release + + Args: + id (UUID): + application_id (int): + release_id (str): + body (CreateReleaseDiffBody): + + 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[ApplicationReleaseDiff | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseDiffBody, +) -> ApplicationReleaseDiff | Error | None: + """Create a new diff for an application release + + Args: + id (UUID): + application_id (int): + release_id (str): + body (CreateReleaseDiffBody): + + 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: + ApplicationReleaseDiff | Error + """ + + return sync_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseDiffBody, +) -> Response[ApplicationReleaseDiff | Error]: + """Create a new diff for an application release + + Args: + id (UUID): + application_id (int): + release_id (str): + body (CreateReleaseDiffBody): + + 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[ApplicationReleaseDiff | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + body: CreateReleaseDiffBody, +) -> ApplicationReleaseDiff | Error | None: + """Create a new diff for an application release + + Args: + id (UUID): + application_id (int): + release_id (str): + body (CreateReleaseDiffBody): + + 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: + ApplicationReleaseDiff | Error + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + body=body, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/delete_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py b/src/infuse_iot/api_client/api/application/delete_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py new file mode 100644 index 00000000..1a3819af --- /dev/null +++ b/src/infuse_iot/api_client/api/application/delete_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py @@ -0,0 +1,208 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "delete", + "url": "/organisation/id/{id}/applications/{application_id}/releases/{release_id}/diffs/{diff_id}".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + release_id=quote(str(release_id), safe=""), + diff_id=quote(str(diff_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Error | None: + if response.status_code == 204: + response_204 = cast(Any, None) + return response_204 + + 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 == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | 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( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | Error]: + """Delete a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> Any | Error | None: + """Delete a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | Error + """ + + return sync_detailed( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | Error]: + """Delete a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> Any | Error | None: + """Delete a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | Error + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/delete_release_by_organisation_id_and_application_id_and_release_id.py b/src/infuse_iot/api_client/api/application/delete_release_by_organisation_id_and_application_id_and_release_id.py new file mode 100644 index 00000000..613032df --- /dev/null +++ b/src/infuse_iot/api_client/api/application/delete_release_by_organisation_id_and_application_id_and_release_id.py @@ -0,0 +1,203 @@ +from http import HTTPStatus +from typing import Any, cast +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + id: UUID, + application_id: int, + release_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "delete", + "url": "/organisation/id/{id}/applications/{application_id}/releases/{release_id}".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + release_id=quote(str(release_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Error | None: + if response.status_code == 204: + response_204 = cast(Any, None) + return response_204 + + 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 == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if response.status_code == 409: + response_409 = Error.from_dict(response.json()) + + return response_409 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | 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( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | Error]: + """Delete a release by organisation ID, application ID and release ID - only allowed if there are no + diffs to or from this release. + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> Any | Error | None: + """Delete a release by organisation ID, application ID and release ID - only allowed if there are no + diffs to or from this release. + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | Error + """ + + return sync_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any | Error]: + """Delete a release by organisation ID, application ID and release ID - only allowed if there are no + diffs to or from this release. + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> Any | Error | None: + """Delete a release by organisation ID, application ID and release ID - only allowed if there are no + diffs to or from this release. + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Any | Error + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/get_application_by_organisation_id_and_application_id.py b/src/infuse_iot/api_client/api/application/get_application_by_organisation_id_and_application_id.py new file mode 100644 index 00000000..6a397e90 --- /dev/null +++ b/src/infuse_iot/api_client/api/application/get_application_by_organisation_id_and_application_id.py @@ -0,0 +1,182 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application import Application +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + id: UUID, + application_id: int, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/organisation/id/{id}/applications/{application_id}".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Application | Error | None: + if response.status_code == 200: + response_200 = Application.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = Error.from_dict(response.json()) + + return response_400 + + if response.status_code == 403: + response_403 = Error.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Application | 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( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[Application | Error]: + """Get an application by organisation ID and application ID + + Args: + id (UUID): + application_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Application | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, +) -> Application | Error | None: + """Get an application by organisation ID and application ID + + Args: + id (UUID): + application_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Application | Error + """ + + return sync_detailed( + id=id, + application_id=application_id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[Application | Error]: + """Get an application by organisation ID and application ID + + Args: + id (UUID): + application_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Application | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, +) -> Application | Error | None: + """Get an application by organisation ID and application ID + + Args: + id (UUID): + application_id (int): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Application | Error + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/get_applications_by_organisation_id.py b/src/infuse_iot/api_client/api/application/get_applications_by_organisation_id.py new file mode 100644 index 00000000..92c1c75f --- /dev/null +++ b/src/infuse_iot/api_client/api/application/get_applications_by_organisation_id.py @@ -0,0 +1,208 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application import Application +from ...models.error import Error +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: UUID, + *, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["offset"] = offset + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/organisation/id/{id}/applications".format( + id=quote(str(id), safe=""), + ), + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Error | list[Application] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = Application.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + 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 client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | list[Application]]: + 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: AuthenticatedClient | Client, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Response[Error | list[Application]]: + """Get all applications for an organisation + + Args: + id (UUID): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Error | list[Application]] + """ + + kwargs = _get_kwargs( + id=id, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Error | list[Application] | None: + """Get all applications for an organisation + + Args: + id (UUID): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Error | list[Application] + """ + + return sync_detailed( + id=id, + client=client, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + id: UUID, + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Response[Error | list[Application]]: + """Get all applications for an organisation + + Args: + id (UUID): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Error | list[Application]] + """ + + kwargs = _get_kwargs( + id=id, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Error | list[Application] | None: + """Get all applications for an organisation + + Args: + id (UUID): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Error | list[Application] + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/get_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py b/src/infuse_iot/api_client/api/application/get_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py new file mode 100644 index 00000000..059a1d79 --- /dev/null +++ b/src/infuse_iot/api_client/api/application/get_diff_by_organisation_id_and_application_id_and_release_id_and_diff_id.py @@ -0,0 +1,214 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_release_diff import ApplicationReleaseDiff +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/organisation/id/{id}/applications/{application_id}/releases/{release_id}/diffs/{diff_id}".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + release_id=quote(str(release_id), safe=""), + diff_id=quote(str(diff_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ApplicationReleaseDiff | Error | None: + if response.status_code == 200: + response_200 = ApplicationReleaseDiff.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = Error.from_dict(response.json()) + + return response_400 + + if response.status_code == 403: + response_403 = Error.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ApplicationReleaseDiff | 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( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[ApplicationReleaseDiff | Error]: + """Get a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationReleaseDiff | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> ApplicationReleaseDiff | Error | None: + """Get a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationReleaseDiff | Error + """ + + return sync_detailed( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[ApplicationReleaseDiff | Error]: + """Get a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationReleaseDiff | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + release_id: str, + diff_id: str, + *, + client: AuthenticatedClient | Client, +) -> ApplicationReleaseDiff | Error | None: + """Get a diff by organisation ID, application ID, release ID and diff ID + + Args: + id (UUID): + application_id (int): + release_id (str): + diff_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationReleaseDiff | Error + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + release_id=release_id, + diff_id=diff_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/get_diffs_by_organisation_id_and_application_id_and_release_id.py b/src/infuse_iot/api_client/api/application/get_diffs_by_organisation_id_and_application_id_and_release_id.py new file mode 100644 index 00000000..1b636b16 --- /dev/null +++ b/src/infuse_iot/api_client/api/application/get_diffs_by_organisation_id_and_application_id_and_release_id.py @@ -0,0 +1,256 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_release_diff import ApplicationReleaseDiff +from ...models.error import Error +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: UUID, + application_id: int, + release_id: str, + *, + from_release_id: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["fromReleaseId"] = from_release_id + + params["limit"] = limit + + params["offset"] = offset + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/organisation/id/{id}/applications/{application_id}/releases/{release_id}/diffs".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + release_id=quote(str(release_id), safe=""), + ), + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Error | list[ApplicationReleaseDiff] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = ApplicationReleaseDiff.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + 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 == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | list[ApplicationReleaseDiff]]: + 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, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + from_release_id: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Response[Error | list[ApplicationReleaseDiff]]: + """Get all diffs to a specific release for an application + + Args: + id (UUID): + application_id (int): + release_id (str): + from_release_id (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Error | list[ApplicationReleaseDiff]] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + from_release_id=from_release_id, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + from_release_id: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Error | list[ApplicationReleaseDiff] | None: + """Get all diffs to a specific release for an application + + Args: + id (UUID): + application_id (int): + release_id (str): + from_release_id (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Error | list[ApplicationReleaseDiff] + """ + + return sync_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + from_release_id=from_release_id, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + from_release_id: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Response[Error | list[ApplicationReleaseDiff]]: + """Get all diffs to a specific release for an application + + Args: + id (UUID): + application_id (int): + release_id (str): + from_release_id (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Error | list[ApplicationReleaseDiff]] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + from_release_id=from_release_id, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, + from_release_id: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Error | list[ApplicationReleaseDiff] | None: + """Get all diffs to a specific release for an application + + Args: + id (UUID): + application_id (int): + release_id (str): + from_release_id (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Error | list[ApplicationReleaseDiff] + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + from_release_id=from_release_id, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/get_release_by_organisation_id_and_application_id_and_release_id.py b/src/infuse_iot/api_client/api/application/get_release_by_organisation_id_and_application_id_and_release_id.py new file mode 100644 index 00000000..9d3cc66b --- /dev/null +++ b/src/infuse_iot/api_client/api/application/get_release_by_organisation_id_and_application_id_and_release_id.py @@ -0,0 +1,200 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_release import ApplicationRelease +from ...models.error import Error +from ...types import Response + + +def _get_kwargs( + id: UUID, + application_id: int, + release_id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/organisation/id/{id}/applications/{application_id}/releases/{release_id}".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + release_id=quote(str(release_id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ApplicationRelease | Error | None: + if response.status_code == 200: + response_200 = ApplicationRelease.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = Error.from_dict(response.json()) + + return response_400 + + if response.status_code == 403: + response_403 = Error.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ApplicationRelease | 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( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[ApplicationRelease | Error]: + """Get a release by organisation ID, application ID and release ID + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationRelease | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> ApplicationRelease | Error | None: + """Get a release by organisation ID, application ID and release ID + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationRelease | Error + """ + + return sync_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[ApplicationRelease | Error]: + """Get a release by organisation ID, application ID and release ID + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationRelease | Error] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + release_id=release_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + release_id: str, + *, + client: AuthenticatedClient | Client, +) -> ApplicationRelease | Error | None: + """Get a release by organisation ID, application ID and release ID + + Args: + id (UUID): + application_id (int): + release_id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationRelease | Error + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + release_id=release_id, + client=client, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/application/get_releases_by_organisation_id_and_application_id.py b/src/infuse_iot/api_client/api/application/get_releases_by_organisation_id_and_application_id.py new file mode 100644 index 00000000..01ff07cc --- /dev/null +++ b/src/infuse_iot/api_client/api/application/get_releases_by_organisation_id_and_application_id.py @@ -0,0 +1,320 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote +from uuid import UUID + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_release import ApplicationRelease +from ...models.error import Error +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: UUID, + application_id: int, + *, + version_major: int | Unset = UNSET, + version_minor: int | Unset = UNSET, + version_revision: int | Unset = UNSET, + version_build_num: int | Unset = UNSET, + board_id: UUID | Unset = UNSET, + board_target: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["versionMajor"] = version_major + + params["versionMinor"] = version_minor + + params["versionRevision"] = version_revision + + params["versionBuildNum"] = version_build_num + + json_board_id: str | Unset = UNSET + if not isinstance(board_id, Unset): + json_board_id = str(board_id) + params["boardId"] = json_board_id + + params["boardTarget"] = board_target + + params["limit"] = limit + + params["offset"] = offset + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/organisation/id/{id}/applications/{application_id}/releases".format( + id=quote(str(id), safe=""), + application_id=quote(str(application_id), safe=""), + ), + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Error | list[ApplicationRelease] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = ApplicationRelease.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + 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 == 404: + response_404 = Error.from_dict(response.json()) + + return response_404 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | list[ApplicationRelease]]: + 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, + application_id: int, + *, + client: AuthenticatedClient | Client, + version_major: int | Unset = UNSET, + version_minor: int | Unset = UNSET, + version_revision: int | Unset = UNSET, + version_build_num: int | Unset = UNSET, + board_id: UUID | Unset = UNSET, + board_target: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Response[Error | list[ApplicationRelease]]: + """Get all releases for an application + + Args: + id (UUID): + application_id (int): + version_major (int | Unset): Major version number of application release + version_minor (int | Unset): Minor version number of application release + version_revision (int | Unset): Revision version number of application release + version_build_num (int | Unset): Build version number of application release + board_id (UUID | Unset): + board_target (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Error | list[ApplicationRelease]] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + version_major=version_major, + version_minor=version_minor, + version_revision=version_revision, + version_build_num=version_build_num, + board_id=board_id, + board_target=board_target, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, + version_major: int | Unset = UNSET, + version_minor: int | Unset = UNSET, + version_revision: int | Unset = UNSET, + version_build_num: int | Unset = UNSET, + board_id: UUID | Unset = UNSET, + board_target: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Error | list[ApplicationRelease] | None: + """Get all releases for an application + + Args: + id (UUID): + application_id (int): + version_major (int | Unset): Major version number of application release + version_minor (int | Unset): Minor version number of application release + version_revision (int | Unset): Revision version number of application release + version_build_num (int | Unset): Build version number of application release + board_id (UUID | Unset): + board_target (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Error | list[ApplicationRelease] + """ + + return sync_detailed( + id=id, + application_id=application_id, + client=client, + version_major=version_major, + version_minor=version_minor, + version_revision=version_revision, + version_build_num=version_build_num, + board_id=board_id, + board_target=board_target, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, + version_major: int | Unset = UNSET, + version_minor: int | Unset = UNSET, + version_revision: int | Unset = UNSET, + version_build_num: int | Unset = UNSET, + board_id: UUID | Unset = UNSET, + board_target: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Response[Error | list[ApplicationRelease]]: + """Get all releases for an application + + Args: + id (UUID): + application_id (int): + version_major (int | Unset): Major version number of application release + version_minor (int | Unset): Minor version number of application release + version_revision (int | Unset): Revision version number of application release + version_build_num (int | Unset): Build version number of application release + board_id (UUID | Unset): + board_target (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Error | list[ApplicationRelease]] + """ + + kwargs = _get_kwargs( + id=id, + application_id=application_id, + version_major=version_major, + version_minor=version_minor, + version_revision=version_revision, + version_build_num=version_build_num, + board_id=board_id, + board_target=board_target, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: UUID, + application_id: int, + *, + client: AuthenticatedClient | Client, + version_major: int | Unset = UNSET, + version_minor: int | Unset = UNSET, + version_revision: int | Unset = UNSET, + version_build_num: int | Unset = UNSET, + board_id: UUID | Unset = UNSET, + board_target: str | Unset = UNSET, + limit: int | Unset = 100, + offset: int | Unset = 0, +) -> Error | list[ApplicationRelease] | None: + """Get all releases for an application + + Args: + id (UUID): + application_id (int): + version_major (int | Unset): Major version number of application release + version_minor (int | Unset): Minor version number of application release + version_revision (int | Unset): Revision version number of application release + version_build_num (int | Unset): Build version number of application release + board_id (UUID | Unset): + board_target (str | Unset): + limit (int | Unset): Default: 100. + offset (int | Unset): Default: 0. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Error | list[ApplicationRelease] + """ + + return ( + await asyncio_detailed( + id=id, + application_id=application_id, + client=client, + version_major=version_major, + version_minor=version_minor, + version_revision=version_revision, + version_build_num=version_build_num, + board_id=board_id, + board_target=board_target, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/src/infuse_iot/api_client/api/board/create_board.py b/src/infuse_iot/api_client/api/board/create_board.py index d7e2e659..9e186017 100644 --- a/src/infuse_iot/api_client/api/board/create_board.py +++ b/src/infuse_iot/api_client/api/board/create_board.py @@ -1,11 +1,12 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any import httpx from ... import errors from ...client import AuthenticatedClient, Client from ...models.board import Board +from ...models.error import Error from ...models.new_board import NewBoard from ...types import Response @@ -29,18 +30,25 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Board | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Board | Error | None: if response.status_code == 201: response_201 = Board.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 == 409: - response_409 = cast(Any, None) + response_409 = Error.from_dict(response.json()) + return response_409 if response.status_code == 422: - response_422 = cast(Any, None) + response_422 = Error.from_dict(response.json()) + return response_422 if client.raise_on_unexpected_status: @@ -49,7 +57,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Board | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,7 +70,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: NewBoard, -) -> Response[Any | Board]: +) -> Response[Board | Error]: """Create a new board Args: @@ -73,7 +81,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Board] + Response[Board | Error] """ kwargs = _get_kwargs( @@ -91,7 +99,7 @@ def sync( *, client: AuthenticatedClient | Client, body: NewBoard, -) -> Any | Board | None: +) -> Board | Error | None: """Create a new board Args: @@ -102,7 +110,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Board + Board | Error """ return sync_detailed( @@ -115,7 +123,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: NewBoard, -) -> Response[Any | Board]: +) -> Response[Board | Error]: """Create a new board Args: @@ -126,7 +134,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Board] + Response[Board | Error] """ kwargs = _get_kwargs( @@ -142,7 +150,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: NewBoard, -) -> Any | Board | None: +) -> Board | Error | None: """Create a new board Args: @@ -153,7 +161,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Board + Board | Error """ return ( diff --git a/src/infuse_iot/api_client/api/board/get_board_by_id.py b/src/infuse_iot/api_client/api/board/get_board_by_id.py index d1fe9186..2a2fa42f 100644 --- a/src/infuse_iot/api_client/api/board/get_board_by_id.py +++ b/src/infuse_iot/api_client/api/board/get_board_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote from uuid import UUID @@ -8,12 +8,14 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.board import Board +from ...models.error import Error from ...types import Response def _get_kwargs( id: UUID, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/board/id/{id}".format( @@ -24,14 +26,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Board | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Board | Error | None: if response.status_code == 200: response_200 = Board.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -40,7 +43,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Board | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,7 +56,7 @@ def sync_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | Board]: +) -> Response[Board | Error]: """Get a board by ID Args: @@ -64,7 +67,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Board] + Response[Board | Error] """ kwargs = _get_kwargs( @@ -82,7 +85,7 @@ def sync( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | Board | None: +) -> Board | Error | None: """Get a board by ID Args: @@ -93,7 +96,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Board + Board | Error """ return sync_detailed( @@ -106,7 +109,7 @@ async def asyncio_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | Board]: +) -> Response[Board | Error]: """Get a board by ID Args: @@ -117,7 +120,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Board] + Response[Board | Error] """ kwargs = _get_kwargs( @@ -133,7 +136,7 @@ async def asyncio( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | Board | None: +) -> Board | Error | None: """Get a board by ID Args: @@ -144,7 +147,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Board + Board | Error """ return ( diff --git a/src/infuse_iot/api_client/api/board/get_boards.py b/src/infuse_iot/api_client/api/board/get_boards.py index 8a615f98..68e128b3 100644 --- a/src/infuse_iot/api_client/api/board/get_boards.py +++ b/src/infuse_iot/api_client/api/board/get_boards.py @@ -14,6 +14,7 @@ def _get_kwargs( *, organisation_id: UUID, ) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id = str(organisation_id) diff --git a/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py b/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py index 1885f541..e3415ed5 100644 --- a/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py +++ b/src/infuse_iot/api_client/api/board/get_devices_by_board_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote from uuid import UUID @@ -8,6 +8,7 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device import Device +from ...models.error import Error from ...types import UNSET, Response, Unset @@ -17,6 +18,7 @@ def _get_kwargs( metadata_name: str | Unset = UNSET, metadata_value: str | Unset = UNSET, ) -> dict[str, Any]: + params: dict[str, Any] = {} params["metadataName"] = metadata_name @@ -36,7 +38,7 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | list[Device] | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | list[Device] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -48,7 +50,8 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -57,7 +60,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | list[Device]]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | list[Device]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -72,7 +77,7 @@ def sync_detailed( client: AuthenticatedClient | Client, metadata_name: str | Unset = UNSET, metadata_value: str | Unset = UNSET, -) -> Response[Any | list[Device]]: +) -> Response[Error | list[Device]]: """Get devices by board id and optional metadata field Args: @@ -85,7 +90,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | list[Device]] + Response[Error | list[Device]] """ kwargs = _get_kwargs( @@ -107,7 +112,7 @@ def sync( client: AuthenticatedClient | Client, metadata_name: str | Unset = UNSET, metadata_value: str | Unset = UNSET, -) -> Any | list[Device] | None: +) -> Error | list[Device] | None: """Get devices by board id and optional metadata field Args: @@ -120,7 +125,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | list[Device] + Error | list[Device] """ return sync_detailed( @@ -137,7 +142,7 @@ async def asyncio_detailed( client: AuthenticatedClient | Client, metadata_name: str | Unset = UNSET, metadata_value: str | Unset = UNSET, -) -> Response[Any | list[Device]]: +) -> Response[Error | list[Device]]: """Get devices by board id and optional metadata field Args: @@ -150,7 +155,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | list[Device]] + Response[Error | list[Device]] """ kwargs = _get_kwargs( @@ -170,7 +175,7 @@ async def asyncio( client: AuthenticatedClient | Client, metadata_name: str | Unset = UNSET, metadata_value: str | Unset = UNSET, -) -> Any | list[Device] | None: +) -> Error | list[Device] | None: """Get devices by board id and optional metadata field Args: @@ -183,7 +188,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | list[Device] + Error | list[Device] """ return ( diff --git a/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py b/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py index e0926d73..29129f79 100644 --- a/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py +++ b/src/infuse_iot/api_client/api/coap/get_coap_file_stats.py @@ -14,6 +14,7 @@ def _get_kwargs( filename: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/coap/file/{filename}/stats".format( diff --git a/src/infuse_iot/api_client/api/coap/get_coap_files.py b/src/infuse_iot/api_client/api/coap/get_coap_files.py index bd40ab40..b04c7718 100644 --- a/src/infuse_iot/api_client/api/coap/get_coap_files.py +++ b/src/infuse_iot/api_client/api/coap/get_coap_files.py @@ -14,6 +14,7 @@ def _get_kwargs( *, regex: str | Unset = UNSET, ) -> dict[str, Any]: + params: dict[str, Any] = {} params["regex"] = regex 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 b4064231..bfad65ea 100644 --- a/src/infuse_iot/api_client/api/default/get_health.py +++ b/src/infuse_iot/api_client/api/default/get_health.py @@ -10,6 +10,7 @@ def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/health", diff --git a/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py b/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py index a8dbddd2..6ceba4a6 100644 --- a/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py +++ b/src/infuse_iot/api_client/api/defs/get_kv_definitions_by_version.py @@ -14,6 +14,7 @@ def _get_kwargs( version: int, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/defs/kv/{version}".format( diff --git a/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py b/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py index e8aa9b02..d3e3b1a4 100644 --- a/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py +++ b/src/infuse_iot/api_client/api/defs/get_latest_kv_definitions.py @@ -11,6 +11,7 @@ def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/defs/kv", diff --git a/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py b/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py index 57433eec..d33183aa 100644 --- a/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py +++ b/src/infuse_iot/api_client/api/defs/get_latest_rpc_definitions.py @@ -11,6 +11,7 @@ def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/defs/rpc", diff --git a/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py b/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py index e759a545..256f6db4 100644 --- a/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py +++ b/src/infuse_iot/api_client/api/defs/get_latest_tdf_definitions.py @@ -11,6 +11,7 @@ def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/defs/tdf", diff --git a/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py b/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py index 060a240e..1e4fce16 100644 --- a/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py +++ b/src/infuse_iot/api_client/api/defs/get_rpc_definitions_by_version.py @@ -14,6 +14,7 @@ def _get_kwargs( version: int, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/defs/rpc/{version}".format( diff --git a/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py b/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py index a6aad750..2e5ae6e3 100644 --- a/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py +++ b/src/infuse_iot/api_client/api/defs/get_tdf_definitions_by_version.py @@ -14,6 +14,7 @@ def _get_kwargs( version: int, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/defs/tdf/{version}".format( diff --git a/src/infuse_iot/api_client/api/device/cancel_pending_device_kv_entry_updates_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/cancel_pending_device_kv_entry_updates_by_device_id_and_key_id.py index 2c918489..219c8a59 100644 --- a/src/infuse_iot/api_client/api/device/cancel_pending_device_kv_entry_updates_by_device_id_and_key_id.py +++ b/src/infuse_iot/api_client/api/device/cancel_pending_device_kv_entry_updates_by_device_id_and_key_id.py @@ -14,6 +14,7 @@ def _get_kwargs( device_id: str, key_id: int, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "delete", "url": "/device/deviceId/{device_id}/kv/entries/{key_id}/updates".format( diff --git a/src/infuse_iot/api_client/api/device/create_device.py b/src/infuse_iot/api_client/api/device/create_device.py index d0fa26b6..598b25ef 100644 --- a/src/infuse_iot/api_client/api/device/create_device.py +++ b/src/infuse_iot/api_client/api/device/create_device.py @@ -1,11 +1,12 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any import httpx from ... import errors from ...client import AuthenticatedClient, Client from ...models.device import Device +from ...models.error import Error from ...models.new_device import NewDevice from ...types import Response @@ -29,18 +30,25 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Device | Error | None: if response.status_code == 201: response_201 = Device.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 == 409: - response_409 = cast(Any, None) + response_409 = Error.from_dict(response.json()) + return response_409 if response.status_code == 422: - response_422 = cast(Any, None) + response_422 = Error.from_dict(response.json()) + return response_422 if client.raise_on_unexpected_status: @@ -49,7 +57,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Device | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,7 +70,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: NewDevice, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Create a new device Args: @@ -73,7 +81,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -91,7 +99,7 @@ def sync( *, client: AuthenticatedClient | Client, body: NewDevice, -) -> Any | Device | None: +) -> Device | Error | None: """Create a new device Args: @@ -102,7 +110,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return sync_detailed( @@ -115,7 +123,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: NewDevice, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Create a new device Args: @@ -126,7 +134,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -142,7 +150,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: NewDevice, -) -> Any | Device | None: +) -> Device | Error | None: """Create a new device Args: @@ -153,7 +161,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/create_device_kv_entry_update_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/create_device_kv_entry_update_by_device_id_and_key_id.py index 9e961089..429fd2e7 100644 --- a/src/infuse_iot/api_client/api/device/create_device_kv_entry_update_by_device_id_and_key_id.py +++ b/src/infuse_iot/api_client/api/device/create_device_kv_entry_update_by_device_id_and_key_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -8,6 +8,7 @@ from ...client import AuthenticatedClient, Client from ...models.device_kv_entry import DeviceKVEntry from ...models.device_kv_entry_update import DeviceKVEntryUpdate +from ...models.error import Error from ...models.new_device_kv_entry_update import NewDeviceKVEntryUpdate from ...types import Response @@ -38,7 +39,7 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Any | DeviceKVEntry | DeviceKVEntryUpdate | None: +) -> DeviceKVEntry | DeviceKVEntryUpdate | Error | None: if response.status_code == 200: response_200 = DeviceKVEntry.from_dict(response.json()) @@ -50,19 +51,23 @@ def _parse_response( return response_201 if response.status_code == 400: - response_400 = cast(Any, None) + response_400 = Error.from_dict(response.json()) + return response_400 if response.status_code == 403: - response_403 = cast(Any, None) + response_403 = Error.from_dict(response.json()) + return response_403 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if response.status_code == 409: - response_409 = cast(Any, None) + response_409 = Error.from_dict(response.json()) + return response_409 if client.raise_on_unexpected_status: @@ -73,7 +78,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | DeviceKVEntry | DeviceKVEntryUpdate]: +) -> Response[DeviceKVEntry | DeviceKVEntryUpdate | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -88,7 +93,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: NewDeviceKVEntryUpdate, -) -> Response[Any | DeviceKVEntry | DeviceKVEntryUpdate]: +) -> Response[DeviceKVEntry | DeviceKVEntryUpdate | Error]: """Create a KV entry update by DeviceID and Key ID Args: @@ -101,7 +106,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceKVEntry | DeviceKVEntryUpdate] + Response[DeviceKVEntry | DeviceKVEntryUpdate | Error] """ kwargs = _get_kwargs( @@ -123,7 +128,7 @@ def sync( *, client: AuthenticatedClient | Client, body: NewDeviceKVEntryUpdate, -) -> Any | DeviceKVEntry | DeviceKVEntryUpdate | None: +) -> DeviceKVEntry | DeviceKVEntryUpdate | Error | None: """Create a KV entry update by DeviceID and Key ID Args: @@ -136,7 +141,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceKVEntry | DeviceKVEntryUpdate + DeviceKVEntry | DeviceKVEntryUpdate | Error """ return sync_detailed( @@ -153,7 +158,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: NewDeviceKVEntryUpdate, -) -> Response[Any | DeviceKVEntry | DeviceKVEntryUpdate]: +) -> Response[DeviceKVEntry | DeviceKVEntryUpdate | Error]: """Create a KV entry update by DeviceID and Key ID Args: @@ -166,7 +171,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceKVEntry | DeviceKVEntryUpdate] + Response[DeviceKVEntry | DeviceKVEntryUpdate | Error] """ kwargs = _get_kwargs( @@ -186,7 +191,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: NewDeviceKVEntryUpdate, -) -> Any | DeviceKVEntry | DeviceKVEntryUpdate | None: +) -> DeviceKVEntry | DeviceKVEntryUpdate | Error | None: """Create a KV entry update by DeviceID and Key ID Args: @@ -199,7 +204,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceKVEntry | DeviceKVEntryUpdate + DeviceKVEntry | DeviceKVEntryUpdate | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_by_device_id.py index 8f16968e..ee69ad8f 100644 --- a/src/infuse_iot/api_client/api/device/get_device_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_device_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -7,12 +7,14 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device import Device +from ...models.error import Error from ...types import Response def _get_kwargs( device_id: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/deviceId/{device_id}".format( @@ -23,14 +25,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Device | Error | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -39,7 +42,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Device | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +55,7 @@ def sync_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Get a device by DeviceID Args: @@ -63,7 +66,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -81,7 +84,7 @@ def sync( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | Device | None: +) -> Device | Error | None: """Get a device by DeviceID Args: @@ -92,7 +95,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return sync_detailed( @@ -105,7 +108,7 @@ async def asyncio_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Get a device by DeviceID Args: @@ -116,7 +119,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -132,7 +135,7 @@ async def asyncio( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | Device | None: +) -> Device | Error | None: """Get a device by DeviceID Args: @@ -143,7 +146,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_by_id.py b/src/infuse_iot/api_client/api/device/get_device_by_id.py index fe933120..8ad86ffa 100644 --- a/src/infuse_iot/api_client/api/device/get_device_by_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote from uuid import UUID @@ -8,12 +8,14 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device import Device +from ...models.error import Error from ...types import Response def _get_kwargs( id: UUID, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/id/{id}".format( @@ -24,14 +26,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Device | Error | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -40,7 +43,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Device | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,7 +56,7 @@ def sync_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Get a device by ID Args: @@ -64,7 +67,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -82,7 +85,7 @@ def sync( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | Device | None: +) -> Device | Error | None: """Get a device by ID Args: @@ -93,7 +96,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return sync_detailed( @@ -106,7 +109,7 @@ async def asyncio_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Get a device by ID Args: @@ -117,7 +120,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -133,7 +136,7 @@ async def asyncio( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | Device | None: +) -> Device | Error | None: """Get a device by ID Args: @@ -144,7 +147,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py b/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py index 0955b911..d4c42f5f 100644 --- a/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_by_soc_and_mcu_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -7,6 +7,7 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device import Device +from ...models.error import Error from ...types import Response @@ -14,6 +15,7 @@ def _get_kwargs( soc: str, mcu_id: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/soc/{soc}/mcuId/{mcu_id}".format( @@ -25,14 +27,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Device | Error | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -41,7 +44,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Device | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -55,7 +58,7 @@ def sync_detailed( mcu_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Get a device by SoC and MCU ID Args: @@ -67,7 +70,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -87,7 +90,7 @@ def sync( mcu_id: str, *, client: AuthenticatedClient | Client, -) -> Any | Device | None: +) -> Device | Error | None: """Get a device by SoC and MCU ID Args: @@ -99,7 +102,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return sync_detailed( @@ -114,7 +117,7 @@ async def asyncio_detailed( mcu_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Get a device by SoC and MCU ID Args: @@ -126,7 +129,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -144,7 +147,7 @@ async def asyncio( mcu_id: str, *, client: AuthenticatedClient | Client, -) -> Any | Device | None: +) -> Device | Error | None: """Get a device by SoC and MCU ID Args: @@ -156,7 +159,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_kv_entries_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_kv_entries_by_device_id.py index ee23ea07..888d2b1d 100644 --- a/src/infuse_iot/api_client/api/device/get_device_kv_entries_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_kv_entries_by_device_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -7,12 +7,14 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device_kv_entry import DeviceKVEntry +from ...models.error import Error from ...types import Response def _get_kwargs( device_id: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/deviceId/{device_id}/kv/entries".format( @@ -25,7 +27,7 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Any | list[DeviceKVEntry] | None: +) -> Error | list[DeviceKVEntry] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -37,7 +39,8 @@ def _parse_response( return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -48,7 +51,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | list[DeviceKVEntry]]: +) -> Response[Error | list[DeviceKVEntry]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -61,7 +64,7 @@ def sync_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | list[DeviceKVEntry]]: +) -> Response[Error | list[DeviceKVEntry]]: """Get KV entries by DeviceID Args: @@ -72,7 +75,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | list[DeviceKVEntry]] + Response[Error | list[DeviceKVEntry]] """ kwargs = _get_kwargs( @@ -90,7 +93,7 @@ def sync( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | list[DeviceKVEntry] | None: +) -> Error | list[DeviceKVEntry] | None: """Get KV entries by DeviceID Args: @@ -101,7 +104,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | list[DeviceKVEntry] + Error | list[DeviceKVEntry] """ return sync_detailed( @@ -114,7 +117,7 @@ async def asyncio_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | list[DeviceKVEntry]]: +) -> Response[Error | list[DeviceKVEntry]]: """Get KV entries by DeviceID Args: @@ -125,7 +128,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | list[DeviceKVEntry]] + Response[Error | list[DeviceKVEntry]] """ kwargs = _get_kwargs( @@ -141,7 +144,7 @@ async def asyncio( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | list[DeviceKVEntry] | None: +) -> Error | list[DeviceKVEntry] | None: """Get KV entries by DeviceID Args: @@ -152,7 +155,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | list[DeviceKVEntry] + Error | list[DeviceKVEntry] """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_kv_entry_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/get_device_kv_entry_by_device_id_and_key_id.py index 151c1b2c..185dce3a 100644 --- a/src/infuse_iot/api_client/api/device/get_device_kv_entry_by_device_id_and_key_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_kv_entry_by_device_id_and_key_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -7,6 +7,7 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device_kv_entry import DeviceKVEntry +from ...models.error import Error from ...types import Response @@ -14,6 +15,7 @@ def _get_kwargs( device_id: str, key_id: int, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/deviceId/{device_id}/kv/entries/{key_id}".format( @@ -25,14 +27,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceKVEntry | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> DeviceKVEntry | Error | None: if response.status_code == 200: response_200 = DeviceKVEntry.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -41,7 +44,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceKVEntry]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DeviceKVEntry | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -55,7 +60,7 @@ def sync_detailed( key_id: int, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceKVEntry]: +) -> Response[DeviceKVEntry | Error]: """Get a KV entry by DeviceID and Key ID Args: @@ -67,7 +72,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceKVEntry] + Response[DeviceKVEntry | Error] """ kwargs = _get_kwargs( @@ -87,7 +92,7 @@ def sync( key_id: int, *, client: AuthenticatedClient | Client, -) -> Any | DeviceKVEntry | None: +) -> DeviceKVEntry | Error | None: """Get a KV entry by DeviceID and Key ID Args: @@ -99,7 +104,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceKVEntry + DeviceKVEntry | Error """ return sync_detailed( @@ -114,7 +119,7 @@ async def asyncio_detailed( key_id: int, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceKVEntry]: +) -> Response[DeviceKVEntry | Error]: """Get a KV entry by DeviceID and Key ID Args: @@ -126,7 +131,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceKVEntry] + Response[DeviceKVEntry | Error] """ kwargs = _get_kwargs( @@ -144,7 +149,7 @@ async def asyncio( key_id: int, *, client: AuthenticatedClient | Client, -) -> Any | DeviceKVEntry | None: +) -> DeviceKVEntry | Error | None: """Get a KV entry by DeviceID and Key ID Args: @@ -156,7 +161,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceKVEntry + DeviceKVEntry | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_kv_entry_updates_by_device_id_and_key_id.py b/src/infuse_iot/api_client/api/device/get_device_kv_entry_updates_by_device_id_and_key_id.py index 0ff9612e..0b3bb334 100644 --- a/src/infuse_iot/api_client/api/device/get_device_kv_entry_updates_by_device_id_and_key_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_kv_entry_updates_by_device_id_and_key_id.py @@ -19,6 +19,7 @@ def _get_kwargs( limit: int | Unset = 100, offset: int | Unset = 0, ) -> dict[str, Any]: + params: dict[str, Any] = {} json_status: str | Unset = UNSET diff --git a/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py index b211ec86..18a77a67 100644 --- a/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_last_route_by_device_id.py @@ -1,11 +1,12 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx from ... import errors from ...client import AuthenticatedClient, Client +from ...models.error import Error from ...models.uplink_route import UplinkRoute from ...types import Response @@ -13,6 +14,7 @@ def _get_kwargs( device_id: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/deviceId/{device_id}/lastRoute".format( @@ -23,14 +25,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | UplinkRoute | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | UplinkRoute | None: if response.status_code == 200: response_200 = UplinkRoute.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -39,7 +42,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | UplinkRoute]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | UplinkRoute]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +55,7 @@ def sync_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | UplinkRoute]: +) -> Response[Error | UplinkRoute]: """Get last route by DeviceID Args: @@ -63,7 +66,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | UplinkRoute] + Response[Error | UplinkRoute] """ kwargs = _get_kwargs( @@ -81,7 +84,7 @@ def sync( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | UplinkRoute | None: +) -> Error | UplinkRoute | None: """Get last route by DeviceID Args: @@ -92,7 +95,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | UplinkRoute + Error | UplinkRoute """ return sync_detailed( @@ -105,7 +108,7 @@ async def asyncio_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | UplinkRoute]: +) -> Response[Error | UplinkRoute]: """Get last route by DeviceID Args: @@ -116,7 +119,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | UplinkRoute] + Response[Error | UplinkRoute] """ kwargs = _get_kwargs( @@ -132,7 +135,7 @@ async def asyncio( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | UplinkRoute | None: +) -> Error | UplinkRoute | None: """Get last route by DeviceID Args: @@ -143,7 +146,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | UplinkRoute + Error | UplinkRoute """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py b/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py index 294003c8..abe03531 100644 --- a/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py +++ b/src/infuse_iot/api_client/api/device/get_device_logger_state_by_device_id_and_index.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -7,6 +7,7 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device_logger_state import DeviceLoggerState +from ...models.error import Error from ...types import Response @@ -14,6 +15,7 @@ def _get_kwargs( device_id: str, index: int, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/deviceId/{device_id}/loggerState/{index}".format( @@ -27,14 +29,15 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Any | DeviceLoggerState | None: +) -> DeviceLoggerState | Error | None: if response.status_code == 200: response_200 = DeviceLoggerState.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -45,7 +48,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | DeviceLoggerState]: +) -> Response[DeviceLoggerState | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -59,7 +62,7 @@ def sync_detailed( index: int, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceLoggerState]: +) -> Response[DeviceLoggerState | Error]: """Get logger state by DeviceID and index Args: @@ -71,7 +74,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceLoggerState] + Response[DeviceLoggerState | Error] """ kwargs = _get_kwargs( @@ -91,7 +94,7 @@ def sync( index: int, *, client: AuthenticatedClient | Client, -) -> Any | DeviceLoggerState | None: +) -> DeviceLoggerState | Error | None: """Get logger state by DeviceID and index Args: @@ -103,7 +106,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceLoggerState + DeviceLoggerState | Error """ return sync_detailed( @@ -118,7 +121,7 @@ async def asyncio_detailed( index: int, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceLoggerState]: +) -> Response[DeviceLoggerState | Error]: """Get logger state by DeviceID and index Args: @@ -130,7 +133,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceLoggerState] + Response[DeviceLoggerState | Error] """ kwargs = _get_kwargs( @@ -148,7 +151,7 @@ async def asyncio( index: int, *, client: AuthenticatedClient | Client, -) -> Any | DeviceLoggerState | None: +) -> DeviceLoggerState | Error | None: """Get logger state by DeviceID and index Args: @@ -160,7 +163,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceLoggerState + DeviceLoggerState | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_logger_states_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_logger_states_by_device_id.py index 6a8c2ce8..7ac9bf36 100644 --- a/src/infuse_iot/api_client/api/device/get_device_logger_states_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_logger_states_by_device_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -7,12 +7,14 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device_logger_state_with_index import DeviceLoggerStateWithIndex +from ...models.error import Error from ...types import Response def _get_kwargs( device_id: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/deviceId/{device_id}/loggerStates".format( @@ -25,7 +27,7 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Any | list[DeviceLoggerStateWithIndex] | None: +) -> Error | list[DeviceLoggerStateWithIndex] | None: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -37,7 +39,8 @@ def _parse_response( return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -48,7 +51,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | list[DeviceLoggerStateWithIndex]]: +) -> Response[Error | list[DeviceLoggerStateWithIndex]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -61,7 +64,7 @@ def sync_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | list[DeviceLoggerStateWithIndex]]: +) -> Response[Error | list[DeviceLoggerStateWithIndex]]: """Get all logger states by DeviceID Args: @@ -72,7 +75,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | list[DeviceLoggerStateWithIndex]] + Response[Error | list[DeviceLoggerStateWithIndex]] """ kwargs = _get_kwargs( @@ -90,7 +93,7 @@ def sync( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | list[DeviceLoggerStateWithIndex] | None: +) -> Error | list[DeviceLoggerStateWithIndex] | None: """Get all logger states by DeviceID Args: @@ -101,7 +104,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | list[DeviceLoggerStateWithIndex] + Error | list[DeviceLoggerStateWithIndex] """ return sync_detailed( @@ -114,7 +117,7 @@ async def asyncio_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | list[DeviceLoggerStateWithIndex]]: +) -> Response[Error | list[DeviceLoggerStateWithIndex]]: """Get all logger states by DeviceID Args: @@ -125,7 +128,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | list[DeviceLoggerStateWithIndex]] + Response[Error | list[DeviceLoggerStateWithIndex]] """ kwargs = _get_kwargs( @@ -141,7 +144,7 @@ async def asyncio( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | list[DeviceLoggerStateWithIndex] | None: +) -> Error | list[DeviceLoggerStateWithIndex] | None: """Get all logger states by DeviceID Args: @@ -152,7 +155,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | list[DeviceLoggerStateWithIndex] + Error | list[DeviceLoggerStateWithIndex] """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py b/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py index f4178a03..b781aaa8 100644 --- a/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_state_by_device_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -7,12 +7,14 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device_state import DeviceState +from ...models.error import Error from ...types import Response def _get_kwargs( device_id: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/deviceId/{device_id}/state".format( @@ -23,14 +25,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceState | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> DeviceState | Error | None: 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) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -39,7 +42,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceState]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[DeviceState | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +55,7 @@ def sync_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceState]: +) -> Response[DeviceState | Error]: """Get device state by DeviceID Args: @@ -63,7 +66,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceState] + Response[DeviceState | Error] """ kwargs = _get_kwargs( @@ -81,7 +84,7 @@ def sync( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | DeviceState | None: +) -> DeviceState | Error | None: """Get device state by DeviceID Args: @@ -92,7 +95,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceState + DeviceState | Error """ return sync_detailed( @@ -105,7 +108,7 @@ async def asyncio_detailed( device_id: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceState]: +) -> Response[DeviceState | Error]: """Get device state by DeviceID Args: @@ -116,7 +119,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceState] + Response[DeviceState | Error] """ kwargs = _get_kwargs( @@ -132,7 +135,7 @@ async def asyncio( device_id: str, *, client: AuthenticatedClient | Client, -) -> Any | DeviceState | None: +) -> DeviceState | Error | None: """Get device state by DeviceID Args: @@ -143,7 +146,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceState + DeviceState | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_device_state_by_id.py b/src/infuse_iot/api_client/api/device/get_device_state_by_id.py index b79bd54e..26749a2b 100644 --- a/src/infuse_iot/api_client/api/device/get_device_state_by_id.py +++ b/src/infuse_iot/api_client/api/device/get_device_state_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote from uuid import UUID @@ -8,12 +8,14 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device_state import DeviceState +from ...models.error import Error from ...types import Response def _get_kwargs( id: UUID, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/device/id/{id}/state".format( @@ -24,14 +26,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceState | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> DeviceState | Error | None: 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) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -40,7 +43,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceState]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[DeviceState | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,7 +56,7 @@ def sync_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceState]: +) -> Response[DeviceState | Error]: """Get device state by ID Args: @@ -64,7 +67,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceState] + Response[DeviceState | Error] """ kwargs = _get_kwargs( @@ -82,7 +85,7 @@ def sync( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | DeviceState | None: +) -> DeviceState | Error | None: """Get device state by ID Args: @@ -93,7 +96,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceState + DeviceState | Error """ return sync_detailed( @@ -106,7 +109,7 @@ async def asyncio_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | DeviceState]: +) -> Response[DeviceState | Error]: """Get device state by ID Args: @@ -117,7 +120,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceState] + Response[DeviceState | Error] """ kwargs = _get_kwargs( @@ -133,7 +136,7 @@ async def asyncio( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | DeviceState | None: +) -> DeviceState | Error | None: """Get device state by ID Args: @@ -144,7 +147,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceState + DeviceState | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/get_devices.py b/src/infuse_iot/api_client/api/device/get_devices.py index 190f2c2c..c2c4f339 100644 --- a/src/infuse_iot/api_client/api/device/get_devices.py +++ b/src/infuse_iot/api_client/api/device/get_devices.py @@ -16,6 +16,7 @@ def _get_kwargs( limit: int | Unset = 100, offset: int | Unset = 0, ) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id = str(organisation_id) diff --git a/src/infuse_iot/api_client/api/device/get_devices_and_states.py b/src/infuse_iot/api_client/api/device/get_devices_and_states.py index 37c7b20c..b6f7e992 100644 --- a/src/infuse_iot/api_client/api/device/get_devices_and_states.py +++ b/src/infuse_iot/api_client/api/device/get_devices_and_states.py @@ -16,6 +16,7 @@ def _get_kwargs( limit: int | Unset = 100, offset: int | Unset = 0, ) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id = str(organisation_id) diff --git a/src/infuse_iot/api_client/api/device/update_device_by_id.py b/src/infuse_iot/api_client/api/device/update_device_by_id.py index 3328ae27..488b7069 100644 --- a/src/infuse_iot/api_client/api/device/update_device_by_id.py +++ b/src/infuse_iot/api_client/api/device/update_device_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote from uuid import UUID @@ -9,6 +9,7 @@ from ...client import AuthenticatedClient, Client from ...models.device import Device from ...models.device_update import DeviceUpdate +from ...models.error import Error from ...types import Response @@ -34,14 +35,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Device | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Device | Error | None: if response.status_code == 200: response_200 = Device.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -50,7 +52,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Device]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Device | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -64,7 +66,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Update a device by ID Args: @@ -76,7 +78,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -96,7 +98,7 @@ def sync( *, client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Any | Device | None: +) -> Device | Error | None: """Update a device by ID Args: @@ -108,7 +110,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return sync_detailed( @@ -123,7 +125,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Response[Any | Device]: +) -> Response[Device | Error]: """Update a device by ID Args: @@ -135,7 +137,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Device] + Response[Device | Error] """ kwargs = _get_kwargs( @@ -153,7 +155,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: DeviceUpdate, -) -> Any | Device | None: +) -> Device | Error | None: """Update a device by ID Args: @@ -165,7 +167,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Device + Device | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/update_device_logger_state_by_device_id_and_index.py b/src/infuse_iot/api_client/api/device/update_device_logger_state_by_device_id_and_index.py index c9eb9a48..76101132 100644 --- a/src/infuse_iot/api_client/api/device/update_device_logger_state_by_device_id_and_index.py +++ b/src/infuse_iot/api_client/api/device/update_device_logger_state_by_device_id_and_index.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx @@ -8,6 +8,7 @@ from ...client import AuthenticatedClient, Client from ...models.device_logger_state import DeviceLoggerState from ...models.device_logger_state_update import DeviceLoggerStateUpdate +from ...models.error import Error from ...types import Response @@ -37,14 +38,15 @@ def _get_kwargs( def _parse_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Any | DeviceLoggerState | None: +) -> DeviceLoggerState | Error | None: if response.status_code == 200: response_200 = DeviceLoggerState.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -55,7 +57,7 @@ def _parse_response( def _build_response( *, client: AuthenticatedClient | Client, response: httpx.Response -) -> Response[Any | DeviceLoggerState]: +) -> Response[DeviceLoggerState | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -70,7 +72,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: DeviceLoggerStateUpdate, -) -> Response[Any | DeviceLoggerState]: +) -> Response[DeviceLoggerState | Error]: """Update logger state by DeviceID and index Args: @@ -83,7 +85,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceLoggerState] + Response[DeviceLoggerState | Error] """ kwargs = _get_kwargs( @@ -105,7 +107,7 @@ def sync( *, client: AuthenticatedClient | Client, body: DeviceLoggerStateUpdate, -) -> Any | DeviceLoggerState | None: +) -> DeviceLoggerState | Error | None: """Update logger state by DeviceID and index Args: @@ -118,7 +120,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceLoggerState + DeviceLoggerState | Error """ return sync_detailed( @@ -135,7 +137,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: DeviceLoggerStateUpdate, -) -> Response[Any | DeviceLoggerState]: +) -> Response[DeviceLoggerState | Error]: """Update logger state by DeviceID and index Args: @@ -148,7 +150,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceLoggerState] + Response[DeviceLoggerState | Error] """ kwargs = _get_kwargs( @@ -168,7 +170,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: DeviceLoggerStateUpdate, -) -> Any | DeviceLoggerState | None: +) -> DeviceLoggerState | Error | None: """Update logger state by DeviceID and index Args: @@ -181,7 +183,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceLoggerState + DeviceLoggerState | Error """ return ( diff --git a/src/infuse_iot/api_client/api/device/update_device_state_by_id.py b/src/infuse_iot/api_client/api/device/update_device_state_by_id.py index 295a2b6d..ce3c40cd 100644 --- a/src/infuse_iot/api_client/api/device/update_device_state_by_id.py +++ b/src/infuse_iot/api_client/api/device/update_device_state_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote from uuid import UUID @@ -8,6 +8,7 @@ from ... import errors from ...client import AuthenticatedClient, Client from ...models.device_state import DeviceState +from ...models.error import Error from ...models.new_device_state import NewDeviceState from ...types import Response @@ -34,14 +35,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | DeviceState | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> DeviceState | Error | None: 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) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -50,7 +52,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | DeviceState]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[DeviceState | Error]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -64,7 +66,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Response[Any | DeviceState]: +) -> Response[DeviceState | Error]: """Update device state by ID Args: @@ -76,7 +78,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceState] + Response[DeviceState | Error] """ kwargs = _get_kwargs( @@ -96,7 +98,7 @@ def sync( *, client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Any | DeviceState | None: +) -> DeviceState | Error | None: """Update device state by ID Args: @@ -108,7 +110,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceState + DeviceState | Error """ return sync_detailed( @@ -123,7 +125,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Response[Any | DeviceState]: +) -> Response[DeviceState | Error]: """Update device state by ID Args: @@ -135,7 +137,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | DeviceState] + Response[DeviceState | Error] """ kwargs = _get_kwargs( @@ -153,7 +155,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: NewDeviceState, -) -> Any | DeviceState | None: +) -> DeviceState | Error | None: """Update device state by ID Args: @@ -165,7 +167,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | DeviceState + DeviceState | Error """ return ( diff --git a/src/infuse_iot/api_client/api/key/get_public_key.py b/src/infuse_iot/api_client/api/key/get_public_key.py index 9d357560..8dae1cf8 100644 --- a/src/infuse_iot/api_client/api/key/get_public_key.py +++ b/src/infuse_iot/api_client/api/key/get_public_key.py @@ -10,6 +10,7 @@ def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/key/publicKey", diff --git a/src/infuse_iot/api_client/api/network/create_network.py b/src/infuse_iot/api_client/api/network/create_network.py index 93d38e0e..870854c7 100644 --- a/src/infuse_iot/api_client/api/network/create_network.py +++ b/src/infuse_iot/api_client/api/network/create_network.py @@ -1,10 +1,11 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any import httpx from ... import errors from ...client import AuthenticatedClient, Client +from ...models.error import Error from ...models.network import Network from ...models.new_network import NewNetwork from ...types import Response @@ -29,18 +30,25 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Network | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | Network | None: if response.status_code == 201: response_201 = Network.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 == 409: - response_409 = cast(Any, None) + response_409 = Error.from_dict(response.json()) + return response_409 if response.status_code == 422: - response_422 = cast(Any, None) + response_422 = Error.from_dict(response.json()) + return response_422 if client.raise_on_unexpected_status: @@ -49,7 +57,7 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Network]: +def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | Network]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,7 +70,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: NewNetwork, -) -> Response[Any | Network]: +) -> Response[Error | Network]: """Create a new network Args: @@ -73,7 +81,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Network] + Response[Error | Network] """ kwargs = _get_kwargs( @@ -91,7 +99,7 @@ def sync( *, client: AuthenticatedClient | Client, body: NewNetwork, -) -> Any | Network | None: +) -> Error | Network | None: """Create a new network Args: @@ -102,7 +110,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Network + Error | Network """ return sync_detailed( @@ -115,7 +123,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: NewNetwork, -) -> Response[Any | Network]: +) -> Response[Error | Network]: """Create a new network Args: @@ -126,7 +134,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Network] + Response[Error | Network] """ kwargs = _get_kwargs( @@ -142,7 +150,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: NewNetwork, -) -> Any | Network | None: +) -> Error | Network | None: """Create a new network Args: @@ -153,7 +161,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Network + Error | Network """ return ( diff --git a/src/infuse_iot/api_client/api/network/get_networks.py b/src/infuse_iot/api_client/api/network/get_networks.py index f16432a7..2661a7a9 100644 --- a/src/infuse_iot/api_client/api/network/get_networks.py +++ b/src/infuse_iot/api_client/api/network/get_networks.py @@ -15,6 +15,7 @@ def _get_kwargs( organisation_id: UUID, include_public: bool = False, ) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id = str(organisation_id) diff --git a/src/infuse_iot/api_client/api/organisation/create_organisation.py b/src/infuse_iot/api_client/api/organisation/create_organisation.py index 77ae18bc..d0556180 100644 --- a/src/infuse_iot/api_client/api/organisation/create_organisation.py +++ b/src/infuse_iot/api_client/api/organisation/create_organisation.py @@ -1,10 +1,11 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any import httpx from ... import errors from ...client import AuthenticatedClient, Client +from ...models.error import Error from ...models.new_organisation import NewOrganisation from ...models.organisation import Organisation from ...types import Response @@ -29,14 +30,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Organisation | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | Organisation | None: if response.status_code == 201: response_201 = Organisation.from_dict(response.json()) return response_201 if response.status_code == 409: - response_409 = cast(Any, None) + response_409 = Error.from_dict(response.json()) + return response_409 if client.raise_on_unexpected_status: @@ -45,7 +47,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Organisation]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | Organisation]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -58,7 +62,7 @@ def sync_detailed( *, client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Response[Any | Organisation]: +) -> Response[Error | Organisation]: """Create a new organisation Args: @@ -69,7 +73,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Organisation] + Response[Error | Organisation] """ kwargs = _get_kwargs( @@ -87,7 +91,7 @@ def sync( *, client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Any | Organisation | None: +) -> Error | Organisation | None: """Create a new organisation Args: @@ -98,7 +102,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Organisation + Error | Organisation """ return sync_detailed( @@ -111,7 +115,7 @@ async def asyncio_detailed( *, client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Response[Any | Organisation]: +) -> Response[Error | Organisation]: """Create a new organisation Args: @@ -122,7 +126,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Organisation] + Response[Error | Organisation] """ kwargs = _get_kwargs( @@ -138,7 +142,7 @@ async def asyncio( *, client: AuthenticatedClient | Client, body: NewOrganisation, -) -> Any | Organisation | None: +) -> Error | Organisation | None: """Create a new organisation Args: @@ -149,7 +153,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Organisation + Error | Organisation """ return ( diff --git a/src/infuse_iot/api_client/api/organisation/get_all_organisations.py b/src/infuse_iot/api_client/api/organisation/get_all_organisations.py index 27500104..6a7170d6 100644 --- a/src/infuse_iot/api_client/api/organisation/get_all_organisations.py +++ b/src/infuse_iot/api_client/api/organisation/get_all_organisations.py @@ -11,6 +11,7 @@ def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/organisation", diff --git a/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py b/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py index a3dcb3f6..fd995eb0 100644 --- a/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py +++ b/src/infuse_iot/api_client/api/organisation/get_organisation_by_id.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote from uuid import UUID @@ -7,6 +7,7 @@ from ... import errors from ...client import AuthenticatedClient, Client +from ...models.error import Error from ...models.organisation import Organisation from ...types import Response @@ -14,6 +15,7 @@ def _get_kwargs( id: UUID, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/organisation/id/{id}".format( @@ -24,14 +26,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Organisation | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | Organisation | None: if response.status_code == 200: response_200 = Organisation.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -40,7 +43,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Organisation]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | Organisation]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -53,7 +58,7 @@ def sync_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | Organisation]: +) -> Response[Error | Organisation]: """Get an organisation by ID Args: @@ -64,7 +69,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Organisation] + Response[Error | Organisation] """ kwargs = _get_kwargs( @@ -82,7 +87,7 @@ def sync( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | Organisation | None: +) -> Error | Organisation | None: """Get an organisation by ID Args: @@ -93,7 +98,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Organisation + Error | Organisation """ return sync_detailed( @@ -106,7 +111,7 @@ async def asyncio_detailed( id: UUID, *, client: AuthenticatedClient | Client, -) -> Response[Any | Organisation]: +) -> Response[Error | Organisation]: """Get an organisation by ID Args: @@ -117,7 +122,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Organisation] + Response[Error | Organisation] """ kwargs = _get_kwargs( @@ -133,7 +138,7 @@ async def asyncio( id: UUID, *, client: AuthenticatedClient | Client, -) -> Any | Organisation | None: +) -> Error | Organisation | None: """Get an organisation by ID Args: @@ -144,7 +149,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Organisation + Error | Organisation """ return ( diff --git a/src/infuse_iot/api_client/api/organisation/get_organisation_by_name.py b/src/infuse_iot/api_client/api/organisation/get_organisation_by_name.py index f4445636..42505d26 100644 --- a/src/infuse_iot/api_client/api/organisation/get_organisation_by_name.py +++ b/src/infuse_iot/api_client/api/organisation/get_organisation_by_name.py @@ -1,11 +1,12 @@ from http import HTTPStatus -from typing import Any, cast +from typing import Any from urllib.parse import quote import httpx from ... import errors from ...client import AuthenticatedClient, Client +from ...models.error import Error from ...models.organisation import Organisation from ...types import Response @@ -13,6 +14,7 @@ def _get_kwargs( name: str, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/organisation/name/{name}".format( @@ -23,14 +25,15 @@ def _get_kwargs( return _kwargs -def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Organisation | None: +def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | Organisation | None: if response.status_code == 200: response_200 = Organisation.from_dict(response.json()) return response_200 if response.status_code == 404: - response_404 = cast(Any, None) + response_404 = Error.from_dict(response.json()) + return response_404 if client.raise_on_unexpected_status: @@ -39,7 +42,9 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res return None -def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Organisation]: +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Error | Organisation]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -52,7 +57,7 @@ def sync_detailed( name: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | Organisation]: +) -> Response[Error | Organisation]: """Get an organisation by name Args: @@ -63,7 +68,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Organisation] + Response[Error | Organisation] """ kwargs = _get_kwargs( @@ -81,7 +86,7 @@ def sync( name: str, *, client: AuthenticatedClient | Client, -) -> Any | Organisation | None: +) -> Error | Organisation | None: """Get an organisation by name Args: @@ -92,7 +97,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Organisation + Error | Organisation """ return sync_detailed( @@ -105,7 +110,7 @@ async def asyncio_detailed( name: str, *, client: AuthenticatedClient | Client, -) -> Response[Any | Organisation]: +) -> Response[Error | Organisation]: """Get an organisation by name Args: @@ -116,7 +121,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Any | Organisation] + Response[Error | Organisation] """ kwargs = _get_kwargs( @@ -132,7 +137,7 @@ async def asyncio( name: str, *, client: AuthenticatedClient | Client, -) -> Any | Organisation | None: +) -> Error | Organisation | None: """Get an organisation by name Args: @@ -143,7 +148,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Any | Organisation + Error | Organisation """ return ( diff --git a/src/infuse_iot/api_client/api/rpc/get_rp_cs.py b/src/infuse_iot/api_client/api/rpc/get_rp_cs.py index d8efd737..bde2d2e9 100644 --- a/src/infuse_iot/api_client/api/rpc/get_rp_cs.py +++ b/src/infuse_iot/api_client/api/rpc/get_rp_cs.py @@ -24,6 +24,7 @@ def _get_kwargs( rpc_command_id: int | Unset = UNSET, show_expired: bool | Unset = True, ) -> dict[str, Any]: + params: dict[str, Any] = {} json_organisation_id: str | Unset = UNSET diff --git a/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py b/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py index 0f0294fc..7994f078 100644 --- a/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py +++ b/src/infuse_iot/api_client/api/rpc/get_rpc_by_id.py @@ -15,6 +15,7 @@ def _get_kwargs( id: UUID, ) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/rpc/{id}".format( diff --git a/src/infuse_iot/api_client/models/__init__.py b/src/infuse_iot/api_client/models/__init__.py index c9fe1817..1287f8bc 100644 --- a/src/infuse_iot/api_client/models/__init__.py +++ b/src/infuse_iot/api_client/models/__init__.py @@ -4,12 +4,20 @@ from .api_key_org_user_type import APIKeyOrgUserType from .api_key_resource_name import APIKeyResourceName from .api_key_resource_perm import APIKeyResourcePerm +from .application import Application +from .application_diff_file_stats import ApplicationDiffFileStats +from .application_release import ApplicationRelease +from .application_release_diff import ApplicationReleaseDiff +from .application_release_file_stats import ApplicationReleaseFileStats +from .application_release_version import ApplicationReleaseVersion from .application_version import ApplicationVersion from .board import Board from .bt_le_route import BtLeRoute from .bt_le_route_type import BtLeRouteType from .coap_file_stats import COAPFileStats from .coap_files_list import COAPFilesList +from .create_release_body import CreateReleaseBody +from .create_release_diff_body import CreateReleaseDiffBody from .created_board_properties import CreatedBoardProperties from .created_device_properties import CreatedDeviceProperties from .created_organisation_properties import CreatedOrganisationProperties @@ -73,6 +81,7 @@ from .key_interface import KeyInterface from .metadata_field import MetadataField from .network import Network +from .new_application import NewApplication from .new_board import NewBoard from .new_device import NewDevice from .new_device_kv_entry_update import NewDeviceKVEntryUpdate @@ -100,6 +109,12 @@ "APIKeyOrgUserType", "APIKeyResourceName", "APIKeyResourcePerm", + "Application", + "ApplicationDiffFileStats", + "ApplicationRelease", + "ApplicationReleaseDiff", + "ApplicationReleaseFileStats", + "ApplicationReleaseVersion", "ApplicationVersion", "Board", "BtLeRoute", @@ -110,6 +125,8 @@ "CreatedDeviceProperties", "CreatedOrganisationProperties", "CreatedRpcMessage", + "CreateReleaseBody", + "CreateReleaseDiffBody", "DefinitionsEnumDefinition", "DefinitionsEnumValue", "DefinitionsFieldConversion", @@ -169,6 +186,7 @@ "KeyInterface", "MetadataField", "Network", + "NewApplication", "NewBoard", "NewDevice", "NewDeviceKVEntryUpdate", diff --git a/src/infuse_iot/api_client/models/application.py b/src/infuse_iot/api_client/models/application.py new file mode 100644 index 00000000..ab171b0a --- /dev/null +++ b/src/infuse_iot/api_client/models/application.py @@ -0,0 +1,104 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +T = TypeVar("T", bound="Application") + + +@_attrs_define +class Application: + """ + Attributes: + id (int): Application ID (must be unique within organisation) + name (str): Unique name of application + description (str): Description of application + organisation_id (UUID): ID of organisation the application belongs to + created_at (datetime.datetime): + updated_at (datetime.datetime): + """ + + id: int + name: str + description: str + organisation_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 + + name = self.name + + description = self.description + + organisation_id = str(self.organisation_id) + + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "name": name, + "description": description, + "organisationId": organisation_id, + "createdAt": created_at, + "updatedAt": updated_at, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id") + + name = d.pop("name") + + description = d.pop("description") + + organisation_id = UUID(d.pop("organisationId")) + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + application = cls( + id=id, + name=name, + description=description, + organisation_id=organisation_id, + created_at=created_at, + updated_at=updated_at, + ) + + application.additional_properties = d + return application + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/application_diff_file_stats.py b/src/infuse_iot/api_client/models/application_diff_file_stats.py new file mode 100644 index 00000000..0e339c56 --- /dev/null +++ b/src/infuse_iot/api_client/models/application_diff_file_stats.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ApplicationDiffFileStats") + + +@_attrs_define +class ApplicationDiffFileStats: + """ + Attributes: + coap_path (str): CoAP path of file Example: /release/12345. + len_ (int): Length of file in bytes + crc (int): CRC32 of file + """ + + coap_path: str + len_: int + crc: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + coap_path = self.coap_path + + len_ = self.len_ + + crc = self.crc + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "coapPath": coap_path, + "len": len_, + "crc": crc, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + coap_path = d.pop("coapPath") + + len_ = d.pop("len") + + crc = d.pop("crc") + + application_diff_file_stats = cls( + coap_path=coap_path, + len_=len_, + crc=crc, + ) + + application_diff_file_stats.additional_properties = d + return application_diff_file_stats + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/application_release.py b/src/infuse_iot/api_client/models/application_release.py new file mode 100644 index 00000000..47699b42 --- /dev/null +++ b/src/infuse_iot/api_client/models/application_release.py @@ -0,0 +1,144 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.application_release_file_stats import ApplicationReleaseFileStats + from ..models.application_release_version import ApplicationReleaseVersion + + +T = TypeVar("T", bound="ApplicationRelease") + + +@_attrs_define +class ApplicationRelease: + """ + Attributes: + id (str): Global unique ID of application release (generated on creation) + application_id (int): ID of application the release belongs to + organisation_id (UUID): ID of organisation the application release belongs to + file (ApplicationReleaseFileStats): + version (ApplicationReleaseVersion): + board_id (UUID): ID of board the application release is for + board_target (str): Board target for application release + board_target_crc (int): CRC16 of board target string + created_at (datetime.datetime): + updated_at (datetime.datetime): + """ + + id: str + application_id: int + organisation_id: UUID + file: ApplicationReleaseFileStats + version: ApplicationReleaseVersion + board_id: UUID + board_target: str + board_target_crc: int + 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 + + application_id = self.application_id + + organisation_id = str(self.organisation_id) + + file = self.file.to_dict() + + version = self.version.to_dict() + + board_id = str(self.board_id) + + board_target = self.board_target + + board_target_crc = self.board_target_crc + + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "applicationId": application_id, + "organisationId": organisation_id, + "file": file, + "version": version, + "boardId": board_id, + "boardTarget": board_target, + "boardTargetCRC": board_target_crc, + "createdAt": created_at, + "updatedAt": updated_at, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.application_release_file_stats import ApplicationReleaseFileStats + from ..models.application_release_version import ApplicationReleaseVersion + + d = dict(src_dict) + id = d.pop("id") + + application_id = d.pop("applicationId") + + organisation_id = UUID(d.pop("organisationId")) + + file = ApplicationReleaseFileStats.from_dict(d.pop("file")) + + version = ApplicationReleaseVersion.from_dict(d.pop("version")) + + board_id = UUID(d.pop("boardId")) + + board_target = d.pop("boardTarget") + + board_target_crc = d.pop("boardTargetCRC") + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + application_release = cls( + id=id, + application_id=application_id, + organisation_id=organisation_id, + file=file, + version=version, + board_id=board_id, + board_target=board_target, + board_target_crc=board_target_crc, + created_at=created_at, + updated_at=updated_at, + ) + + application_release.additional_properties = d + return application_release + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/application_release_diff.py b/src/infuse_iot/api_client/models/application_release_diff.py new file mode 100644 index 00000000..b530c15a --- /dev/null +++ b/src/infuse_iot/api_client/models/application_release_diff.py @@ -0,0 +1,109 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field +from dateutil.parser import isoparse + +if TYPE_CHECKING: + from ..models.application_diff_file_stats import ApplicationDiffFileStats + + +T = TypeVar("T", bound="ApplicationReleaseDiff") + + +@_attrs_define +class ApplicationReleaseDiff: + """ + Attributes: + id (str): Global unique ID of application release diff (generated on creation) + from_release_id (str): ID of application release the diff is from + to_release_id (str): ID of application release the diff is to + file (ApplicationDiffFileStats): + created_at (datetime.datetime): + updated_at (datetime.datetime): + """ + + id: str + from_release_id: str + to_release_id: str + file: ApplicationDiffFileStats + 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 + + from_release_id = self.from_release_id + + to_release_id = self.to_release_id + + file = self.file.to_dict() + + created_at = self.created_at.isoformat() + + updated_at = self.updated_at.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "fromReleaseId": from_release_id, + "toReleaseId": to_release_id, + "file": file, + "createdAt": created_at, + "updatedAt": updated_at, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.application_diff_file_stats import ApplicationDiffFileStats + + d = dict(src_dict) + id = d.pop("id") + + from_release_id = d.pop("fromReleaseId") + + to_release_id = d.pop("toReleaseId") + + file = ApplicationDiffFileStats.from_dict(d.pop("file")) + + created_at = isoparse(d.pop("createdAt")) + + updated_at = isoparse(d.pop("updatedAt")) + + application_release_diff = cls( + id=id, + from_release_id=from_release_id, + to_release_id=to_release_id, + file=file, + created_at=created_at, + updated_at=updated_at, + ) + + application_release_diff.additional_properties = d + return application_release_diff + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/application_release_file_stats.py b/src/infuse_iot/api_client/models/application_release_file_stats.py new file mode 100644 index 00000000..1db23930 --- /dev/null +++ b/src/infuse_iot/api_client/models/application_release_file_stats.py @@ -0,0 +1,85 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ApplicationReleaseFileStats") + + +@_attrs_define +class ApplicationReleaseFileStats: + """ + Attributes: + coap_path (str): CoAP path of file Example: /release/12345. + len_ (int): Length of file in bytes + crc (int): CRC32 of file + diff_len (int): How much of the file is immutable and can be used to generate diffs. + """ + + coap_path: str + len_: int + crc: int + diff_len: int + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + coap_path = self.coap_path + + len_ = self.len_ + + crc = self.crc + + diff_len = self.diff_len + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "coapPath": coap_path, + "len": len_, + "crc": crc, + "diffLen": diff_len, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + coap_path = d.pop("coapPath") + + len_ = d.pop("len") + + crc = d.pop("crc") + + diff_len = d.pop("diffLen") + + application_release_file_stats = cls( + coap_path=coap_path, + len_=len_, + crc=crc, + diff_len=diff_len, + ) + + application_release_file_stats.additional_properties = d + return application_release_file_stats + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/application_release_version.py b/src/infuse_iot/api_client/models/application_release_version.py new file mode 100644 index 00000000..00136a5f --- /dev/null +++ b/src/infuse_iot/api_client/models/application_release_version.py @@ -0,0 +1,85 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ApplicationReleaseVersion") + + +@_attrs_define +class ApplicationReleaseVersion: + """ + Attributes: + major (int): Major version number of application release + minor (int): Minor version number of application release + revision (int): Revision version number of application release + build_num (int): Build version number of application release + """ + + 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: Mapping[str, Any]) -> T: + d = dict(src_dict) + major = d.pop("major") + + minor = d.pop("minor") + + revision = d.pop("revision") + + build_num = d.pop("buildNum") + + application_release_version = cls( + major=major, + minor=minor, + revision=revision, + build_num=build_num, + ) + + application_release_version.additional_properties = d + return application_release_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 c74fa6ac..790e66cf 100644 --- a/src/infuse_iot/api_client/models/board.py +++ b/src/infuse_iot/api_client/models/board.py @@ -27,6 +27,7 @@ class Board: description (str): Description of board Example: Extended description of board. soc (str): System on Chip (SoC) of board Example: nRF9151. organisation_id (UUID): ID of organisation for board to exist in + public (bool): Whether the board is public (devices from other organisations can use it) Default: False. metadata_fields (list[MetadataField]): Metadata fields for board Example: [{'name': 'Field Name', 'required': True, 'unique': False}]. """ @@ -39,6 +40,7 @@ class Board: soc: str organisation_id: UUID metadata_fields: list[MetadataField] + public: bool = False additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -56,6 +58,8 @@ def to_dict(self) -> dict[str, Any]: organisation_id = str(self.organisation_id) + public = self.public + metadata_fields = [] for componentsschemas_board_metadata_fields_item_data in self.metadata_fields: componentsschemas_board_metadata_fields_item = componentsschemas_board_metadata_fields_item_data.to_dict() @@ -72,6 +76,7 @@ def to_dict(self) -> dict[str, Any]: "description": description, "soc": soc, "organisationId": organisation_id, + "public": public, "metadataFields": metadata_fields, } ) @@ -97,6 +102,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: organisation_id = UUID(d.pop("organisationId")) + public = d.pop("public") + metadata_fields = [] _metadata_fields = d.pop("metadataFields") for componentsschemas_board_metadata_fields_item_data in _metadata_fields: @@ -114,6 +121,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: description=description, soc=soc, organisation_id=organisation_id, + public=public, metadata_fields=metadata_fields, ) diff --git a/src/infuse_iot/api_client/models/create_release_body.py b/src/infuse_iot/api_client/models/create_release_body.py new file mode 100644 index 00000000..e4f89647 --- /dev/null +++ b/src/infuse_iot/api_client/models/create_release_body.py @@ -0,0 +1,146 @@ +from __future__ import annotations + +from collections.abc import Mapping +from io import BytesIO +from typing import Any, TypeVar +from uuid import UUID + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from .. import types +from ..types import File + +T = TypeVar("T", bound="CreateReleaseBody") + + +@_attrs_define +class CreateReleaseBody: + """ + Attributes: + file (File): + file_diff_len (str): + version_major (str): + version_minor (str): + version_revision (str): + version_build_num (str): + board_id (UUID): ID of board the application release is for + board_target (str): Revision of board the application release is for + """ + + file: File + file_diff_len: str + version_major: str + version_minor: str + version_revision: str + version_build_num: str + board_id: UUID + board_target: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + file = self.file.to_tuple() + + file_diff_len = self.file_diff_len + + version_major = self.version_major + + version_minor = self.version_minor + + version_revision = self.version_revision + + version_build_num = self.version_build_num + + board_id = str(self.board_id) + + board_target = self.board_target + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "file": file, + "fileDiffLen": file_diff_len, + "versionMajor": version_major, + "versionMinor": version_minor, + "versionRevision": version_revision, + "versionBuildNum": version_build_num, + "boardId": board_id, + "boardTarget": board_target, + } + ) + + return field_dict + + def to_multipart(self) -> types.RequestFiles: + files: types.RequestFiles = [] + + files.append(("file", self.file.to_tuple())) + + files.append(("fileDiffLen", (None, str(self.file_diff_len).encode(), "text/plain"))) + + files.append(("versionMajor", (None, str(self.version_major).encode(), "text/plain"))) + + files.append(("versionMinor", (None, str(self.version_minor).encode(), "text/plain"))) + + files.append(("versionRevision", (None, str(self.version_revision).encode(), "text/plain"))) + + files.append(("versionBuildNum", (None, str(self.version_build_num).encode(), "text/plain"))) + + files.append(("boardId", (None, str(self.board_id), "text/plain"))) + + files.append(("boardTarget", (None, str(self.board_target).encode(), "text/plain"))) + + for prop_name, prop in self.additional_properties.items(): + files.append((prop_name, (None, str(prop).encode(), "text/plain"))) + + return files + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + file = File(payload=BytesIO(d.pop("file"))) + + file_diff_len = d.pop("fileDiffLen") + + version_major = d.pop("versionMajor") + + version_minor = d.pop("versionMinor") + + version_revision = d.pop("versionRevision") + + version_build_num = d.pop("versionBuildNum") + + board_id = UUID(d.pop("boardId")) + + board_target = d.pop("boardTarget") + + create_release_body = cls( + file=file, + file_diff_len=file_diff_len, + version_major=version_major, + version_minor=version_minor, + version_revision=version_revision, + version_build_num=version_build_num, + board_id=board_id, + board_target=board_target, + ) + + create_release_body.additional_properties = d + return create_release_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/create_release_diff_body.py b/src/infuse_iot/api_client/models/create_release_diff_body.py new file mode 100644 index 00000000..f8ab63ab --- /dev/null +++ b/src/infuse_iot/api_client/models/create_release_diff_body.py @@ -0,0 +1,85 @@ +from __future__ import annotations + +from collections.abc import Mapping +from io import BytesIO +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from .. import types +from ..types import File + +T = TypeVar("T", bound="CreateReleaseDiffBody") + + +@_attrs_define +class CreateReleaseDiffBody: + """ + Attributes: + file (File): + from_release_id (str): + """ + + file: File + from_release_id: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + file = self.file.to_tuple() + + from_release_id = self.from_release_id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "file": file, + "fromReleaseId": from_release_id, + } + ) + + return field_dict + + def to_multipart(self) -> types.RequestFiles: + files: types.RequestFiles = [] + + files.append(("file", self.file.to_tuple())) + + files.append(("fromReleaseId", (None, str(self.from_release_id).encode(), "text/plain"))) + + for prop_name, prop in self.additional_properties.items(): + files.append((prop_name, (None, str(prop).encode(), "text/plain"))) + + return files + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + file = File(payload=BytesIO(d.pop("file"))) + + from_release_id = d.pop("fromReleaseId") + + create_release_diff_body = cls( + file=file, + from_release_id=from_release_id, + ) + + create_release_diff_body.additional_properties = d + return create_release_diff_body + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/infuse_iot/api_client/models/definitions_kv_definitions.py b/src/infuse_iot/api_client/models/definitions_kv_definitions.py index 261c224a..6314253b 100644 --- a/src/infuse_iot/api_client/models/definitions_kv_definitions.py +++ b/src/infuse_iot/api_client/models/definitions_kv_definitions.py @@ -20,6 +20,7 @@ class DefinitionsKVDefinitions: additional_properties: dict[str, DefinitionsKVDefinition] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() diff --git a/src/infuse_iot/api_client/models/definitions_kv_structs.py b/src/infuse_iot/api_client/models/definitions_kv_structs.py index 3bf749f6..75d3a741 100644 --- a/src/infuse_iot/api_client/models/definitions_kv_structs.py +++ b/src/infuse_iot/api_client/models/definitions_kv_structs.py @@ -20,6 +20,7 @@ class DefinitionsKVStructs: additional_properties: dict[str, DefinitionsStructDefinition] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() diff --git a/src/infuse_iot/api_client/models/definitions_rpc_commands.py b/src/infuse_iot/api_client/models/definitions_rpc_commands.py index b042f301..4aeac715 100644 --- a/src/infuse_iot/api_client/models/definitions_rpc_commands.py +++ b/src/infuse_iot/api_client/models/definitions_rpc_commands.py @@ -20,6 +20,7 @@ class DefinitionsRPCCommands: additional_properties: dict[str, DefinitionsRPCCommand] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() diff --git a/src/infuse_iot/api_client/models/definitions_rpc_enums.py b/src/infuse_iot/api_client/models/definitions_rpc_enums.py index 6735b34e..4488d7a4 100644 --- a/src/infuse_iot/api_client/models/definitions_rpc_enums.py +++ b/src/infuse_iot/api_client/models/definitions_rpc_enums.py @@ -20,6 +20,7 @@ class DefinitionsRPCEnums: additional_properties: dict[str, DefinitionsEnumDefinition] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() diff --git a/src/infuse_iot/api_client/models/definitions_rpc_structs.py b/src/infuse_iot/api_client/models/definitions_rpc_structs.py index fd759a68..d3c8d5af 100644 --- a/src/infuse_iot/api_client/models/definitions_rpc_structs.py +++ b/src/infuse_iot/api_client/models/definitions_rpc_structs.py @@ -20,6 +20,7 @@ class DefinitionsRPCStructs: additional_properties: dict[str, DefinitionsStructDefinition] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() diff --git a/src/infuse_iot/api_client/models/definitions_tdf_definitions.py b/src/infuse_iot/api_client/models/definitions_tdf_definitions.py index dfa4c9bb..97cc7645 100644 --- a/src/infuse_iot/api_client/models/definitions_tdf_definitions.py +++ b/src/infuse_iot/api_client/models/definitions_tdf_definitions.py @@ -20,6 +20,7 @@ class DefinitionsTDFDefinitions: additional_properties: dict[str, DefinitionsTDFDefinition] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() diff --git a/src/infuse_iot/api_client/models/definitions_tdf_structs.py b/src/infuse_iot/api_client/models/definitions_tdf_structs.py index 7690b2c9..77317d18 100644 --- a/src/infuse_iot/api_client/models/definitions_tdf_structs.py +++ b/src/infuse_iot/api_client/models/definitions_tdf_structs.py @@ -20,6 +20,7 @@ class DefinitionsTDFStructs: additional_properties: dict[str, DefinitionsStructDefinition] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() diff --git a/src/infuse_iot/api_client/models/device_kv_entry_decoded.py b/src/infuse_iot/api_client/models/device_kv_entry_decoded.py index f82cc71e..da9eccf8 100644 --- a/src/infuse_iot/api_client/models/device_kv_entry_decoded.py +++ b/src/infuse_iot/api_client/models/device_kv_entry_decoded.py @@ -16,6 +16,7 @@ class DeviceKVEntryDecoded: 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) diff --git a/src/infuse_iot/api_client/models/device_kv_entry_update.py b/src/infuse_iot/api_client/models/device_kv_entry_update.py index 9710eb54..84bcb59e 100644 --- a/src/infuse_iot/api_client/models/device_kv_entry_update.py +++ b/src/infuse_iot/api_client/models/device_kv_entry_update.py @@ -21,35 +21,34 @@ @_attrs_define class DeviceKVEntryUpdate: - """ + """Device KV entry update - note for write-only entries the data/decoded fields will not be returned, only CRC. + Attributes: - data (str): Raw entry data as a base64 encoded string (must provide either data or decoded) id (UUID): ID of update key_id (int): Key id crc (int): CRC32 of entry update value status (DeviceEntryUpdateStatus): Status of device KV entry update created_at (datetime.datetime): updated_at (datetime.datetime): + data (str | Unset): Raw entry data as a base64 encoded string (must provide either data or decoded) decoded (NewDeviceKVEntryUpdateDecoded | Unset): Decoded entry value (must provide either data or decoded) last_error (str | Unset): Last error message if update failed last_attempt_at (datetime.datetime | Unset): Time of last attempt """ - data: str id: UUID key_id: int crc: int status: DeviceEntryUpdateStatus created_at: datetime.datetime updated_at: datetime.datetime + data: str | Unset = UNSET decoded: NewDeviceKVEntryUpdateDecoded | Unset = UNSET last_error: str | Unset = UNSET last_attempt_at: datetime.datetime | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - data = self.data - id = str(self.id) key_id = self.key_id @@ -62,6 +61,8 @@ def to_dict(self) -> dict[str, Any]: updated_at = self.updated_at.isoformat() + data = self.data + decoded: dict[str, Any] | Unset = UNSET if not isinstance(self.decoded, Unset): decoded = self.decoded.to_dict() @@ -76,7 +77,6 @@ def to_dict(self) -> dict[str, Any]: field_dict.update(self.additional_properties) field_dict.update( { - "data": data, "id": id, "keyId": key_id, "crc": crc, @@ -85,6 +85,8 @@ def to_dict(self) -> dict[str, Any]: "updatedAt": updated_at, } ) + if data is not UNSET: + field_dict["data"] = data if decoded is not UNSET: field_dict["decoded"] = decoded if last_error is not UNSET: @@ -99,8 +101,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.new_device_kv_entry_update_decoded import NewDeviceKVEntryUpdateDecoded d = dict(src_dict) - data = d.pop("data") - id = UUID(d.pop("id")) key_id = d.pop("keyId") @@ -113,6 +113,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: updated_at = isoparse(d.pop("updatedAt")) + data = d.pop("data", UNSET) + _decoded = d.pop("decoded", UNSET) decoded: NewDeviceKVEntryUpdateDecoded | Unset if isinstance(_decoded, Unset): @@ -130,13 +132,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: last_attempt_at = isoparse(_last_attempt_at) device_kv_entry_update = cls( - data=data, id=id, key_id=key_id, crc=crc, status=status, created_at=created_at, updated_at=updated_at, + data=data, decoded=decoded, last_error=last_error, last_attempt_at=last_attempt_at, diff --git a/src/infuse_iot/api_client/models/device_metadata.py b/src/infuse_iot/api_client/models/device_metadata.py index 425a1764..14ef95ab 100644 --- a/src/infuse_iot/api_client/models/device_metadata.py +++ b/src/infuse_iot/api_client/models/device_metadata.py @@ -21,6 +21,7 @@ class DeviceMetadata: additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) diff --git a/src/infuse_iot/api_client/models/device_state.py b/src/infuse_iot/api_client/models/device_state.py index 9a875bea..c95f727d 100644 --- a/src/infuse_iot/api_client/models/device_state.py +++ b/src/infuse_iot/api_client/models/device_state.py @@ -14,6 +14,7 @@ if TYPE_CHECKING: from ..models.algorithm import Algorithm from ..models.application_version import ApplicationVersion + from ..models.uplink_route import UplinkRoute T = TypeVar("T", bound="DeviceState") @@ -29,7 +30,10 @@ class DeviceState: application_version (ApplicationVersion | Unset): Application version algorithms (list[Algorithm] | Unset): Last announced algorithms last_route_interface (RouteType | Unset): Interface of route - last_route_udp_address (str | Unset): UDP address of last packet sent by device + last_route_udp_address (str | Unset): Address of last packet sent directly via UDP + last_route_udp_time (datetime.datetime | Unset): Time of last packet sent directly via UDP + last_route (UplinkRoute | Unset): + last_route_time (datetime.datetime | Unset): Time of last packet sent by device (via any route) """ created_at: datetime.datetime @@ -39,6 +43,9 @@ class DeviceState: algorithms: list[Algorithm] | Unset = UNSET last_route_interface: RouteType | Unset = UNSET last_route_udp_address: str | Unset = UNSET + last_route_udp_time: datetime.datetime | Unset = UNSET + last_route: UplinkRoute | Unset = UNSET + last_route_time: datetime.datetime | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -65,6 +72,18 @@ def to_dict(self) -> dict[str, Any]: last_route_udp_address = self.last_route_udp_address + last_route_udp_time: str | Unset = UNSET + if not isinstance(self.last_route_udp_time, Unset): + last_route_udp_time = self.last_route_udp_time.isoformat() + + last_route: dict[str, Any] | Unset = UNSET + if not isinstance(self.last_route, Unset): + last_route = self.last_route.to_dict() + + last_route_time: str | Unset = UNSET + if not isinstance(self.last_route_time, Unset): + last_route_time = self.last_route_time.isoformat() + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( @@ -83,6 +102,12 @@ def to_dict(self) -> dict[str, Any]: field_dict["lastRouteInterface"] = last_route_interface if last_route_udp_address is not UNSET: field_dict["lastRouteUdpAddress"] = last_route_udp_address + if last_route_udp_time is not UNSET: + field_dict["lastRouteUdpTime"] = last_route_udp_time + if last_route is not UNSET: + field_dict["lastRoute"] = last_route + if last_route_time is not UNSET: + field_dict["lastRouteTime"] = last_route_time return field_dict @@ -90,6 +115,7 @@ def to_dict(self) -> dict[str, Any]: def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.algorithm import Algorithm from ..models.application_version import ApplicationVersion + from ..models.uplink_route import UplinkRoute d = dict(src_dict) created_at = isoparse(d.pop("createdAt")) @@ -123,6 +149,27 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: last_route_udp_address = d.pop("lastRouteUdpAddress", UNSET) + _last_route_udp_time = d.pop("lastRouteUdpTime", UNSET) + last_route_udp_time: datetime.datetime | Unset + if isinstance(_last_route_udp_time, Unset): + last_route_udp_time = UNSET + else: + last_route_udp_time = isoparse(_last_route_udp_time) + + _last_route = d.pop("lastRoute", UNSET) + last_route: UplinkRoute | Unset + if isinstance(_last_route, Unset): + last_route = UNSET + else: + last_route = UplinkRoute.from_dict(_last_route) + + _last_route_time = d.pop("lastRouteTime", UNSET) + last_route_time: datetime.datetime | Unset + if isinstance(_last_route_time, Unset): + last_route_time = UNSET + else: + last_route_time = isoparse(_last_route_time) + device_state = cls( created_at=created_at, updated_at=updated_at, @@ -131,6 +178,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: algorithms=algorithms, last_route_interface=last_route_interface, last_route_udp_address=last_route_udp_address, + last_route_udp_time=last_route_udp_time, + last_route=last_route, + last_route_time=last_route_time, ) device_state.additional_properties = d diff --git a/src/infuse_iot/api_client/models/generate_api_key_body_resource_perms.py b/src/infuse_iot/api_client/models/generate_api_key_body_resource_perms.py index ea322d97..39f0ffd2 100644 --- a/src/infuse_iot/api_client/models/generate_api_key_body_resource_perms.py +++ b/src/infuse_iot/api_client/models/generate_api_key_body_resource_perms.py @@ -18,6 +18,7 @@ class GenerateAPIKeyBodyResourcePerms: additional_properties: dict[str, list[APIKeyResourcePerm]] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = [] diff --git a/src/infuse_iot/api_client/models/new_application.py b/src/infuse_iot/api_client/models/new_application.py new file mode 100644 index 00000000..648d82a4 --- /dev/null +++ b/src/infuse_iot/api_client/models/new_application.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="NewApplication") + + +@_attrs_define +class NewApplication: + """ + Attributes: + id (int): Application ID (must be unique within organisation) + name (str): Unique name of application + description (str): Description of application + """ + + id: int + name: str + description: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + name = self.name + + description = self.description + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "name": name, + "description": description, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id") + + name = d.pop("name") + + description = d.pop("description") + + new_application = cls( + id=id, + name=name, + description=description, + ) + + new_application.additional_properties = d + return new_application + + @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 ce092b8a..d8a7a269 100644 --- a/src/infuse_iot/api_client/models/new_board.py +++ b/src/infuse_iot/api_client/models/new_board.py @@ -24,6 +24,7 @@ class NewBoard: description (str): Description of board Example: Extended description of board. soc (str): System on Chip (SoC) of board Example: nRF9151. organisation_id (UUID): ID of organisation for board to exist in + public (bool | Unset): Whether the board is public (devices from other organisations can use it) Default: False. metadata_fields (list[MetadataField] | Unset): Metadata fields for board Example: [{'name': 'Field Name', 'required': True, 'unique': False}]. """ @@ -32,6 +33,7 @@ class NewBoard: description: str soc: str organisation_id: UUID + public: bool | Unset = False metadata_fields: list[MetadataField] | Unset = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) @@ -44,6 +46,8 @@ def to_dict(self) -> dict[str, Any]: organisation_id = str(self.organisation_id) + public = self.public + metadata_fields: list[dict[str, Any]] | Unset = UNSET if not isinstance(self.metadata_fields, Unset): metadata_fields = [] @@ -63,6 +67,8 @@ def to_dict(self) -> dict[str, Any]: "organisationId": organisation_id, } ) + if public is not UNSET: + field_dict["public"] = public if metadata_fields is not UNSET: field_dict["metadataFields"] = metadata_fields @@ -81,6 +87,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: organisation_id = UUID(d.pop("organisationId")) + public = d.pop("public", UNSET) + _metadata_fields = d.pop("metadataFields", UNSET) metadata_fields: list[MetadataField] | Unset = UNSET if _metadata_fields is not UNSET: @@ -97,6 +105,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: description=description, soc=soc, organisation_id=organisation_id, + public=public, metadata_fields=metadata_fields, ) diff --git a/src/infuse_iot/api_client/models/new_device_kv_entry_update_decoded.py b/src/infuse_iot/api_client/models/new_device_kv_entry_update_decoded.py index b55b1bac..d08fdc3e 100644 --- a/src/infuse_iot/api_client/models/new_device_kv_entry_update_decoded.py +++ b/src/infuse_iot/api_client/models/new_device_kv_entry_update_decoded.py @@ -16,6 +16,7 @@ class NewDeviceKVEntryUpdateDecoded: 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) diff --git a/src/infuse_iot/api_client/models/rpc_params.py b/src/infuse_iot/api_client/models/rpc_params.py index 8d86c789..a83edb35 100644 --- a/src/infuse_iot/api_client/models/rpc_params.py +++ b/src/infuse_iot/api_client/models/rpc_params.py @@ -22,6 +22,7 @@ class RPCParams: 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) From 45fc6a8a5272627c2ce2a0cba925e92cb462d867 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Wed, 3 Jun 2026 14:51:41 +1000 Subject: [PATCH 2/5] tools: update cloud API response handling Update cloud API response handling due to schema updates. Signed-off-by: Jordan Yates --- src/infuse_iot/tools/cloud.py | 57 +++++++++++++++++-------------- src/infuse_iot/tools/provision.py | 10 +++--- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/infuse_iot/tools/cloud.py b/src/infuse_iot/tools/cloud.py index 3ae9e297..b8edc2f9 100644 --- a/src/infuse_iot/tools/cloud.py +++ b/src/infuse_iot/tools/cloud.py @@ -6,12 +6,11 @@ __copyright__ = "Copyright 2024, Embeint Holdings Pty Ltd" import sys -from http import HTTPStatus -from json import loads from typing import Any from tabulate import tabulate +import infuse_iot.api_client.models as models from infuse_iot.api_client import Client from infuse_iot.api_client.api.board import ( create_board, @@ -72,7 +71,7 @@ def list(self, client: Client): org_list = [] orgs = get_all_organisations.sync(client=client) - if isinstance(orgs, Error) or orgs is None: + if isinstance(orgs, models.Error) or orgs is None: sys.exit(f"Organisation query failed {orgs}") for o in orgs: org_list.append([o.name, o.id]) @@ -87,15 +86,15 @@ def list(self, client: Client): def create(self, client: Client): rsp = create_organisation.sync_detailed( client=client, - body=NewOrganisation(self.args.name), + body=models.NewOrganisation(self.args.name), ) - if rsp.status_code == HTTPStatus.CREATED: - assert rsp.parsed is not None - print(f"Created organisation {rsp.parsed.name} with ID {rsp.parsed.id}") + if rsp.parsed is None: + print(f"<{rsp.status_code}>: {rsp.content.decode('utf-8')}") + elif isinstance(rsp.parsed, models.Error): + print(f"<{rsp.status_code}>: {rsp.parsed.message}") else: - c = loads(rsp.content.decode("utf-8")) - print(f"<{rsp.status_code}>: {c['message']}") + print(f"Created organisation {rsp.parsed.name} with ID {rsp.parsed.id}") class Boards(CloudSubCommand): @@ -124,11 +123,11 @@ def list(self, client: Client): board_list = [] orgs = get_all_organisations.sync(client=client) - if isinstance(orgs, Error) or orgs is None: + if isinstance(orgs, models.Error) or orgs is None: sys.exit(f"Organisation query failed {orgs}") for org in orgs: boards = get_boards.sync(client=client, organisation_id=org.id) - if isinstance(boards, Error) or boards is None: + if isinstance(boards, models.Error) or boards is None: sys.exit(f"Boards query failed {boards}") for b in boards: @@ -144,19 +143,20 @@ def list(self, client: Client): def create(self, client: Client): rsp = create_board.sync_detailed( client=client, - body=NewBoard( + body=models.NewBoard( name=self.args.name, description=self.args.desc, soc=self.args.soc, organisation_id=self.args.org, ), ) - if rsp.status_code == HTTPStatus.CREATED: - assert rsp.parsed is not None - print(f"Created board {rsp.parsed.name} with ID {rsp.parsed.id}") + + if rsp.parsed is None: + print(f"<{rsp.status_code}>: {rsp.content.decode('utf-8')}") + elif isinstance(rsp.parsed, models.Error): + print(f"<{rsp.status_code}>: {rsp.parsed.message}") else: - c = loads(rsp.content.decode("utf-8")) - print(f"<{rsp.status_code}>: {c['message']}") + print(f"Created board {rsp.parsed.name} with ID {rsp.parsed.id}") class Device(CloudSubCommand): @@ -185,6 +185,8 @@ def info(self, client: Client): info = get_device_by_device_id.sync(client=client, device_id=id_str) if info is None: sys.exit(f"No device with Infuse-IoT ID {id_str} found") + elif isinstance(info, models.Error): + sys.exit(f"<{info.code}>: {info.message}") metadata: list[tuple[str, Any]] = [] if info.metadata: metadata = [(f"Metadata.{k}", v) for k, v in info.metadata.additional_properties.items()] @@ -198,13 +200,16 @@ def info(self, client: Client): table: list[tuple[str, Any]] = [ ("UUID", info.id), ("MCU ID", info.mcu_id), - ("Organisation", f"{info.organisation_id} ({org.name if org else 'Unknown'})"), - ("Board", f"{info.board_id} ({board.name if board else 'Unknown'})"), + ( + "Organisation", + f"{info.organisation_id} ({org.name if isinstance(org, models.Organisation) else 'Unknown'})", + ), + ("Board", f"{info.board_id} ({board.name if isinstance(board, models.Board) else 'Unknown'})"), ("Created", info.created_at), ("Updated", info.updated_at), *metadata, ] - if state is not None: + if isinstance(state, models.DeviceState): v = state.application_version table += [ @@ -215,7 +220,7 @@ def info(self, client: Client): table += [("Application ID", f"0x{state.application_id:08x}")] if v: table += [("Version", f"{v.major}.{v.minor}.{v.revision}+{v.build_num:08x}")] - if route is not None: + if isinstance(route, models.UplinkRoute): table += [ ("~~~Latest Route~~~", ""), ("Interface", route.interface.upper()), @@ -263,7 +268,7 @@ def kv_state(self, client: Client): id_str = f"{id_int:016x}" kv_state = get_device_kv_entries_by_device_id.sync(client=client, device_id=id_str) - if kv_state is None: + if not isinstance(kv_state, list): print(f"Unable to query KV state for {id_str}") return @@ -307,12 +312,14 @@ def run(self): def list(self, client: Client): files = get_coap_files.sync(client=client) - if isinstance(files, COAPFilesList): + if files is None: + print("Failed to retrieve file list (No response)") + elif isinstance(files, models.Error): + print(f"<{files.code}>: {files.message}") + else: sorted_list: list[str] = sorted(files.filenames) print("CoAP Files:") print("\t" + "\n\t".join(sorted_list)) - else: - print(f"Failed to retrieve file list {files}") class SubCommand(InfuseCommand): diff --git a/src/infuse_iot/tools/provision.py b/src/infuse_iot/tools/provision.py index 21d2893f..daa24604 100644 --- a/src/infuse_iot/tools/provision.py +++ b/src/infuse_iot/tools/provision.py @@ -143,9 +143,8 @@ def run(self): response = get_device_by_soc_and_mcu_id.sync_detailed( client=client, soc=interface.soc_name, mcu_id=hardware_id_str ) - if response.status_code == HTTPStatus.OK: + if isinstance(response.parsed, Device): # Device found, fall through - assert isinstance(response.parsed, Device) assert isinstance(response.parsed.device_id, str) self._org = response.parsed.organisation_id self._board = response.parsed.board_id @@ -166,7 +165,11 @@ def run(self): response = get_device_by_soc_and_mcu_id.sync_detailed( client=client, soc=interface.soc_name, mcu_id=hardware_id_str ) - if response.status_code != HTTPStatus.OK: + if isinstance(response.parsed, Error): + err = "Failed to query device after creation:\n" + err += f"\t<{response.status_code}> {response.parsed.message}" + sys.exit(err) + elif response.parsed is None: err = "Failed to query device after creation:\n" err += f"\t<{response.status_code}> {response.content.decode('utf-8')}" sys.exit(err) @@ -175,7 +178,6 @@ def run(self): err += f"\t<{response.status_code}> {response.content.decode('utf-8')}" sys.exit(err) - assert response.parsed is not None assert isinstance(response.parsed.device_id, str) # Compare current flash contents to desired flash contents cloud_id = int(response.parsed.device_id, 16) From 21c51896959f97f47cd7b1191f5c073920f58bc8 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Wed, 3 Jun 2026 14:01:34 +1000 Subject: [PATCH 3/5] util: version: version parsing helper Add a helper class for parsing version strings and test. Signed-off-by: Jordan Yates --- src/infuse_iot/util/version.py | 37 ++++++++++++++++++++++++++++++++++ tests/util/test_version.py | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/infuse_iot/util/version.py create mode 100644 tests/util/test_version.py diff --git a/src/infuse_iot/util/version.py b/src/infuse_iot/util/version.py new file mode 100644 index 00000000..5e61057d --- /dev/null +++ b/src/infuse_iot/util/version.py @@ -0,0 +1,37 @@ +#!/usr/bin/env + + +class Version: + def __init__(self, major: int, minor: int, revision: int, build_num: int): + self.major = major + self.minor = minor + self.revision = revision + self.build_num = build_num + + @classmethod + def from_string(cls, version_string: str): + "Convert 'x.y.z+rev' string to version instance" + + rev_split = version_string.split("+") + if len(rev_split) != 2: + raise ValueError(f"'{version_string}' is not a valid version string") + ver_split = rev_split[0].split(".") + if len(ver_split) != 3: + raise ValueError(f"'{version_string}' is not a valid version string") + return cls(int(ver_split[0]), int(ver_split[1]), int(ver_split[2]), int(rev_split[1], 16)) + + def __str__(self): + return f"{self.major}.{self.minor}.{self.revision}+{self.build_num:08x}" + + def __hash__(self): + return self.major << 56 | self.minor << 48 | self.revision << 32 | self.build_num + + def __eq__(self, other): + if not isinstance(other, Version): + raise NotImplementedError + return ( + self.major == other.major + and self.minor == other.minor + and self.revision == other.revision + and self.build_num == other.build_num + ) diff --git a/tests/util/test_version.py b/tests/util/test_version.py new file mode 100644 index 00000000..1ff19883 --- /dev/null +++ b/tests/util/test_version.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import os + +import pytest + +from infuse_iot.util.version import Version + +assert "TOXTEMPDIR" in os.environ, "you must run these tests using tox" + + +def test_version_parsing(): + with pytest.raises(ValueError): + Version.from_string("random string") + with pytest.raises(ValueError): + Version.from_string("1.2.3") + with pytest.raises(ValueError): + Version.from_string("1.2+aaaaaaaa") + + def equality(str, major, minor, rev, build): + from_str = Version.from_string("1.2.3+aaaaaaaa") + from_int = Version(1, 2, 3, 0xAAAAAAAA) + assert from_str == from_int + assert hash(from_str) == hash(from_int) + + equality("1.2.3+aaaaaaaa", 1, 2, 3, 0xAAAAAAAA) + equality("10.2.3+12345678", 10, 2, 3, 0x12345678) + equality("1.20.354+50", 1, 20, 354, 0x50) + + def round_trip(string: str): + assert str(Version.from_string(string)) == string + + round_trip("1.2.3+aaaaaaaa") + round_trip("10.2.3+12345678") + round_trip("2.20.1+00000aaa") From 0c3b9ce3770e18a8ef386c521061e1dc0335449e Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Wed, 3 Jun 2026 14:03:27 +1000 Subject: [PATCH 4/5] util: console: helpers for user input Add a helper function for requesting confirmation from the user before performing some action and requesting a response in a loop. Signed-off-by: Jordan Yates --- src/infuse_iot/util/console.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/infuse_iot/util/console.py b/src/infuse_iot/util/console.py index 86499935..0b1126cc 100644 --- a/src/infuse_iot/util/console.py +++ b/src/infuse_iot/util/console.py @@ -88,3 +88,27 @@ def choose_one(title: str, options: list[str]) -> tuple[int, str]: pass return idx, options[idx] + + +def user_confirm(question: str) -> bool: + """Ask a question of the user and get confirmation""" + + yes_options = ["Y", "y", "Yes", "yes"] + no_options = ["N", "n", "No", "no"] + + print(question) + while True: + rsp = input("Y/N:") + if rsp in yes_options: + return True + elif rsp in no_options: + return False + + +def user_response(prompt: str) -> str: + """Get a response from the user""" + rsp = "" + + while rsp == "": + rsp = input(prompt) + return rsp From 5958631d4e4897835451dbe2c0c8909f74dc5227 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 2 Jun 2026 16:53:52 +1000 Subject: [PATCH 5/5] tools: cloud: application/release CLI Add subcommands to `cloud` to display applications and releases and upload releases from a release folder. Signed-off-by: Jordan Yates --- src/infuse_iot/tools/cloud.py | 250 +++++++++++++++++++++++++++++++++- 1 file changed, 248 insertions(+), 2 deletions(-) diff --git a/src/infuse_iot/tools/cloud.py b/src/infuse_iot/tools/cloud.py index b8edc2f9..4e015ed9 100644 --- a/src/infuse_iot/tools/cloud.py +++ b/src/infuse_iot/tools/cloud.py @@ -5,13 +5,23 @@ __author__ = "Jordan Yates" __copyright__ = "Copyright 2024, Embeint Holdings Pty Ltd" +import glob import sys from typing import Any +from uuid import UUID from tabulate import tabulate import infuse_iot.api_client.models as models from infuse_iot.api_client import Client +from infuse_iot.api_client.api.application import ( + create_application, + create_release, + create_release_diff, + get_application_by_organisation_id_and_application_id, + get_applications_by_organisation_id, + get_releases_by_organisation_id_and_application_id, +) from infuse_iot.api_client.api.board import ( create_board, get_board_by_id, @@ -30,10 +40,12 @@ get_all_organisations, get_organisation_by_id, ) -from infuse_iot.api_client.models import COAPFilesList, Error, NewBoard, NewOrganisation -from infuse_iot.api_client.types import Unset +from infuse_iot.api_client.types import File, Unset from infuse_iot.commands import InfuseCommand from infuse_iot.credentials import get_api_key +from infuse_iot.util.argparse import ValidRelease +from infuse_iot.util.console import choose_one, user_confirm, user_response +from infuse_iot.util.version import Version class CloudSubCommand: @@ -322,6 +334,239 @@ def list(self, client: Client): print("\t" + "\n\t".join(sorted_list)) +class Applications(CloudSubCommand): + @classmethod + def add_parser(cls, parser): + parser_coap = parser.add_parser("apps", help="Application release management") + parser_coap.set_defaults(command_class=cls) + + tool_parser = parser_coap.add_subparsers(title="commands", metavar="", required=True) + + list_parser = tool_parser.add_parser("list", help="List all application releases") + list_parser.add_argument("--org", "-o", type=str, required=True, help="Organisation ID") + list_parser.set_defaults(command_fn=cls.list) + + info_parser = tool_parser.add_parser("info", help="Display summary of application releases") + info_parser.add_argument("--org", "-o", type=str, required=True, help="Organisation ID") + info_parser.add_argument("--app", "-a", type=lambda x: int(x, 16), required=True, help="Application ID (hex)") + info_parser.set_defaults(command_fn=cls.info) + + upload_parser = tool_parser.add_parser("upload", help="Upload application release") + upload_parser.add_argument("--org", "-o", type=str, help="Organisation ID") + upload_parser.add_argument("--board", "-b", type=str, help="Board ID") + upload_parser.add_argument("--release", "-r", type=ValidRelease, required=True, help="Release to upload") + upload_parser.set_defaults(command_fn=cls.upload) + + def run(self): + with self.client() as client: + self.args.command_fn(self, client) + + def list(self, client: Client): + applications = get_applications_by_organisation_id.sync(client=client, id=UUID(self.args.org)) + + if not isinstance(applications, list): + print(f"Failed to retrieve application list {applications}") + return + + app_list = [] + for app in applications: + app_list.append( + [ + f"0x{app.id:08X}", + app.name, + app.description, + ] + ) + print( + tabulate( + app_list, + headers=["ID", "Name", "Description"], + ) + ) + + def info(self, client: Client): + releases = get_releases_by_organisation_id_and_application_id.sync( + client=client, id=UUID(self.args.org), application_id=self.args.app + ) + + if releases is None: + sys.exit("Failed to retrieve release list (No response)") + elif isinstance(releases, models.Error): + sys.exit(f"<{releases.code}>: {releases.message}") + + release_list = [] + for release in releases: + version = release.version + version_str = f"{version.major}.{version.minor}.{version.revision}+{version.build_num:08x}" + release_list.append( + [ + f"{release.board_target}", + version_str, + f"{release.id}", + f"{release.file.len_ / 1024:.2f} kB", + str(release.created_at), + ] + ) + print( + tabulate( + release_list, + headers=["Board Target", "Version", "ID", "Full OTA", "Created"], + ) + ) + + def upload(self, client: Client): + try: + self._board = UUID(self.args.board) if self.args.board else None + except ValueError: + sys.exit(f"Board ID: '{self.args.board}' is not a valid UUID") + try: + self._org = UUID(self.args.org) if self.args.org else None + except ValueError: + sys.exit(f"Organisation ID: '{self.args.org}' is not a valid UUID") + + release: ValidRelease = self.args.release + release_app_meta = release.metadata["application"] + name = release_app_meta["primary"] + app_id = release_app_meta["id"] + board_target = release_app_meta["board"] + version = Version.from_string(release_app_meta["version"]) + + if self._org is None: + orgs = get_all_organisations.sync(client=client) + if isinstance(orgs, models.Error) or orgs is None: + sys.exit(f"Organisation query failed {orgs}") + options = [f"{o.name:20s} ({o.id})" for o in orgs] + + idx, _val = choose_one("Organisation", options) + self._org = orgs[idx].id + self._org_name = orgs[idx].name + else: + org = get_organisation_by_id.sync(client=client, id=self._org) + if not isinstance(org, models.Organisation): + sys.exit(f"Failed to query org for ID {self._org}") + self._org_name = org.name + + if self._board is None: + boards = get_boards.sync(client=client, organisation_id=self._org) + if isinstance(boards, models.Error) or boards is None: + sys.exit(f"Board query failed {boards}") + options = [f"{b.name:20s} ({b.id})" for b in boards] + + idx, _val = choose_one("Board", options) + self._board = boards[idx].id + self._board_name = boards[idx].name + else: + board = get_board_by_id.sync(client=client, id=self._board) + if not isinstance(org, models.Board): + sys.exit(f"Failed to query board for ID {self._board}") + self._board_name = board.name + + application = get_application_by_organisation_id_and_application_id.sync( + client=client, id=self._org, application_id=app_id + ) + + if application is None: + dialog = f"Application 0x{app_id:08x} does not exist in organisation {self.args.org}, create?" + if not user_confirm(dialog): + return + print(f"Creating application 0x{app_id:08x} in organisation {self.args.org}") + description = user_response("Application description:") + body = models.NewApplication(id=app_id, name=name, description=description) + application = create_application.sync(client=client, id=self._org, body=body) + + if not isinstance(application, models.Application): + sys.exit(f"Unexpected internal type {type(application)}") + + ota_files = glob.glob(str(release.dir / "ota-*.bin")) + if len(ota_files) != 1: + sys.exit(f"Unexpected OTA file search result {ota_files}") + + releases = get_releases_by_organisation_id_and_application_id.sync( + client=client, + id=self._org, + application_id=app_id, + ) + if not isinstance(releases, list): + sys.exit(f"Unexpected release query result {releases}") + + cloud_release: None | models.ApplicationRelease = None + cloud_releases_by_version: dict[Version, models.ApplicationRelease] = {} + for r in releases: + v = Version(r.version.major, r.version.minor, r.version.revision, r.version.build_num) + cloud_releases_by_version[v] = r + if v == version: + print(f"Found release for application '0x{app_id:08x} {str(version)}' ({r.id})") + cloud_release = r + + if cloud_release is None: + dialog = ( + f"Create release for application '0x{app_id:08x} {str(version)}'" + + f" in organisation '{self._org_name}' for board '{self._board_name}'?" + ) + if not user_confirm(dialog): + return + + with open(ota_files[0], "rb") as f: + ota_file = File(f, ota_files[0], None) + + release_obj = models.CreateReleaseBody( + file=ota_file, + file_diff_len=str(0), + version_major=str(version.major), + version_minor=str(version.minor), + version_revision=str(version.revision), + version_build_num=str(version.build_num), + board_id=self._board, + board_target=board_target, + ) + + rsp = create_release.sync( + client=client, + id=self._org, + application_id=app_id, + body=release_obj, + ) + if rsp is None: + sys.exit("Create release: No response") + elif isinstance(rsp, models.Error): + sys.exit(f"<{rsp.code}>: {rsp.message}") + else: + print(f"Release created with ID '{rsp.id}'") + cloud_release = rsp + + # Upload any diffs + diff_folder = release.dir / "diffs" + if not diff_folder.exists(): + return + for path in diff_folder.iterdir(): + if not path.is_file() or path.suffix != ".bin": + continue + try: + diff_from_version = Version.from_string(path.stem) + except ValueError: + print(f"Couldn't parse diff files version '{path.stem}'") + continue + from_version = cloud_releases_by_version.get(diff_from_version) + if from_version is None: + print(f"Version {diff_from_version} doesn't exist on cloud") + continue + + with open(path, "rb") as f: + diff_file = File(f, str(path), None) + + create_body = models.CreateReleaseDiffBody(file=diff_file, from_release_id=from_version.id) + diff_rsp = create_release_diff.sync( + client=client, id=self._org, application_id=app_id, release_id=cloud_release.id, body=create_body + ) + prefix = f"{str(diff_from_version)} -> {str(version)}" + if isinstance(diff_rsp, models.Error): + print(f"{prefix}: <{diff_rsp.code}> {diff_rsp.message}") + elif isinstance(diff_rsp, models.ApplicationReleaseDiff): + print(f"{prefix}: Diff created with ID '{diff_rsp.id}'") + else: + print(f"{prefix}: No response") + + class SubCommand(InfuseCommand): NAME = "cloud" HELP = "Infuse-IoT cloud interaction" @@ -335,6 +580,7 @@ def add_parser(cls, parser): Boards.add_parser(subparser) Device.add_parser(subparser) Coap.add_parser(subparser) + Applications.add_parser(subparser) def __init__(self, args): self.tool = args.command_class(args)