Coverage for src/hush_hush/_generated/api/tokens/purge_token.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": "/tokens/{id}/purge".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 """Permanently delete a dead write bearer token 

85 

86 Permanently removes the token issued under id, once it's already 

87 revoked or past its expiry - `revokeToken`'s soft-delete stays the 

88 only way to invalidate a still-active token. Unlike `revokeToken`, 

89 an audit-log entry attributed to a purged token's id no longer 

90 resolves to a description or owner afterward - the accepted 

91 tradeoff for actually removing it. 

92 

93 Args: 

94 id (str): 

95 x_csrf_token (str): 

96 

97 Raises: 

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

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

100 

101 Returns: 

102 Response[Any | Error] 

103 """ 

104 

105 kwargs = _get_kwargs( 

106 id=id, 

107 x_csrf_token=x_csrf_token, 

108 ) 

109 

110 response = client.get_httpx_client().request( 

111 **kwargs, 

112 ) 

113 

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

115 

116 

117def sync( 

118 id: str, 

119 *, 

120 client: AuthenticatedClient, 

121 x_csrf_token: str, 

122) -> Any | Error | None: 

123 """Permanently delete a dead write bearer token 

124 

125 Permanently removes the token issued under id, once it's already 

126 revoked or past its expiry - `revokeToken`'s soft-delete stays the 

127 only way to invalidate a still-active token. Unlike `revokeToken`, 

128 an audit-log entry attributed to a purged token's id no longer 

129 resolves to a description or owner afterward - the accepted 

130 tradeoff for actually removing it. 

131 

132 Args: 

133 id (str): 

134 x_csrf_token (str): 

135 

136 Raises: 

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

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

139 

140 Returns: 

141 Any | Error 

142 """ 

143 

144 return sync_detailed( 

145 id=id, 

146 client=client, 

147 x_csrf_token=x_csrf_token, 

148 ).parsed 

149 

150 

151async def asyncio_detailed( 

152 id: str, 

153 *, 

154 client: AuthenticatedClient, 

155 x_csrf_token: str, 

156) -> Response[Any | Error]: 

157 """Permanently delete a dead write bearer token 

158 

159 Permanently removes the token issued under id, once it's already 

160 revoked or past its expiry - `revokeToken`'s soft-delete stays the 

161 only way to invalidate a still-active token. Unlike `revokeToken`, 

162 an audit-log entry attributed to a purged token's id no longer 

163 resolves to a description or owner afterward - the accepted 

164 tradeoff for actually removing it. 

165 

166 Args: 

167 id (str): 

168 x_csrf_token (str): 

169 

170 Raises: 

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

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

173 

174 Returns: 

175 Response[Any | Error] 

176 """ 

177 

178 kwargs = _get_kwargs( 

179 id=id, 

180 x_csrf_token=x_csrf_token, 

181 ) 

182 

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

184 

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

186 

187 

188async def asyncio( 

189 id: str, 

190 *, 

191 client: AuthenticatedClient, 

192 x_csrf_token: str, 

193) -> Any | Error | None: 

194 """Permanently delete a dead write bearer token 

195 

196 Permanently removes the token issued under id, once it's already 

197 revoked or past its expiry - `revokeToken`'s soft-delete stays the 

198 only way to invalidate a still-active token. Unlike `revokeToken`, 

199 an audit-log entry attributed to a purged token's id no longer 

200 resolves to a description or owner afterward - the accepted 

201 tradeoff for actually removing it. 

202 

203 Args: 

204 id (str): 

205 x_csrf_token (str): 

206 

207 Raises: 

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

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

210 

211 Returns: 

212 Any | Error 

213 """ 

214 

215 return ( 

216 await asyncio_detailed( 

217 id=id, 

218 client=client, 

219 x_csrf_token=x_csrf_token, 

220 ) 

221 ).parsed