Coverage for src/hush_hush/_generated/api/credentials/rename_credential.py: 0%
51 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
5from urllib.parse import quote
7import httpx
9from ... import errors
10from ...client import AuthenticatedClient, Client
11from ...models.credential import Credential
12from ...models.credential_rename_request import CredentialRenameRequest
13from ...models.error import Error
14from ...types import Response
17def _get_kwargs(
18 id: str,
19 *,
20 body: CredentialRenameRequest,
21 x_csrf_token: str,
22) -> dict[str, Any]:
23 headers: dict[str, Any] = {}
24 headers["X-CSRF-Token"] = x_csrf_token
26 _kwargs: dict[str, Any] = {
27 "method": "patch",
28 "url": "/credentials/{id}".format(
29 id=quote(str(id), safe=""),
30 ),
31 }
33 _kwargs["json"] = body.to_dict()
35 headers["Content-Type"] = "application/json"
37 _kwargs["headers"] = headers
38 return _kwargs
41def _parse_response(
42 *, client: AuthenticatedClient | Client, response: httpx.Response
43) -> Credential | Error | None:
44 if response.status_code == 200:
45 response_200 = Credential.from_dict(response.json())
47 return response_200
49 if response.status_code == 401:
50 response_401 = Error.from_dict(response.json())
52 return response_401
54 if response.status_code == 404:
55 response_404 = Error.from_dict(response.json())
57 return response_404
59 if response.status_code == 413:
60 response_413 = Error.from_dict(response.json())
62 return response_413
64 if response.status_code == 422:
65 response_422 = Error.from_dict(response.json())
67 return response_422
69 if client.raise_on_unexpected_status:
70 raise errors.UnexpectedStatus(response.status_code, response.content)
71 else:
72 return None
75def _build_response(
76 *, client: AuthenticatedClient | Client, response: httpx.Response
77) -> Response[Credential | Error]:
78 return Response(
79 status_code=HTTPStatus(response.status_code),
80 content=response.content,
81 headers=response.headers,
82 parsed=_parse_response(client=client, response=response),
83 )
86def sync_detailed(
87 id: str,
88 *,
89 client: AuthenticatedClient,
90 body: CredentialRenameRequest,
91 x_csrf_token: str,
92) -> Response[Credential | Error]:
93 """Rename a passkey
95 Args:
96 id (str):
97 x_csrf_token (str):
98 body (CredentialRenameRequest):
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[Credential | Error]
106 """
108 kwargs = _get_kwargs(
109 id=id,
110 body=body,
111 x_csrf_token=x_csrf_token,
112 )
114 response = client.get_httpx_client().request(
115 **kwargs,
116 )
118 return _build_response(client=client, response=response)
121def sync(
122 id: str,
123 *,
124 client: AuthenticatedClient,
125 body: CredentialRenameRequest,
126 x_csrf_token: str,
127) -> Credential | Error | None:
128 """Rename a passkey
130 Args:
131 id (str):
132 x_csrf_token (str):
133 body (CredentialRenameRequest):
135 Raises:
136 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
137 httpx.TimeoutException: If the request takes longer than Client.timeout.
139 Returns:
140 Credential | Error
141 """
143 return sync_detailed(
144 id=id,
145 client=client,
146 body=body,
147 x_csrf_token=x_csrf_token,
148 ).parsed
151async def asyncio_detailed(
152 id: str,
153 *,
154 client: AuthenticatedClient,
155 body: CredentialRenameRequest,
156 x_csrf_token: str,
157) -> Response[Credential | Error]:
158 """Rename a passkey
160 Args:
161 id (str):
162 x_csrf_token (str):
163 body (CredentialRenameRequest):
165 Raises:
166 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
167 httpx.TimeoutException: If the request takes longer than Client.timeout.
169 Returns:
170 Response[Credential | Error]
171 """
173 kwargs = _get_kwargs(
174 id=id,
175 body=body,
176 x_csrf_token=x_csrf_token,
177 )
179 response = await client.get_async_httpx_client().request(**kwargs)
181 return _build_response(client=client, response=response)
184async def asyncio(
185 id: str,
186 *,
187 client: AuthenticatedClient,
188 body: CredentialRenameRequest,
189 x_csrf_token: str,
190) -> Credential | Error | None:
191 """Rename a passkey
193 Args:
194 id (str):
195 x_csrf_token (str):
196 body (CredentialRenameRequest):
198 Raises:
199 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
200 httpx.TimeoutException: If the request takes longer than Client.timeout.
202 Returns:
203 Credential | Error
204 """
206 return (
207 await asyncio_detailed(
208 id=id,
209 client=client,
210 body=body,
211 x_csrf_token=x_csrf_token,
212 )
213 ).parsed