Coverage for src/hush_hush/_generated/api/consumers/list_consumers.py: 0%
58 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-16 16:01 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-10-16 16:01 +0000
1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT.
3from http import HTTPStatus
4from typing import Any, cast
6import httpx
8from ... import errors
9from ...client import AuthenticatedClient, Client
10from ...models.consumers_page import ConsumersPage
11from ...models.error import Error
12from ...types import UNSET, Response, Unset
15def _get_kwargs(
16 *,
17 q: str | Unset = UNSET,
18 page: int | Unset = UNSET,
19 page_size: int | Unset = 20,
20) -> dict[str, Any]:
22 params: dict[str, Any] = {}
24 params["q"] = q
26 params["page"] = page
28 params["page_size"] = page_size
30 params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
32 _kwargs: dict[str, Any] = {
33 "method": "get",
34 "url": "/consumers",
35 "params": params,
36 }
38 return _kwargs
41def _parse_response(
42 *, client: AuthenticatedClient | Client, response: httpx.Response
43) -> ConsumersPage | list[str] | Error | None:
44 if response.status_code == 200:
46 def _parse_response_200(data: object) -> ConsumersPage | list[str]:
47 try:
48 if not isinstance(data, list):
49 raise TypeError()
50 response_200_type_0 = cast(list[str], data)
52 return response_200_type_0
53 except (TypeError, ValueError, AttributeError, KeyError):
54 pass
55 if not isinstance(data, dict):
56 raise TypeError()
57 response_200_type_1 = ConsumersPage.from_dict(data)
59 return response_200_type_1
61 response_200 = _parse_response_200(response.json())
63 return response_200
65 if response.status_code == 400:
66 response_400 = Error.from_dict(response.json())
68 return response_400
70 if response.status_code == 401:
71 response_401 = Error.from_dict(response.json())
73 return response_401
75 if response.status_code == 422:
76 response_422 = Error.from_dict(response.json())
78 return response_422
80 if client.raise_on_unexpected_status:
81 raise errors.UnexpectedStatus(response.status_code, response.content)
82 else:
83 return None
86def _build_response(
87 *, client: AuthenticatedClient | Client, response: httpx.Response
88) -> Response[ConsumersPage | list[str] | Error]:
89 return Response(
90 status_code=HTTPStatus(response.status_code),
91 content=response.content,
92 headers=response.headers,
93 parsed=_parse_response(client=client, response=response),
94 )
97def sync_detailed(
98 *,
99 client: AuthenticatedClient,
100 q: str | Unset = UNSET,
101 page: int | Unset = UNSET,
102 page_size: int | Unset = 20,
103) -> Response[ConsumersPage | list[str] | Error]:
104 """List every distinct recorded consumer
106 Returns every distinct consumer name currently present in any
107 object's `used_by` list - gated the same way `GET /objects` is (a
108 write token or a session), since listing needs no id the caller
109 already holds.
111 Called with none of `q`, `page`, or `page_size`, it returns the
112 original plain, unpaginated array of names, sorted, with no
113 duplicates - `consumer-combobox`'s (alrayyes/hush-hush#251) own
114 call site depends on this shape staying unchanged. Given any of
115 the three, it instead returns a `ConsumersPage`: one page of
116 consumers whose name contains `q` (case-insensitive) when given,
117 each with a count of the secret objects that reference it and its
118 registered age public key when one has been set (absent
119 otherwise), plus the total matching count so a caller can render
120 page-number navigation.
122 Args:
123 q (str | Unset):
124 page (int | Unset):
125 page_size (int | Unset): Default: 20.
127 Raises:
128 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
129 httpx.TimeoutException: If the request takes longer than Client.timeout.
131 Returns:
132 Response[ConsumersPage | list[str] | Error]
133 """
135 kwargs = _get_kwargs(
136 q=q,
137 page=page,
138 page_size=page_size,
139 )
141 response = client.get_httpx_client().request(
142 **kwargs,
143 )
145 return _build_response(client=client, response=response)
148def sync(
149 *,
150 client: AuthenticatedClient,
151 q: str | Unset = UNSET,
152 page: int | Unset = UNSET,
153 page_size: int | Unset = 20,
154) -> ConsumersPage | list[str] | Error | None:
155 """List every distinct recorded consumer
157 Returns every distinct consumer name currently present in any
158 object's `used_by` list - gated the same way `GET /objects` is (a
159 write token or a session), since listing needs no id the caller
160 already holds.
162 Called with none of `q`, `page`, or `page_size`, it returns the
163 original plain, unpaginated array of names, sorted, with no
164 duplicates - `consumer-combobox`'s (alrayyes/hush-hush#251) own
165 call site depends on this shape staying unchanged. Given any of
166 the three, it instead returns a `ConsumersPage`: one page of
167 consumers whose name contains `q` (case-insensitive) when given,
168 each with a count of the secret objects that reference it and its
169 registered age public key when one has been set (absent
170 otherwise), plus the total matching count so a caller can render
171 page-number navigation.
173 Args:
174 q (str | Unset):
175 page (int | Unset):
176 page_size (int | Unset): Default: 20.
178 Raises:
179 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
180 httpx.TimeoutException: If the request takes longer than Client.timeout.
182 Returns:
183 ConsumersPage | list[str] | Error
184 """
186 return sync_detailed(
187 client=client,
188 q=q,
189 page=page,
190 page_size=page_size,
191 ).parsed
194async def asyncio_detailed(
195 *,
196 client: AuthenticatedClient,
197 q: str | Unset = UNSET,
198 page: int | Unset = UNSET,
199 page_size: int | Unset = 20,
200) -> Response[ConsumersPage | list[str] | Error]:
201 """List every distinct recorded consumer
203 Returns every distinct consumer name currently present in any
204 object's `used_by` list - gated the same way `GET /objects` is (a
205 write token or a session), since listing needs no id the caller
206 already holds.
208 Called with none of `q`, `page`, or `page_size`, it returns the
209 original plain, unpaginated array of names, sorted, with no
210 duplicates - `consumer-combobox`'s (alrayyes/hush-hush#251) own
211 call site depends on this shape staying unchanged. Given any of
212 the three, it instead returns a `ConsumersPage`: one page of
213 consumers whose name contains `q` (case-insensitive) when given,
214 each with a count of the secret objects that reference it and its
215 registered age public key when one has been set (absent
216 otherwise), plus the total matching count so a caller can render
217 page-number navigation.
219 Args:
220 q (str | Unset):
221 page (int | Unset):
222 page_size (int | Unset): Default: 20.
224 Raises:
225 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
226 httpx.TimeoutException: If the request takes longer than Client.timeout.
228 Returns:
229 Response[ConsumersPage | list[str] | Error]
230 """
232 kwargs = _get_kwargs(
233 q=q,
234 page=page,
235 page_size=page_size,
236 )
238 response = await client.get_async_httpx_client().request(**kwargs)
240 return _build_response(client=client, response=response)
243async def asyncio(
244 *,
245 client: AuthenticatedClient,
246 q: str | Unset = UNSET,
247 page: int | Unset = UNSET,
248 page_size: int | Unset = 20,
249) -> ConsumersPage | list[str] | Error | None:
250 """List every distinct recorded consumer
252 Returns every distinct consumer name currently present in any
253 object's `used_by` list - gated the same way `GET /objects` is (a
254 write token or a session), since listing needs no id the caller
255 already holds.
257 Called with none of `q`, `page`, or `page_size`, it returns the
258 original plain, unpaginated array of names, sorted, with no
259 duplicates - `consumer-combobox`'s (alrayyes/hush-hush#251) own
260 call site depends on this shape staying unchanged. Given any of
261 the three, it instead returns a `ConsumersPage`: one page of
262 consumers whose name contains `q` (case-insensitive) when given,
263 each with a count of the secret objects that reference it and its
264 registered age public key when one has been set (absent
265 otherwise), plus the total matching count so a caller can render
266 page-number navigation.
268 Args:
269 q (str | Unset):
270 page (int | Unset):
271 page_size (int | Unset): Default: 20.
273 Raises:
274 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
275 httpx.TimeoutException: If the request takes longer than Client.timeout.
277 Returns:
278 ConsumersPage | list[str] | Error
279 """
281 return (
282 await asyncio_detailed(
283 client=client,
284 q=q,
285 page=page,
286 page_size=page_size,
287 )
288 ).parsed