formatjet 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.
- formatjet/__init__.py +53 -0
- formatjet/_client.py +417 -0
- formatjet/_errors.py +75 -0
- formatjet/_transport.py +66 -0
- formatjet/_webhooks.py +93 -0
- formatjet/openapi/__init__.py +9 -0
- formatjet/openapi/api/__init__.py +1 -0
- formatjet/openapi/api/account/__init__.py +1 -0
- formatjet/openapi/api/account/get_account.py +144 -0
- formatjet/openapi/api/account/get_usage.py +197 -0
- formatjet/openapi/api/catalog/__init__.py +1 -0
- formatjet/openapi/api/catalog/get_pricing.py +128 -0
- formatjet/openapi/api/catalog/list_formats.py +128 -0
- formatjet/openapi/api/catalog/list_operations.py +193 -0
- formatjet/openapi/api/jobs/__init__.py +1 -0
- formatjet/openapi/api/jobs/cancel_job.py +220 -0
- formatjet/openapi/api/jobs/convert.py +396 -0
- formatjet/openapi/api/jobs/create_job.py +241 -0
- formatjet/openapi/api/jobs/create_upload.py +230 -0
- formatjet/openapi/api/jobs/delete_job.py +188 -0
- formatjet/openapi/api/jobs/estimate_job.py +239 -0
- formatjet/openapi/api/jobs/get_job.py +188 -0
- formatjet/openapi/api/jobs/list_jobs.py +208 -0
- formatjet/openapi/api/jobs/stream_job_events.py +194 -0
- formatjet/openapi/api/webhooks/__init__.py +1 -0
- formatjet/openapi/api/webhooks/create_webhook.py +225 -0
- formatjet/openapi/api/webhooks/delete_webhook.py +174 -0
- formatjet/openapi/api/webhooks/get_webhook.py +176 -0
- formatjet/openapi/api/webhooks/list_webhook_deliveries.py +234 -0
- formatjet/openapi/api/webhooks/list_webhooks.py +144 -0
- formatjet/openapi/api/webhooks/replay_webhook_event.py +242 -0
- formatjet/openapi/api/webhooks/rotate_webhook_secret.py +224 -0
- formatjet/openapi/api/webhooks/update_webhook.py +214 -0
- formatjet/openapi/client.py +280 -0
- formatjet/openapi/errors.py +16 -0
- formatjet/openapi/models/__init__.py +231 -0
- formatjet/openapi/models/account.py +114 -0
- formatjet/openapi/models/account_credits.py +102 -0
- formatjet/openapi/models/account_credits_monthly_type_0.py +78 -0
- formatjet/openapi/models/account_key.py +107 -0
- formatjet/openapi/models/account_key_mode.py +16 -0
- formatjet/openapi/models/account_key_scopes_item.py +17 -0
- formatjet/openapi/models/account_limits.py +111 -0
- formatjet/openapi/models/account_organization.py +69 -0
- formatjet/openapi/models/account_plan.py +69 -0
- formatjet/openapi/models/convert_files_body.py +75 -0
- formatjet/openapi/models/convert_from.py +95 -0
- formatjet/openapi/models/convert_to.py +95 -0
- formatjet/openapi/models/deletion_receipt_response.py +79 -0
- formatjet/openapi/models/deletion_receipt_response_receipt.py +50 -0
- formatjet/openapi/models/estimate.py +136 -0
- formatjet/openapi/models/estimate_credit_weight.py +70 -0
- formatjet/openapi/models/estimate_from.py +95 -0
- formatjet/openapi/models/estimate_request.py +79 -0
- formatjet/openapi/models/estimate_request_steps_item.py +124 -0
- formatjet/openapi/models/estimate_request_steps_item_from.py +95 -0
- formatjet/openapi/models/estimate_request_steps_item_op.py +15 -0
- formatjet/openapi/models/estimate_request_steps_item_options.py +47 -0
- formatjet/openapi/models/estimate_request_steps_item_to.py +95 -0
- formatjet/openapi/models/estimate_to.py +95 -0
- formatjet/openapi/models/format_.py +109 -0
- formatjet/openapi/models/job.py +297 -0
- formatjet/openapi/models/job_error_type_0.py +69 -0
- formatjet/openapi/models/job_estimate.py +61 -0
- formatjet/openapi/models/job_input.py +163 -0
- formatjet/openapi/models/job_input_format_type_1.py +95 -0
- formatjet/openapi/models/job_input_format_type_2_type_1.py +95 -0
- formatjet/openapi/models/job_input_format_type_3_type_1.py +95 -0
- formatjet/openapi/models/job_inputs_item.py +165 -0
- formatjet/openapi/models/job_inputs_item_format_type_1.py +95 -0
- formatjet/openapi/models/job_inputs_item_format_type_2_type_1.py +97 -0
- formatjet/openapi/models/job_inputs_item_format_type_3_type_1.py +97 -0
- formatjet/openapi/models/job_links.py +69 -0
- formatjet/openapi/models/job_metadata.py +45 -0
- formatjet/openapi/models/job_mode.py +14 -0
- formatjet/openapi/models/job_outputs_item.py +133 -0
- formatjet/openapi/models/job_request.py +213 -0
- formatjet/openapi/models/job_request_input_type_0.py +42 -0
- formatjet/openapi/models/job_request_input_type_1.py +53 -0
- formatjet/openapi/models/job_request_input_type_2.py +54 -0
- formatjet/openapi/models/job_request_inputs_item_type_0.py +42 -0
- formatjet/openapi/models/job_request_inputs_item_type_1.py +53 -0
- formatjet/openapi/models/job_request_metadata.py +47 -0
- formatjet/openapi/models/job_request_output.py +51 -0
- formatjet/openapi/models/job_request_steps_item.py +120 -0
- formatjet/openapi/models/job_request_steps_item_from.py +95 -0
- formatjet/openapi/models/job_request_steps_item_op.py +15 -0
- formatjet/openapi/models/job_request_steps_item_options.py +47 -0
- formatjet/openapi/models/job_request_steps_item_to.py +95 -0
- formatjet/openapi/models/job_status.py +29 -0
- formatjet/openapi/models/job_steps_item.py +234 -0
- formatjet/openapi/models/job_steps_item_from_type_1.py +95 -0
- formatjet/openapi/models/job_steps_item_from_type_2_type_1.py +95 -0
- formatjet/openapi/models/job_steps_item_from_type_3_type_1.py +95 -0
- formatjet/openapi/models/job_steps_item_op.py +15 -0
- formatjet/openapi/models/job_steps_item_options.py +45 -0
- formatjet/openapi/models/job_steps_item_status.py +29 -0
- formatjet/openapi/models/job_steps_item_to_type_1.py +95 -0
- formatjet/openapi/models/job_steps_item_to_type_2_type_1.py +95 -0
- formatjet/openapi/models/job_steps_item_to_type_3_type_1.py +95 -0
- formatjet/openapi/models/job_summary.py +160 -0
- formatjet/openapi/models/job_summary_mode.py +16 -0
- formatjet/openapi/models/job_summary_status.py +29 -0
- formatjet/openapi/models/list_formats_response_200.py +84 -0
- formatjet/openapi/models/list_jobs_response_200.py +95 -0
- formatjet/openapi/models/list_operations_from.py +95 -0
- formatjet/openapi/models/list_operations_response_200.py +82 -0
- formatjet/openapi/models/list_operations_to.py +95 -0
- formatjet/openapi/models/list_webhook_deliveries_response_200.py +95 -0
- formatjet/openapi/models/list_webhooks_response_200.py +81 -0
- formatjet/openapi/models/operation.py +148 -0
- formatjet/openapi/models/operation_credits.py +69 -0
- formatjet/openapi/models/operation_engines_item.py +87 -0
- formatjet/openapi/models/operation_engines_item_engines_item.py +69 -0
- formatjet/openapi/models/operation_files.py +70 -0
- formatjet/openapi/models/operation_kind.py +16 -0
- formatjet/openapi/models/operation_options_schema.py +45 -0
- formatjet/openapi/models/pricing.py +153 -0
- formatjet/openapi/models/pricing_credit_packs_item.py +77 -0
- formatjet/openapi/models/pricing_credit_weights_item.py +85 -0
- formatjet/openapi/models/pricing_plans_item.py +156 -0
- formatjet/openapi/models/pricing_plans_item_overage_type_1.py +61 -0
- formatjet/openapi/models/problem.py +155 -0
- formatjet/openapi/models/problem_code.py +47 -0
- formatjet/openapi/models/problem_errors_item.py +69 -0
- formatjet/openapi/models/replay_webhook_event_body.py +45 -0
- formatjet/openapi/models/upload.py +115 -0
- formatjet/openapi/models/upload_headers.py +47 -0
- formatjet/openapi/models/upload_method.py +15 -0
- formatjet/openapi/models/upload_request.py +56 -0
- formatjet/openapi/models/usage.py +93 -0
- formatjet/openapi/models/usage_days_item.py +93 -0
- formatjet/openapi/models/usage_totals.py +85 -0
- formatjet/openapi/models/webhook_delivery.py +204 -0
- formatjet/openapi/models/webhook_delivery_event_type.py +17 -0
- formatjet/openapi/models/webhook_delivery_mode.py +16 -0
- formatjet/openapi/models/webhook_endpoint.py +258 -0
- formatjet/openapi/models/webhook_endpoint_disabled_reason_type_1.py +20 -0
- formatjet/openapi/models/webhook_endpoint_disabled_reason_type_2_type_1.py +20 -0
- formatjet/openapi/models/webhook_endpoint_disabled_reason_type_3_type_1.py +20 -0
- formatjet/openapi/models/webhook_endpoint_events_item.py +17 -0
- formatjet/openapi/models/webhook_endpoint_mode.py +16 -0
- formatjet/openapi/models/webhook_endpoint_request.py +84 -0
- formatjet/openapi/models/webhook_endpoint_request_events_item.py +21 -0
- formatjet/openapi/models/webhook_endpoint_update.py +101 -0
- formatjet/openapi/models/webhook_endpoint_update_events_item.py +19 -0
- formatjet/openapi/models/webhook_endpoint_with_secret.py +267 -0
- formatjet/openapi/types.py +54 -0
- formatjet/py.typed +0 -0
- formatjet-0.1.0.dist-info/METADATA +126 -0
- formatjet-0.1.0.dist-info/RECORD +153 -0
- formatjet-0.1.0.dist-info/WHEEL +4 -0
- formatjet-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from io import BytesIO
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.convert_files_body import ConvertFilesBody
|
|
10
|
+
from ...models.convert_from import ConvertFrom
|
|
11
|
+
from ...models.convert_to import ConvertTo
|
|
12
|
+
from ...models.job import Job
|
|
13
|
+
from ...models.problem import Problem
|
|
14
|
+
from ...types import UNSET, File, Response, Unset
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _get_kwargs(
|
|
18
|
+
*,
|
|
19
|
+
body: ConvertFilesBody | File | Unset = UNSET,
|
|
20
|
+
conversion: str | Unset = UNSET,
|
|
21
|
+
from_: ConvertFrom | Unset = UNSET,
|
|
22
|
+
to: ConvertTo | Unset = UNSET,
|
|
23
|
+
options: str | Unset = UNSET,
|
|
24
|
+
filename: str | Unset = UNSET,
|
|
25
|
+
output_filename: str | Unset = UNSET,
|
|
26
|
+
ttl: int | Unset = UNSET,
|
|
27
|
+
idempotency_key: str | Unset = UNSET,
|
|
28
|
+
) -> dict[str, Any]:
|
|
29
|
+
headers: dict[str, Any] = {}
|
|
30
|
+
if not isinstance(idempotency_key, Unset):
|
|
31
|
+
headers["idempotency-key"] = idempotency_key
|
|
32
|
+
|
|
33
|
+
params: dict[str, Any] = {}
|
|
34
|
+
|
|
35
|
+
params["conversion"] = conversion
|
|
36
|
+
|
|
37
|
+
json_from_: str | Unset = UNSET
|
|
38
|
+
if not isinstance(from_, Unset):
|
|
39
|
+
json_from_ = from_
|
|
40
|
+
|
|
41
|
+
params["from"] = json_from_
|
|
42
|
+
|
|
43
|
+
json_to: str | Unset = UNSET
|
|
44
|
+
if not isinstance(to, Unset):
|
|
45
|
+
json_to = to
|
|
46
|
+
|
|
47
|
+
params["to"] = json_to
|
|
48
|
+
|
|
49
|
+
params["options"] = options
|
|
50
|
+
|
|
51
|
+
params["filename"] = filename
|
|
52
|
+
|
|
53
|
+
params["output_filename"] = output_filename
|
|
54
|
+
|
|
55
|
+
params["ttl"] = ttl
|
|
56
|
+
|
|
57
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
58
|
+
|
|
59
|
+
_kwargs: dict[str, Any] = {
|
|
60
|
+
"method": "post",
|
|
61
|
+
"url": "/v1/convert",
|
|
62
|
+
"params": params,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if isinstance(body, ConvertFilesBody):
|
|
66
|
+
_kwargs["files"] = body.to_multipart()
|
|
67
|
+
|
|
68
|
+
headers["Content-Type"] = "multipart/form-data; boundary=+++"
|
|
69
|
+
if isinstance(body, File):
|
|
70
|
+
_kwargs["content"] = body.payload
|
|
71
|
+
headers["Content-Type"] = "application/octet-stream"
|
|
72
|
+
|
|
73
|
+
_kwargs["headers"] = headers
|
|
74
|
+
return _kwargs
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _parse_response(
|
|
78
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
79
|
+
) -> File | Job | Problem | None:
|
|
80
|
+
if response.status_code == 200:
|
|
81
|
+
response_200 = File(payload=BytesIO(response.content))
|
|
82
|
+
|
|
83
|
+
return response_200
|
|
84
|
+
|
|
85
|
+
if response.status_code == 202:
|
|
86
|
+
response_202 = Job.from_dict(response.json())
|
|
87
|
+
|
|
88
|
+
return response_202
|
|
89
|
+
|
|
90
|
+
if response.status_code == 400:
|
|
91
|
+
response_400 = Problem.from_dict(response.json())
|
|
92
|
+
|
|
93
|
+
return response_400
|
|
94
|
+
|
|
95
|
+
if response.status_code == 401:
|
|
96
|
+
response_401 = Problem.from_dict(response.json())
|
|
97
|
+
|
|
98
|
+
return response_401
|
|
99
|
+
|
|
100
|
+
if response.status_code == 402:
|
|
101
|
+
response_402 = Problem.from_dict(response.json())
|
|
102
|
+
|
|
103
|
+
return response_402
|
|
104
|
+
|
|
105
|
+
if response.status_code == 403:
|
|
106
|
+
response_403 = Problem.from_dict(response.json())
|
|
107
|
+
|
|
108
|
+
return response_403
|
|
109
|
+
|
|
110
|
+
if response.status_code == 409:
|
|
111
|
+
response_409 = Problem.from_dict(response.json())
|
|
112
|
+
|
|
113
|
+
return response_409
|
|
114
|
+
|
|
115
|
+
if response.status_code == 413:
|
|
116
|
+
response_413 = Problem.from_dict(response.json())
|
|
117
|
+
|
|
118
|
+
return response_413
|
|
119
|
+
|
|
120
|
+
if response.status_code == 422:
|
|
121
|
+
response_422 = Problem.from_dict(response.json())
|
|
122
|
+
|
|
123
|
+
return response_422
|
|
124
|
+
|
|
125
|
+
if response.status_code == 429:
|
|
126
|
+
response_429 = Problem.from_dict(response.json())
|
|
127
|
+
|
|
128
|
+
return response_429
|
|
129
|
+
|
|
130
|
+
if response.status_code == 500:
|
|
131
|
+
response_500 = Problem.from_dict(response.json())
|
|
132
|
+
|
|
133
|
+
return response_500
|
|
134
|
+
|
|
135
|
+
if response.status_code == 504:
|
|
136
|
+
response_504 = Problem.from_dict(response.json())
|
|
137
|
+
|
|
138
|
+
return response_504
|
|
139
|
+
|
|
140
|
+
if client.raise_on_unexpected_status:
|
|
141
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
142
|
+
else:
|
|
143
|
+
return None
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _build_response(
|
|
147
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
148
|
+
) -> Response[File | Job | Problem]:
|
|
149
|
+
return Response(
|
|
150
|
+
status_code=HTTPStatus(response.status_code),
|
|
151
|
+
content=response.content,
|
|
152
|
+
headers=response.headers,
|
|
153
|
+
parsed=_parse_response(client=client, response=response),
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def sync_detailed(
|
|
158
|
+
*,
|
|
159
|
+
client: AuthenticatedClient,
|
|
160
|
+
body: ConvertFilesBody | File | Unset = UNSET,
|
|
161
|
+
conversion: str | Unset = UNSET,
|
|
162
|
+
from_: ConvertFrom | Unset = UNSET,
|
|
163
|
+
to: ConvertTo | Unset = UNSET,
|
|
164
|
+
options: str | Unset = UNSET,
|
|
165
|
+
filename: str | Unset = UNSET,
|
|
166
|
+
output_filename: str | Unset = UNSET,
|
|
167
|
+
ttl: int | Unset = UNSET,
|
|
168
|
+
idempotency_key: str | Unset = UNSET,
|
|
169
|
+
) -> Response[File | Job | Problem]:
|
|
170
|
+
"""Convert one file and get the result in the response (up to 25 MB)
|
|
171
|
+
|
|
172
|
+
Send the file as `multipart/form-data` (a `file` part) or as the raw body; for a conversion that
|
|
173
|
+
joins files (merge-pdf, image-to-pdf), send a `file` part for each, in order, 25 MB in all. The same
|
|
174
|
+
pipeline as a job: if it hasn’t finished within 30 seconds, the answer is `202` with the job, which
|
|
175
|
+
carries on. With `Accept: application/json` the answer is the job, with a download URL, instead of
|
|
176
|
+
the file. A conversion that makes several files (Split PDF, a PDF’s pages as images, a workbook’s
|
|
177
|
+
sheets as CSV) always answers with the job, whose `outputs` list them in order.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
conversion (str | Unset): Example: word-to-pdf.
|
|
181
|
+
from_ (ConvertFrom | Unset):
|
|
182
|
+
to (ConvertTo | Unset):
|
|
183
|
+
options (str | Unset): The step’s options, as a JSON object
|
|
184
|
+
filename (str | Unset): The file’s name, for a raw body. Never logged.
|
|
185
|
+
output_filename (str | Unset):
|
|
186
|
+
ttl (int | Unset): Seconds the output is kept after completion (default 86400)
|
|
187
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
188
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
189
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
190
|
+
body (ConvertFilesBody):
|
|
191
|
+
body (File):
|
|
192
|
+
|
|
193
|
+
Raises:
|
|
194
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
195
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
Response[File | Job | Problem]
|
|
199
|
+
"""
|
|
200
|
+
|
|
201
|
+
kwargs = _get_kwargs(
|
|
202
|
+
body=body,
|
|
203
|
+
conversion=conversion,
|
|
204
|
+
from_=from_,
|
|
205
|
+
to=to,
|
|
206
|
+
options=options,
|
|
207
|
+
filename=filename,
|
|
208
|
+
output_filename=output_filename,
|
|
209
|
+
ttl=ttl,
|
|
210
|
+
idempotency_key=idempotency_key,
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
response = client.get_httpx_client().request(
|
|
214
|
+
**kwargs,
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
return _build_response(client=client, response=response)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def sync(
|
|
221
|
+
*,
|
|
222
|
+
client: AuthenticatedClient,
|
|
223
|
+
body: ConvertFilesBody | File | Unset = UNSET,
|
|
224
|
+
conversion: str | Unset = UNSET,
|
|
225
|
+
from_: ConvertFrom | Unset = UNSET,
|
|
226
|
+
to: ConvertTo | Unset = UNSET,
|
|
227
|
+
options: str | Unset = UNSET,
|
|
228
|
+
filename: str | Unset = UNSET,
|
|
229
|
+
output_filename: str | Unset = UNSET,
|
|
230
|
+
ttl: int | Unset = UNSET,
|
|
231
|
+
idempotency_key: str | Unset = UNSET,
|
|
232
|
+
) -> File | Job | Problem | None:
|
|
233
|
+
"""Convert one file and get the result in the response (up to 25 MB)
|
|
234
|
+
|
|
235
|
+
Send the file as `multipart/form-data` (a `file` part) or as the raw body; for a conversion that
|
|
236
|
+
joins files (merge-pdf, image-to-pdf), send a `file` part for each, in order, 25 MB in all. The same
|
|
237
|
+
pipeline as a job: if it hasn’t finished within 30 seconds, the answer is `202` with the job, which
|
|
238
|
+
carries on. With `Accept: application/json` the answer is the job, with a download URL, instead of
|
|
239
|
+
the file. A conversion that makes several files (Split PDF, a PDF’s pages as images, a workbook’s
|
|
240
|
+
sheets as CSV) always answers with the job, whose `outputs` list them in order.
|
|
241
|
+
|
|
242
|
+
Args:
|
|
243
|
+
conversion (str | Unset): Example: word-to-pdf.
|
|
244
|
+
from_ (ConvertFrom | Unset):
|
|
245
|
+
to (ConvertTo | Unset):
|
|
246
|
+
options (str | Unset): The step’s options, as a JSON object
|
|
247
|
+
filename (str | Unset): The file’s name, for a raw body. Never logged.
|
|
248
|
+
output_filename (str | Unset):
|
|
249
|
+
ttl (int | Unset): Seconds the output is kept after completion (default 86400)
|
|
250
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
251
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
252
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
253
|
+
body (ConvertFilesBody):
|
|
254
|
+
body (File):
|
|
255
|
+
|
|
256
|
+
Raises:
|
|
257
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
258
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
259
|
+
|
|
260
|
+
Returns:
|
|
261
|
+
File | Job | Problem
|
|
262
|
+
"""
|
|
263
|
+
|
|
264
|
+
return sync_detailed(
|
|
265
|
+
client=client,
|
|
266
|
+
body=body,
|
|
267
|
+
conversion=conversion,
|
|
268
|
+
from_=from_,
|
|
269
|
+
to=to,
|
|
270
|
+
options=options,
|
|
271
|
+
filename=filename,
|
|
272
|
+
output_filename=output_filename,
|
|
273
|
+
ttl=ttl,
|
|
274
|
+
idempotency_key=idempotency_key,
|
|
275
|
+
).parsed
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
async def asyncio_detailed(
|
|
279
|
+
*,
|
|
280
|
+
client: AuthenticatedClient,
|
|
281
|
+
body: ConvertFilesBody | File | Unset = UNSET,
|
|
282
|
+
conversion: str | Unset = UNSET,
|
|
283
|
+
from_: ConvertFrom | Unset = UNSET,
|
|
284
|
+
to: ConvertTo | Unset = UNSET,
|
|
285
|
+
options: str | Unset = UNSET,
|
|
286
|
+
filename: str | Unset = UNSET,
|
|
287
|
+
output_filename: str | Unset = UNSET,
|
|
288
|
+
ttl: int | Unset = UNSET,
|
|
289
|
+
idempotency_key: str | Unset = UNSET,
|
|
290
|
+
) -> Response[File | Job | Problem]:
|
|
291
|
+
"""Convert one file and get the result in the response (up to 25 MB)
|
|
292
|
+
|
|
293
|
+
Send the file as `multipart/form-data` (a `file` part) or as the raw body; for a conversion that
|
|
294
|
+
joins files (merge-pdf, image-to-pdf), send a `file` part for each, in order, 25 MB in all. The same
|
|
295
|
+
pipeline as a job: if it hasn’t finished within 30 seconds, the answer is `202` with the job, which
|
|
296
|
+
carries on. With `Accept: application/json` the answer is the job, with a download URL, instead of
|
|
297
|
+
the file. A conversion that makes several files (Split PDF, a PDF’s pages as images, a workbook’s
|
|
298
|
+
sheets as CSV) always answers with the job, whose `outputs` list them in order.
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
conversion (str | Unset): Example: word-to-pdf.
|
|
302
|
+
from_ (ConvertFrom | Unset):
|
|
303
|
+
to (ConvertTo | Unset):
|
|
304
|
+
options (str | Unset): The step’s options, as a JSON object
|
|
305
|
+
filename (str | Unset): The file’s name, for a raw body. Never logged.
|
|
306
|
+
output_filename (str | Unset):
|
|
307
|
+
ttl (int | Unset): Seconds the output is kept after completion (default 86400)
|
|
308
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
309
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
310
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
311
|
+
body (ConvertFilesBody):
|
|
312
|
+
body (File):
|
|
313
|
+
|
|
314
|
+
Raises:
|
|
315
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
316
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
317
|
+
|
|
318
|
+
Returns:
|
|
319
|
+
Response[File | Job | Problem]
|
|
320
|
+
"""
|
|
321
|
+
|
|
322
|
+
kwargs = _get_kwargs(
|
|
323
|
+
body=body,
|
|
324
|
+
conversion=conversion,
|
|
325
|
+
from_=from_,
|
|
326
|
+
to=to,
|
|
327
|
+
options=options,
|
|
328
|
+
filename=filename,
|
|
329
|
+
output_filename=output_filename,
|
|
330
|
+
ttl=ttl,
|
|
331
|
+
idempotency_key=idempotency_key,
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
335
|
+
|
|
336
|
+
return _build_response(client=client, response=response)
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
async def asyncio(
|
|
340
|
+
*,
|
|
341
|
+
client: AuthenticatedClient,
|
|
342
|
+
body: ConvertFilesBody | File | Unset = UNSET,
|
|
343
|
+
conversion: str | Unset = UNSET,
|
|
344
|
+
from_: ConvertFrom | Unset = UNSET,
|
|
345
|
+
to: ConvertTo | Unset = UNSET,
|
|
346
|
+
options: str | Unset = UNSET,
|
|
347
|
+
filename: str | Unset = UNSET,
|
|
348
|
+
output_filename: str | Unset = UNSET,
|
|
349
|
+
ttl: int | Unset = UNSET,
|
|
350
|
+
idempotency_key: str | Unset = UNSET,
|
|
351
|
+
) -> File | Job | Problem | None:
|
|
352
|
+
"""Convert one file and get the result in the response (up to 25 MB)
|
|
353
|
+
|
|
354
|
+
Send the file as `multipart/form-data` (a `file` part) or as the raw body; for a conversion that
|
|
355
|
+
joins files (merge-pdf, image-to-pdf), send a `file` part for each, in order, 25 MB in all. The same
|
|
356
|
+
pipeline as a job: if it hasn’t finished within 30 seconds, the answer is `202` with the job, which
|
|
357
|
+
carries on. With `Accept: application/json` the answer is the job, with a download URL, instead of
|
|
358
|
+
the file. A conversion that makes several files (Split PDF, a PDF’s pages as images, a workbook’s
|
|
359
|
+
sheets as CSV) always answers with the job, whose `outputs` list them in order.
|
|
360
|
+
|
|
361
|
+
Args:
|
|
362
|
+
conversion (str | Unset): Example: word-to-pdf.
|
|
363
|
+
from_ (ConvertFrom | Unset):
|
|
364
|
+
to (ConvertTo | Unset):
|
|
365
|
+
options (str | Unset): The step’s options, as a JSON object
|
|
366
|
+
filename (str | Unset): The file’s name, for a raw body. Never logged.
|
|
367
|
+
output_filename (str | Unset):
|
|
368
|
+
ttl (int | Unset): Seconds the output is kept after completion (default 86400)
|
|
369
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
370
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
371
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
372
|
+
body (ConvertFilesBody):
|
|
373
|
+
body (File):
|
|
374
|
+
|
|
375
|
+
Raises:
|
|
376
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
377
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
378
|
+
|
|
379
|
+
Returns:
|
|
380
|
+
File | Job | Problem
|
|
381
|
+
"""
|
|
382
|
+
|
|
383
|
+
return (
|
|
384
|
+
await asyncio_detailed(
|
|
385
|
+
client=client,
|
|
386
|
+
body=body,
|
|
387
|
+
conversion=conversion,
|
|
388
|
+
from_=from_,
|
|
389
|
+
to=to,
|
|
390
|
+
options=options,
|
|
391
|
+
filename=filename,
|
|
392
|
+
output_filename=output_filename,
|
|
393
|
+
ttl=ttl,
|
|
394
|
+
idempotency_key=idempotency_key,
|
|
395
|
+
)
|
|
396
|
+
).parsed
|
|
@@ -0,0 +1,241 @@
|
|
|
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 import Job
|
|
9
|
+
from ...models.job_request import JobRequest
|
|
10
|
+
from ...models.problem import Problem
|
|
11
|
+
from ...types import UNSET, Response, Unset
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
*,
|
|
16
|
+
body: JobRequest,
|
|
17
|
+
idempotency_key: str | Unset = UNSET,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
headers: dict[str, Any] = {}
|
|
20
|
+
if not isinstance(idempotency_key, Unset):
|
|
21
|
+
headers["idempotency-key"] = idempotency_key
|
|
22
|
+
|
|
23
|
+
_kwargs: dict[str, Any] = {
|
|
24
|
+
"method": "post",
|
|
25
|
+
"url": "/v1/jobs",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_kwargs["json"] = body.to_dict()
|
|
29
|
+
|
|
30
|
+
headers["Content-Type"] = "application/json"
|
|
31
|
+
|
|
32
|
+
_kwargs["headers"] = headers
|
|
33
|
+
return _kwargs
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _parse_response(
|
|
37
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
38
|
+
) -> Job | Problem | None:
|
|
39
|
+
if response.status_code == 201:
|
|
40
|
+
response_201 = Job.from_dict(response.json())
|
|
41
|
+
|
|
42
|
+
return response_201
|
|
43
|
+
|
|
44
|
+
if response.status_code == 400:
|
|
45
|
+
response_400 = Problem.from_dict(response.json())
|
|
46
|
+
|
|
47
|
+
return response_400
|
|
48
|
+
|
|
49
|
+
if response.status_code == 401:
|
|
50
|
+
response_401 = Problem.from_dict(response.json())
|
|
51
|
+
|
|
52
|
+
return response_401
|
|
53
|
+
|
|
54
|
+
if response.status_code == 402:
|
|
55
|
+
response_402 = Problem.from_dict(response.json())
|
|
56
|
+
|
|
57
|
+
return response_402
|
|
58
|
+
|
|
59
|
+
if response.status_code == 403:
|
|
60
|
+
response_403 = Problem.from_dict(response.json())
|
|
61
|
+
|
|
62
|
+
return response_403
|
|
63
|
+
|
|
64
|
+
if response.status_code == 404:
|
|
65
|
+
response_404 = Problem.from_dict(response.json())
|
|
66
|
+
|
|
67
|
+
return response_404
|
|
68
|
+
|
|
69
|
+
if response.status_code == 409:
|
|
70
|
+
response_409 = Problem.from_dict(response.json())
|
|
71
|
+
|
|
72
|
+
return response_409
|
|
73
|
+
|
|
74
|
+
if response.status_code == 413:
|
|
75
|
+
response_413 = Problem.from_dict(response.json())
|
|
76
|
+
|
|
77
|
+
return response_413
|
|
78
|
+
|
|
79
|
+
if response.status_code == 422:
|
|
80
|
+
response_422 = Problem.from_dict(response.json())
|
|
81
|
+
|
|
82
|
+
return response_422
|
|
83
|
+
|
|
84
|
+
if response.status_code == 429:
|
|
85
|
+
response_429 = Problem.from_dict(response.json())
|
|
86
|
+
|
|
87
|
+
return response_429
|
|
88
|
+
|
|
89
|
+
if client.raise_on_unexpected_status:
|
|
90
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
91
|
+
else:
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _build_response(
|
|
96
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
97
|
+
) -> Response[Job | Problem]:
|
|
98
|
+
return Response(
|
|
99
|
+
status_code=HTTPStatus(response.status_code),
|
|
100
|
+
content=response.content,
|
|
101
|
+
headers=response.headers,
|
|
102
|
+
parsed=_parse_response(client=client, response=response),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def sync_detailed(
|
|
107
|
+
*,
|
|
108
|
+
client: AuthenticatedClient,
|
|
109
|
+
body: JobRequest,
|
|
110
|
+
idempotency_key: str | Unset = UNSET,
|
|
111
|
+
) -> Response[Job | Problem]:
|
|
112
|
+
"""Make a job: convert an upload, a base64 file or a file at a URL
|
|
113
|
+
|
|
114
|
+
The job starts at once and is answered while it runs: wait for it with `GET /v1/jobs/{id}`, its
|
|
115
|
+
event stream, or a webhook. Credits are held now and charged only if it succeeds.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
119
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
120
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
121
|
+
body (JobRequest):
|
|
122
|
+
|
|
123
|
+
Raises:
|
|
124
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
125
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
Response[Job | Problem]
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
kwargs = _get_kwargs(
|
|
132
|
+
body=body,
|
|
133
|
+
idempotency_key=idempotency_key,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
response = client.get_httpx_client().request(
|
|
137
|
+
**kwargs,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
return _build_response(client=client, response=response)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def sync(
|
|
144
|
+
*,
|
|
145
|
+
client: AuthenticatedClient,
|
|
146
|
+
body: JobRequest,
|
|
147
|
+
idempotency_key: str | Unset = UNSET,
|
|
148
|
+
) -> Job | Problem | None:
|
|
149
|
+
"""Make a job: convert an upload, a base64 file or a file at a URL
|
|
150
|
+
|
|
151
|
+
The job starts at once and is answered while it runs: wait for it with `GET /v1/jobs/{id}`, its
|
|
152
|
+
event stream, or a webhook. Credits are held now and charged only if it succeeds.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
156
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
157
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
158
|
+
body (JobRequest):
|
|
159
|
+
|
|
160
|
+
Raises:
|
|
161
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
162
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Job | Problem
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
return sync_detailed(
|
|
169
|
+
client=client,
|
|
170
|
+
body=body,
|
|
171
|
+
idempotency_key=idempotency_key,
|
|
172
|
+
).parsed
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
async def asyncio_detailed(
|
|
176
|
+
*,
|
|
177
|
+
client: AuthenticatedClient,
|
|
178
|
+
body: JobRequest,
|
|
179
|
+
idempotency_key: str | Unset = UNSET,
|
|
180
|
+
) -> Response[Job | Problem]:
|
|
181
|
+
"""Make a job: convert an upload, a base64 file or a file at a URL
|
|
182
|
+
|
|
183
|
+
The job starts at once and is answered while it runs: wait for it with `GET /v1/jobs/{id}`, its
|
|
184
|
+
event stream, or a webhook. Credits are held now and charged only if it succeeds.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
188
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
189
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
190
|
+
body (JobRequest):
|
|
191
|
+
|
|
192
|
+
Raises:
|
|
193
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
194
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
Response[Job | Problem]
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
kwargs = _get_kwargs(
|
|
201
|
+
body=body,
|
|
202
|
+
idempotency_key=idempotency_key,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
206
|
+
|
|
207
|
+
return _build_response(client=client, response=response)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
async def asyncio(
|
|
211
|
+
*,
|
|
212
|
+
client: AuthenticatedClient,
|
|
213
|
+
body: JobRequest,
|
|
214
|
+
idempotency_key: str | Unset = UNSET,
|
|
215
|
+
) -> Job | Problem | None:
|
|
216
|
+
"""Make a job: convert an upload, a base64 file or a file at a URL
|
|
217
|
+
|
|
218
|
+
The job starts at once and is answered while it runs: wait for it with `GET /v1/jobs/{id}`, its
|
|
219
|
+
event stream, or a webhook. Credits are held now and charged only if it succeeds.
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
idempotency_key (str | Unset): Up to 255 printable ASCII characters, such as a UUID. A
|
|
223
|
+
repeat of the same request within 24 hours gets the first one’s successful answer again
|
|
224
|
+
(`Idempotent-Replayed: true`); the same key with a different request is a 409.
|
|
225
|
+
body (JobRequest):
|
|
226
|
+
|
|
227
|
+
Raises:
|
|
228
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
229
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
230
|
+
|
|
231
|
+
Returns:
|
|
232
|
+
Job | Problem
|
|
233
|
+
"""
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
await asyncio_detailed(
|
|
237
|
+
client=client,
|
|
238
|
+
body=body,
|
|
239
|
+
idempotency_key=idempotency_key,
|
|
240
|
+
)
|
|
241
|
+
).parsed
|