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

1# Code generated by openapi-python-client from hush-hush/api/openapi.yaml; DO NOT EDIT. 

2 

3from http import HTTPStatus 

4from typing import Any 

5 

6import httpx 

7 

8from ... import errors 

9from ...client import AuthenticatedClient, Client 

10from ...models.error import Error 

11from ...models.registration_options import RegistrationOptions 

12from ...types import Response 

13 

14 

15def _get_kwargs() -> dict[str, Any]: 

16 

17 _kwargs: dict[str, Any] = { 

18 "method": "post", 

19 "url": "/auth/register/begin", 

20 } 

21 

22 return _kwargs 

23 

24 

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()) 

30 

31 return response_200 

32 

33 if response.status_code == 400: 

34 response_400 = Error.from_dict(response.json()) 

35 

36 return response_400 

37 

38 if response.status_code == 401: 

39 response_401 = Error.from_dict(response.json()) 

40 

41 return response_401 

42 

43 if response.status_code == 413: 

44 response_413 = Error.from_dict(response.json()) 

45 

46 return response_413 

47 

48 if client.raise_on_unexpected_status: 

49 raise errors.UnexpectedStatus(response.status_code, response.content) 

50 else: 

51 return None 

52 

53 

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 ) 

63 

64 

65def sync_detailed( 

66 *, 

67 client: AuthenticatedClient, 

68) -> Response[Error | RegistrationOptions]: 

69 """Begin passkey registration 

70 

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. 

77 

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. 

81 

82 Returns: 

83 Response[Error | RegistrationOptions] 

84 """ 

85 

86 kwargs = _get_kwargs() 

87 

88 response = client.get_httpx_client().request( 

89 **kwargs, 

90 ) 

91 

92 return _build_response(client=client, response=response) 

93 

94 

95def sync( 

96 *, 

97 client: AuthenticatedClient, 

98) -> Error | RegistrationOptions | None: 

99 """Begin passkey registration 

100 

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. 

107 

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. 

111 

112 Returns: 

113 Error | RegistrationOptions 

114 """ 

115 

116 return sync_detailed( 

117 client=client, 

118 ).parsed 

119 

120 

121async def asyncio_detailed( 

122 *, 

123 client: AuthenticatedClient, 

124) -> Response[Error | RegistrationOptions]: 

125 """Begin passkey registration 

126 

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. 

133 

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. 

137 

138 Returns: 

139 Response[Error | RegistrationOptions] 

140 """ 

141 

142 kwargs = _get_kwargs() 

143 

144 response = await client.get_async_httpx_client().request(**kwargs) 

145 

146 return _build_response(client=client, response=response) 

147 

148 

149async def asyncio( 

150 *, 

151 client: AuthenticatedClient, 

152) -> Error | RegistrationOptions | None: 

153 """Begin passkey registration 

154 

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. 

161 

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. 

165 

166 Returns: 

167 Error | RegistrationOptions 

168 """ 

169 

170 return ( 

171 await asyncio_detailed( 

172 client=client, 

173 ) 

174 ).parsed