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 src/infuse_iot/api_client/api/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
169 changes: 169 additions & 0 deletions src/infuse_iot/api_client/api/admin/generate_api_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
from http import HTTPStatus
from typing import Any

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.generate_api_key_body import GenerateAPIKeyBody
from ...models.generated_api_key import GeneratedAPIKey
from ...types import Response


def _get_kwargs(
*,
body: GenerateAPIKeyBody,
) -> dict[str, Any]:
headers: dict[str, Any] = {}

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/admin/apiKey",
}

_body = body.to_dict()

_kwargs["json"] = _body
headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Error | GeneratedAPIKey | None:
if response.status_code == 200:
response_200 = GeneratedAPIKey.from_dict(response.json())

return response_200
if response.status_code == 400:
response_400 = Error.from_dict(response.json())

return response_400
if response.status_code == 500:
response_500 = Error.from_dict(response.json())

return response_500
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[Error | GeneratedAPIKey]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
*,
client: AuthenticatedClient | Client,
body: GenerateAPIKeyBody,
) -> Response[Error | GeneratedAPIKey]:
"""Generate an API key

Args:
body (GenerateAPIKeyBody):

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

Returns:
Response[Union[Error, GeneratedAPIKey]]
"""

kwargs = _get_kwargs(
body=body,
)

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

return _build_response(client=client, response=response)


def sync(
*,
client: AuthenticatedClient | Client,
body: GenerateAPIKeyBody,
) -> Error | GeneratedAPIKey | None:
"""Generate an API key

Args:
body (GenerateAPIKeyBody):

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

Returns:
Union[Error, GeneratedAPIKey]
"""

return sync_detailed(
client=client,
body=body,
).parsed


async def asyncio_detailed(
*,
client: AuthenticatedClient | Client,
body: GenerateAPIKeyBody,
) -> Response[Error | GeneratedAPIKey]:
"""Generate an API key

Args:
body (GenerateAPIKeyBody):

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

Returns:
Response[Union[Error, GeneratedAPIKey]]
"""

kwargs = _get_kwargs(
body=body,
)

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

return _build_response(client=client, response=response)


async def asyncio(
*,
client: AuthenticatedClient | Client,
body: GenerateAPIKeyBody,
) -> Error | GeneratedAPIKey | None:
"""Generate an API key

Args:
body (GenerateAPIKeyBody):

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

Returns:
Union[Error, GeneratedAPIKey]
"""

return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
26 changes: 11 additions & 15 deletions src/infuse_iot/api_client/api/board/create_board.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
from typing import Any, cast

import httpx

Expand Down Expand Up @@ -30,9 +30,7 @@ def _get_kwargs(
return _kwargs


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, Board]]:
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Board | None:
if response.status_code == 201:
response_201 = Board.from_dict(response.json())

Expand All @@ -49,9 +47,7 @@ def _parse_response(
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Any, Board]]:
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -62,9 +58,9 @@ def _build_response(

def sync_detailed(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
body: NewBoard,
) -> Response[Union[Any, Board]]:
) -> Response[Any | Board]:
"""Create a new board

Args:
Expand All @@ -91,9 +87,9 @@ def sync_detailed(

def sync(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
body: NewBoard,
) -> Optional[Union[Any, Board]]:
) -> Any | Board | None:
"""Create a new board

Args:
Expand All @@ -115,9 +111,9 @@ def sync(

async def asyncio_detailed(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
body: NewBoard,
) -> Response[Union[Any, Board]]:
) -> Response[Any | Board]:
"""Create a new board

Args:
Expand All @@ -142,9 +138,9 @@ async def asyncio_detailed(

async def asyncio(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
body: NewBoard,
) -> Optional[Union[Any, Board]]:
) -> Any | Board | None:
"""Create a new board

Args:
Expand Down
26 changes: 11 additions & 15 deletions src/infuse_iot/api_client/api/board/get_board_by_id.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
from typing import Any, cast
from uuid import UUID

import httpx
Expand All @@ -21,9 +21,7 @@ def _get_kwargs(
return _kwargs


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, Board]]:
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | Board | None:
if response.status_code == 200:
response_200 = Board.from_dict(response.json())

Expand All @@ -37,9 +35,7 @@ def _parse_response(
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Any, Board]]:
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -51,8 +47,8 @@ def _build_response(
def sync_detailed(
id: UUID,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Any, Board]]:
client: AuthenticatedClient | Client,
) -> Response[Any | Board]:
"""Get a board by ID

Args:
Expand Down Expand Up @@ -80,8 +76,8 @@ def sync_detailed(
def sync(
id: UUID,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Any, Board]]:
client: AuthenticatedClient | Client,
) -> Any | Board | None:
"""Get a board by ID

Args:
Expand All @@ -104,8 +100,8 @@ def sync(
async def asyncio_detailed(
id: UUID,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Any, Board]]:
client: AuthenticatedClient | Client,
) -> Response[Any | Board]:
"""Get a board by ID

Args:
Expand All @@ -131,8 +127,8 @@ async def asyncio_detailed(
async def asyncio(
id: UUID,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Any, Board]]:
client: AuthenticatedClient | Client,
) -> Any | Board | None:
"""Get a board by ID

Args:
Expand Down
18 changes: 9 additions & 9 deletions src/infuse_iot/api_client/api/board/get_boards.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from typing import Any
from uuid import UUID

import httpx
Expand Down Expand Up @@ -30,7 +30,7 @@ def _get_kwargs(
return _kwargs


def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list["Board"]]:
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> list["Board"] | None:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
Expand All @@ -46,7 +46,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
return None


def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list["Board"]]:
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[list["Board"]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -57,7 +57,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt

def sync_detailed(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
organisation_id: UUID,
) -> Response[list["Board"]]:
"""Get all boards in an organisation
Expand Down Expand Up @@ -86,9 +86,9 @@ def sync_detailed(

def sync(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
organisation_id: UUID,
) -> Optional[list["Board"]]:
) -> list["Board"] | None:
"""Get all boards in an organisation

Args:
Expand All @@ -110,7 +110,7 @@ def sync(

async def asyncio_detailed(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
organisation_id: UUID,
) -> Response[list["Board"]]:
"""Get all boards in an organisation
Expand All @@ -137,9 +137,9 @@ async def asyncio_detailed(

async def asyncio(
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient | Client,
organisation_id: UUID,
) -> Optional[list["Board"]]:
) -> list["Board"] | None:
"""Get all boards in an organisation

Args:
Expand Down
Loading