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
« 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.
3from http import HTTPStatus
4from typing import Any, cast
5from urllib.parse import quote
6from uuid import UUID
8import httpx
10from ... import errors
11from ...client import AuthenticatedClient, Client
12from ...models.error import Error
13from ...types import UNSET, Response, Unset
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
28 if not isinstance(x_csrf_token, Unset):
29 headers["X-CSRF-Token"] = x_csrf_token
31 params: dict[str, Any] = {}
33 json_id: str | Unset = UNSET
34 if not isinstance(id, Unset):
35 json_id = str(id)
36 params["id"] = json_id
38 params["consumer"] = consumer
40 params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
42 _kwargs: dict[str, Any] = {
43 "method": "delete",
44 "url": "/objects/{slug}".format(
45 slug=quote(str(slug), safe=""),
46 ),
47 "params": params,
48 }
50 _kwargs["headers"] = headers
51 return _kwargs
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
61 if response.status_code == 400:
62 response_400 = Error.from_dict(response.json())
64 return response_400
66 if response.status_code == 401:
67 response_401 = Error.from_dict(response.json())
69 return response_401
71 if response.status_code == 404:
72 response_404 = Error.from_dict(response.json())
74 return response_404
76 if response.status_code == 409:
77 response_409 = Error.from_dict(response.json())
79 return response_409
81 if response.status_code == 422:
82 response_422 = Error.from_dict(response.json())
84 return response_422
86 if client.raise_on_unexpected_status:
87 raise errors.UnexpectedStatus(response.status_code, response.content)
88 else:
89 return None
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 )
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
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.
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):
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.
136 Returns:
137 Response[Any | Error]
138 """
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 )
148 response = client.get_httpx_client().request(
149 **kwargs,
150 )
152 return _build_response(client=client, response=response)
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
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.
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):
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.
188 Returns:
189 Any | Error
190 """
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
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
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.
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):
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.
235 Returns:
236 Response[Any | Error]
237 """
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 )
247 response = await client.get_async_httpx_client().request(**kwargs)
249 return _build_response(client=client, response=response)
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
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.
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):
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.
285 Returns:
286 Any | Error
287 """
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