Coverage for src/hush_hush/_generated/api/auth/finish_registration.py: 0%
46 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
6import httpx
8from ... import errors
9from ...client import AuthenticatedClient, Client
10from ...models.credential import Credential
11from ...models.error import Error
12from ...models.registration_finish_request import RegistrationFinishRequest
13from ...types import Response
16def _get_kwargs(
17 *,
18 body: RegistrationFinishRequest,
19) -> dict[str, Any]:
20 headers: dict[str, Any] = {}
22 _kwargs: dict[str, Any] = {
23 "method": "post",
24 "url": "/auth/register/finish",
25 }
27 _kwargs["json"] = body.to_dict()
29 headers["Content-Type"] = "application/json"
31 _kwargs["headers"] = headers
32 return _kwargs
35def _parse_response(
36 *, client: AuthenticatedClient | Client, response: httpx.Response
37) -> Credential | Error | None:
38 if response.status_code == 201:
39 response_201 = Credential.from_dict(response.json())
41 return response_201
43 if response.status_code == 400:
44 response_400 = Error.from_dict(response.json())
46 return response_400
48 if response.status_code == 401:
49 response_401 = Error.from_dict(response.json())
51 return response_401
53 if response.status_code == 413:
54 response_413 = Error.from_dict(response.json())
56 return response_413
58 if client.raise_on_unexpected_status:
59 raise errors.UnexpectedStatus(response.status_code, response.content)
60 else:
61 return None
64def _build_response(
65 *, client: AuthenticatedClient | Client, response: httpx.Response
66) -> Response[Credential | Error]:
67 return Response(
68 status_code=HTTPStatus(response.status_code),
69 content=response.content,
70 headers=response.headers,
71 parsed=_parse_response(client=client, response=response),
72 )
75def sync_detailed(
76 *,
77 client: AuthenticatedClient,
78 body: RegistrationFinishRequest,
79) -> Response[Credential | Error]:
80 """Complete passkey registration
82 Verifies the browser's attestation response and stores the new
83 credential. The first successful call (no admin account yet)
84 creates the account; every later call adds another credential to
85 it. Issues a new session either way.
87 Args:
88 body (RegistrationFinishRequest):
90 Raises:
91 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
92 httpx.TimeoutException: If the request takes longer than Client.timeout.
94 Returns:
95 Response[Credential | Error]
96 """
98 kwargs = _get_kwargs(
99 body=body,
100 )
102 response = client.get_httpx_client().request(
103 **kwargs,
104 )
106 return _build_response(client=client, response=response)
109def sync(
110 *,
111 client: AuthenticatedClient,
112 body: RegistrationFinishRequest,
113) -> Credential | Error | None:
114 """Complete passkey registration
116 Verifies the browser's attestation response and stores the new
117 credential. The first successful call (no admin account yet)
118 creates the account; every later call adds another credential to
119 it. Issues a new session either way.
121 Args:
122 body (RegistrationFinishRequest):
124 Raises:
125 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
126 httpx.TimeoutException: If the request takes longer than Client.timeout.
128 Returns:
129 Credential | Error
130 """
132 return sync_detailed(
133 client=client,
134 body=body,
135 ).parsed
138async def asyncio_detailed(
139 *,
140 client: AuthenticatedClient,
141 body: RegistrationFinishRequest,
142) -> Response[Credential | Error]:
143 """Complete passkey registration
145 Verifies the browser's attestation response and stores the new
146 credential. The first successful call (no admin account yet)
147 creates the account; every later call adds another credential to
148 it. Issues a new session either way.
150 Args:
151 body (RegistrationFinishRequest):
153 Raises:
154 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155 httpx.TimeoutException: If the request takes longer than Client.timeout.
157 Returns:
158 Response[Credential | Error]
159 """
161 kwargs = _get_kwargs(
162 body=body,
163 )
165 response = await client.get_async_httpx_client().request(**kwargs)
167 return _build_response(client=client, response=response)
170async def asyncio(
171 *,
172 client: AuthenticatedClient,
173 body: RegistrationFinishRequest,
174) -> Credential | Error | None:
175 """Complete passkey registration
177 Verifies the browser's attestation response and stores the new
178 credential. The first successful call (no admin account yet)
179 creates the account; every later call adds another credential to
180 it. Issues a new session either way.
182 Args:
183 body (RegistrationFinishRequest):
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 Credential | Error
191 """
193 return (
194 await asyncio_detailed(
195 client=client,
196 body=body,
197 )
198 ).parsed