Coverage for src/hush_hush/_generated/api/tokens/revoke_consumer_token.py: 0%
42 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}".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 == 422:
48 response_422 = Error.from_dict(response.json())
50 return response_422
52 if client.raise_on_unexpected_status:
53 raise errors.UnexpectedStatus(response.status_code, response.content)
54 else:
55 return None
58def _build_response(
59 *, client: AuthenticatedClient | Client, response: httpx.Response
60) -> Response[Any | Error]:
61 return Response(
62 status_code=HTTPStatus(response.status_code),
63 content=response.content,
64 headers=response.headers,
65 parsed=_parse_response(client=client, response=response),
66 )
69def sync_detailed(
70 id: str,
71 *,
72 client: AuthenticatedClient,
73 x_csrf_token: str | Unset = UNSET,
74) -> Response[Any | Error]:
75 """Revoke a consumer read token
77 Invalidates the consumer token issued under id. Revoking an id
78 that's already expired or doesn't exist isn't an error - both
79 leave every other token's state unaffected either way. A write
80 bearer token may revoke one too, the same as it may create one
81 (alrayyes/hush-hush#467).
83 Args:
84 id (str):
85 x_csrf_token (str | Unset):
87 Raises:
88 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
89 httpx.TimeoutException: If the request takes longer than Client.timeout.
91 Returns:
92 Response[Any | Error]
93 """
95 kwargs = _get_kwargs(
96 id=id,
97 x_csrf_token=x_csrf_token,
98 )
100 response = client.get_httpx_client().request(
101 **kwargs,
102 )
104 return _build_response(client=client, response=response)
107def sync(
108 id: str,
109 *,
110 client: AuthenticatedClient,
111 x_csrf_token: str | Unset = UNSET,
112) -> Any | Error | None:
113 """Revoke a consumer read token
115 Invalidates the consumer token issued under id. Revoking an id
116 that's already expired or doesn't exist isn't an error - both
117 leave every other token's state unaffected either way. A write
118 bearer token may revoke one too, the same as it may create one
119 (alrayyes/hush-hush#467).
121 Args:
122 id (str):
123 x_csrf_token (str | Unset):
125 Raises:
126 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
127 httpx.TimeoutException: If the request takes longer than Client.timeout.
129 Returns:
130 Any | Error
131 """
133 return sync_detailed(
134 id=id,
135 client=client,
136 x_csrf_token=x_csrf_token,
137 ).parsed
140async def asyncio_detailed(
141 id: str,
142 *,
143 client: AuthenticatedClient,
144 x_csrf_token: str | Unset = UNSET,
145) -> Response[Any | Error]:
146 """Revoke a consumer read token
148 Invalidates the consumer token issued under id. Revoking an id
149 that's already expired or doesn't exist isn't an error - both
150 leave every other token's state unaffected either way. A write
151 bearer token may revoke one too, the same as it may create one
152 (alrayyes/hush-hush#467).
154 Args:
155 id (str):
156 x_csrf_token (str | Unset):
158 Raises:
159 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
160 httpx.TimeoutException: If the request takes longer than Client.timeout.
162 Returns:
163 Response[Any | Error]
164 """
166 kwargs = _get_kwargs(
167 id=id,
168 x_csrf_token=x_csrf_token,
169 )
171 response = await client.get_async_httpx_client().request(**kwargs)
173 return _build_response(client=client, response=response)
176async def asyncio(
177 id: str,
178 *,
179 client: AuthenticatedClient,
180 x_csrf_token: str | Unset = UNSET,
181) -> Any | Error | None:
182 """Revoke a consumer read token
184 Invalidates the consumer token issued under id. Revoking an id
185 that's already expired or doesn't exist isn't an error - both
186 leave every other token's state unaffected either way. A write
187 bearer token may revoke one too, the same as it may create one
188 (alrayyes/hush-hush#467).
190 Args:
191 id (str):
192 x_csrf_token (str | Unset):
194 Raises:
195 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
196 httpx.TimeoutException: If the request takes longer than Client.timeout.
198 Returns:
199 Any | Error
200 """
202 return (
203 await asyncio_detailed(
204 id=id,
205 client=client,
206 x_csrf_token=x_csrf_token,
207 )
208 ).parsed