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

40 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, cast 

5 

6import httpx 

7 

8from ... import errors 

9from ...client import AuthenticatedClient, Client 

10from ...models.error import Error 

11from ...types import Response 

12 

13 

14def _get_kwargs( 

15 *, 

16 x_csrf_token: str, 

17) -> dict[str, Any]: 

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

19 headers["X-CSRF-Token"] = x_csrf_token 

20 

21 _kwargs: dict[str, Any] = { 

22 "method": "post", 

23 "url": "/auth/logout", 

24 } 

25 

26 _kwargs["headers"] = headers 

27 return _kwargs 

28 

29 

30def _parse_response( 

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

32) -> Any | Error | None: 

33 if response.status_code == 204: 

34 response_204 = cast(Any, None) 

35 return response_204 

36 

37 if response.status_code == 401: 

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

39 

40 return response_401 

41 

42 if response.status_code == 422: 

43 response_422 = Error.from_dict(response.json()) 

44 

45 return response_422 

46 

47 if client.raise_on_unexpected_status: 

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

49 else: 

50 return None 

51 

52 

53def _build_response( 

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

55) -> Response[Any | Error]: 

56 return Response( 

57 status_code=HTTPStatus(response.status_code), 

58 content=response.content, 

59 headers=response.headers, 

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

61 ) 

62 

63 

64def sync_detailed( 

65 *, 

66 client: AuthenticatedClient, 

67 x_csrf_token: str, 

68) -> Response[Any | Error]: 

69 """End the current session 

70 

71 Invalidates the session presented with the request. State-changing 

72 and session-authenticated, so it requires the session's own CSRF 

73 token echoed back in a header, on top of the cookie itself - the 

74 gap `SameSite=Lax` alone leaves open. 

75 

76 Args: 

77 x_csrf_token (str): 

78 

79 Raises: 

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

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

82 

83 Returns: 

84 Response[Any | Error] 

85 """ 

86 

87 kwargs = _get_kwargs( 

88 x_csrf_token=x_csrf_token, 

89 ) 

90 

91 response = client.get_httpx_client().request( 

92 **kwargs, 

93 ) 

94 

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

96 

97 

98def sync( 

99 *, 

100 client: AuthenticatedClient, 

101 x_csrf_token: str, 

102) -> Any | Error | None: 

103 """End the current session 

104 

105 Invalidates the session presented with the request. State-changing 

106 and session-authenticated, so it requires the session's own CSRF 

107 token echoed back in a header, on top of the cookie itself - the 

108 gap `SameSite=Lax` alone leaves open. 

109 

110 Args: 

111 x_csrf_token (str): 

112 

113 Raises: 

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

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

116 

117 Returns: 

118 Any | Error 

119 """ 

120 

121 return sync_detailed( 

122 client=client, 

123 x_csrf_token=x_csrf_token, 

124 ).parsed 

125 

126 

127async def asyncio_detailed( 

128 *, 

129 client: AuthenticatedClient, 

130 x_csrf_token: str, 

131) -> Response[Any | Error]: 

132 """End the current session 

133 

134 Invalidates the session presented with the request. State-changing 

135 and session-authenticated, so it requires the session's own CSRF 

136 token echoed back in a header, on top of the cookie itself - the 

137 gap `SameSite=Lax` alone leaves open. 

138 

139 Args: 

140 x_csrf_token (str): 

141 

142 Raises: 

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

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

145 

146 Returns: 

147 Response[Any | Error] 

148 """ 

149 

150 kwargs = _get_kwargs( 

151 x_csrf_token=x_csrf_token, 

152 ) 

153 

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

155 

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

157 

158 

159async def asyncio( 

160 *, 

161 client: AuthenticatedClient, 

162 x_csrf_token: str, 

163) -> Any | Error | None: 

164 """End the current session 

165 

166 Invalidates the session presented with the request. State-changing 

167 and session-authenticated, so it requires the session's own CSRF 

168 token echoed back in a header, on top of the cookie itself - the 

169 gap `SameSite=Lax` alone leaves open. 

170 

171 Args: 

172 x_csrf_token (str): 

173 

174 Raises: 

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

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

177 

178 Returns: 

179 Any | Error 

180 """ 

181 

182 return ( 

183 await asyncio_detailed( 

184 client=client, 

185 x_csrf_token=x_csrf_token, 

186 ) 

187 ).parsed