tembuilder 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tembuilder/__init__.py +68 -0
- tembuilder/_client.py +575 -0
- tembuilder/_errors.py +99 -0
- tembuilder/_generated/__init__.py +8 -0
- tembuilder/_generated/api/__init__.py +1 -0
- tembuilder/_generated/api/account/__init__.py +1 -0
- tembuilder/_generated/api/account/get_account.py +142 -0
- tembuilder/_generated/api/renders/__init__.py +1 -0
- tembuilder/_generated/api/renders/create_render.py +213 -0
- tembuilder/_generated/api/renders/download_render.py +187 -0
- tembuilder/_generated/api/renders/get_render.py +192 -0
- tembuilder/_generated/api/renders/list_renders.py +279 -0
- tembuilder/_generated/api/templates/__init__.py +1 -0
- tembuilder/_generated/api/templates/get_template.py +219 -0
- tembuilder/_generated/api/templates/list_templates.py +248 -0
- tembuilder/_generated/client.py +268 -0
- tembuilder/_generated/errors.py +16 -0
- tembuilder/_generated/models/__init__.py +65 -0
- tembuilder/_generated/models/account.py +93 -0
- tembuilder/_generated/models/error.py +78 -0
- tembuilder/_generated/models/list_renders_status.py +17 -0
- tembuilder/_generated/models/list_templates_status.py +15 -0
- tembuilder/_generated/models/project.py +78 -0
- tembuilder/_generated/models/render.py +192 -0
- tembuilder/_generated/models/render_page.py +100 -0
- tembuilder/_generated/models/render_queued.py +80 -0
- tembuilder/_generated/models/render_queued_status.py +13 -0
- tembuilder/_generated/models/render_request.py +105 -0
- tembuilder/_generated/models/render_request_parameters.py +46 -0
- tembuilder/_generated/models/render_status.py +99 -0
- tembuilder/_generated/models/render_status_event.py +98 -0
- tembuilder/_generated/models/render_status_event_data.py +189 -0
- tembuilder/_generated/models/render_status_event_data_error.py +69 -0
- tembuilder/_generated/models/render_status_event_data_links.py +61 -0
- tembuilder/_generated/models/render_status_event_data_output.py +77 -0
- tembuilder/_generated/models/render_status_event_type.py +13 -0
- tembuilder/_generated/models/template.py +153 -0
- tembuilder/_generated/models/template_detail.py +186 -0
- tembuilder/_generated/models/template_input.py +125 -0
- tembuilder/_generated/models/template_input_example_parameters.py +46 -0
- tembuilder/_generated/models/template_input_parameters_item.py +44 -0
- tembuilder/_generated/models/template_input_parameters_schema.py +46 -0
- tembuilder/_generated/models/template_page.py +100 -0
- tembuilder/_generated/models/template_variant.py +69 -0
- tembuilder/_generated/models/template_version.py +128 -0
- tembuilder/_generated/models/webhook_test_event.py +87 -0
- tembuilder/_generated/models/webhook_test_event_data.py +61 -0
- tembuilder/_generated/models/webhook_test_event_type.py +13 -0
- tembuilder/_generated/types.py +54 -0
- tembuilder/_transport.py +115 -0
- tembuilder/_version.py +1 -0
- tembuilder/_webhooks.py +71 -0
- tembuilder/py.typed +0 -0
- tembuilder-0.1.0.dist-info/METADATA +112 -0
- tembuilder-0.1.0.dist-info/RECORD +57 -0
- tembuilder-0.1.0.dist-info/WHEEL +4 -0
- tembuilder-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...models.error import Error
|
|
9
|
+
from ...models.list_templates_status import ListTemplatesStatus
|
|
10
|
+
from ...models.template_page import TemplatePage
|
|
11
|
+
from ...types import UNSET, Response, Unset
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
*,
|
|
16
|
+
page: int | Unset = UNSET,
|
|
17
|
+
per_page: int | Unset = UNSET,
|
|
18
|
+
status: ListTemplatesStatus | Unset = UNSET,
|
|
19
|
+
search: str | Unset = UNSET,
|
|
20
|
+
) -> dict[str, Any]:
|
|
21
|
+
params: dict[str, Any] = {}
|
|
22
|
+
|
|
23
|
+
params["page"] = page
|
|
24
|
+
|
|
25
|
+
params["per_page"] = per_page
|
|
26
|
+
|
|
27
|
+
json_status: str | Unset = UNSET
|
|
28
|
+
if not isinstance(status, Unset):
|
|
29
|
+
json_status = status
|
|
30
|
+
|
|
31
|
+
params["status"] = json_status
|
|
32
|
+
|
|
33
|
+
params["search"] = search
|
|
34
|
+
|
|
35
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
36
|
+
|
|
37
|
+
_kwargs: dict[str, Any] = {
|
|
38
|
+
"method": "get",
|
|
39
|
+
"url": "/v1/templates",
|
|
40
|
+
"params": params,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return _kwargs
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | TemplatePage | None:
|
|
47
|
+
if response.status_code == 200:
|
|
48
|
+
response_200 = TemplatePage.from_dict(response.json())
|
|
49
|
+
|
|
50
|
+
return response_200
|
|
51
|
+
|
|
52
|
+
if response.status_code == 400:
|
|
53
|
+
response_400 = Error.from_dict(response.json())
|
|
54
|
+
|
|
55
|
+
return response_400
|
|
56
|
+
|
|
57
|
+
if response.status_code == 401:
|
|
58
|
+
response_401 = Error.from_dict(response.json())
|
|
59
|
+
|
|
60
|
+
return response_401
|
|
61
|
+
|
|
62
|
+
if response.status_code == 403:
|
|
63
|
+
response_403 = Error.from_dict(response.json())
|
|
64
|
+
|
|
65
|
+
return response_403
|
|
66
|
+
|
|
67
|
+
if response.status_code == 500:
|
|
68
|
+
response_500 = Error.from_dict(response.json())
|
|
69
|
+
|
|
70
|
+
return response_500
|
|
71
|
+
|
|
72
|
+
if client.raise_on_unexpected_status:
|
|
73
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
74
|
+
else:
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _build_response(
|
|
79
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
80
|
+
) -> Response[Error | TemplatePage]:
|
|
81
|
+
return Response(
|
|
82
|
+
status_code=HTTPStatus(response.status_code),
|
|
83
|
+
content=response.content,
|
|
84
|
+
headers=response.headers,
|
|
85
|
+
parsed=_parse_response(client=client, response=response),
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def sync_detailed(
|
|
90
|
+
*,
|
|
91
|
+
client: AuthenticatedClient | Client,
|
|
92
|
+
page: int | Unset = UNSET,
|
|
93
|
+
per_page: int | Unset = UNSET,
|
|
94
|
+
status: ListTemplatesStatus | Unset = UNSET,
|
|
95
|
+
search: str | Unset = UNSET,
|
|
96
|
+
) -> Response[Error | TemplatePage]:
|
|
97
|
+
"""List templates
|
|
98
|
+
|
|
99
|
+
Lists the project's templates, most recently updated first. `status`
|
|
100
|
+
filters by the status of each template's current version; use
|
|
101
|
+
`published_versions` to see every version you can render.
|
|
102
|
+
Requires the `template:read` or `template:render` scope.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
page (int | Unset):
|
|
106
|
+
per_page (int | Unset):
|
|
107
|
+
status (ListTemplatesStatus | Unset):
|
|
108
|
+
search (str | Unset):
|
|
109
|
+
|
|
110
|
+
Raises:
|
|
111
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
112
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
Response[Error | TemplatePage]
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
kwargs = _get_kwargs(
|
|
119
|
+
page=page,
|
|
120
|
+
per_page=per_page,
|
|
121
|
+
status=status,
|
|
122
|
+
search=search,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
response = client.get_httpx_client().request(
|
|
126
|
+
**kwargs,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
return _build_response(client=client, response=response)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def sync(
|
|
133
|
+
*,
|
|
134
|
+
client: AuthenticatedClient | Client,
|
|
135
|
+
page: int | Unset = UNSET,
|
|
136
|
+
per_page: int | Unset = UNSET,
|
|
137
|
+
status: ListTemplatesStatus | Unset = UNSET,
|
|
138
|
+
search: str | Unset = UNSET,
|
|
139
|
+
) -> Error | TemplatePage | None:
|
|
140
|
+
"""List templates
|
|
141
|
+
|
|
142
|
+
Lists the project's templates, most recently updated first. `status`
|
|
143
|
+
filters by the status of each template's current version; use
|
|
144
|
+
`published_versions` to see every version you can render.
|
|
145
|
+
Requires the `template:read` or `template:render` scope.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
page (int | Unset):
|
|
149
|
+
per_page (int | Unset):
|
|
150
|
+
status (ListTemplatesStatus | Unset):
|
|
151
|
+
search (str | Unset):
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
155
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
Error | TemplatePage
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
return sync_detailed(
|
|
162
|
+
client=client,
|
|
163
|
+
page=page,
|
|
164
|
+
per_page=per_page,
|
|
165
|
+
status=status,
|
|
166
|
+
search=search,
|
|
167
|
+
).parsed
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
async def asyncio_detailed(
|
|
171
|
+
*,
|
|
172
|
+
client: AuthenticatedClient | Client,
|
|
173
|
+
page: int | Unset = UNSET,
|
|
174
|
+
per_page: int | Unset = UNSET,
|
|
175
|
+
status: ListTemplatesStatus | Unset = UNSET,
|
|
176
|
+
search: str | Unset = UNSET,
|
|
177
|
+
) -> Response[Error | TemplatePage]:
|
|
178
|
+
"""List templates
|
|
179
|
+
|
|
180
|
+
Lists the project's templates, most recently updated first. `status`
|
|
181
|
+
filters by the status of each template's current version; use
|
|
182
|
+
`published_versions` to see every version you can render.
|
|
183
|
+
Requires the `template:read` or `template:render` scope.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
page (int | Unset):
|
|
187
|
+
per_page (int | Unset):
|
|
188
|
+
status (ListTemplatesStatus | Unset):
|
|
189
|
+
search (str | Unset):
|
|
190
|
+
|
|
191
|
+
Raises:
|
|
192
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
193
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
Response[Error | TemplatePage]
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
kwargs = _get_kwargs(
|
|
200
|
+
page=page,
|
|
201
|
+
per_page=per_page,
|
|
202
|
+
status=status,
|
|
203
|
+
search=search,
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
207
|
+
|
|
208
|
+
return _build_response(client=client, response=response)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
async def asyncio(
|
|
212
|
+
*,
|
|
213
|
+
client: AuthenticatedClient | Client,
|
|
214
|
+
page: int | Unset = UNSET,
|
|
215
|
+
per_page: int | Unset = UNSET,
|
|
216
|
+
status: ListTemplatesStatus | Unset = UNSET,
|
|
217
|
+
search: str | Unset = UNSET,
|
|
218
|
+
) -> Error | TemplatePage | None:
|
|
219
|
+
"""List templates
|
|
220
|
+
|
|
221
|
+
Lists the project's templates, most recently updated first. `status`
|
|
222
|
+
filters by the status of each template's current version; use
|
|
223
|
+
`published_versions` to see every version you can render.
|
|
224
|
+
Requires the `template:read` or `template:render` scope.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
page (int | Unset):
|
|
228
|
+
per_page (int | Unset):
|
|
229
|
+
status (ListTemplatesStatus | Unset):
|
|
230
|
+
search (str | Unset):
|
|
231
|
+
|
|
232
|
+
Raises:
|
|
233
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
234
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
Error | TemplatePage
|
|
238
|
+
"""
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
await asyncio_detailed(
|
|
242
|
+
client=client,
|
|
243
|
+
page=page,
|
|
244
|
+
per_page=per_page,
|
|
245
|
+
status=status,
|
|
246
|
+
search=search,
|
|
247
|
+
)
|
|
248
|
+
).parsed
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
from typing import Any, Self
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from attrs import define, evolve, field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@define
|
|
9
|
+
class Client:
|
|
10
|
+
"""A class for keeping track of data related to the API
|
|
11
|
+
|
|
12
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
13
|
+
|
|
14
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
15
|
+
|
|
16
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
17
|
+
|
|
18
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
19
|
+
|
|
20
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
21
|
+
httpx.TimeoutException if this is exceeded.
|
|
22
|
+
|
|
23
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
24
|
+
but can be set to False for testing purposes.
|
|
25
|
+
|
|
26
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
27
|
+
|
|
28
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
33
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
34
|
+
argument to the constructor.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
38
|
+
_base_url: str = field(alias="base_url")
|
|
39
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
40
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
41
|
+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
42
|
+
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
|
|
43
|
+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
|
44
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
45
|
+
_client: httpx.Client | None = field(default=None, init=False)
|
|
46
|
+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
|
|
47
|
+
|
|
48
|
+
def with_headers(self, headers: dict[str, str]) -> "Client":
|
|
49
|
+
"""Get a new client matching this one with additional headers"""
|
|
50
|
+
if self._client is not None:
|
|
51
|
+
self._client.headers.update(headers)
|
|
52
|
+
if self._async_client is not None:
|
|
53
|
+
self._async_client.headers.update(headers)
|
|
54
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
55
|
+
|
|
56
|
+
def with_cookies(self, cookies: dict[str, str]) -> "Client":
|
|
57
|
+
"""Get a new client matching this one with additional cookies"""
|
|
58
|
+
if self._client is not None:
|
|
59
|
+
self._client.cookies.update(cookies)
|
|
60
|
+
if self._async_client is not None:
|
|
61
|
+
self._async_client.cookies.update(cookies)
|
|
62
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
63
|
+
|
|
64
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
|
|
65
|
+
"""Get a new client matching this one with a new timeout configuration"""
|
|
66
|
+
if self._client is not None:
|
|
67
|
+
self._client.timeout = timeout
|
|
68
|
+
if self._async_client is not None:
|
|
69
|
+
self._async_client.timeout = timeout
|
|
70
|
+
return evolve(self, timeout=timeout)
|
|
71
|
+
|
|
72
|
+
def set_httpx_client(self, client: httpx.Client) -> Self:
|
|
73
|
+
"""Manually set the underlying httpx.Client
|
|
74
|
+
|
|
75
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
76
|
+
"""
|
|
77
|
+
self._client = client
|
|
78
|
+
return self
|
|
79
|
+
|
|
80
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
81
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
82
|
+
if self._client is None:
|
|
83
|
+
self._client = httpx.Client(
|
|
84
|
+
base_url=self._base_url,
|
|
85
|
+
cookies=self._cookies,
|
|
86
|
+
headers=self._headers,
|
|
87
|
+
timeout=self._timeout,
|
|
88
|
+
verify=self._verify_ssl,
|
|
89
|
+
follow_redirects=self._follow_redirects,
|
|
90
|
+
**self._httpx_args,
|
|
91
|
+
)
|
|
92
|
+
return self._client
|
|
93
|
+
|
|
94
|
+
def __enter__(self) -> Self:
|
|
95
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
96
|
+
self.get_httpx_client().__enter__()
|
|
97
|
+
return self
|
|
98
|
+
|
|
99
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
100
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
101
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
102
|
+
|
|
103
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
|
|
104
|
+
"""Manually set the underlying httpx.AsyncClient
|
|
105
|
+
|
|
106
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
107
|
+
"""
|
|
108
|
+
self._async_client = async_client
|
|
109
|
+
return self
|
|
110
|
+
|
|
111
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
112
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
113
|
+
if self._async_client is None:
|
|
114
|
+
self._async_client = httpx.AsyncClient(
|
|
115
|
+
base_url=self._base_url,
|
|
116
|
+
cookies=self._cookies,
|
|
117
|
+
headers=self._headers,
|
|
118
|
+
timeout=self._timeout,
|
|
119
|
+
verify=self._verify_ssl,
|
|
120
|
+
follow_redirects=self._follow_redirects,
|
|
121
|
+
**self._httpx_args,
|
|
122
|
+
)
|
|
123
|
+
return self._async_client
|
|
124
|
+
|
|
125
|
+
async def __aenter__(self) -> Self:
|
|
126
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
127
|
+
await self.get_async_httpx_client().__aenter__()
|
|
128
|
+
return self
|
|
129
|
+
|
|
130
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
131
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
132
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@define
|
|
136
|
+
class AuthenticatedClient:
|
|
137
|
+
"""A Client which has been authenticated for use on secured endpoints
|
|
138
|
+
|
|
139
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
140
|
+
|
|
141
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
142
|
+
|
|
143
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
144
|
+
|
|
145
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
146
|
+
|
|
147
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
148
|
+
httpx.TimeoutException if this is exceeded.
|
|
149
|
+
|
|
150
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
151
|
+
but can be set to False for testing purposes.
|
|
152
|
+
|
|
153
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
154
|
+
|
|
155
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
Attributes:
|
|
159
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
160
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
161
|
+
argument to the constructor.
|
|
162
|
+
token: The token to use for authentication
|
|
163
|
+
prefix: The prefix to use for the Authorization header
|
|
164
|
+
auth_header_name: The name of the Authorization header
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
168
|
+
_base_url: str = field(alias="base_url")
|
|
169
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
170
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
171
|
+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
|
|
172
|
+
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
|
|
173
|
+
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
|
|
174
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
175
|
+
_client: httpx.Client | None = field(default=None, init=False)
|
|
176
|
+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
|
|
177
|
+
|
|
178
|
+
token: str
|
|
179
|
+
prefix: str = "Bearer"
|
|
180
|
+
auth_header_name: str = "Authorization"
|
|
181
|
+
|
|
182
|
+
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
|
|
183
|
+
"""Get a new client matching this one with additional headers"""
|
|
184
|
+
if self._client is not None:
|
|
185
|
+
self._client.headers.update(headers)
|
|
186
|
+
if self._async_client is not None:
|
|
187
|
+
self._async_client.headers.update(headers)
|
|
188
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
189
|
+
|
|
190
|
+
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
|
|
191
|
+
"""Get a new client matching this one with additional cookies"""
|
|
192
|
+
if self._client is not None:
|
|
193
|
+
self._client.cookies.update(cookies)
|
|
194
|
+
if self._async_client is not None:
|
|
195
|
+
self._async_client.cookies.update(cookies)
|
|
196
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
197
|
+
|
|
198
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
|
|
199
|
+
"""Get a new client matching this one with a new timeout configuration"""
|
|
200
|
+
if self._client is not None:
|
|
201
|
+
self._client.timeout = timeout
|
|
202
|
+
if self._async_client is not None:
|
|
203
|
+
self._async_client.timeout = timeout
|
|
204
|
+
return evolve(self, timeout=timeout)
|
|
205
|
+
|
|
206
|
+
def set_httpx_client(self, client: httpx.Client) -> Self:
|
|
207
|
+
"""Manually set the underlying httpx.Client
|
|
208
|
+
|
|
209
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
210
|
+
"""
|
|
211
|
+
self._client = client
|
|
212
|
+
return self
|
|
213
|
+
|
|
214
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
215
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
216
|
+
if self._client is None:
|
|
217
|
+
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
218
|
+
self._client = httpx.Client(
|
|
219
|
+
base_url=self._base_url,
|
|
220
|
+
cookies=self._cookies,
|
|
221
|
+
headers=self._headers,
|
|
222
|
+
timeout=self._timeout,
|
|
223
|
+
verify=self._verify_ssl,
|
|
224
|
+
follow_redirects=self._follow_redirects,
|
|
225
|
+
**self._httpx_args,
|
|
226
|
+
)
|
|
227
|
+
return self._client
|
|
228
|
+
|
|
229
|
+
def __enter__(self) -> Self:
|
|
230
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
231
|
+
self.get_httpx_client().__enter__()
|
|
232
|
+
return self
|
|
233
|
+
|
|
234
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
235
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
236
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
237
|
+
|
|
238
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self:
|
|
239
|
+
"""Manually set the underlying httpx.AsyncClient
|
|
240
|
+
|
|
241
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
242
|
+
"""
|
|
243
|
+
self._async_client = async_client
|
|
244
|
+
return self
|
|
245
|
+
|
|
246
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
247
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
248
|
+
if self._async_client is None:
|
|
249
|
+
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
250
|
+
self._async_client = httpx.AsyncClient(
|
|
251
|
+
base_url=self._base_url,
|
|
252
|
+
cookies=self._cookies,
|
|
253
|
+
headers=self._headers,
|
|
254
|
+
timeout=self._timeout,
|
|
255
|
+
verify=self._verify_ssl,
|
|
256
|
+
follow_redirects=self._follow_redirects,
|
|
257
|
+
**self._httpx_args,
|
|
258
|
+
)
|
|
259
|
+
return self._async_client
|
|
260
|
+
|
|
261
|
+
async def __aenter__(self) -> Self:
|
|
262
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
263
|
+
await self.get_async_httpx_client().__aenter__()
|
|
264
|
+
return self
|
|
265
|
+
|
|
266
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
267
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
268
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Contains shared errors types that can be raised from API functions"""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UnexpectedStatus(Exception):
|
|
5
|
+
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
|
6
|
+
|
|
7
|
+
def __init__(self, status_code: int, content: bytes):
|
|
8
|
+
self.status_code = status_code
|
|
9
|
+
self.content = content
|
|
10
|
+
|
|
11
|
+
super().__init__(
|
|
12
|
+
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ["UnexpectedStatus"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Contains all the data models used in inputs/outputs"""
|
|
2
|
+
|
|
3
|
+
from .account import Account
|
|
4
|
+
from .error import Error
|
|
5
|
+
from .list_renders_status import ListRendersStatus
|
|
6
|
+
from .list_templates_status import ListTemplatesStatus
|
|
7
|
+
from .project import Project
|
|
8
|
+
from .render import Render
|
|
9
|
+
from .render_page import RenderPage
|
|
10
|
+
from .render_queued import RenderQueued
|
|
11
|
+
from .render_queued_status import RenderQueuedStatus
|
|
12
|
+
from .render_request import RenderRequest
|
|
13
|
+
from .render_request_parameters import RenderRequestParameters
|
|
14
|
+
from .render_status import RenderStatus
|
|
15
|
+
from .render_status_event import RenderStatusEvent
|
|
16
|
+
from .render_status_event_data import RenderStatusEventData
|
|
17
|
+
from .render_status_event_data_error import RenderStatusEventDataError
|
|
18
|
+
from .render_status_event_data_links import RenderStatusEventDataLinks
|
|
19
|
+
from .render_status_event_data_output import RenderStatusEventDataOutput
|
|
20
|
+
from .render_status_event_type import RenderStatusEventType
|
|
21
|
+
from .template import Template
|
|
22
|
+
from .template_detail import TemplateDetail
|
|
23
|
+
from .template_input import TemplateInput
|
|
24
|
+
from .template_input_example_parameters import TemplateInputExampleParameters
|
|
25
|
+
from .template_input_parameters_item import TemplateInputParametersItem
|
|
26
|
+
from .template_input_parameters_schema import TemplateInputParametersSchema
|
|
27
|
+
from .template_page import TemplatePage
|
|
28
|
+
from .template_variant import TemplateVariant
|
|
29
|
+
from .template_version import TemplateVersion
|
|
30
|
+
from .webhook_test_event import WebhookTestEvent
|
|
31
|
+
from .webhook_test_event_data import WebhookTestEventData
|
|
32
|
+
from .webhook_test_event_type import WebhookTestEventType
|
|
33
|
+
|
|
34
|
+
__all__ = (
|
|
35
|
+
"Account",
|
|
36
|
+
"Error",
|
|
37
|
+
"ListRendersStatus",
|
|
38
|
+
"ListTemplatesStatus",
|
|
39
|
+
"Project",
|
|
40
|
+
"Render",
|
|
41
|
+
"RenderPage",
|
|
42
|
+
"RenderQueued",
|
|
43
|
+
"RenderQueuedStatus",
|
|
44
|
+
"RenderRequest",
|
|
45
|
+
"RenderRequestParameters",
|
|
46
|
+
"RenderStatus",
|
|
47
|
+
"RenderStatusEvent",
|
|
48
|
+
"RenderStatusEventData",
|
|
49
|
+
"RenderStatusEventDataError",
|
|
50
|
+
"RenderStatusEventDataLinks",
|
|
51
|
+
"RenderStatusEventDataOutput",
|
|
52
|
+
"RenderStatusEventType",
|
|
53
|
+
"Template",
|
|
54
|
+
"TemplateDetail",
|
|
55
|
+
"TemplateInput",
|
|
56
|
+
"TemplateInputExampleParameters",
|
|
57
|
+
"TemplateInputParametersItem",
|
|
58
|
+
"TemplateInputParametersSchema",
|
|
59
|
+
"TemplatePage",
|
|
60
|
+
"TemplateVariant",
|
|
61
|
+
"TemplateVersion",
|
|
62
|
+
"WebhookTestEvent",
|
|
63
|
+
"WebhookTestEventData",
|
|
64
|
+
"WebhookTestEventType",
|
|
65
|
+
)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
|
|
7
|
+
from attrs import define as _attrs_define
|
|
8
|
+
from attrs import field as _attrs_field
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from ..models.project import Project
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
T = TypeVar("T", bound="Account")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@_attrs_define
|
|
18
|
+
class Account:
|
|
19
|
+
"""
|
|
20
|
+
Attributes:
|
|
21
|
+
api_key_id (UUID):
|
|
22
|
+
workspace_id (UUID):
|
|
23
|
+
project (Project):
|
|
24
|
+
scopes (list[str]): Granted scopes, e.g. template:render, template:read.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
api_key_id: UUID
|
|
28
|
+
workspace_id: UUID
|
|
29
|
+
project: Project
|
|
30
|
+
scopes: list[str]
|
|
31
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
32
|
+
|
|
33
|
+
def to_dict(self) -> dict[str, Any]:
|
|
34
|
+
|
|
35
|
+
api_key_id = str(self.api_key_id)
|
|
36
|
+
|
|
37
|
+
workspace_id = str(self.workspace_id)
|
|
38
|
+
|
|
39
|
+
project = self.project.to_dict()
|
|
40
|
+
|
|
41
|
+
scopes = self.scopes
|
|
42
|
+
|
|
43
|
+
field_dict: dict[str, Any] = {}
|
|
44
|
+
field_dict.update(self.additional_properties)
|
|
45
|
+
field_dict.update(
|
|
46
|
+
{
|
|
47
|
+
"api_key_id": api_key_id,
|
|
48
|
+
"workspace_id": workspace_id,
|
|
49
|
+
"project": project,
|
|
50
|
+
"scopes": scopes,
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
return field_dict
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
58
|
+
from ..models.project import Project # noqa: PLC0415
|
|
59
|
+
|
|
60
|
+
d = dict(src_dict)
|
|
61
|
+
api_key_id = UUID(d.pop("api_key_id"))
|
|
62
|
+
|
|
63
|
+
workspace_id = UUID(d.pop("workspace_id"))
|
|
64
|
+
|
|
65
|
+
project = Project.from_dict(d.pop("project"))
|
|
66
|
+
|
|
67
|
+
scopes = cast(list[str], d.pop("scopes"))
|
|
68
|
+
|
|
69
|
+
account = cls(
|
|
70
|
+
api_key_id=api_key_id,
|
|
71
|
+
workspace_id=workspace_id,
|
|
72
|
+
project=project,
|
|
73
|
+
scopes=scopes,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
account.additional_properties = d
|
|
77
|
+
return account
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def additional_keys(self) -> list[str]:
|
|
81
|
+
return list(self.additional_properties.keys())
|
|
82
|
+
|
|
83
|
+
def __getitem__(self, key: str) -> Any:
|
|
84
|
+
return self.additional_properties[key]
|
|
85
|
+
|
|
86
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
87
|
+
self.additional_properties[key] = value
|
|
88
|
+
|
|
89
|
+
def __delitem__(self, key: str) -> None:
|
|
90
|
+
del self.additional_properties[key]
|
|
91
|
+
|
|
92
|
+
def __contains__(self, key: str) -> bool:
|
|
93
|
+
return key in self.additional_properties
|