Coverage for src/hush_hush/_generated/api/tokens/purge_consumer_token.py: 0%
48 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
5from urllib.parse import quote
7import httpx
9from ... import errors
10from ...client import AuthenticatedClient, Client
11from ...models.error import Error
12from ...types import UNSET, Response, Unset
15def _get_kwargs(
16 id: str,
17 *,
18 x_csrf_token: str | Unset = UNSET,
19) -> dict[str, Any]:
20 headers: dict[str, Any] = {}
21 if not isinstance(x_csrf_token, Unset):
22 headers["X-CSRF-Token"] = x_csrf_token
24 _kwargs: dict[str, Any] = {
25 "method": "delete",
26 "url": "/consumer-tokens/{id}/purge".format(
27 id=quote(str(id), safe=""),
28 ),
29 }
31 _kwargs["headers"] = headers
32 return _kwargs
35def _parse_response(
36 *, client: AuthenticatedClient | Client, response: httpx.Response
37) -> Any | Error | None:
38 if response.status_code == 204:
39 response_204 = cast(Any, None)
40 return response_204
42 if response.status_code == 401:
43 response_401 = Error.from_dict(response.json())
45 return response_401
47 if response.status_code == 404:
48 response_404 = Error.from_dict(response.json())
50 return response_404
52 if response.status_code == 409:
53 response_409 = Error.from_dict(response.json())
55 return response_409
57 if response.status_code == 422:
58 response_422 = Error.from_dict(response.json())
60 return response_422
62 if client.raise_on_unexpected_status:
63 raise errors.UnexpectedStatus(response.status_code, response.content)
64 else:
65 return None
68def _build_response(
69 *, client: AuthenticatedClient | Client, response: httpx.Response
70) -> Response[Any | Error]:
71 return Response(
72 status_code=HTTPStatus(response.status_code),
73 content=response.content,
74 headers=response.headers,
75 parsed=_parse_response(client=client, response=response),
76 )
79def sync_detailed(
80 id: str,
81 *,
82 client: AuthenticatedClient,
83 x_csrf_token: str | Unset = UNSET,
84) -> Response[Any | Error]:
85 """Permanently delete a dead consumer read token
87 Permanently removes the consumer token issued under id, once it's
88 already revoked or past its expiry - `revokeConsumerToken`'s
89 soft-delete stays the only way to invalidate a still-active token.
90 Unlike `revokeConsumerToken`, an audit-log entry attributed to a
91 purged token's id no longer resolves to a description or owner
92 afterward - the accepted tradeoff for actually removing it. A
93 write bearer token may purge one too, the same as it may create
94 one (alrayyes/hush-hush#467).
96 Args:
97 id (str):
98 x_csrf_token (str | Unset):
100 Raises:
101 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
102 httpx.TimeoutException: If the request takes longer than Client.timeout.
104 Returns:
105 Response[Any | Error]
106 """
108 kwargs = _get_kwargs(
109 id=id,
110 x_csrf_token=x_csrf_token,
111 )
113 response = client.get_httpx_client().request(
114 **kwargs,
115 )
117 return _build_response(client=client, response=response)
120def sync(
121 id: str,
122 *,
123 client: AuthenticatedClient,
124 x_csrf_token: str | Unset = UNSET,
125) -> Any | Error | None:
126 """Permanently delete a dead consumer read token
128 Permanently removes the consumer token issued under id, once it's
129 already revoked or past its expiry - `revokeConsumerToken`'s
130 soft-delete stays the only way to invalidate a still-active token.
131 Unlike `revokeConsumerToken`, an audit-log entry attributed to a
132 purged token's id no longer resolves to a description or owner
133 afterward - the accepted tradeoff for actually removing it. A
134 write bearer token may purge one too, the same as it may create
135 one (alrayyes/hush-hush#467).
137 Args:
138 id (str):
139 x_csrf_token (str | Unset):
141 Raises:
142 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
143 httpx.TimeoutException: If the request takes longer than Client.timeout.
145 Returns:
146 Any | Error
147 """
149 return sync_detailed(
150 id=id,
151 client=client,
152 x_csrf_token=x_csrf_token,
153 ).parsed
156async def asyncio_detailed(
157 id: str,
158 *,
159 client: AuthenticatedClient,
160 x_csrf_token: str | Unset = UNSET,
161) -> Response[Any | Error]:
162 """Permanently delete a dead consumer read token
164 Permanently removes the consumer token issued under id, once it's
165 already revoked or past its expiry - `revokeConsumerToken`'s
166 soft-delete stays the only way to invalidate a still-active token.
167 Unlike `revokeConsumerToken`, an audit-log entry attributed to a
168 purged token's id no longer resolves to a description or owner
169 afterward - the accepted tradeoff for actually removing it. A
170 write bearer token may purge one too, the same as it may create
171 one (alrayyes/hush-hush#467).
173 Args:
174 id (str):
175 x_csrf_token (str | Unset):
177 Raises:
178 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
179 httpx.TimeoutException: If the request takes longer than Client.timeout.
181 Returns:
182 Response[Any | Error]
183 """
185 kwargs = _get_kwargs(
186 id=id,
187 x_csrf_token=x_csrf_token,
188 )
190 response = await client.get_async_httpx_client().request(**kwargs)
192 return _build_response(client=client, response=response)
195async def asyncio(
196 id: str,
197 *,
198 client: AuthenticatedClient,
199 x_csrf_token: str | Unset = UNSET,
200) -> Any | Error | None:
201 """Permanently delete a dead consumer read token
203 Permanently removes the consumer token issued under id, once it's
204 already revoked or past its expiry - `revokeConsumerToken`'s
205 soft-delete stays the only way to invalidate a still-active token.
206 Unlike `revokeConsumerToken`, an audit-log entry attributed to a
207 purged token's id no longer resolves to a description or owner
208 afterward - the accepted tradeoff for actually removing it. A
209 write bearer token may purge one too, the same as it may create
210 one (alrayyes/hush-hush#467).
212 Args:
213 id (str):
214 x_csrf_token (str | Unset):
216 Raises:
217 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
218 httpx.TimeoutException: If the request takes longer than Client.timeout.
220 Returns:
221 Any | Error
222 """
224 return (
225 await asyncio_detailed(
226 id=id,
227 client=client,
228 x_csrf_token=x_csrf_token,
229 )
230 ).parsed