Coverage for src/hush_hush/_generated/api/credentials/delete_credential.py: 0%
47 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": "/credentials/{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 == 404:
47 response_404 = Error.from_dict(response.json())
49 return response_404
51 if response.status_code == 409:
52 response_409 = Error.from_dict(response.json())
54 return response_409
56 if response.status_code == 422:
57 response_422 = Error.from_dict(response.json())
59 return response_422
61 if client.raise_on_unexpected_status:
62 raise errors.UnexpectedStatus(response.status_code, response.content)
63 else:
64 return None
67def _build_response(
68 *, client: AuthenticatedClient | Client, response: httpx.Response
69) -> Response[Any | Error]:
70 return Response(
71 status_code=HTTPStatus(response.status_code),
72 content=response.content,
73 headers=response.headers,
74 parsed=_parse_response(client=client, response=response),
75 )
78def sync_detailed(
79 id: str,
80 *,
81 client: AuthenticatedClient,
82 x_csrf_token: str,
83) -> Response[Any | Error]:
84 """Remove a passkey
86 Permanently removes a credential. Refused when it's the only one
87 remaining - a passkey the account can't log in with is never left
88 as its last one.
90 Args:
91 id (str):
92 x_csrf_token (str):
94 Raises:
95 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
96 httpx.TimeoutException: If the request takes longer than Client.timeout.
98 Returns:
99 Response[Any | Error]
100 """
102 kwargs = _get_kwargs(
103 id=id,
104 x_csrf_token=x_csrf_token,
105 )
107 response = client.get_httpx_client().request(
108 **kwargs,
109 )
111 return _build_response(client=client, response=response)
114def sync(
115 id: str,
116 *,
117 client: AuthenticatedClient,
118 x_csrf_token: str,
119) -> Any | Error | None:
120 """Remove a passkey
122 Permanently removes a credential. Refused when it's the only one
123 remaining - a passkey the account can't log in with is never left
124 as its last one.
126 Args:
127 id (str):
128 x_csrf_token (str):
130 Raises:
131 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
132 httpx.TimeoutException: If the request takes longer than Client.timeout.
134 Returns:
135 Any | Error
136 """
138 return sync_detailed(
139 id=id,
140 client=client,
141 x_csrf_token=x_csrf_token,
142 ).parsed
145async def asyncio_detailed(
146 id: str,
147 *,
148 client: AuthenticatedClient,
149 x_csrf_token: str,
150) -> Response[Any | Error]:
151 """Remove a passkey
153 Permanently removes a credential. Refused when it's the only one
154 remaining - a passkey the account can't log in with is never left
155 as its last one.
157 Args:
158 id (str):
159 x_csrf_token (str):
161 Raises:
162 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
163 httpx.TimeoutException: If the request takes longer than Client.timeout.
165 Returns:
166 Response[Any | Error]
167 """
169 kwargs = _get_kwargs(
170 id=id,
171 x_csrf_token=x_csrf_token,
172 )
174 response = await client.get_async_httpx_client().request(**kwargs)
176 return _build_response(client=client, response=response)
179async def asyncio(
180 id: str,
181 *,
182 client: AuthenticatedClient,
183 x_csrf_token: str,
184) -> Any | Error | None:
185 """Remove a passkey
187 Permanently removes a credential. Refused when it's the only one
188 remaining - a passkey the account can't log in with is never left
189 as its last one.
191 Args:
192 id (str):
193 x_csrf_token (str):
195 Raises:
196 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
197 httpx.TimeoutException: If the request takes longer than Client.timeout.
199 Returns:
200 Any | Error
201 """
203 return (
204 await asyncio_detailed(
205 id=id,
206 client=client,
207 x_csrf_token=x_csrf_token,
208 )
209 ).parsed