Coverage for src/hush_hush/_generated/api/tokens/revoke_consumer_token.py: 0%

42 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 UNSET, Response, Unset 

13 

14 

15def _get_kwargs( 

16 id: str, 

17 *, 

18 x_csrf_token: str | Unset = UNSET, 

19) -> dict[str, Any]: 

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

21 if not isinstance(x_csrf_token, Unset): 

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

23 

24 _kwargs: dict[str, Any] = { 

25 "method": "delete", 

26 "url": "/consumer-tokens/{id}".format( 

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

28 ), 

29 } 

30 

31 _kwargs["headers"] = headers 

32 return _kwargs 

33 

34 

35def _parse_response( 

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

37) -> Any | Error | None: 

38 if response.status_code == 204: 

39 response_204 = cast(Any, None) 

40 return response_204 

41 

42 if response.status_code == 401: 

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

44 

45 return response_401 

46 

47 if response.status_code == 422: 

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

49 

50 return response_422 

51 

52 if client.raise_on_unexpected_status: 

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

54 else: 

55 return None 

56 

57 

58def _build_response( 

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

60) -> Response[Any | Error]: 

61 return Response( 

62 status_code=HTTPStatus(response.status_code), 

63 content=response.content, 

64 headers=response.headers, 

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

66 ) 

67 

68 

69def sync_detailed( 

70 id: str, 

71 *, 

72 client: AuthenticatedClient, 

73 x_csrf_token: str | Unset = UNSET, 

74) -> Response[Any | Error]: 

75 """Revoke a consumer read token 

76 

77 Invalidates the consumer token issued under id. Revoking an id 

78 that's already expired or doesn't exist isn't an error - both 

79 leave every other token's state unaffected either way. A write 

80 bearer token may revoke one too, the same as it may create one 

81 (alrayyes/hush-hush#467). 

82 

83 Args: 

84 id (str): 

85 x_csrf_token (str | Unset): 

86 

87 Raises: 

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

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

90 

91 Returns: 

92 Response[Any | Error] 

93 """ 

94 

95 kwargs = _get_kwargs( 

96 id=id, 

97 x_csrf_token=x_csrf_token, 

98 ) 

99 

100 response = client.get_httpx_client().request( 

101 **kwargs, 

102 ) 

103 

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

105 

106 

107def sync( 

108 id: str, 

109 *, 

110 client: AuthenticatedClient, 

111 x_csrf_token: str | Unset = UNSET, 

112) -> Any | Error | None: 

113 """Revoke a consumer read token 

114 

115 Invalidates the consumer token issued under id. Revoking an id 

116 that's already expired or doesn't exist isn't an error - both 

117 leave every other token's state unaffected either way. A write 

118 bearer token may revoke one too, the same as it may create one 

119 (alrayyes/hush-hush#467). 

120 

121 Args: 

122 id (str): 

123 x_csrf_token (str | Unset): 

124 

125 Raises: 

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

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

128 

129 Returns: 

130 Any | Error 

131 """ 

132 

133 return sync_detailed( 

134 id=id, 

135 client=client, 

136 x_csrf_token=x_csrf_token, 

137 ).parsed 

138 

139 

140async def asyncio_detailed( 

141 id: str, 

142 *, 

143 client: AuthenticatedClient, 

144 x_csrf_token: str | Unset = UNSET, 

145) -> Response[Any | Error]: 

146 """Revoke a consumer read token 

147 

148 Invalidates the consumer token issued under id. Revoking an id 

149 that's already expired or doesn't exist isn't an error - both 

150 leave every other token's state unaffected either way. A write 

151 bearer token may revoke one too, the same as it may create one 

152 (alrayyes/hush-hush#467). 

153 

154 Args: 

155 id (str): 

156 x_csrf_token (str | Unset): 

157 

158 Raises: 

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

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

161 

162 Returns: 

163 Response[Any | Error] 

164 """ 

165 

166 kwargs = _get_kwargs( 

167 id=id, 

168 x_csrf_token=x_csrf_token, 

169 ) 

170 

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

172 

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

174 

175 

176async def asyncio( 

177 id: str, 

178 *, 

179 client: AuthenticatedClient, 

180 x_csrf_token: str | Unset = UNSET, 

181) -> Any | Error | None: 

182 """Revoke a consumer read token 

183 

184 Invalidates the consumer token issued under id. Revoking an id 

185 that's already expired or doesn't exist isn't an error - both 

186 leave every other token's state unaffected either way. A write 

187 bearer token may revoke one too, the same as it may create one 

188 (alrayyes/hush-hush#467). 

189 

190 Args: 

191 id (str): 

192 x_csrf_token (str | Unset): 

193 

194 Raises: 

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

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

197 

198 Returns: 

199 Any | Error 

200 """ 

201 

202 return ( 

203 await asyncio_detailed( 

204 id=id, 

205 client=client, 

206 x_csrf_token=x_csrf_token, 

207 ) 

208 ).parsed