Coverage for src/hush_hush/_generated/api/auth/begin_login.py: 0%

38 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.login_options import LoginOptions 

12from ...types import Response 

13 

14 

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

16 

17 _kwargs: dict[str, Any] = { 

18 "method": "post", 

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

20 } 

21 

22 return _kwargs 

23 

24 

25def _parse_response( 

26 *, client: AuthenticatedClient | Client, response: httpx.Response 

27) -> Error | LoginOptions | None: 

28 if response.status_code == 200: 

29 response_200 = LoginOptions.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 == 413: 

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

40 

41 return response_413 

42 

43 if client.raise_on_unexpected_status: 

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

45 else: 

46 return None 

47 

48 

49def _build_response( 

50 *, client: AuthenticatedClient | Client, response: httpx.Response 

51) -> Response[Error | LoginOptions]: 

52 return Response( 

53 status_code=HTTPStatus(response.status_code), 

54 content=response.content, 

55 headers=response.headers, 

56 parsed=_parse_response(client=client, response=response), 

57 ) 

58 

59 

60def sync_detailed( 

61 *, 

62 client: AuthenticatedClient | Client, 

63) -> Response[Error | LoginOptions]: 

64 """Begin passkey login 

65 

66 Starts a WebAuthn login ceremony and returns the credential-request 

67 options a browser passes to `navigator.credentials.get()`. 

68 

69 Raises: 

70 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

71 httpx.TimeoutException: If the request takes longer than Client.timeout. 

72 

73 Returns: 

74 Response[Error | LoginOptions] 

75 """ 

76 

77 kwargs = _get_kwargs() 

78 

79 response = client.get_httpx_client().request( 

80 **kwargs, 

81 ) 

82 

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

84 

85 

86def sync( 

87 *, 

88 client: AuthenticatedClient | Client, 

89) -> Error | LoginOptions | None: 

90 """Begin passkey login 

91 

92 Starts a WebAuthn login ceremony and returns the credential-request 

93 options a browser passes to `navigator.credentials.get()`. 

94 

95 Raises: 

96 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

97 httpx.TimeoutException: If the request takes longer than Client.timeout. 

98 

99 Returns: 

100 Error | LoginOptions 

101 """ 

102 

103 return sync_detailed( 

104 client=client, 

105 ).parsed 

106 

107 

108async def asyncio_detailed( 

109 *, 

110 client: AuthenticatedClient | Client, 

111) -> Response[Error | LoginOptions]: 

112 """Begin passkey login 

113 

114 Starts a WebAuthn login ceremony and returns the credential-request 

115 options a browser passes to `navigator.credentials.get()`. 

116 

117 Raises: 

118 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

119 httpx.TimeoutException: If the request takes longer than Client.timeout. 

120 

121 Returns: 

122 Response[Error | LoginOptions] 

123 """ 

124 

125 kwargs = _get_kwargs() 

126 

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

128 

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

130 

131 

132async def asyncio( 

133 *, 

134 client: AuthenticatedClient | Client, 

135) -> Error | LoginOptions | None: 

136 """Begin passkey login 

137 

138 Starts a WebAuthn login ceremony and returns the credential-request 

139 options a browser passes to `navigator.credentials.get()`. 

140 

141 Raises: 

142 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. 

143 httpx.TimeoutException: If the request takes longer than Client.timeout. 

144 

145 Returns: 

146 Error | LoginOptions 

147 """ 

148 

149 return ( 

150 await asyncio_detailed( 

151 client=client, 

152 ) 

153 ).parsed