@planqk/planqk-service-sdk 2.2.1 → 2.4.0
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.
- package/README-node.md +1 -0
- package/README-python.md +7 -7
- package/README.md +1 -0
- package/notebooks/python-sdk.ipynb +56 -114
- package/package.json +1 -1
- package/planqk/service/_version.py +1 -1
- package/planqk/service/client.py +13 -12
- package/planqk/service/datapool.py +24 -0
- package/planqk/service/sdk/__init__.py +4 -30
- package/planqk/service/sdk/client.py +20 -19
- package/planqk/service/sdk/core/__init__.py +5 -0
- package/planqk/service/sdk/core/api_error.py +12 -6
- package/planqk/service/sdk/core/client_wrapper.py +12 -4
- package/planqk/service/sdk/core/datetime_utils.py +1 -3
- package/planqk/service/sdk/core/file.py +2 -5
- package/planqk/service/sdk/core/force_multipart.py +16 -0
- package/planqk/service/sdk/core/http_client.py +86 -118
- package/planqk/service/sdk/core/http_response.py +55 -0
- package/planqk/service/sdk/core/jsonable_encoder.py +1 -4
- package/planqk/service/sdk/core/pydantic_utilities.py +79 -147
- package/planqk/service/sdk/core/query_encoder.py +1 -3
- package/planqk/service/sdk/core/serialization.py +10 -10
- package/planqk/service/sdk/environment.py +1 -1
- package/planqk/service/sdk/service_api/__init__.py +4 -12
- package/planqk/service/sdk/service_api/client.py +138 -860
- package/planqk/service/sdk/service_api/raw_client.py +606 -0
- package/planqk/service/sdk/service_api/types/__init__.py +3 -7
- package/planqk/service/sdk/service_api/types/get_result_response.py +7 -11
- package/planqk/service/sdk/service_api/types/get_result_response_embedded.py +4 -6
- package/planqk/service/sdk/service_api/types/get_result_response_links.py +4 -6
- package/planqk/service/sdk/types/__init__.py +3 -11
- package/planqk/service/sdk/types/hal_link.py +3 -5
- package/planqk/service/sdk/types/service_execution.py +8 -16
- package/planqk/service/sdk/types/service_execution_status.py +1 -2
- package/pyproject.toml +1 -1
- package/uv.lock +250 -256
- package/planqk/service/sdk/errors/__init__.py +0 -15
- package/planqk/service/sdk/errors/bad_request_error.py +0 -9
- package/planqk/service/sdk/errors/forbidden_error.py +0 -9
- package/planqk/service/sdk/errors/internal_server_error.py +0 -9
- package/planqk/service/sdk/errors/not_found_error.py +0 -9
- package/planqk/service/sdk/errors/unauthorized_error.py +0 -9
- package/planqk/service/sdk/service_api/types/health_check_response.py +0 -24
- package/planqk/service/sdk/types/input_data.py +0 -5
- package/planqk/service/sdk/types/input_data_ref.py +0 -27
- package/planqk/service/sdk/types/input_params.py +0 -5
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from ..core.api_error import ApiError
|
|
8
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
10
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
12
|
+
from ..core.request_options import RequestOptions
|
|
13
|
+
from ..types.service_execution import ServiceExecution
|
|
14
|
+
from .types.get_result_response import GetResultResponse
|
|
15
|
+
|
|
16
|
+
# this is used as the default value for optional parameters
|
|
17
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RawServiceApiClient:
|
|
21
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
22
|
+
self._client_wrapper = client_wrapper
|
|
23
|
+
|
|
24
|
+
def get_service_executions(
|
|
25
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
26
|
+
) -> HttpResponse[typing.List[ServiceExecution]]:
|
|
27
|
+
"""
|
|
28
|
+
Retrieves a list of all service executions.
|
|
29
|
+
The response includes links to each service execution, allowing for further queries on their status and results.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
request_options : typing.Optional[RequestOptions]
|
|
34
|
+
Request-specific configuration.
|
|
35
|
+
|
|
36
|
+
Returns
|
|
37
|
+
-------
|
|
38
|
+
HttpResponse[typing.List[ServiceExecution]]
|
|
39
|
+
List of service executions
|
|
40
|
+
"""
|
|
41
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
42
|
+
method="GET",
|
|
43
|
+
request_options=request_options,
|
|
44
|
+
)
|
|
45
|
+
try:
|
|
46
|
+
if 200 <= _response.status_code < 300:
|
|
47
|
+
_data = typing.cast(
|
|
48
|
+
typing.List[ServiceExecution],
|
|
49
|
+
parse_obj_as(
|
|
50
|
+
type_=typing.List[ServiceExecution], # type: ignore
|
|
51
|
+
object_=_response.json(),
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
return HttpResponse(response=_response, data=_data)
|
|
55
|
+
_response_json = _response.json()
|
|
56
|
+
except JSONDecodeError:
|
|
57
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
58
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
59
|
+
|
|
60
|
+
def start_execution(
|
|
61
|
+
self,
|
|
62
|
+
*,
|
|
63
|
+
request: typing.Dict[str, typing.Optional[typing.Any]],
|
|
64
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
65
|
+
) -> HttpResponse[ServiceExecution]:
|
|
66
|
+
"""
|
|
67
|
+
Starts a service execution, which in turn is processed asynchronously.
|
|
68
|
+
The location header of the response contains the URL which can be used to query the status and the result of the service execution.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
request : typing.Dict[str, typing.Optional[typing.Any]]
|
|
73
|
+
|
|
74
|
+
request_options : typing.Optional[RequestOptions]
|
|
75
|
+
Request-specific configuration.
|
|
76
|
+
|
|
77
|
+
Returns
|
|
78
|
+
-------
|
|
79
|
+
HttpResponse[ServiceExecution]
|
|
80
|
+
Service execution is submitted
|
|
81
|
+
"""
|
|
82
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
83
|
+
method="POST",
|
|
84
|
+
json=request,
|
|
85
|
+
headers={
|
|
86
|
+
"content-type": "application/json",
|
|
87
|
+
},
|
|
88
|
+
request_options=request_options,
|
|
89
|
+
omit=OMIT,
|
|
90
|
+
)
|
|
91
|
+
try:
|
|
92
|
+
if 200 <= _response.status_code < 300:
|
|
93
|
+
_data = typing.cast(
|
|
94
|
+
ServiceExecution,
|
|
95
|
+
parse_obj_as(
|
|
96
|
+
type_=ServiceExecution, # type: ignore
|
|
97
|
+
object_=_response.json(),
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
return HttpResponse(response=_response, data=_data)
|
|
101
|
+
_response_json = _response.json()
|
|
102
|
+
except JSONDecodeError:
|
|
103
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
104
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
105
|
+
|
|
106
|
+
def get_status(
|
|
107
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
108
|
+
) -> HttpResponse[ServiceExecution]:
|
|
109
|
+
"""
|
|
110
|
+
Retrieves the status of a service execution.
|
|
111
|
+
The status can be one of the following: UNKNOWN, PENDING, RUNNING, SUCCEEDED, CANCELLED, FAILED.
|
|
112
|
+
|
|
113
|
+
Parameters
|
|
114
|
+
----------
|
|
115
|
+
id : str
|
|
116
|
+
The id of a service execution
|
|
117
|
+
|
|
118
|
+
request_options : typing.Optional[RequestOptions]
|
|
119
|
+
Request-specific configuration.
|
|
120
|
+
|
|
121
|
+
Returns
|
|
122
|
+
-------
|
|
123
|
+
HttpResponse[ServiceExecution]
|
|
124
|
+
A service execution
|
|
125
|
+
"""
|
|
126
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
127
|
+
f"{jsonable_encoder(id)}",
|
|
128
|
+
method="GET",
|
|
129
|
+
request_options=request_options,
|
|
130
|
+
)
|
|
131
|
+
try:
|
|
132
|
+
if 200 <= _response.status_code < 300:
|
|
133
|
+
_data = typing.cast(
|
|
134
|
+
ServiceExecution,
|
|
135
|
+
parse_obj_as(
|
|
136
|
+
type_=ServiceExecution, # type: ignore
|
|
137
|
+
object_=_response.json(),
|
|
138
|
+
),
|
|
139
|
+
)
|
|
140
|
+
return HttpResponse(response=_response, data=_data)
|
|
141
|
+
_response_json = _response.json()
|
|
142
|
+
except JSONDecodeError:
|
|
143
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
144
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
145
|
+
|
|
146
|
+
def get_result(
|
|
147
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
148
|
+
) -> HttpResponse[GetResultResponse]:
|
|
149
|
+
"""
|
|
150
|
+
Retrieves the result of a service execution.
|
|
151
|
+
The result is returned as a JSON object containing the status and any additional data.
|
|
152
|
+
The result may include links to download specific result files.
|
|
153
|
+
|
|
154
|
+
Parameters
|
|
155
|
+
----------
|
|
156
|
+
id : str
|
|
157
|
+
The id of a service execution
|
|
158
|
+
|
|
159
|
+
request_options : typing.Optional[RequestOptions]
|
|
160
|
+
Request-specific configuration.
|
|
161
|
+
|
|
162
|
+
Returns
|
|
163
|
+
-------
|
|
164
|
+
HttpResponse[GetResultResponse]
|
|
165
|
+
The service execution result
|
|
166
|
+
"""
|
|
167
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
168
|
+
f"{jsonable_encoder(id)}/result",
|
|
169
|
+
method="GET",
|
|
170
|
+
request_options=request_options,
|
|
171
|
+
)
|
|
172
|
+
try:
|
|
173
|
+
if 200 <= _response.status_code < 300:
|
|
174
|
+
_data = typing.cast(
|
|
175
|
+
GetResultResponse,
|
|
176
|
+
parse_obj_as(
|
|
177
|
+
type_=GetResultResponse, # type: ignore
|
|
178
|
+
object_=_response.json(),
|
|
179
|
+
),
|
|
180
|
+
)
|
|
181
|
+
return HttpResponse(response=_response, data=_data)
|
|
182
|
+
_response_json = _response.json()
|
|
183
|
+
except JSONDecodeError:
|
|
184
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
185
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
186
|
+
|
|
187
|
+
@contextlib.contextmanager
|
|
188
|
+
def get_result_file(
|
|
189
|
+
self, id: str, file: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
190
|
+
) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]:
|
|
191
|
+
"""
|
|
192
|
+
Retrieves a specific result file of a service execution.
|
|
193
|
+
The file name is provided in the path parameter.
|
|
194
|
+
The result file is returned as a binary stream.
|
|
195
|
+
|
|
196
|
+
Parameters
|
|
197
|
+
----------
|
|
198
|
+
id : str
|
|
199
|
+
The id of a service execution
|
|
200
|
+
|
|
201
|
+
file : str
|
|
202
|
+
The name of the result file
|
|
203
|
+
|
|
204
|
+
request_options : typing.Optional[RequestOptions]
|
|
205
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
206
|
+
|
|
207
|
+
Returns
|
|
208
|
+
-------
|
|
209
|
+
typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
|
|
210
|
+
The content of a result file
|
|
211
|
+
"""
|
|
212
|
+
with self._client_wrapper.httpx_client.stream(
|
|
213
|
+
f"{jsonable_encoder(id)}/result/{jsonable_encoder(file)}",
|
|
214
|
+
method="GET",
|
|
215
|
+
request_options=request_options,
|
|
216
|
+
) as _response:
|
|
217
|
+
|
|
218
|
+
def _stream() -> HttpResponse[typing.Iterator[bytes]]:
|
|
219
|
+
try:
|
|
220
|
+
if 200 <= _response.status_code < 300:
|
|
221
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
|
222
|
+
return HttpResponse(
|
|
223
|
+
response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size))
|
|
224
|
+
)
|
|
225
|
+
_response.read()
|
|
226
|
+
_response_json = _response.json()
|
|
227
|
+
except JSONDecodeError:
|
|
228
|
+
raise ApiError(
|
|
229
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
|
230
|
+
)
|
|
231
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
232
|
+
|
|
233
|
+
yield _stream()
|
|
234
|
+
|
|
235
|
+
def get_logs(
|
|
236
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
237
|
+
) -> HttpResponse[typing.List[str]]:
|
|
238
|
+
"""
|
|
239
|
+
Returns a list of log entries for a service execution in chronological order, where the first entry is the oldest.
|
|
240
|
+
|
|
241
|
+
Parameters
|
|
242
|
+
----------
|
|
243
|
+
id : str
|
|
244
|
+
The id of a service execution
|
|
245
|
+
|
|
246
|
+
request_options : typing.Optional[RequestOptions]
|
|
247
|
+
Request-specific configuration.
|
|
248
|
+
|
|
249
|
+
Returns
|
|
250
|
+
-------
|
|
251
|
+
HttpResponse[typing.List[str]]
|
|
252
|
+
List of log entries
|
|
253
|
+
"""
|
|
254
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
255
|
+
f"{jsonable_encoder(id)}/log",
|
|
256
|
+
method="GET",
|
|
257
|
+
request_options=request_options,
|
|
258
|
+
)
|
|
259
|
+
try:
|
|
260
|
+
if 200 <= _response.status_code < 300:
|
|
261
|
+
_data = typing.cast(
|
|
262
|
+
typing.List[str],
|
|
263
|
+
parse_obj_as(
|
|
264
|
+
type_=typing.List[str], # type: ignore
|
|
265
|
+
object_=_response.json(),
|
|
266
|
+
),
|
|
267
|
+
)
|
|
268
|
+
return HttpResponse(response=_response, data=_data)
|
|
269
|
+
_response_json = _response.json()
|
|
270
|
+
except JSONDecodeError:
|
|
271
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
272
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
273
|
+
|
|
274
|
+
def cancel_execution(
|
|
275
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
276
|
+
) -> HttpResponse[ServiceExecution]:
|
|
277
|
+
"""
|
|
278
|
+
Cancel a pending or running service execution.
|
|
279
|
+
|
|
280
|
+
Parameters
|
|
281
|
+
----------
|
|
282
|
+
id : str
|
|
283
|
+
The id of a service execution
|
|
284
|
+
|
|
285
|
+
request_options : typing.Optional[RequestOptions]
|
|
286
|
+
Request-specific configuration.
|
|
287
|
+
|
|
288
|
+
Returns
|
|
289
|
+
-------
|
|
290
|
+
HttpResponse[ServiceExecution]
|
|
291
|
+
Service execution is cancelled
|
|
292
|
+
"""
|
|
293
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
294
|
+
f"{jsonable_encoder(id)}/cancel",
|
|
295
|
+
method="PUT",
|
|
296
|
+
request_options=request_options,
|
|
297
|
+
)
|
|
298
|
+
try:
|
|
299
|
+
if 200 <= _response.status_code < 300:
|
|
300
|
+
_data = typing.cast(
|
|
301
|
+
ServiceExecution,
|
|
302
|
+
parse_obj_as(
|
|
303
|
+
type_=ServiceExecution, # type: ignore
|
|
304
|
+
object_=_response.json(),
|
|
305
|
+
),
|
|
306
|
+
)
|
|
307
|
+
return HttpResponse(response=_response, data=_data)
|
|
308
|
+
_response_json = _response.json()
|
|
309
|
+
except JSONDecodeError:
|
|
310
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
311
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class AsyncRawServiceApiClient:
|
|
315
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
316
|
+
self._client_wrapper = client_wrapper
|
|
317
|
+
|
|
318
|
+
async def get_service_executions(
|
|
319
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
320
|
+
) -> AsyncHttpResponse[typing.List[ServiceExecution]]:
|
|
321
|
+
"""
|
|
322
|
+
Retrieves a list of all service executions.
|
|
323
|
+
The response includes links to each service execution, allowing for further queries on their status and results.
|
|
324
|
+
|
|
325
|
+
Parameters
|
|
326
|
+
----------
|
|
327
|
+
request_options : typing.Optional[RequestOptions]
|
|
328
|
+
Request-specific configuration.
|
|
329
|
+
|
|
330
|
+
Returns
|
|
331
|
+
-------
|
|
332
|
+
AsyncHttpResponse[typing.List[ServiceExecution]]
|
|
333
|
+
List of service executions
|
|
334
|
+
"""
|
|
335
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
336
|
+
method="GET",
|
|
337
|
+
request_options=request_options,
|
|
338
|
+
)
|
|
339
|
+
try:
|
|
340
|
+
if 200 <= _response.status_code < 300:
|
|
341
|
+
_data = typing.cast(
|
|
342
|
+
typing.List[ServiceExecution],
|
|
343
|
+
parse_obj_as(
|
|
344
|
+
type_=typing.List[ServiceExecution], # type: ignore
|
|
345
|
+
object_=_response.json(),
|
|
346
|
+
),
|
|
347
|
+
)
|
|
348
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
349
|
+
_response_json = _response.json()
|
|
350
|
+
except JSONDecodeError:
|
|
351
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
352
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
353
|
+
|
|
354
|
+
async def start_execution(
|
|
355
|
+
self,
|
|
356
|
+
*,
|
|
357
|
+
request: typing.Dict[str, typing.Optional[typing.Any]],
|
|
358
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
359
|
+
) -> AsyncHttpResponse[ServiceExecution]:
|
|
360
|
+
"""
|
|
361
|
+
Starts a service execution, which in turn is processed asynchronously.
|
|
362
|
+
The location header of the response contains the URL which can be used to query the status and the result of the service execution.
|
|
363
|
+
|
|
364
|
+
Parameters
|
|
365
|
+
----------
|
|
366
|
+
request : typing.Dict[str, typing.Optional[typing.Any]]
|
|
367
|
+
|
|
368
|
+
request_options : typing.Optional[RequestOptions]
|
|
369
|
+
Request-specific configuration.
|
|
370
|
+
|
|
371
|
+
Returns
|
|
372
|
+
-------
|
|
373
|
+
AsyncHttpResponse[ServiceExecution]
|
|
374
|
+
Service execution is submitted
|
|
375
|
+
"""
|
|
376
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
377
|
+
method="POST",
|
|
378
|
+
json=request,
|
|
379
|
+
headers={
|
|
380
|
+
"content-type": "application/json",
|
|
381
|
+
},
|
|
382
|
+
request_options=request_options,
|
|
383
|
+
omit=OMIT,
|
|
384
|
+
)
|
|
385
|
+
try:
|
|
386
|
+
if 200 <= _response.status_code < 300:
|
|
387
|
+
_data = typing.cast(
|
|
388
|
+
ServiceExecution,
|
|
389
|
+
parse_obj_as(
|
|
390
|
+
type_=ServiceExecution, # type: ignore
|
|
391
|
+
object_=_response.json(),
|
|
392
|
+
),
|
|
393
|
+
)
|
|
394
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
395
|
+
_response_json = _response.json()
|
|
396
|
+
except JSONDecodeError:
|
|
397
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
398
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
399
|
+
|
|
400
|
+
async def get_status(
|
|
401
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
402
|
+
) -> AsyncHttpResponse[ServiceExecution]:
|
|
403
|
+
"""
|
|
404
|
+
Retrieves the status of a service execution.
|
|
405
|
+
The status can be one of the following: UNKNOWN, PENDING, RUNNING, SUCCEEDED, CANCELLED, FAILED.
|
|
406
|
+
|
|
407
|
+
Parameters
|
|
408
|
+
----------
|
|
409
|
+
id : str
|
|
410
|
+
The id of a service execution
|
|
411
|
+
|
|
412
|
+
request_options : typing.Optional[RequestOptions]
|
|
413
|
+
Request-specific configuration.
|
|
414
|
+
|
|
415
|
+
Returns
|
|
416
|
+
-------
|
|
417
|
+
AsyncHttpResponse[ServiceExecution]
|
|
418
|
+
A service execution
|
|
419
|
+
"""
|
|
420
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
421
|
+
f"{jsonable_encoder(id)}",
|
|
422
|
+
method="GET",
|
|
423
|
+
request_options=request_options,
|
|
424
|
+
)
|
|
425
|
+
try:
|
|
426
|
+
if 200 <= _response.status_code < 300:
|
|
427
|
+
_data = typing.cast(
|
|
428
|
+
ServiceExecution,
|
|
429
|
+
parse_obj_as(
|
|
430
|
+
type_=ServiceExecution, # type: ignore
|
|
431
|
+
object_=_response.json(),
|
|
432
|
+
),
|
|
433
|
+
)
|
|
434
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
435
|
+
_response_json = _response.json()
|
|
436
|
+
except JSONDecodeError:
|
|
437
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
438
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
439
|
+
|
|
440
|
+
async def get_result(
|
|
441
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
442
|
+
) -> AsyncHttpResponse[GetResultResponse]:
|
|
443
|
+
"""
|
|
444
|
+
Retrieves the result of a service execution.
|
|
445
|
+
The result is returned as a JSON object containing the status and any additional data.
|
|
446
|
+
The result may include links to download specific result files.
|
|
447
|
+
|
|
448
|
+
Parameters
|
|
449
|
+
----------
|
|
450
|
+
id : str
|
|
451
|
+
The id of a service execution
|
|
452
|
+
|
|
453
|
+
request_options : typing.Optional[RequestOptions]
|
|
454
|
+
Request-specific configuration.
|
|
455
|
+
|
|
456
|
+
Returns
|
|
457
|
+
-------
|
|
458
|
+
AsyncHttpResponse[GetResultResponse]
|
|
459
|
+
The service execution result
|
|
460
|
+
"""
|
|
461
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
462
|
+
f"{jsonable_encoder(id)}/result",
|
|
463
|
+
method="GET",
|
|
464
|
+
request_options=request_options,
|
|
465
|
+
)
|
|
466
|
+
try:
|
|
467
|
+
if 200 <= _response.status_code < 300:
|
|
468
|
+
_data = typing.cast(
|
|
469
|
+
GetResultResponse,
|
|
470
|
+
parse_obj_as(
|
|
471
|
+
type_=GetResultResponse, # type: ignore
|
|
472
|
+
object_=_response.json(),
|
|
473
|
+
),
|
|
474
|
+
)
|
|
475
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
476
|
+
_response_json = _response.json()
|
|
477
|
+
except JSONDecodeError:
|
|
478
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
479
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
480
|
+
|
|
481
|
+
@contextlib.asynccontextmanager
|
|
482
|
+
async def get_result_file(
|
|
483
|
+
self, id: str, file: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
484
|
+
) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]:
|
|
485
|
+
"""
|
|
486
|
+
Retrieves a specific result file of a service execution.
|
|
487
|
+
The file name is provided in the path parameter.
|
|
488
|
+
The result file is returned as a binary stream.
|
|
489
|
+
|
|
490
|
+
Parameters
|
|
491
|
+
----------
|
|
492
|
+
id : str
|
|
493
|
+
The id of a service execution
|
|
494
|
+
|
|
495
|
+
file : str
|
|
496
|
+
The name of the result file
|
|
497
|
+
|
|
498
|
+
request_options : typing.Optional[RequestOptions]
|
|
499
|
+
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
500
|
+
|
|
501
|
+
Returns
|
|
502
|
+
-------
|
|
503
|
+
typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
|
|
504
|
+
The content of a result file
|
|
505
|
+
"""
|
|
506
|
+
async with self._client_wrapper.httpx_client.stream(
|
|
507
|
+
f"{jsonable_encoder(id)}/result/{jsonable_encoder(file)}",
|
|
508
|
+
method="GET",
|
|
509
|
+
request_options=request_options,
|
|
510
|
+
) as _response:
|
|
511
|
+
|
|
512
|
+
async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]:
|
|
513
|
+
try:
|
|
514
|
+
if 200 <= _response.status_code < 300:
|
|
515
|
+
_chunk_size = request_options.get("chunk_size", None) if request_options is not None else None
|
|
516
|
+
return AsyncHttpResponse(
|
|
517
|
+
response=_response,
|
|
518
|
+
data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)),
|
|
519
|
+
)
|
|
520
|
+
await _response.aread()
|
|
521
|
+
_response_json = _response.json()
|
|
522
|
+
except JSONDecodeError:
|
|
523
|
+
raise ApiError(
|
|
524
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.text
|
|
525
|
+
)
|
|
526
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
527
|
+
|
|
528
|
+
yield await _stream()
|
|
529
|
+
|
|
530
|
+
async def get_logs(
|
|
531
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
532
|
+
) -> AsyncHttpResponse[typing.List[str]]:
|
|
533
|
+
"""
|
|
534
|
+
Returns a list of log entries for a service execution in chronological order, where the first entry is the oldest.
|
|
535
|
+
|
|
536
|
+
Parameters
|
|
537
|
+
----------
|
|
538
|
+
id : str
|
|
539
|
+
The id of a service execution
|
|
540
|
+
|
|
541
|
+
request_options : typing.Optional[RequestOptions]
|
|
542
|
+
Request-specific configuration.
|
|
543
|
+
|
|
544
|
+
Returns
|
|
545
|
+
-------
|
|
546
|
+
AsyncHttpResponse[typing.List[str]]
|
|
547
|
+
List of log entries
|
|
548
|
+
"""
|
|
549
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
550
|
+
f"{jsonable_encoder(id)}/log",
|
|
551
|
+
method="GET",
|
|
552
|
+
request_options=request_options,
|
|
553
|
+
)
|
|
554
|
+
try:
|
|
555
|
+
if 200 <= _response.status_code < 300:
|
|
556
|
+
_data = typing.cast(
|
|
557
|
+
typing.List[str],
|
|
558
|
+
parse_obj_as(
|
|
559
|
+
type_=typing.List[str], # type: ignore
|
|
560
|
+
object_=_response.json(),
|
|
561
|
+
),
|
|
562
|
+
)
|
|
563
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
564
|
+
_response_json = _response.json()
|
|
565
|
+
except JSONDecodeError:
|
|
566
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
567
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
568
|
+
|
|
569
|
+
async def cancel_execution(
|
|
570
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
571
|
+
) -> AsyncHttpResponse[ServiceExecution]:
|
|
572
|
+
"""
|
|
573
|
+
Cancel a pending or running service execution.
|
|
574
|
+
|
|
575
|
+
Parameters
|
|
576
|
+
----------
|
|
577
|
+
id : str
|
|
578
|
+
The id of a service execution
|
|
579
|
+
|
|
580
|
+
request_options : typing.Optional[RequestOptions]
|
|
581
|
+
Request-specific configuration.
|
|
582
|
+
|
|
583
|
+
Returns
|
|
584
|
+
-------
|
|
585
|
+
AsyncHttpResponse[ServiceExecution]
|
|
586
|
+
Service execution is cancelled
|
|
587
|
+
"""
|
|
588
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
589
|
+
f"{jsonable_encoder(id)}/cancel",
|
|
590
|
+
method="PUT",
|
|
591
|
+
request_options=request_options,
|
|
592
|
+
)
|
|
593
|
+
try:
|
|
594
|
+
if 200 <= _response.status_code < 300:
|
|
595
|
+
_data = typing.cast(
|
|
596
|
+
ServiceExecution,
|
|
597
|
+
parse_obj_as(
|
|
598
|
+
type_=ServiceExecution, # type: ignore
|
|
599
|
+
object_=_response.json(),
|
|
600
|
+
),
|
|
601
|
+
)
|
|
602
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
603
|
+
_response_json = _response.json()
|
|
604
|
+
except JSONDecodeError:
|
|
605
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
606
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
3
5
|
from .get_result_response import GetResultResponse
|
|
4
6
|
from .get_result_response_embedded import GetResultResponseEmbedded
|
|
5
7
|
from .get_result_response_links import GetResultResponseLinks
|
|
6
|
-
from .health_check_response import HealthCheckResponse
|
|
7
8
|
|
|
8
|
-
__all__ = [
|
|
9
|
-
"GetResultResponse",
|
|
10
|
-
"GetResultResponseEmbedded",
|
|
11
|
-
"GetResultResponseLinks",
|
|
12
|
-
"HealthCheckResponse",
|
|
13
|
-
]
|
|
9
|
+
__all__ = ["GetResultResponse", "GetResultResponseEmbedded", "GetResultResponseLinks"]
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from ...core.pydantic_utilities import UniversalBaseModel
|
|
4
|
-
import typing_extensions
|
|
5
3
|
import typing
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
import typing_extensions
|
|
7
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
8
|
from ...core.serialization import FieldMetadata
|
|
8
9
|
from .get_result_response_embedded import GetResultResponseEmbedded
|
|
9
|
-
from
|
|
10
|
-
import pydantic
|
|
10
|
+
from .get_result_response_links import GetResultResponseLinks
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class GetResultResponse(UniversalBaseModel):
|
|
14
|
-
links: typing_extensions.Annotated[
|
|
15
|
-
typing.Optional[GetResultResponseLinks], FieldMetadata(alias="_links")
|
|
16
|
-
] = None
|
|
14
|
+
links: typing_extensions.Annotated[typing.Optional[GetResultResponseLinks], FieldMetadata(alias="_links")] = None
|
|
17
15
|
embedded: typing_extensions.Annotated[
|
|
18
16
|
typing.Optional[GetResultResponseEmbedded], FieldMetadata(alias="_embedded")
|
|
19
17
|
] = None
|
|
20
18
|
|
|
21
19
|
if IS_PYDANTIC_V2:
|
|
22
|
-
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
23
|
-
extra="allow", frozen=True
|
|
24
|
-
) # type: ignore # Pydantic v2
|
|
20
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
25
21
|
else:
|
|
26
22
|
|
|
27
23
|
class Config:
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
from ...core.pydantic_utilities import UniversalBaseModel
|
|
4
3
|
import typing
|
|
5
|
-
|
|
6
|
-
from ...core.pydantic_utilities import IS_PYDANTIC_V2
|
|
4
|
+
|
|
7
5
|
import pydantic
|
|
6
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from ...types.service_execution import ServiceExecution
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class GetResultResponseEmbedded(UniversalBaseModel):
|
|
11
11
|
status: typing.Optional[ServiceExecution] = None
|
|
12
12
|
|
|
13
13
|
if IS_PYDANTIC_V2:
|
|
14
|
-
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
|
|
15
|
-
extra="allow", frozen=True
|
|
16
|
-
) # type: ignore # Pydantic v2
|
|
14
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
17
15
|
else:
|
|
18
16
|
|
|
19
17
|
class Config:
|