Coverage for src/hush_hush/_generated/api/credentials/delete_credential.py: 0%

47 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 

5from urllib.parse import quote 

6 

7import httpx 

8 

9from ... import errors 

10from ...client import AuthenticatedClient, Client 

11from ...models.error import Error 

12from ...types import Response 

13 

14 

15def _get_kwargs( 

16 id: str, 

17 *, 

18 x_csrf_token: str, 

19) -> dict[str, Any]: 

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

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

22 

23 _kwargs: dict[str, Any] = { 

24 "method": "delete", 

25 "url": "/credentials/{id}".format( 

26 id=quote(str(id), safe=""), 

27 ), 

28 } 

29 

30 _kwargs["headers"] = headers 

31 return _kwargs 

32 

33 

34def _parse_response( 

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

36) -> Any | Error | None: 

37 if response.status_code == 204: 

38 response_204 = cast(Any, None) 

39 return response_204 

40 

41 if response.status_code == 401: 

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

43 

44 return response_401 

45 

46 if response.status_code == 404: 

47 response_404 = Error.from_dict(response.json()) 

48 

49 return response_404 

50 

51 if response.status_code == 409: 

52 response_409 = Error.from_dict(response.json()) 

53 

54 return response_409 

55 

56 if response.status_code == 422: 

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

58 

59 return response_422 

60 

61 if client.raise_on_unexpected_status: 

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

63 else: 

64 return None 

65 

66 

67def _build_response( 

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

69) -> Response[Any | Error]: 

70 return Response( 

71 status_code=HTTPStatus(response.status_code), 

72 content=response.content, 

73 headers=response.headers, 

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

75 ) 

76 

77 

78def sync_detailed( 

79 id: str, 

80 *, 

81 client: AuthenticatedClient, 

82 x_csrf_token: str, 

83) -> Response[Any | Error]: 

84 """Remove a passkey 

85 

86 Permanently removes a credential. Refused when it's the only one 

87 remaining - a passkey the account can't log in with is never left 

88 as its last one. 

89 

90 Args: 

91 id (str): 

92 x_csrf_token (str): 

93 

94 Raises: 

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

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

97 

98 Returns: 

99 Response[Any | Error] 

100 """ 

101 

102 kwargs = _get_kwargs( 

103 id=id, 

104 x_csrf_token=x_csrf_token, 

105 ) 

106 

107 response = client.get_httpx_client().request( 

108 **kwargs, 

109 ) 

110 

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

112 

113 

114def sync( 

115 id: str, 

116 *, 

117 client: AuthenticatedClient, 

118 x_csrf_token: str, 

119) -> Any | Error | None: 

120 """Remove a passkey 

121 

122 Permanently removes a credential. Refused when it's the only one 

123 remaining - a passkey the account can't log in with is never left 

124 as its last one. 

125 

126 Args: 

127 id (str): 

128 x_csrf_token (str): 

129 

130 Raises: 

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

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

133 

134 Returns: 

135 Any | Error 

136 """ 

137 

138 return sync_detailed( 

139 id=id, 

140 client=client, 

141 x_csrf_token=x_csrf_token, 

142 ).parsed 

143 

144 

145async def asyncio_detailed( 

146 id: str, 

147 *, 

148 client: AuthenticatedClient, 

149 x_csrf_token: str, 

150) -> Response[Any | Error]: 

151 """Remove a passkey 

152 

153 Permanently removes a credential. Refused when it's the only one 

154 remaining - a passkey the account can't log in with is never left 

155 as its last one. 

156 

157 Args: 

158 id (str): 

159 x_csrf_token (str): 

160 

161 Raises: 

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

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

164 

165 Returns: 

166 Response[Any | Error] 

167 """ 

168 

169 kwargs = _get_kwargs( 

170 id=id, 

171 x_csrf_token=x_csrf_token, 

172 ) 

173 

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

175 

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

177 

178 

179async def asyncio( 

180 id: str, 

181 *, 

182 client: AuthenticatedClient, 

183 x_csrf_token: str, 

184) -> Any | Error | None: 

185 """Remove a passkey 

186 

187 Permanently removes a credential. Refused when it's the only one 

188 remaining - a passkey the account can't log in with is never left 

189 as its last one. 

190 

191 Args: 

192 id (str): 

193 x_csrf_token (str): 

194 

195 Raises: 

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

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

198 

199 Returns: 

200 Any | Error 

201 """ 

202 

203 return ( 

204 await asyncio_detailed( 

205 id=id, 

206 client=client, 

207 x_csrf_token=x_csrf_token, 

208 ) 

209 ).parsed