Coverage for src/hush_hush/_generated/api/objects/delete_object.py: 26%

61 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 

6from uuid import UUID 

7 

8import httpx 

9 

10from ... import errors 

11from ...client import AuthenticatedClient, Client 

12from ...models.error import Error 

13from ...types import UNSET, Response, Unset 

14 

15 

16def _get_kwargs( 

17 slug: str, 

18 *, 

19 id: UUID | Unset = UNSET, 

20 consumer: str | Unset = UNSET, 

21 x_caller: str | Unset = UNSET, 

22 x_csrf_token: str | Unset = UNSET, 

23) -> dict[str, Any]: 

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

25 if not isinstance(x_caller, Unset): 

26 headers["X-Caller"] = x_caller 

27 

28 if not isinstance(x_csrf_token, Unset): 

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

30 

31 params: dict[str, Any] = {} 

32 

33 json_id: str | Unset = UNSET 

34 if not isinstance(id, Unset): 

35 json_id = str(id) 

36 params["id"] = json_id 

37 

38 params["consumer"] = consumer 

39 

40 params = {k: v for k, v in params.items() if v is not UNSET and v is not None} 

41 

42 _kwargs: dict[str, Any] = { 

43 "method": "delete", 

44 "url": "/objects/{slug}".format( 

45 slug=quote(str(slug), safe=""), 

46 ), 

47 "params": params, 

48 } 

49 

50 _kwargs["headers"] = headers 

51 return _kwargs 

52 

53 

54def _parse_response( 

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

56) -> Any | Error | None: 

57 if response.status_code == 204: 

58 response_204 = cast(Any, None) 

59 return response_204 

60 

61 if response.status_code == 400: 

62 response_400 = Error.from_dict(response.json()) 

63 

64 return response_400 

65 

66 if response.status_code == 401: 

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

68 

69 return response_401 

70 

71 if response.status_code == 404: 

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

73 

74 return response_404 

75 

76 if response.status_code == 409: 

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

78 

79 return response_409 

80 

81 if response.status_code == 422: 

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

83 

84 return response_422 

85 

86 if client.raise_on_unexpected_status: 

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

88 else: 

89 return None 

90 

91 

92def _build_response( 

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

94) -> Response[Any | Error]: 

95 return Response( 

96 status_code=HTTPStatus(response.status_code), 

97 content=response.content, 

98 headers=response.headers, 

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

100 ) 

101 

102 

103def sync_detailed( 

104 slug: str, 

105 *, 

106 client: AuthenticatedClient, 

107 id: UUID | Unset = UNSET, 

108 consumer: str | Unset = UNSET, 

109 x_caller: str | Unset = UNSET, 

110 x_csrf_token: str | Unset = UNSET, 

111) -> Response[Any | Error]: 

112 """Remove an object 

113 

114 Permanently removes an object. A subsequent fetch by this slug 

115 returns 404. A session-authenticated call needs its CSRF token 

116 too; a bearer-token-authenticated one doesn't. 

117 

118 Args: 

119 slug (str): A caller-chosen, unique identifier for an object - what every 

120 documented request path (URL, CLI, API) addresses it by. Letters of 

121 either case, digits, `_` and `-`, starting with a letter or digit; 

122 names are case-sensitive, so `Api_Token` and `api_token` are two 

123 secrets. Create and rename follow the same rule. The 

124 object's internal id is a separate, opaque value never exposed to 

125 or accepted from a caller (specs/secret-objects/spec.md's 

126 "Internal id decoupled from user-facing slug" requirement). 

127 id (UUID | Unset): 

128 consumer (str | Unset): 

129 x_caller (str | Unset): 

130 x_csrf_token (str | Unset): 

131 

132 Raises: 

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

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

135 

136 Returns: 

137 Response[Any | Error] 

138 """ 

139 

140 kwargs = _get_kwargs( 

141 slug=slug, 

142 id=id, 

143 consumer=consumer, 

144 x_caller=x_caller, 

145 x_csrf_token=x_csrf_token, 

146 ) 

147 

148 response = client.get_httpx_client().request( 

149 **kwargs, 

150 ) 

151 

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

153 

154 

155def sync( 

156 slug: str, 

157 *, 

158 client: AuthenticatedClient, 

159 id: UUID | Unset = UNSET, 

160 consumer: str | Unset = UNSET, 

161 x_caller: str | Unset = UNSET, 

162 x_csrf_token: str | Unset = UNSET, 

163) -> Any | Error | None: 

164 """Remove an object 

165 

166 Permanently removes an object. A subsequent fetch by this slug 

167 returns 404. A session-authenticated call needs its CSRF token 

168 too; a bearer-token-authenticated one doesn't. 

169 

170 Args: 

171 slug (str): A caller-chosen, unique identifier for an object - what every 

172 documented request path (URL, CLI, API) addresses it by. Letters of 

173 either case, digits, `_` and `-`, starting with a letter or digit; 

174 names are case-sensitive, so `Api_Token` and `api_token` are two 

175 secrets. Create and rename follow the same rule. The 

176 object's internal id is a separate, opaque value never exposed to 

177 or accepted from a caller (specs/secret-objects/spec.md's 

178 "Internal id decoupled from user-facing slug" requirement). 

179 id (UUID | Unset): 

180 consumer (str | Unset): 

181 x_caller (str | Unset): 

182 x_csrf_token (str | Unset): 

183 

184 Raises: 

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

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

187 

188 Returns: 

189 Any | Error 

190 """ 

191 

192 return sync_detailed( 

193 slug=slug, 

194 client=client, 

195 id=id, 

196 consumer=consumer, 

197 x_caller=x_caller, 

198 x_csrf_token=x_csrf_token, 

199 ).parsed 

200 

201 

202async def asyncio_detailed( 

203 slug: str, 

204 *, 

205 client: AuthenticatedClient, 

206 id: UUID | Unset = UNSET, 

207 consumer: str | Unset = UNSET, 

208 x_caller: str | Unset = UNSET, 

209 x_csrf_token: str | Unset = UNSET, 

210) -> Response[Any | Error]: 

211 """Remove an object 

212 

213 Permanently removes an object. A subsequent fetch by this slug 

214 returns 404. A session-authenticated call needs its CSRF token 

215 too; a bearer-token-authenticated one doesn't. 

216 

217 Args: 

218 slug (str): A caller-chosen, unique identifier for an object - what every 

219 documented request path (URL, CLI, API) addresses it by. Letters of 

220 either case, digits, `_` and `-`, starting with a letter or digit; 

221 names are case-sensitive, so `Api_Token` and `api_token` are two 

222 secrets. Create and rename follow the same rule. The 

223 object's internal id is a separate, opaque value never exposed to 

224 or accepted from a caller (specs/secret-objects/spec.md's 

225 "Internal id decoupled from user-facing slug" requirement). 

226 id (UUID | Unset): 

227 consumer (str | Unset): 

228 x_caller (str | Unset): 

229 x_csrf_token (str | Unset): 

230 

231 Raises: 

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

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

234 

235 Returns: 

236 Response[Any | Error] 

237 """ 

238 

239 kwargs = _get_kwargs( 

240 slug=slug, 

241 id=id, 

242 consumer=consumer, 

243 x_caller=x_caller, 

244 x_csrf_token=x_csrf_token, 

245 ) 

246 

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

248 

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

250 

251 

252async def asyncio( 

253 slug: str, 

254 *, 

255 client: AuthenticatedClient, 

256 id: UUID | Unset = UNSET, 

257 consumer: str | Unset = UNSET, 

258 x_caller: str | Unset = UNSET, 

259 x_csrf_token: str | Unset = UNSET, 

260) -> Any | Error | None: 

261 """Remove an object 

262 

263 Permanently removes an object. A subsequent fetch by this slug 

264 returns 404. A session-authenticated call needs its CSRF token 

265 too; a bearer-token-authenticated one doesn't. 

266 

267 Args: 

268 slug (str): A caller-chosen, unique identifier for an object - what every 

269 documented request path (URL, CLI, API) addresses it by. Letters of 

270 either case, digits, `_` and `-`, starting with a letter or digit; 

271 names are case-sensitive, so `Api_Token` and `api_token` are two 

272 secrets. Create and rename follow the same rule. The 

273 object's internal id is a separate, opaque value never exposed to 

274 or accepted from a caller (specs/secret-objects/spec.md's 

275 "Internal id decoupled from user-facing slug" requirement). 

276 id (UUID | Unset): 

277 consumer (str | Unset): 

278 x_caller (str | Unset): 

279 x_csrf_token (str | Unset): 

280 

281 Raises: 

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

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

284 

285 Returns: 

286 Any | Error 

287 """ 

288 

289 return ( 

290 await asyncio_detailed( 

291 slug=slug, 

292 client=client, 

293 id=id, 

294 consumer=consumer, 

295 x_caller=x_caller, 

296 x_csrf_token=x_csrf_token, 

297 ) 

298 ).parsed