Coverage for src/hush_hush/_generated/api/auth/begin_registration.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
6import httpx
8from ... import errors
9from ...client import AuthenticatedClient, Client
10from ...models.error import Error
11from ...models.registration_options import RegistrationOptions
12from ...types import Response
15def _get_kwargs() -> dict[str, Any]:
17 _kwargs: dict[str, Any] = {
18 "method": "post",
19 "url": "/auth/register/begin",
20 }
22 return _kwargs
25def _parse_response(
26 *, client: AuthenticatedClient | Client, response: httpx.Response
27) -> Error | RegistrationOptions | None:
28 if response.status_code == 200:
29 response_200 = RegistrationOptions.from_dict(response.json())
31 return response_200
33 if response.status_code == 400:
34 response_400 = Error.from_dict(response.json())
36 return response_400
38 if response.status_code == 401:
39 response_401 = Error.from_dict(response.json())
41 return response_401
43 if response.status_code == 413:
44 response_413 = Error.from_dict(response.json())
46 return response_413
48 if client.raise_on_unexpected_status:
49 raise errors.UnexpectedStatus(response.status_code, response.content)
50 else:
51 return None
54def _build_response(
55 *, client: AuthenticatedClient | Client, response: httpx.Response
56) -> Response[Error | RegistrationOptions]:
57 return Response(
58 status_code=HTTPStatus(response.status_code),
59 content=response.content,
60 headers=response.headers,
61 parsed=_parse_response(client=client, response=response),
62 )
65def sync_detailed(
66 *,
67 client: AuthenticatedClient,
68) -> Response[Error | RegistrationOptions]:
69 """Begin passkey registration
71 Starts a WebAuthn registration ceremony and returns the
72 credential-creation options a browser passes to
73 `navigator.credentials.create()`. Anonymous when no admin account
74 exists yet (this is how the account is first created); requires a
75 valid session otherwise, since adding a passkey to an existing
76 account shouldn't be reachable by an unauthenticated caller.
78 Raises:
79 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
80 httpx.TimeoutException: If the request takes longer than Client.timeout.
82 Returns:
83 Response[Error | RegistrationOptions]
84 """
86 kwargs = _get_kwargs()
88 response = client.get_httpx_client().request(
89 **kwargs,
90 )
92 return _build_response(client=client, response=response)
95def sync(
96 *,
97 client: AuthenticatedClient,
98) -> Error | RegistrationOptions | None:
99 """Begin passkey registration
101 Starts a WebAuthn registration ceremony and returns the
102 credential-creation options a browser passes to
103 `navigator.credentials.create()`. Anonymous when no admin account
104 exists yet (this is how the account is first created); requires a
105 valid session otherwise, since adding a passkey to an existing
106 account shouldn't be reachable by an unauthenticated caller.
108 Raises:
109 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
110 httpx.TimeoutException: If the request takes longer than Client.timeout.
112 Returns:
113 Error | RegistrationOptions
114 """
116 return sync_detailed(
117 client=client,
118 ).parsed
121async def asyncio_detailed(
122 *,
123 client: AuthenticatedClient,
124) -> Response[Error | RegistrationOptions]:
125 """Begin passkey registration
127 Starts a WebAuthn registration ceremony and returns the
128 credential-creation options a browser passes to
129 `navigator.credentials.create()`. Anonymous when no admin account
130 exists yet (this is how the account is first created); requires a
131 valid session otherwise, since adding a passkey to an existing
132 account shouldn't be reachable by an unauthenticated caller.
134 Raises:
135 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
136 httpx.TimeoutException: If the request takes longer than Client.timeout.
138 Returns:
139 Response[Error | RegistrationOptions]
140 """
142 kwargs = _get_kwargs()
144 response = await client.get_async_httpx_client().request(**kwargs)
146 return _build_response(client=client, response=response)
149async def asyncio(
150 *,
151 client: AuthenticatedClient,
152) -> Error | RegistrationOptions | None:
153 """Begin passkey registration
155 Starts a WebAuthn registration ceremony and returns the
156 credential-creation options a browser passes to
157 `navigator.credentials.create()`. Anonymous when no admin account
158 exists yet (this is how the account is first created); requires a
159 valid session otherwise, since adding a passkey to an existing
160 account shouldn't be reachable by an unauthenticated caller.
162 Raises:
163 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
164 httpx.TimeoutException: If the request takes longer than Client.timeout.
166 Returns:
167 Error | RegistrationOptions
168 """
170 return (
171 await asyncio_detailed(
172 client=client,
173 )
174 ).parsed