Coverage for src/hush_hush/_generated/api/tokens/revoke_token.py: 0%
41 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 Response
15def _get_kwargs(
16 id: str,
17 *,
18 x_csrf_token: str,
19) -> dict[str, Any]:
20 headers: dict[str, Any] = {}
21 headers["X-CSRF-Token"] = x_csrf_token
23 _kwargs: dict[str, Any] = {
24 "method": "delete",
25 "url": "/tokens/{id}".format(
26 id=quote(str(id), safe=""),
27 ),
28 }
30 _kwargs["headers"] = headers
31 return _kwargs
34def _parse_response(
35 *, client: AuthenticatedClient | Client, response: httpx.Response
36) -> Any | Error | None:
37 if response.status_code == 204:
38 response_204 = cast(Any, None)
39 return response_204
41 if response.status_code == 401:
42 response_401 = Error.from_dict(response.json())
44 return response_401
46 if response.status_code == 422:
47 response_422 = Error.from_dict(response.json())
49 return response_422
51 if client.raise_on_unexpected_status:
52 raise errors.UnexpectedStatus(response.status_code, response.content)
53 else:
54 return None
57def _build_response(
58 *, client: AuthenticatedClient | Client, response: httpx.Response
59) -> Response[Any | Error]:
60 return Response(
61 status_code=HTTPStatus(response.status_code),
62 content=response.content,
63 headers=response.headers,
64 parsed=_parse_response(client=client, response=response),
65 )
68def sync_detailed(
69 id: str,
70 *,
71 client: AuthenticatedClient,
72 x_csrf_token: str,
73) -> Response[Any | Error]:
74 """Revoke a write bearer token
76 Invalidates the token issued under id. Revoking an id that's
77 already expired or doesn't exist isn't an error - both leave
78 every other token's state unaffected either way.
80 Args:
81 id (str):
82 x_csrf_token (str):
84 Raises:
85 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
86 httpx.TimeoutException: If the request takes longer than Client.timeout.
88 Returns:
89 Response[Any | Error]
90 """
92 kwargs = _get_kwargs(
93 id=id,
94 x_csrf_token=x_csrf_token,
95 )
97 response = client.get_httpx_client().request(
98 **kwargs,
99 )
101 return _build_response(client=client, response=response)
104def sync(
105 id: str,
106 *,
107 client: AuthenticatedClient,
108 x_csrf_token: str,
109) -> Any | Error | None:
110 """Revoke a write bearer token
112 Invalidates the token issued under id. Revoking an id that's
113 already expired or doesn't exist isn't an error - both leave
114 every other token's state unaffected either way.
116 Args:
117 id (str):
118 x_csrf_token (str):
120 Raises:
121 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
122 httpx.TimeoutException: If the request takes longer than Client.timeout.
124 Returns:
125 Any | Error
126 """
128 return sync_detailed(
129 id=id,
130 client=client,
131 x_csrf_token=x_csrf_token,
132 ).parsed
135async def asyncio_detailed(
136 id: str,
137 *,
138 client: AuthenticatedClient,
139 x_csrf_token: str,
140) -> Response[Any | Error]:
141 """Revoke a write bearer token
143 Invalidates the token issued under id. Revoking an id that's
144 already expired or doesn't exist isn't an error - both leave
145 every other token's state unaffected either way.
147 Args:
148 id (str):
149 x_csrf_token (str):
151 Raises:
152 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
153 httpx.TimeoutException: If the request takes longer than Client.timeout.
155 Returns:
156 Response[Any | Error]
157 """
159 kwargs = _get_kwargs(
160 id=id,
161 x_csrf_token=x_csrf_token,
162 )
164 response = await client.get_async_httpx_client().request(**kwargs)
166 return _build_response(client=client, response=response)
169async def asyncio(
170 id: str,
171 *,
172 client: AuthenticatedClient,
173 x_csrf_token: str,
174) -> Any | Error | None:
175 """Revoke a write bearer token
177 Invalidates the token issued under id. Revoking an id that's
178 already expired or doesn't exist isn't an error - both leave
179 every other token's state unaffected either way.
181 Args:
182 id (str):
183 x_csrf_token (str):
185 Raises:
186 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
187 httpx.TimeoutException: If the request takes longer than Client.timeout.
189 Returns:
190 Any | Error
191 """
193 return (
194 await asyncio_detailed(
195 id=id,
196 client=client,
197 x_csrf_token=x_csrf_token,
198 )
199 ).parsed