Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__pycache__
*.egg-info
.vscode
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ classifiers = [
requires-python = ">=3.10"
dependencies = [
"argcomplete",
"aiohttp",
"attrs",
"cryptography",
"colorama",
Expand Down
194 changes: 194 additions & 0 deletions src/infuse_iot/api_client/api/default/get_devices_by_board_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
from http import HTTPStatus
from typing import Any, Dict, List, Optional, Union, cast

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.device import Device
from ...types import UNSET, Response, Unset


def _get_kwargs(
id: str,
*,
metadata_name: Union[Unset, str] = UNSET,
metadata_value: Union[Unset, str] = UNSET,
) -> Dict[str, Any]:
params: Dict[str, Any] = {}

params["metadataName"] = metadata_name

params["metadataValue"] = metadata_value

params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

_kwargs: Dict[str, Any] = {
"method": "get",
"url": f"/board/id/{id}/devices",
"params": params,
}

return _kwargs


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, List["Device"]]]:
if response.status_code == HTTPStatus.OK:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = Device.from_dict(response_200_item_data)

response_200.append(response_200_item)

return response_200
if response.status_code == HTTPStatus.NOT_FOUND:
response_404 = cast(Any, None)
return response_404
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Any, List["Device"]]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
id: str,
*,
client: Union[AuthenticatedClient, Client],
metadata_name: Union[Unset, str] = UNSET,
metadata_value: Union[Unset, str] = UNSET,
) -> Response[Union[Any, List["Device"]]]:
"""Get devices by board id and optional metadata field

Args:
id (str):
metadata_name (Union[Unset, str]):
metadata_value (Union[Unset, str]):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, List['Device']]]
"""

kwargs = _get_kwargs(
id=id,
metadata_name=metadata_name,
metadata_value=metadata_value,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
id: str,
*,
client: Union[AuthenticatedClient, Client],
metadata_name: Union[Unset, str] = UNSET,
metadata_value: Union[Unset, str] = UNSET,
) -> Optional[Union[Any, List["Device"]]]:
"""Get devices by board id and optional metadata field

Args:
id (str):
metadata_name (Union[Unset, str]):
metadata_value (Union[Unset, str]):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Any, List['Device']]
"""

return sync_detailed(
id=id,
client=client,
metadata_name=metadata_name,
metadata_value=metadata_value,
).parsed


async def asyncio_detailed(
id: str,
*,
client: Union[AuthenticatedClient, Client],
metadata_name: Union[Unset, str] = UNSET,
metadata_value: Union[Unset, str] = UNSET,
) -> Response[Union[Any, List["Device"]]]:
"""Get devices by board id and optional metadata field

Args:
id (str):
metadata_name (Union[Unset, str]):
metadata_value (Union[Unset, str]):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Any, List['Device']]]
"""

kwargs = _get_kwargs(
id=id,
metadata_name=metadata_name,
metadata_value=metadata_value,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
id: str,
*,
client: Union[AuthenticatedClient, Client],
metadata_name: Union[Unset, str] = UNSET,
metadata_value: Union[Unset, str] = UNSET,
) -> Optional[Union[Any, List["Device"]]]:
"""Get devices by board id and optional metadata field

Args:
id (str):
metadata_name (Union[Unset, str]):
metadata_value (Union[Unset, str]):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Any, List['Device']]
"""

return (
await asyncio_detailed(
id=id,
client=client,
metadata_name=metadata_name,
metadata_value=metadata_value,
)
).parsed
4 changes: 4 additions & 0 deletions src/infuse_iot/api_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
from .error import Error
from .health_check import HealthCheck
from .key import Key
from .metadata_field import MetadataField
from .new_board import NewBoard
from .new_device import NewDevice
from .new_device_metadata import NewDeviceMetadata
from .new_organisation import NewOrganisation
from .organisation import Organisation

Expand All @@ -24,8 +26,10 @@
"Error",
"HealthCheck",
"Key",
"MetadataField",
"NewBoard",
"NewDevice",
"NewDeviceMetadata",
"NewOrganisation",
"Organisation",
)
34 changes: 33 additions & 1 deletion src/infuse_iot/api_client/models/board.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import datetime
from typing import Any, Dict, List, Type, TypeVar
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union

from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse

from ..types import UNSET, Unset

if TYPE_CHECKING:
from ..models.metadata_field import MetadataField


T = TypeVar("T", bound="Board")


Expand All @@ -19,6 +25,8 @@ class Board:
description (str): Description of board Example: Extended description of board.
soc (str): System on Chip (SoC) of board Example: nRF9151.
organisation_id (str): ID of organisation for board to exist in
metadata_fields (Union[Unset, List['MetadataField']]): Metadata fields for board Example: [{'name': 'Field
Name', 'required': True, 'unique': False}].
"""

id: str
Expand All @@ -28,6 +36,7 @@ class Board:
description: str
soc: str
organisation_id: str
metadata_fields: Union[Unset, List["MetadataField"]] = UNSET
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
Expand All @@ -45,6 +54,15 @@ def to_dict(self) -> Dict[str, Any]:

organisation_id = self.organisation_id

metadata_fields: Union[Unset, List[Dict[str, Any]]] = UNSET
if not isinstance(self.metadata_fields, Unset):
metadata_fields = []
for componentsschemas_board_metadata_fields_item_data in self.metadata_fields:
componentsschemas_board_metadata_fields_item = (
componentsschemas_board_metadata_fields_item_data.to_dict()
)
metadata_fields.append(componentsschemas_board_metadata_fields_item)

field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
Expand All @@ -58,11 +76,15 @@ def to_dict(self) -> Dict[str, Any]:
"organisationId": organisation_id,
}
)
if metadata_fields is not UNSET:
field_dict["metadataFields"] = metadata_fields

return field_dict

@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
from ..models.metadata_field import MetadataField

d = src_dict.copy()
id = d.pop("id")

Expand All @@ -78,6 +100,15 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:

organisation_id = d.pop("organisationId")

metadata_fields = []
_metadata_fields = d.pop("metadataFields", UNSET)
for componentsschemas_board_metadata_fields_item_data in _metadata_fields or []:
componentsschemas_board_metadata_fields_item = MetadataField.from_dict(
componentsschemas_board_metadata_fields_item_data
)

metadata_fields.append(componentsschemas_board_metadata_fields_item)

board = cls(
id=id,
created_at=created_at,
Expand All @@ -86,6 +117,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
description=description,
soc=soc,
organisation_id=organisation_id,
metadata_fields=metadata_fields,
)

board.additional_properties = d
Expand Down
Loading