Coverage for src/hush_hush/_generated/api/consumers/delete_consumer.py: 0%

45 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 name: 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": "/consumers/{name}".format( 

27 name=quote(str(name), 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 == 404: 

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

49 

50 return response_404 

51 

52 if response.status_code == 422: 

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

54 

55 return response_422 

56 

57 if client.raise_on_unexpected_status: 

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

59 else: 

60 return None 

61 

62 

63def _build_response( 

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

65) -> Response[Any | Error]: 

66 return Response( 

67 status_code=HTTPStatus(response.status_code), 

68 content=response.content, 

69 headers=response.headers, 

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

71 ) 

72 

73 

74def sync_detailed( 

75 name: str, 

76 *, 

77 client: AuthenticatedClient, 

78 x_csrf_token: str | Unset = UNSET, 

79) -> Response[Any | Error]: 

80 """Remove a consumer from every object that references it 

81 

82 Strips `name` from the `used_by` list of every stored object that 

83 currently records it - the objects themselves aren't touched 

84 otherwise, and none are deleted even if this empties their 

85 `used_by` list. A subsequent `GET /consumers` no longer lists this 

86 name. The consumer's read tokens are revoked in the same step, so a 

87 token never outlives the consumer it was minted for and can't read 

88 again if a consumer of that name is added later. A 

89 session-authenticated call needs its CSRF token too; a 

90 bearer-token-authenticated one doesn't. 

91 

92 Args: 

93 name (str): 

94 x_csrf_token (str | Unset): 

95 

96 Raises: 

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

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

99 

100 Returns: 

101 Response[Any | Error] 

102 """ 

103 

104 kwargs = _get_kwargs( 

105 name=name, 

106 x_csrf_token=x_csrf_token, 

107 ) 

108 

109 response = client.get_httpx_client().request( 

110 **kwargs, 

111 ) 

112 

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

114 

115 

116def sync( 

117 name: str, 

118 *, 

119 client: AuthenticatedClient, 

120 x_csrf_token: str | Unset = UNSET, 

121) -> Any | Error | None: 

122 """Remove a consumer from every object that references it 

123 

124 Strips `name` from the `used_by` list of every stored object that 

125 currently records it - the objects themselves aren't touched 

126 otherwise, and none are deleted even if this empties their 

127 `used_by` list. A subsequent `GET /consumers` no longer lists this 

128 name. The consumer's read tokens are revoked in the same step, so a 

129 token never outlives the consumer it was minted for and can't read 

130 again if a consumer of that name is added later. A 

131 session-authenticated call needs its CSRF token too; a 

132 bearer-token-authenticated one doesn't. 

133 

134 Args: 

135 name (str): 

136 x_csrf_token (str | Unset): 

137 

138 Raises: 

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

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

141 

142 Returns: 

143 Any | Error 

144 """ 

145 

146 return sync_detailed( 

147 name=name, 

148 client=client, 

149 x_csrf_token=x_csrf_token, 

150 ).parsed 

151 

152 

153async def asyncio_detailed( 

154 name: str, 

155 *, 

156 client: AuthenticatedClient, 

157 x_csrf_token: str | Unset = UNSET, 

158) -> Response[Any | Error]: 

159 """Remove a consumer from every object that references it 

160 

161 Strips `name` from the `used_by` list of every stored object that 

162 currently records it - the objects themselves aren't touched 

163 otherwise, and none are deleted even if this empties their 

164 `used_by` list. A subsequent `GET /consumers` no longer lists this 

165 name. The consumer's read tokens are revoked in the same step, so a 

166 token never outlives the consumer it was minted for and can't read 

167 again if a consumer of that name is added later. A 

168 session-authenticated call needs its CSRF token too; a 

169 bearer-token-authenticated one doesn't. 

170 

171 Args: 

172 name (str): 

173 x_csrf_token (str | Unset): 

174 

175 Raises: 

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

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

178 

179 Returns: 

180 Response[Any | Error] 

181 """ 

182 

183 kwargs = _get_kwargs( 

184 name=name, 

185 x_csrf_token=x_csrf_token, 

186 ) 

187 

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

189 

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

191 

192 

193async def asyncio( 

194 name: str, 

195 *, 

196 client: AuthenticatedClient, 

197 x_csrf_token: str | Unset = UNSET, 

198) -> Any | Error | None: 

199 """Remove a consumer from every object that references it 

200 

201 Strips `name` from the `used_by` list of every stored object that 

202 currently records it - the objects themselves aren't touched 

203 otherwise, and none are deleted even if this empties their 

204 `used_by` list. A subsequent `GET /consumers` no longer lists this 

205 name. The consumer's read tokens are revoked in the same step, so a 

206 token never outlives the consumer it was minted for and can't read 

207 again if a consumer of that name is added later. A 

208 session-authenticated call needs its CSRF token too; a 

209 bearer-token-authenticated one doesn't. 

210 

211 Args: 

212 name (str): 

213 x_csrf_token (str | Unset): 

214 

215 Raises: 

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

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

218 

219 Returns: 

220 Any | Error 

221 """ 

222 

223 return ( 

224 await asyncio_detailed( 

225 name=name, 

226 client=client, 

227 x_csrf_token=x_csrf_token, 

228 ) 

229 ).parsed