Coverage for src/hush_hush/_generated/api/objects/get_object_used_by.py: 32%
53 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
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 ...models.used_by import UsedBy
14from ...types import UNSET, Response, Unset
17def _get_kwargs(
18 slug: str,
19 *,
20 id: UUID | Unset = UNSET,
21 consumer: str | Unset = UNSET,
22) -> dict[str, Any]:
24 params: dict[str, Any] = {}
26 json_id: str | Unset = UNSET
27 if not isinstance(id, Unset):
28 json_id = str(id)
29 params["id"] = json_id
31 params["consumer"] = consumer
33 params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
35 _kwargs: dict[str, Any] = {
36 "method": "get",
37 "url": "/objects/{slug}/used-by".format(
38 slug=quote(str(slug), safe=""),
39 ),
40 "params": params,
41 }
43 return _kwargs
46def _parse_response(
47 *, client: AuthenticatedClient | Client, response: httpx.Response
48) -> Error | UsedBy | None:
49 if response.status_code == 200:
50 response_200 = UsedBy.from_dict(response.json())
52 return response_200
54 if response.status_code == 400:
55 response_400 = Error.from_dict(response.json())
57 return response_400
59 if response.status_code == 404:
60 response_404 = Error.from_dict(response.json())
62 return response_404
64 if response.status_code == 409:
65 response_409 = Error.from_dict(response.json())
67 return response_409
69 if response.status_code == 422:
70 response_422 = Error.from_dict(response.json())
72 return response_422
74 if client.raise_on_unexpected_status:
75 raise errors.UnexpectedStatus(response.status_code, response.content)
76 else:
77 return None
80def _build_response(
81 *, client: AuthenticatedClient | Client, response: httpx.Response
82) -> Response[Error | UsedBy]:
83 return Response(
84 status_code=HTTPStatus(response.status_code),
85 content=response.content,
86 headers=response.headers,
87 parsed=_parse_response(client=client, response=response),
88 )
91def sync_detailed(
92 slug: str,
93 *,
94 client: AuthenticatedClient | Client,
95 id: UUID | Unset = UNSET,
96 consumer: str | Unset = UNSET,
97) -> Response[Error | UsedBy]:
98 """Query what depends on an object
100 Returns the recorded list of consumers (repos or hosts) for an
101 object - the "what depends on this" mapping, kept queryable rather
102 than left as an implied convention.
104 Args:
105 slug (str): A caller-chosen, unique identifier for an object - what every
106 documented request path (URL, CLI, API) addresses it by. Letters of
107 either case, digits, `_` and `-`, starting with a letter or digit;
108 names are case-sensitive, so `Api_Token` and `api_token` are two
109 secrets. Create and rename follow the same rule. The
110 object's internal id is a separate, opaque value never exposed to
111 or accepted from a caller (specs/secret-objects/spec.md's
112 "Internal id decoupled from user-facing slug" requirement).
113 id (UUID | Unset):
114 consumer (str | Unset):
116 Raises:
117 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
118 httpx.TimeoutException: If the request takes longer than Client.timeout.
120 Returns:
121 Response[Error | UsedBy]
122 """
124 kwargs = _get_kwargs(
125 slug=slug,
126 id=id,
127 consumer=consumer,
128 )
130 response = client.get_httpx_client().request(
131 **kwargs,
132 )
134 return _build_response(client=client, response=response)
137def sync(
138 slug: str,
139 *,
140 client: AuthenticatedClient | Client,
141 id: UUID | Unset = UNSET,
142 consumer: str | Unset = UNSET,
143) -> Error | UsedBy | None:
144 """Query what depends on an object
146 Returns the recorded list of consumers (repos or hosts) for an
147 object - the "what depends on this" mapping, kept queryable rather
148 than left as an implied convention.
150 Args:
151 slug (str): A caller-chosen, unique identifier for an object - what every
152 documented request path (URL, CLI, API) addresses it by. Letters of
153 either case, digits, `_` and `-`, starting with a letter or digit;
154 names are case-sensitive, so `Api_Token` and `api_token` are two
155 secrets. Create and rename follow the same rule. The
156 object's internal id is a separate, opaque value never exposed to
157 or accepted from a caller (specs/secret-objects/spec.md's
158 "Internal id decoupled from user-facing slug" requirement).
159 id (UUID | Unset):
160 consumer (str | Unset):
162 Raises:
163 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
164 httpx.TimeoutException: If the request takes longer than Client.timeout.
166 Returns:
167 Error | UsedBy
168 """
170 return sync_detailed(
171 slug=slug,
172 client=client,
173 id=id,
174 consumer=consumer,
175 ).parsed
178async def asyncio_detailed(
179 slug: str,
180 *,
181 client: AuthenticatedClient | Client,
182 id: UUID | Unset = UNSET,
183 consumer: str | Unset = UNSET,
184) -> Response[Error | UsedBy]:
185 """Query what depends on an object
187 Returns the recorded list of consumers (repos or hosts) for an
188 object - the "what depends on this" mapping, kept queryable rather
189 than left as an implied convention.
191 Args:
192 slug (str): A caller-chosen, unique identifier for an object - what every
193 documented request path (URL, CLI, API) addresses it by. Letters of
194 either case, digits, `_` and `-`, starting with a letter or digit;
195 names are case-sensitive, so `Api_Token` and `api_token` are two
196 secrets. Create and rename follow the same rule. The
197 object's internal id is a separate, opaque value never exposed to
198 or accepted from a caller (specs/secret-objects/spec.md's
199 "Internal id decoupled from user-facing slug" requirement).
200 id (UUID | Unset):
201 consumer (str | Unset):
203 Raises:
204 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
205 httpx.TimeoutException: If the request takes longer than Client.timeout.
207 Returns:
208 Response[Error | UsedBy]
209 """
211 kwargs = _get_kwargs(
212 slug=slug,
213 id=id,
214 consumer=consumer,
215 )
217 response = await client.get_async_httpx_client().request(**kwargs)
219 return _build_response(client=client, response=response)
222async def asyncio(
223 slug: str,
224 *,
225 client: AuthenticatedClient | Client,
226 id: UUID | Unset = UNSET,
227 consumer: str | Unset = UNSET,
228) -> Error | UsedBy | None:
229 """Query what depends on an object
231 Returns the recorded list of consumers (repos or hosts) for an
232 object - the "what depends on this" mapping, kept queryable rather
233 than left as an implied convention.
235 Args:
236 slug (str): A caller-chosen, unique identifier for an object - what every
237 documented request path (URL, CLI, API) addresses it by. Letters of
238 either case, digits, `_` and `-`, starting with a letter or digit;
239 names are case-sensitive, so `Api_Token` and `api_token` are two
240 secrets. Create and rename follow the same rule. The
241 object's internal id is a separate, opaque value never exposed to
242 or accepted from a caller (specs/secret-objects/spec.md's
243 "Internal id decoupled from user-facing slug" requirement).
244 id (UUID | Unset):
245 consumer (str | Unset):
247 Raises:
248 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
249 httpx.TimeoutException: If the request takes longer than Client.timeout.
251 Returns:
252 Error | UsedBy
253 """
255 return (
256 await asyncio_detailed(
257 slug=slug,
258 client=client,
259 id=id,
260 consumer=consumer,
261 )
262 ).parsed