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

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.credential import Credential 

11from ...models.error import Error 

12from ...models.registration_finish_request import RegistrationFinishRequest 

13from ...types import Response 

14 

15 

16def _get_kwargs( 

17 *, 

18 body: RegistrationFinishRequest, 

19) -> dict[str, Any]: 

20 headers: dict[str, Any] = {} 

21 

22 _kwargs: dict[str, Any] = { 

23 "method": "post", 

24 "url": "/auth/register/finish", 

25 } 

26 

27 _kwargs["json"] = body.to_dict() 

28 

29 headers["Content-Type"] = "application/json" 

30 

31 _kwargs["headers"] = headers 

32 return _kwargs 

33 

34 

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

40 

41 return response_201 

42 

43 if response.status_code == 400: 

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

45 

46 return response_400 

47 

48 if response.status_code == 401: 

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

50 

51 return response_401 

52 

53 if response.status_code == 413: 

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

55 

56 return response_413 

57 

58 if client.raise_on_unexpected_status: 

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

60 else: 

61 return None 

62 

63 

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 ) 

73 

74 

75def sync_detailed( 

76 *, 

77 client: AuthenticatedClient, 

78 body: RegistrationFinishRequest, 

79) -> Response[Credential | Error]: 

80 """Complete passkey registration 

81 

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. 

86 

87 Args: 

88 body (RegistrationFinishRequest): 

89 

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. 

93 

94 Returns: 

95 Response[Credential | Error] 

96 """ 

97 

98 kwargs = _get_kwargs( 

99 body=body, 

100 ) 

101 

102 response = client.get_httpx_client().request( 

103 **kwargs, 

104 ) 

105 

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

107 

108 

109def sync( 

110 *, 

111 client: AuthenticatedClient, 

112 body: RegistrationFinishRequest, 

113) -> Credential | Error | None: 

114 """Complete passkey registration 

115 

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. 

120 

121 Args: 

122 body (RegistrationFinishRequest): 

123 

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. 

127 

128 Returns: 

129 Credential | Error 

130 """ 

131 

132 return sync_detailed( 

133 client=client, 

134 body=body, 

135 ).parsed 

136 

137 

138async def asyncio_detailed( 

139 *, 

140 client: AuthenticatedClient, 

141 body: RegistrationFinishRequest, 

142) -> Response[Credential | Error]: 

143 """Complete passkey registration 

144 

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. 

149 

150 Args: 

151 body (RegistrationFinishRequest): 

152 

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. 

156 

157 Returns: 

158 Response[Credential | Error] 

159 """ 

160 

161 kwargs = _get_kwargs( 

162 body=body, 

163 ) 

164 

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

166 

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

168 

169 

170async def asyncio( 

171 *, 

172 client: AuthenticatedClient, 

173 body: RegistrationFinishRequest, 

174) -> Credential | Error | None: 

175 """Complete passkey registration 

176 

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. 

181 

182 Args: 

183 body (RegistrationFinishRequest): 

184 

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. 

188 

189 Returns: 

190 Credential | Error 

191 """ 

192 

193 return ( 

194 await asyncio_detailed( 

195 client=client, 

196 body=body, 

197 ) 

198 ).parsed