Coverage for src/hush_hush/_generated/api/auth/logout.py: 0%
40 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.error import Error
11from ...types import Response
14def _get_kwargs(
15 *,
16 x_csrf_token: str,
17) -> dict[str, Any]:
18 headers: dict[str, Any] = {}
19 headers["X-CSRF-Token"] = x_csrf_token
21 _kwargs: dict[str, Any] = {
22 "method": "post",
23 "url": "/auth/logout",
24 }
26 _kwargs["headers"] = headers
27 return _kwargs
30def _parse_response(
31 *, client: AuthenticatedClient | Client, response: httpx.Response
32) -> Any | Error | None:
33 if response.status_code == 204:
34 response_204 = cast(Any, None)
35 return response_204
37 if response.status_code == 401:
38 response_401 = Error.from_dict(response.json())
40 return response_401
42 if response.status_code == 422:
43 response_422 = Error.from_dict(response.json())
45 return response_422
47 if client.raise_on_unexpected_status:
48 raise errors.UnexpectedStatus(response.status_code, response.content)
49 else:
50 return None
53def _build_response(
54 *, client: AuthenticatedClient | Client, response: httpx.Response
55) -> Response[Any | Error]:
56 return Response(
57 status_code=HTTPStatus(response.status_code),
58 content=response.content,
59 headers=response.headers,
60 parsed=_parse_response(client=client, response=response),
61 )
64def sync_detailed(
65 *,
66 client: AuthenticatedClient,
67 x_csrf_token: str,
68) -> Response[Any | Error]:
69 """End the current session
71 Invalidates the session presented with the request. State-changing
72 and session-authenticated, so it requires the session's own CSRF
73 token echoed back in a header, on top of the cookie itself - the
74 gap `SameSite=Lax` alone leaves open.
76 Args:
77 x_csrf_token (str):
79 Raises:
80 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
81 httpx.TimeoutException: If the request takes longer than Client.timeout.
83 Returns:
84 Response[Any | Error]
85 """
87 kwargs = _get_kwargs(
88 x_csrf_token=x_csrf_token,
89 )
91 response = client.get_httpx_client().request(
92 **kwargs,
93 )
95 return _build_response(client=client, response=response)
98def sync(
99 *,
100 client: AuthenticatedClient,
101 x_csrf_token: str,
102) -> Any | Error | None:
103 """End the current session
105 Invalidates the session presented with the request. State-changing
106 and session-authenticated, so it requires the session's own CSRF
107 token echoed back in a header, on top of the cookie itself - the
108 gap `SameSite=Lax` alone leaves open.
110 Args:
111 x_csrf_token (str):
113 Raises:
114 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
115 httpx.TimeoutException: If the request takes longer than Client.timeout.
117 Returns:
118 Any | Error
119 """
121 return sync_detailed(
122 client=client,
123 x_csrf_token=x_csrf_token,
124 ).parsed
127async def asyncio_detailed(
128 *,
129 client: AuthenticatedClient,
130 x_csrf_token: str,
131) -> Response[Any | Error]:
132 """End the current session
134 Invalidates the session presented with the request. State-changing
135 and session-authenticated, so it requires the session's own CSRF
136 token echoed back in a header, on top of the cookie itself - the
137 gap `SameSite=Lax` alone leaves open.
139 Args:
140 x_csrf_token (str):
142 Raises:
143 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
144 httpx.TimeoutException: If the request takes longer than Client.timeout.
146 Returns:
147 Response[Any | Error]
148 """
150 kwargs = _get_kwargs(
151 x_csrf_token=x_csrf_token,
152 )
154 response = await client.get_async_httpx_client().request(**kwargs)
156 return _build_response(client=client, response=response)
159async def asyncio(
160 *,
161 client: AuthenticatedClient,
162 x_csrf_token: str,
163) -> Any | Error | None:
164 """End the current session
166 Invalidates the session presented with the request. State-changing
167 and session-authenticated, so it requires the session's own CSRF
168 token echoed back in a header, on top of the cookie itself - the
169 gap `SameSite=Lax` alone leaves open.
171 Args:
172 x_csrf_token (str):
174 Raises:
175 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
176 httpx.TimeoutException: If the request takes longer than Client.timeout.
178 Returns:
179 Any | Error
180 """
182 return (
183 await asyncio_detailed(
184 client=client,
185 x_csrf_token=x_csrf_token,
186 )
187 ).parsed