flatmark 1.0.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.
- flatmark/__init__.py +8 -0
- flatmark/api/__init__.py +1 -0
- flatmark/api/account/__init__.py +1 -0
- flatmark/api/account/get_me.py +176 -0
- flatmark/api/convert/__init__.py +1 -0
- flatmark/api/convert/convert_document.py +253 -0
- flatmark/api/convert/get_conversion_result.py +237 -0
- flatmark/api/convert/submit_conversion_job.py +284 -0
- flatmark/api/jobs/__init__.py +1 -0
- flatmark/api/jobs/get_job.py +189 -0
- flatmark/api/jobs/list_jobs.py +211 -0
- flatmark/client.py +268 -0
- flatmark/errors.py +16 -0
- flatmark/models/__init__.py +33 -0
- flatmark/models/body_convert_document.py +75 -0
- flatmark/models/body_submit_conversion_job.py +102 -0
- flatmark/models/credits_info.py +95 -0
- flatmark/models/get_conversion_result_format.py +9 -0
- flatmark/models/job_response.py +230 -0
- flatmark/models/job_response_page.py +97 -0
- flatmark/models/job_response_result_type_0.py +45 -0
- flatmark/models/job_submit_response.py +109 -0
- flatmark/models/me_response.py +135 -0
- flatmark/models/problem.py +190 -0
- flatmark/models/problem_errors_type_0_item.py +45 -0
- flatmark/models/rate_limit_info.py +118 -0
- flatmark/models/sync_convert_response.py +87 -0
- flatmark/models/sync_convert_response_meta.py +47 -0
- flatmark/py.typed +1 -0
- flatmark/types.py +54 -0
- flatmark-1.0.0.dist-info/METADATA +50 -0
- flatmark-1.0.0.dist-info/RECORD +33 -0
- flatmark-1.0.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,284 @@
|
|
|
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.body_submit_conversion_job import BodySubmitConversionJob
|
|
9
|
+
from ...models.job_submit_response import JobSubmitResponse
|
|
10
|
+
from ...models.problem import Problem
|
|
11
|
+
from ...types import Response
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
*,
|
|
16
|
+
body: BodySubmitConversionJob,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
headers: dict[str, Any] = {}
|
|
19
|
+
|
|
20
|
+
_kwargs: dict[str, Any] = {
|
|
21
|
+
"method": "post",
|
|
22
|
+
"url": "/v1/convert/jobs",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_kwargs["files"] = body.to_multipart()
|
|
26
|
+
|
|
27
|
+
headers["Content-Type"] = "multipart/form-data; boundary=+++"
|
|
28
|
+
|
|
29
|
+
_kwargs["headers"] = headers
|
|
30
|
+
return _kwargs
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _parse_response(
|
|
34
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
35
|
+
) -> JobSubmitResponse | Problem | None:
|
|
36
|
+
if response.status_code == 200:
|
|
37
|
+
response_200 = JobSubmitResponse.from_dict(response.json())
|
|
38
|
+
|
|
39
|
+
return response_200
|
|
40
|
+
|
|
41
|
+
if response.status_code == 401:
|
|
42
|
+
response_401 = Problem.from_dict(response.json())
|
|
43
|
+
|
|
44
|
+
return response_401
|
|
45
|
+
|
|
46
|
+
if response.status_code == 402:
|
|
47
|
+
response_402 = Problem.from_dict(response.json())
|
|
48
|
+
|
|
49
|
+
return response_402
|
|
50
|
+
|
|
51
|
+
if response.status_code == 413:
|
|
52
|
+
response_413 = Problem.from_dict(response.json())
|
|
53
|
+
|
|
54
|
+
return response_413
|
|
55
|
+
|
|
56
|
+
if response.status_code == 415:
|
|
57
|
+
response_415 = Problem.from_dict(response.json())
|
|
58
|
+
|
|
59
|
+
return response_415
|
|
60
|
+
|
|
61
|
+
if response.status_code == 422:
|
|
62
|
+
response_422 = Problem.from_dict(response.json())
|
|
63
|
+
|
|
64
|
+
return response_422
|
|
65
|
+
|
|
66
|
+
if response.status_code == 429:
|
|
67
|
+
response_429 = Problem.from_dict(response.json())
|
|
68
|
+
|
|
69
|
+
return response_429
|
|
70
|
+
|
|
71
|
+
if response.status_code == 503:
|
|
72
|
+
response_503 = Problem.from_dict(response.json())
|
|
73
|
+
|
|
74
|
+
return response_503
|
|
75
|
+
|
|
76
|
+
if client.raise_on_unexpected_status:
|
|
77
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
78
|
+
else:
|
|
79
|
+
return None
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _build_response(
|
|
83
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
84
|
+
) -> Response[JobSubmitResponse | Problem]:
|
|
85
|
+
return Response(
|
|
86
|
+
status_code=HTTPStatus(response.status_code),
|
|
87
|
+
content=response.content,
|
|
88
|
+
headers=response.headers,
|
|
89
|
+
parsed=_parse_response(client=client, response=response),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def sync_detailed(
|
|
94
|
+
*,
|
|
95
|
+
client: AuthenticatedClient,
|
|
96
|
+
body: BodySubmitConversionJob,
|
|
97
|
+
) -> Response[JobSubmitResponse | Problem]:
|
|
98
|
+
"""Queue a document for conversion with OCR and tables
|
|
99
|
+
|
|
100
|
+
Queues one document up to 25 MB and 200 pages for conversion with Docling.
|
|
101
|
+
|
|
102
|
+
Accepted types are the same as for `POST /v1/convert`. The queue runs OCR
|
|
103
|
+
(text recognition) and recognizes tables, headings and reading order. A
|
|
104
|
+
conversion may take up to about 2 minutes; longer ones are stopped and fail.
|
|
105
|
+
|
|
106
|
+
Poll `GET /v1/jobs/{id}` (free) until `status` is `succeeded` or `failed`,
|
|
107
|
+
then download the result from `result_url` (free). The result is Markdown, or
|
|
108
|
+
the DoclingDocument JSON with `?format=json`.
|
|
109
|
+
|
|
110
|
+
With `webhook_url`, the job's final state is POSTed there as JSON
|
|
111
|
+
(`job_id`, `status`, `result`, `error`). The request carries
|
|
112
|
+
`X-Appkit-Signature: sha256=<hex>`, an HMAC-SHA256 of the raw request body
|
|
113
|
+
keyed with the `webhook_secret` from this response. `webhook_secret` is shown
|
|
114
|
+
only once. A delivery that fails is retried, 3 attempts in total.
|
|
115
|
+
|
|
116
|
+
Requires an API key. The credits are charged at submission and refunded if
|
|
117
|
+
the job fails. The uploaded file is deleted when the job finishes. Results
|
|
118
|
+
are kept for 7 days after submission.
|
|
119
|
+
|
|
120
|
+
**Credits:** 10 per call.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
body (BodySubmitConversionJob):
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
127
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Response[JobSubmitResponse | Problem]
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
kwargs = _get_kwargs(
|
|
134
|
+
body=body,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
response = client.get_httpx_client().request(
|
|
138
|
+
**kwargs,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
return _build_response(client=client, response=response)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def sync(
|
|
145
|
+
*,
|
|
146
|
+
client: AuthenticatedClient,
|
|
147
|
+
body: BodySubmitConversionJob,
|
|
148
|
+
) -> JobSubmitResponse | Problem | None:
|
|
149
|
+
"""Queue a document for conversion with OCR and tables
|
|
150
|
+
|
|
151
|
+
Queues one document up to 25 MB and 200 pages for conversion with Docling.
|
|
152
|
+
|
|
153
|
+
Accepted types are the same as for `POST /v1/convert`. The queue runs OCR
|
|
154
|
+
(text recognition) and recognizes tables, headings and reading order. A
|
|
155
|
+
conversion may take up to about 2 minutes; longer ones are stopped and fail.
|
|
156
|
+
|
|
157
|
+
Poll `GET /v1/jobs/{id}` (free) until `status` is `succeeded` or `failed`,
|
|
158
|
+
then download the result from `result_url` (free). The result is Markdown, or
|
|
159
|
+
the DoclingDocument JSON with `?format=json`.
|
|
160
|
+
|
|
161
|
+
With `webhook_url`, the job's final state is POSTed there as JSON
|
|
162
|
+
(`job_id`, `status`, `result`, `error`). The request carries
|
|
163
|
+
`X-Appkit-Signature: sha256=<hex>`, an HMAC-SHA256 of the raw request body
|
|
164
|
+
keyed with the `webhook_secret` from this response. `webhook_secret` is shown
|
|
165
|
+
only once. A delivery that fails is retried, 3 attempts in total.
|
|
166
|
+
|
|
167
|
+
Requires an API key. The credits are charged at submission and refunded if
|
|
168
|
+
the job fails. The uploaded file is deleted when the job finishes. Results
|
|
169
|
+
are kept for 7 days after submission.
|
|
170
|
+
|
|
171
|
+
**Credits:** 10 per call.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
body (BodySubmitConversionJob):
|
|
175
|
+
|
|
176
|
+
Raises:
|
|
177
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
178
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
JobSubmitResponse | Problem
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
return sync_detailed(
|
|
185
|
+
client=client,
|
|
186
|
+
body=body,
|
|
187
|
+
).parsed
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
async def asyncio_detailed(
|
|
191
|
+
*,
|
|
192
|
+
client: AuthenticatedClient,
|
|
193
|
+
body: BodySubmitConversionJob,
|
|
194
|
+
) -> Response[JobSubmitResponse | Problem]:
|
|
195
|
+
"""Queue a document for conversion with OCR and tables
|
|
196
|
+
|
|
197
|
+
Queues one document up to 25 MB and 200 pages for conversion with Docling.
|
|
198
|
+
|
|
199
|
+
Accepted types are the same as for `POST /v1/convert`. The queue runs OCR
|
|
200
|
+
(text recognition) and recognizes tables, headings and reading order. A
|
|
201
|
+
conversion may take up to about 2 minutes; longer ones are stopped and fail.
|
|
202
|
+
|
|
203
|
+
Poll `GET /v1/jobs/{id}` (free) until `status` is `succeeded` or `failed`,
|
|
204
|
+
then download the result from `result_url` (free). The result is Markdown, or
|
|
205
|
+
the DoclingDocument JSON with `?format=json`.
|
|
206
|
+
|
|
207
|
+
With `webhook_url`, the job's final state is POSTed there as JSON
|
|
208
|
+
(`job_id`, `status`, `result`, `error`). The request carries
|
|
209
|
+
`X-Appkit-Signature: sha256=<hex>`, an HMAC-SHA256 of the raw request body
|
|
210
|
+
keyed with the `webhook_secret` from this response. `webhook_secret` is shown
|
|
211
|
+
only once. A delivery that fails is retried, 3 attempts in total.
|
|
212
|
+
|
|
213
|
+
Requires an API key. The credits are charged at submission and refunded if
|
|
214
|
+
the job fails. The uploaded file is deleted when the job finishes. Results
|
|
215
|
+
are kept for 7 days after submission.
|
|
216
|
+
|
|
217
|
+
**Credits:** 10 per call.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
body (BodySubmitConversionJob):
|
|
221
|
+
|
|
222
|
+
Raises:
|
|
223
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
224
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
Response[JobSubmitResponse | Problem]
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
kwargs = _get_kwargs(
|
|
231
|
+
body=body,
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
235
|
+
|
|
236
|
+
return _build_response(client=client, response=response)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
async def asyncio(
|
|
240
|
+
*,
|
|
241
|
+
client: AuthenticatedClient,
|
|
242
|
+
body: BodySubmitConversionJob,
|
|
243
|
+
) -> JobSubmitResponse | Problem | None:
|
|
244
|
+
"""Queue a document for conversion with OCR and tables
|
|
245
|
+
|
|
246
|
+
Queues one document up to 25 MB and 200 pages for conversion with Docling.
|
|
247
|
+
|
|
248
|
+
Accepted types are the same as for `POST /v1/convert`. The queue runs OCR
|
|
249
|
+
(text recognition) and recognizes tables, headings and reading order. A
|
|
250
|
+
conversion may take up to about 2 minutes; longer ones are stopped and fail.
|
|
251
|
+
|
|
252
|
+
Poll `GET /v1/jobs/{id}` (free) until `status` is `succeeded` or `failed`,
|
|
253
|
+
then download the result from `result_url` (free). The result is Markdown, or
|
|
254
|
+
the DoclingDocument JSON with `?format=json`.
|
|
255
|
+
|
|
256
|
+
With `webhook_url`, the job's final state is POSTed there as JSON
|
|
257
|
+
(`job_id`, `status`, `result`, `error`). The request carries
|
|
258
|
+
`X-Appkit-Signature: sha256=<hex>`, an HMAC-SHA256 of the raw request body
|
|
259
|
+
keyed with the `webhook_secret` from this response. `webhook_secret` is shown
|
|
260
|
+
only once. A delivery that fails is retried, 3 attempts in total.
|
|
261
|
+
|
|
262
|
+
Requires an API key. The credits are charged at submission and refunded if
|
|
263
|
+
the job fails. The uploaded file is deleted when the job finishes. Results
|
|
264
|
+
are kept for 7 days after submission.
|
|
265
|
+
|
|
266
|
+
**Credits:** 10 per call.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
body (BodySubmitConversionJob):
|
|
270
|
+
|
|
271
|
+
Raises:
|
|
272
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
273
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
JobSubmitResponse | Problem
|
|
277
|
+
"""
|
|
278
|
+
|
|
279
|
+
return (
|
|
280
|
+
await asyncio_detailed(
|
|
281
|
+
client=client,
|
|
282
|
+
body=body,
|
|
283
|
+
)
|
|
284
|
+
).parsed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.job_response import JobResponse
|
|
10
|
+
from ...models.problem import Problem
|
|
11
|
+
from ...types import Response
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
job_id: str,
|
|
16
|
+
) -> dict[str, Any]:
|
|
17
|
+
|
|
18
|
+
_kwargs: dict[str, Any] = {
|
|
19
|
+
"method": "get",
|
|
20
|
+
"url": "/v1/jobs/{job_id}".format(
|
|
21
|
+
job_id=quote(str(job_id), safe=""),
|
|
22
|
+
),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return _kwargs
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> JobResponse | Problem | None:
|
|
29
|
+
if response.status_code == 200:
|
|
30
|
+
response_200 = JobResponse.from_dict(response.json())
|
|
31
|
+
|
|
32
|
+
return response_200
|
|
33
|
+
|
|
34
|
+
if response.status_code == 404:
|
|
35
|
+
response_404 = Problem.from_dict(response.json())
|
|
36
|
+
|
|
37
|
+
return response_404
|
|
38
|
+
|
|
39
|
+
if response.status_code == 422:
|
|
40
|
+
response_422 = Problem.from_dict(response.json())
|
|
41
|
+
|
|
42
|
+
return response_422
|
|
43
|
+
|
|
44
|
+
if response.status_code == 429:
|
|
45
|
+
response_429 = Problem.from_dict(response.json())
|
|
46
|
+
|
|
47
|
+
return response_429
|
|
48
|
+
|
|
49
|
+
if client.raise_on_unexpected_status:
|
|
50
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
51
|
+
else:
|
|
52
|
+
return None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _build_response(
|
|
56
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
57
|
+
) -> Response[JobResponse | Problem]:
|
|
58
|
+
return Response(
|
|
59
|
+
status_code=HTTPStatus(response.status_code),
|
|
60
|
+
content=response.content,
|
|
61
|
+
headers=response.headers,
|
|
62
|
+
parsed=_parse_response(client=client, response=response),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def sync_detailed(
|
|
67
|
+
job_id: str,
|
|
68
|
+
*,
|
|
69
|
+
client: AuthenticatedClient,
|
|
70
|
+
) -> Response[JobResponse | Problem]:
|
|
71
|
+
"""Get one queued job by ID
|
|
72
|
+
|
|
73
|
+
Returns one of your jobs. An unknown ID, or a job owned by someone else,
|
|
74
|
+
returns 404.
|
|
75
|
+
|
|
76
|
+
**Credits:** free. This endpoint is not metered.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
job_id (str): The `job_id` from the submit response.
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
83
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
Response[JobResponse | Problem]
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
kwargs = _get_kwargs(
|
|
90
|
+
job_id=job_id,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
response = client.get_httpx_client().request(
|
|
94
|
+
**kwargs,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
return _build_response(client=client, response=response)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def sync(
|
|
101
|
+
job_id: str,
|
|
102
|
+
*,
|
|
103
|
+
client: AuthenticatedClient,
|
|
104
|
+
) -> JobResponse | Problem | None:
|
|
105
|
+
"""Get one queued job by ID
|
|
106
|
+
|
|
107
|
+
Returns one of your jobs. An unknown ID, or a job owned by someone else,
|
|
108
|
+
returns 404.
|
|
109
|
+
|
|
110
|
+
**Credits:** free. This endpoint is not metered.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
job_id (str): The `job_id` from the submit response.
|
|
114
|
+
|
|
115
|
+
Raises:
|
|
116
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
117
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
JobResponse | Problem
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
return sync_detailed(
|
|
124
|
+
job_id=job_id,
|
|
125
|
+
client=client,
|
|
126
|
+
).parsed
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
async def asyncio_detailed(
|
|
130
|
+
job_id: str,
|
|
131
|
+
*,
|
|
132
|
+
client: AuthenticatedClient,
|
|
133
|
+
) -> Response[JobResponse | Problem]:
|
|
134
|
+
"""Get one queued job by ID
|
|
135
|
+
|
|
136
|
+
Returns one of your jobs. An unknown ID, or a job owned by someone else,
|
|
137
|
+
returns 404.
|
|
138
|
+
|
|
139
|
+
**Credits:** free. This endpoint is not metered.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
job_id (str): The `job_id` from the submit response.
|
|
143
|
+
|
|
144
|
+
Raises:
|
|
145
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
146
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
Response[JobResponse | Problem]
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
kwargs = _get_kwargs(
|
|
153
|
+
job_id=job_id,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
157
|
+
|
|
158
|
+
return _build_response(client=client, response=response)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
async def asyncio(
|
|
162
|
+
job_id: str,
|
|
163
|
+
*,
|
|
164
|
+
client: AuthenticatedClient,
|
|
165
|
+
) -> JobResponse | Problem | None:
|
|
166
|
+
"""Get one queued job by ID
|
|
167
|
+
|
|
168
|
+
Returns one of your jobs. An unknown ID, or a job owned by someone else,
|
|
169
|
+
returns 404.
|
|
170
|
+
|
|
171
|
+
**Credits:** free. This endpoint is not metered.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
job_id (str): The `job_id` from the submit response.
|
|
175
|
+
|
|
176
|
+
Raises:
|
|
177
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
178
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
179
|
+
|
|
180
|
+
Returns:
|
|
181
|
+
JobResponse | Problem
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
await asyncio_detailed(
|
|
186
|
+
job_id=job_id,
|
|
187
|
+
client=client,
|
|
188
|
+
)
|
|
189
|
+
).parsed
|
|
@@ -0,0 +1,211 @@
|
|
|
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.job_response_page import JobResponsePage
|
|
9
|
+
from ...models.problem import Problem
|
|
10
|
+
from ...types import UNSET, Response, Unset
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_kwargs(
|
|
14
|
+
*,
|
|
15
|
+
limit: int | Unset = 50,
|
|
16
|
+
cursor: None | str | Unset = UNSET,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
|
|
19
|
+
params: dict[str, Any] = {}
|
|
20
|
+
|
|
21
|
+
params["limit"] = limit
|
|
22
|
+
|
|
23
|
+
json_cursor: None | str | Unset
|
|
24
|
+
if isinstance(cursor, Unset):
|
|
25
|
+
json_cursor = UNSET
|
|
26
|
+
else:
|
|
27
|
+
json_cursor = cursor
|
|
28
|
+
params["cursor"] = json_cursor
|
|
29
|
+
|
|
30
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
31
|
+
|
|
32
|
+
_kwargs: dict[str, Any] = {
|
|
33
|
+
"method": "get",
|
|
34
|
+
"url": "/v1/jobs",
|
|
35
|
+
"params": params,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return _kwargs
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _parse_response(
|
|
42
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
43
|
+
) -> JobResponsePage | Problem | None:
|
|
44
|
+
if response.status_code == 200:
|
|
45
|
+
response_200 = JobResponsePage.from_dict(response.json())
|
|
46
|
+
|
|
47
|
+
return response_200
|
|
48
|
+
|
|
49
|
+
if response.status_code == 422:
|
|
50
|
+
response_422 = Problem.from_dict(response.json())
|
|
51
|
+
|
|
52
|
+
return response_422
|
|
53
|
+
|
|
54
|
+
if response.status_code == 429:
|
|
55
|
+
response_429 = Problem.from_dict(response.json())
|
|
56
|
+
|
|
57
|
+
return response_429
|
|
58
|
+
|
|
59
|
+
if client.raise_on_unexpected_status:
|
|
60
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
61
|
+
else:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _build_response(
|
|
66
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
67
|
+
) -> Response[JobResponsePage | Problem]:
|
|
68
|
+
return Response(
|
|
69
|
+
status_code=HTTPStatus(response.status_code),
|
|
70
|
+
content=response.content,
|
|
71
|
+
headers=response.headers,
|
|
72
|
+
parsed=_parse_response(client=client, response=response),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def sync_detailed(
|
|
77
|
+
*,
|
|
78
|
+
client: AuthenticatedClient,
|
|
79
|
+
limit: int | Unset = 50,
|
|
80
|
+
cursor: None | str | Unset = UNSET,
|
|
81
|
+
) -> Response[JobResponsePage | Problem]:
|
|
82
|
+
"""List your queued jobs, newest first
|
|
83
|
+
|
|
84
|
+
Lists your jobs, newest first. Pass `next_cursor` back as `cursor` to get
|
|
85
|
+
the next page.
|
|
86
|
+
|
|
87
|
+
**Credits:** free. This endpoint is not metered.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
limit (int | Unset): Items per page. Default: 50.
|
|
91
|
+
cursor (None | str | Unset): The `next_cursor` from the previous page.
|
|
92
|
+
|
|
93
|
+
Raises:
|
|
94
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
95
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
Response[JobResponsePage | Problem]
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
kwargs = _get_kwargs(
|
|
102
|
+
limit=limit,
|
|
103
|
+
cursor=cursor,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
response = client.get_httpx_client().request(
|
|
107
|
+
**kwargs,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return _build_response(client=client, response=response)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def sync(
|
|
114
|
+
*,
|
|
115
|
+
client: AuthenticatedClient,
|
|
116
|
+
limit: int | Unset = 50,
|
|
117
|
+
cursor: None | str | Unset = UNSET,
|
|
118
|
+
) -> JobResponsePage | Problem | None:
|
|
119
|
+
"""List your queued jobs, newest first
|
|
120
|
+
|
|
121
|
+
Lists your jobs, newest first. Pass `next_cursor` back as `cursor` to get
|
|
122
|
+
the next page.
|
|
123
|
+
|
|
124
|
+
**Credits:** free. This endpoint is not metered.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
limit (int | Unset): Items per page. Default: 50.
|
|
128
|
+
cursor (None | str | Unset): The `next_cursor` from the previous page.
|
|
129
|
+
|
|
130
|
+
Raises:
|
|
131
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
132
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
JobResponsePage | Problem
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
return sync_detailed(
|
|
139
|
+
client=client,
|
|
140
|
+
limit=limit,
|
|
141
|
+
cursor=cursor,
|
|
142
|
+
).parsed
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
async def asyncio_detailed(
|
|
146
|
+
*,
|
|
147
|
+
client: AuthenticatedClient,
|
|
148
|
+
limit: int | Unset = 50,
|
|
149
|
+
cursor: None | str | Unset = UNSET,
|
|
150
|
+
) -> Response[JobResponsePage | Problem]:
|
|
151
|
+
"""List your queued jobs, newest first
|
|
152
|
+
|
|
153
|
+
Lists your jobs, newest first. Pass `next_cursor` back as `cursor` to get
|
|
154
|
+
the next page.
|
|
155
|
+
|
|
156
|
+
**Credits:** free. This endpoint is not metered.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
limit (int | Unset): Items per page. Default: 50.
|
|
160
|
+
cursor (None | str | Unset): The `next_cursor` from the previous page.
|
|
161
|
+
|
|
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.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
Response[JobResponsePage | Problem]
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
kwargs = _get_kwargs(
|
|
171
|
+
limit=limit,
|
|
172
|
+
cursor=cursor,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
176
|
+
|
|
177
|
+
return _build_response(client=client, response=response)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
async def asyncio(
|
|
181
|
+
*,
|
|
182
|
+
client: AuthenticatedClient,
|
|
183
|
+
limit: int | Unset = 50,
|
|
184
|
+
cursor: None | str | Unset = UNSET,
|
|
185
|
+
) -> JobResponsePage | Problem | None:
|
|
186
|
+
"""List your queued jobs, newest first
|
|
187
|
+
|
|
188
|
+
Lists your jobs, newest first. Pass `next_cursor` back as `cursor` to get
|
|
189
|
+
the next page.
|
|
190
|
+
|
|
191
|
+
**Credits:** free. This endpoint is not metered.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
limit (int | Unset): Items per page. Default: 50.
|
|
195
|
+
cursor (None | str | Unset): The `next_cursor` from the previous page.
|
|
196
|
+
|
|
197
|
+
Raises:
|
|
198
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
199
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
JobResponsePage | Problem
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
await asyncio_detailed(
|
|
207
|
+
client=client,
|
|
208
|
+
limit=limit,
|
|
209
|
+
cursor=cursor,
|
|
210
|
+
)
|
|
211
|
+
).parsed
|