Skip to content

Commit 172152e

Browse files
committed
api_client: regenerate from spec
Regenerate the cloud API client from the OpenAPI specification. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 7f9fde8 commit 172152e

90 files changed

Lines changed: 2956 additions & 740 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
from http import HTTPStatus
2+
from typing import Any
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.error import Error
9+
from ...models.generate_api_key_body import GenerateAPIKeyBody
10+
from ...models.generated_api_key import GeneratedAPIKey
11+
from ...types import Response
12+
13+
14+
def _get_kwargs(
15+
*,
16+
body: GenerateAPIKeyBody,
17+
) -> dict[str, Any]:
18+
headers: dict[str, Any] = {}
19+
20+
_kwargs: dict[str, Any] = {
21+
"method": "post",
22+
"url": "/admin/apiKey",
23+
}
24+
25+
_body = body.to_dict()
26+
27+
_kwargs["json"] = _body
28+
headers["Content-Type"] = "application/json"
29+
30+
_kwargs["headers"] = headers
31+
return _kwargs
32+
33+
34+
def _parse_response(
35+
*, client: AuthenticatedClient | Client, response: httpx.Response
36+
) -> Error | GeneratedAPIKey | None:
37+
if response.status_code == 200:
38+
response_200 = GeneratedAPIKey.from_dict(response.json())
39+
40+
return response_200
41+
if response.status_code == 400:
42+
response_400 = Error.from_dict(response.json())
43+
44+
return response_400
45+
if response.status_code == 500:
46+
response_500 = Error.from_dict(response.json())
47+
48+
return response_500
49+
if client.raise_on_unexpected_status:
50+
raise errors.UnexpectedStatus(response.status_code, response.content)
51+
else:
52+
return None
53+
54+
55+
def _build_response(
56+
*, client: AuthenticatedClient | Client, response: httpx.Response
57+
) -> Response[Error | GeneratedAPIKey]:
58+
return Response(
59+
status_code=HTTPStatus(response.status_code),
60+
content=response.content,
61+
headers=response.headers,
62+
parsed=_parse_response(client=client, response=response),
63+
)
64+
65+
66+
def sync_detailed(
67+
*,
68+
client: AuthenticatedClient | Client,
69+
body: GenerateAPIKeyBody,
70+
) -> Response[Error | GeneratedAPIKey]:
71+
"""Generate an API key
72+
73+
Args:
74+
body (GenerateAPIKeyBody):
75+
76+
Raises:
77+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
78+
httpx.TimeoutException: If the request takes longer than Client.timeout.
79+
80+
Returns:
81+
Response[Union[Error, GeneratedAPIKey]]
82+
"""
83+
84+
kwargs = _get_kwargs(
85+
body=body,
86+
)
87+
88+
response = client.get_httpx_client().request(
89+
**kwargs,
90+
)
91+
92+
return _build_response(client=client, response=response)
93+
94+
95+
def sync(
96+
*,
97+
client: AuthenticatedClient | Client,
98+
body: GenerateAPIKeyBody,
99+
) -> Error | GeneratedAPIKey | None:
100+
"""Generate an API key
101+
102+
Args:
103+
body (GenerateAPIKeyBody):
104+
105+
Raises:
106+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
107+
httpx.TimeoutException: If the request takes longer than Client.timeout.
108+
109+
Returns:
110+
Union[Error, GeneratedAPIKey]
111+
"""
112+
113+
return sync_detailed(
114+
client=client,
115+
body=body,
116+
).parsed
117+
118+
119+
async def asyncio_detailed(
120+
*,
121+
client: AuthenticatedClient | Client,
122+
body: GenerateAPIKeyBody,
123+
) -> Response[Error | GeneratedAPIKey]:
124+
"""Generate an API key
125+
126+
Args:
127+
body (GenerateAPIKeyBody):
128+
129+
Raises:
130+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131+
httpx.TimeoutException: If the request takes longer than Client.timeout.
132+
133+
Returns:
134+
Response[Union[Error, GeneratedAPIKey]]
135+
"""
136+
137+
kwargs = _get_kwargs(
138+
body=body,
139+
)
140+
141+
response = await client.get_async_httpx_client().request(**kwargs)
142+
143+
return _build_response(client=client, response=response)
144+
145+
146+
async def asyncio(
147+
*,
148+
client: AuthenticatedClient | Client,
149+
body: GenerateAPIKeyBody,
150+
) -> Error | GeneratedAPIKey | None:
151+
"""Generate an API key
152+
153+
Args:
154+
body (GenerateAPIKeyBody):
155+
156+
Raises:
157+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
158+
httpx.TimeoutException: If the request takes longer than Client.timeout.
159+
160+
Returns:
161+
Union[Error, GeneratedAPIKey]
162+
"""
163+
164+
return (
165+
await asyncio_detailed(
166+
client=client,
167+
body=body,
168+
)
169+
).parsed

src/infuse_iot/api_client/api/board/create_board.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Optional, Union, cast
2+
from typing import Any, cast
33

44
import httpx
55

@@ -30,9 +30,7 @@ def _get_kwargs(
3030
return _kwargs
3131

3232

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

@@ -49,9 +47,7 @@ def _parse_response(
4947
return None
5048

5149

52-
def _build_response(
53-
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
54-
) -> Response[Union[Any, Board]]:
50+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]:
5551
return Response(
5652
status_code=HTTPStatus(response.status_code),
5753
content=response.content,
@@ -62,9 +58,9 @@ def _build_response(
6258

6359
def sync_detailed(
6460
*,
65-
client: Union[AuthenticatedClient, Client],
61+
client: AuthenticatedClient | Client,
6662
body: NewBoard,
67-
) -> Response[Union[Any, Board]]:
63+
) -> Response[Any | Board]:
6864
"""Create a new board
6965
7066
Args:
@@ -91,9 +87,9 @@ def sync_detailed(
9187

9288
def sync(
9389
*,
94-
client: Union[AuthenticatedClient, Client],
90+
client: AuthenticatedClient | Client,
9591
body: NewBoard,
96-
) -> Optional[Union[Any, Board]]:
92+
) -> Any | Board | None:
9793
"""Create a new board
9894
9995
Args:
@@ -115,9 +111,9 @@ def sync(
115111

116112
async def asyncio_detailed(
117113
*,
118-
client: Union[AuthenticatedClient, Client],
114+
client: AuthenticatedClient | Client,
119115
body: NewBoard,
120-
) -> Response[Union[Any, Board]]:
116+
) -> Response[Any | Board]:
121117
"""Create a new board
122118
123119
Args:
@@ -142,9 +138,9 @@ async def asyncio_detailed(
142138

143139
async def asyncio(
144140
*,
145-
client: Union[AuthenticatedClient, Client],
141+
client: AuthenticatedClient | Client,
146142
body: NewBoard,
147-
) -> Optional[Union[Any, Board]]:
143+
) -> Any | Board | None:
148144
"""Create a new board
149145
150146
Args:

src/infuse_iot/api_client/api/board/get_board_by_id.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Optional, Union, cast
2+
from typing import Any, cast
33
from uuid import UUID
44

55
import httpx
@@ -21,9 +21,7 @@ def _get_kwargs(
2121
return _kwargs
2222

2323

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

@@ -37,9 +35,7 @@ def _parse_response(
3735
return None
3836

3937

40-
def _build_response(
41-
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
42-
) -> Response[Union[Any, Board]]:
38+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any | Board]:
4339
return Response(
4440
status_code=HTTPStatus(response.status_code),
4541
content=response.content,
@@ -51,8 +47,8 @@ def _build_response(
5147
def sync_detailed(
5248
id: UUID,
5349
*,
54-
client: Union[AuthenticatedClient, Client],
55-
) -> Response[Union[Any, Board]]:
50+
client: AuthenticatedClient | Client,
51+
) -> Response[Any | Board]:
5652
"""Get a board by ID
5753
5854
Args:
@@ -80,8 +76,8 @@ def sync_detailed(
8076
def sync(
8177
id: UUID,
8278
*,
83-
client: Union[AuthenticatedClient, Client],
84-
) -> Optional[Union[Any, Board]]:
79+
client: AuthenticatedClient | Client,
80+
) -> Any | Board | None:
8581
"""Get a board by ID
8682
8783
Args:
@@ -104,8 +100,8 @@ def sync(
104100
async def asyncio_detailed(
105101
id: UUID,
106102
*,
107-
client: Union[AuthenticatedClient, Client],
108-
) -> Response[Union[Any, Board]]:
103+
client: AuthenticatedClient | Client,
104+
) -> Response[Any | Board]:
109105
"""Get a board by ID
110106
111107
Args:
@@ -131,8 +127,8 @@ async def asyncio_detailed(
131127
async def asyncio(
132128
id: UUID,
133129
*,
134-
client: Union[AuthenticatedClient, Client],
135-
) -> Optional[Union[Any, Board]]:
130+
client: AuthenticatedClient | Client,
131+
) -> Any | Board | None:
136132
"""Get a board by ID
137133
138134
Args:

src/infuse_iot/api_client/api/board/get_boards.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Optional, Union
2+
from typing import Any
33
from uuid import UUID
44

55
import httpx
@@ -30,7 +30,7 @@ def _get_kwargs(
3030
return _kwargs
3131

3232

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

4848

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

5858
def sync_detailed(
5959
*,
60-
client: Union[AuthenticatedClient, Client],
60+
client: AuthenticatedClient | Client,
6161
organisation_id: UUID,
6262
) -> Response[list["Board"]]:
6363
"""Get all boards in an organisation
@@ -86,9 +86,9 @@ def sync_detailed(
8686

8787
def sync(
8888
*,
89-
client: Union[AuthenticatedClient, Client],
89+
client: AuthenticatedClient | Client,
9090
organisation_id: UUID,
91-
) -> Optional[list["Board"]]:
91+
) -> list["Board"] | None:
9292
"""Get all boards in an organisation
9393
9494
Args:
@@ -110,7 +110,7 @@ def sync(
110110

111111
async def asyncio_detailed(
112112
*,
113-
client: Union[AuthenticatedClient, Client],
113+
client: AuthenticatedClient | Client,
114114
organisation_id: UUID,
115115
) -> Response[list["Board"]]:
116116
"""Get all boards in an organisation
@@ -137,9 +137,9 @@ async def asyncio_detailed(
137137

138138
async def asyncio(
139139
*,
140-
client: Union[AuthenticatedClient, Client],
140+
client: AuthenticatedClient | Client,
141141
organisation_id: UUID,
142-
) -> Optional[list["Board"]]:
142+
) -> list["Board"] | None:
143143
"""Get all boards in an organisation
144144
145145
Args:

0 commit comments

Comments
 (0)