@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
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
5
6
|
from ..core.request_options import RequestOptions
|
|
6
|
-
from .types.health_check_response import HealthCheckResponse
|
|
7
|
-
from ..core.pydantic_utilities import parse_obj_as
|
|
8
|
-
from json.decoder import JSONDecodeError
|
|
9
|
-
from ..core.api_error import ApiError
|
|
10
7
|
from ..types.service_execution import ServiceExecution
|
|
11
|
-
from
|
|
12
|
-
from ..errors.unauthorized_error import UnauthorizedError
|
|
13
|
-
from ..errors.forbidden_error import ForbiddenError
|
|
14
|
-
from ..errors.not_found_error import NotFoundError
|
|
15
|
-
from ..errors.internal_server_error import InternalServerError
|
|
16
|
-
from ..core.jsonable_encoder import jsonable_encoder
|
|
8
|
+
from .raw_client import AsyncRawServiceApiClient, RawServiceApiClient
|
|
17
9
|
from .types.get_result_response import GetResultResponse
|
|
18
|
-
from ..core.client_wrapper import AsyncClientWrapper
|
|
19
10
|
|
|
20
11
|
# this is used as the default value for optional parameters
|
|
21
12
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -23,13 +14,25 @@ OMIT = typing.cast(typing.Any, ...)
|
|
|
23
14
|
|
|
24
15
|
class ServiceApiClient:
|
|
25
16
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
26
|
-
self.
|
|
17
|
+
self._raw_client = RawServiceApiClient(client_wrapper=client_wrapper)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def with_raw_response(self) -> RawServiceApiClient:
|
|
21
|
+
"""
|
|
22
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
RawServiceApiClient
|
|
27
|
+
"""
|
|
28
|
+
return self._raw_client
|
|
27
29
|
|
|
28
|
-
def
|
|
30
|
+
def get_service_executions(
|
|
29
31
|
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
30
|
-
) ->
|
|
32
|
+
) -> typing.List[ServiceExecution]:
|
|
31
33
|
"""
|
|
32
|
-
|
|
34
|
+
Retrieves a list of all service executions.
|
|
35
|
+
The response includes links to each service execution, allowing for further queries on their status and results.
|
|
33
36
|
|
|
34
37
|
Parameters
|
|
35
38
|
----------
|
|
@@ -38,8 +41,8 @@ class ServiceApiClient:
|
|
|
38
41
|
|
|
39
42
|
Returns
|
|
40
43
|
-------
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
typing.List[ServiceExecution]
|
|
45
|
+
List of service executions
|
|
43
46
|
|
|
44
47
|
Examples
|
|
45
48
|
--------
|
|
@@ -48,39 +51,24 @@ class ServiceApiClient:
|
|
|
48
51
|
client = PlanqkServiceApi(
|
|
49
52
|
token="YOUR_TOKEN",
|
|
50
53
|
)
|
|
51
|
-
client.service_api.
|
|
54
|
+
client.service_api.get_service_executions()
|
|
52
55
|
"""
|
|
53
|
-
_response = self.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
try:
|
|
58
|
-
if 200 <= _response.status_code < 300:
|
|
59
|
-
return typing.cast(
|
|
60
|
-
HealthCheckResponse,
|
|
61
|
-
parse_obj_as(
|
|
62
|
-
type_=HealthCheckResponse, # type: ignore
|
|
63
|
-
object_=_response.json(),
|
|
64
|
-
),
|
|
65
|
-
)
|
|
66
|
-
_response_json = _response.json()
|
|
67
|
-
except JSONDecodeError:
|
|
68
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
69
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
70
|
-
|
|
71
|
-
def execute(
|
|
56
|
+
_response = self._raw_client.get_service_executions(request_options=request_options)
|
|
57
|
+
return _response.data
|
|
58
|
+
|
|
59
|
+
def start_execution(
|
|
72
60
|
self,
|
|
73
61
|
*,
|
|
74
|
-
request: typing.Dict[str, typing.
|
|
62
|
+
request: typing.Dict[str, typing.Optional[typing.Any]],
|
|
75
63
|
request_options: typing.Optional[RequestOptions] = None,
|
|
76
64
|
) -> ServiceExecution:
|
|
77
65
|
"""
|
|
78
|
-
|
|
66
|
+
Starts a service execution, which in turn is processed asynchronously.
|
|
79
67
|
The location header of the response contains the URL which can be used to query the status and the result of the service execution.
|
|
80
68
|
|
|
81
69
|
Parameters
|
|
82
70
|
----------
|
|
83
|
-
request : typing.Dict[str, typing.
|
|
71
|
+
request : typing.Dict[str, typing.Optional[typing.Any]]
|
|
84
72
|
|
|
85
73
|
request_options : typing.Optional[RequestOptions]
|
|
86
74
|
Request-specific configuration.
|
|
@@ -88,7 +76,7 @@ class ServiceApiClient:
|
|
|
88
76
|
Returns
|
|
89
77
|
-------
|
|
90
78
|
ServiceExecution
|
|
91
|
-
Service execution
|
|
79
|
+
Service execution is submitted
|
|
92
80
|
|
|
93
81
|
Examples
|
|
94
82
|
--------
|
|
@@ -97,85 +85,17 @@ class ServiceApiClient:
|
|
|
97
85
|
client = PlanqkServiceApi(
|
|
98
86
|
token="YOUR_TOKEN",
|
|
99
87
|
)
|
|
100
|
-
client.service_api.
|
|
101
|
-
request={"key":
|
|
88
|
+
client.service_api.start_execution(
|
|
89
|
+
request={"key": "value"},
|
|
102
90
|
)
|
|
103
91
|
"""
|
|
104
|
-
_response = self.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
omit=OMIT,
|
|
109
|
-
)
|
|
110
|
-
try:
|
|
111
|
-
if 200 <= _response.status_code < 300:
|
|
112
|
-
return typing.cast(
|
|
113
|
-
ServiceExecution,
|
|
114
|
-
parse_obj_as(
|
|
115
|
-
type_=ServiceExecution, # type: ignore
|
|
116
|
-
object_=_response.json(),
|
|
117
|
-
),
|
|
118
|
-
)
|
|
119
|
-
if _response.status_code == 400:
|
|
120
|
-
raise BadRequestError(
|
|
121
|
-
typing.cast(
|
|
122
|
-
typing.Optional[typing.Any],
|
|
123
|
-
parse_obj_as(
|
|
124
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
125
|
-
object_=_response.json(),
|
|
126
|
-
),
|
|
127
|
-
)
|
|
128
|
-
)
|
|
129
|
-
if _response.status_code == 401:
|
|
130
|
-
raise UnauthorizedError(
|
|
131
|
-
typing.cast(
|
|
132
|
-
typing.Optional[typing.Any],
|
|
133
|
-
parse_obj_as(
|
|
134
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
135
|
-
object_=_response.json(),
|
|
136
|
-
),
|
|
137
|
-
)
|
|
138
|
-
)
|
|
139
|
-
if _response.status_code == 403:
|
|
140
|
-
raise ForbiddenError(
|
|
141
|
-
typing.cast(
|
|
142
|
-
typing.Optional[typing.Any],
|
|
143
|
-
parse_obj_as(
|
|
144
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
145
|
-
object_=_response.json(),
|
|
146
|
-
),
|
|
147
|
-
)
|
|
148
|
-
)
|
|
149
|
-
if _response.status_code == 404:
|
|
150
|
-
raise NotFoundError(
|
|
151
|
-
typing.cast(
|
|
152
|
-
typing.Optional[typing.Any],
|
|
153
|
-
parse_obj_as(
|
|
154
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
155
|
-
object_=_response.json(),
|
|
156
|
-
),
|
|
157
|
-
)
|
|
158
|
-
)
|
|
159
|
-
if _response.status_code == 500:
|
|
160
|
-
raise InternalServerError(
|
|
161
|
-
typing.cast(
|
|
162
|
-
typing.Optional[typing.Any],
|
|
163
|
-
parse_obj_as(
|
|
164
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
165
|
-
object_=_response.json(),
|
|
166
|
-
),
|
|
167
|
-
)
|
|
168
|
-
)
|
|
169
|
-
_response_json = _response.json()
|
|
170
|
-
except JSONDecodeError:
|
|
171
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
172
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
173
|
-
|
|
174
|
-
def get_status(
|
|
175
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
176
|
-
) -> ServiceExecution:
|
|
92
|
+
_response = self._raw_client.start_execution(request=request, request_options=request_options)
|
|
93
|
+
return _response.data
|
|
94
|
+
|
|
95
|
+
def get_status(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ServiceExecution:
|
|
177
96
|
"""
|
|
178
|
-
|
|
97
|
+
Retrieves the status of a service execution.
|
|
98
|
+
The status can be one of the following: UNKNOWN, PENDING, RUNNING, SUCCEEDED, CANCELLED, FAILED.
|
|
179
99
|
|
|
180
100
|
Parameters
|
|
181
101
|
----------
|
|
@@ -188,7 +108,7 @@ class ServiceApiClient:
|
|
|
188
108
|
Returns
|
|
189
109
|
-------
|
|
190
110
|
ServiceExecution
|
|
191
|
-
|
|
111
|
+
A service execution
|
|
192
112
|
|
|
193
113
|
Examples
|
|
194
114
|
--------
|
|
@@ -201,70 +121,14 @@ class ServiceApiClient:
|
|
|
201
121
|
id="id",
|
|
202
122
|
)
|
|
203
123
|
"""
|
|
204
|
-
_response = self.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
)
|
|
209
|
-
try:
|
|
210
|
-
if 200 <= _response.status_code < 300:
|
|
211
|
-
return typing.cast(
|
|
212
|
-
ServiceExecution,
|
|
213
|
-
parse_obj_as(
|
|
214
|
-
type_=ServiceExecution, # type: ignore
|
|
215
|
-
object_=_response.json(),
|
|
216
|
-
),
|
|
217
|
-
)
|
|
218
|
-
if _response.status_code == 401:
|
|
219
|
-
raise UnauthorizedError(
|
|
220
|
-
typing.cast(
|
|
221
|
-
typing.Optional[typing.Any],
|
|
222
|
-
parse_obj_as(
|
|
223
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
224
|
-
object_=_response.json(),
|
|
225
|
-
),
|
|
226
|
-
)
|
|
227
|
-
)
|
|
228
|
-
if _response.status_code == 403:
|
|
229
|
-
raise ForbiddenError(
|
|
230
|
-
typing.cast(
|
|
231
|
-
typing.Optional[typing.Any],
|
|
232
|
-
parse_obj_as(
|
|
233
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
234
|
-
object_=_response.json(),
|
|
235
|
-
),
|
|
236
|
-
)
|
|
237
|
-
)
|
|
238
|
-
if _response.status_code == 404:
|
|
239
|
-
raise NotFoundError(
|
|
240
|
-
typing.cast(
|
|
241
|
-
typing.Optional[typing.Any],
|
|
242
|
-
parse_obj_as(
|
|
243
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
244
|
-
object_=_response.json(),
|
|
245
|
-
),
|
|
246
|
-
)
|
|
247
|
-
)
|
|
248
|
-
if _response.status_code == 500:
|
|
249
|
-
raise InternalServerError(
|
|
250
|
-
typing.cast(
|
|
251
|
-
typing.Optional[typing.Any],
|
|
252
|
-
parse_obj_as(
|
|
253
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
254
|
-
object_=_response.json(),
|
|
255
|
-
),
|
|
256
|
-
)
|
|
257
|
-
)
|
|
258
|
-
_response_json = _response.json()
|
|
259
|
-
except JSONDecodeError:
|
|
260
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
261
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
262
|
-
|
|
263
|
-
def get_result(
|
|
264
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
265
|
-
) -> GetResultResponse:
|
|
124
|
+
_response = self._raw_client.get_status(id, request_options=request_options)
|
|
125
|
+
return _response.data
|
|
126
|
+
|
|
127
|
+
def get_result(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetResultResponse:
|
|
266
128
|
"""
|
|
267
|
-
|
|
129
|
+
Retrieves the result of a service execution.
|
|
130
|
+
The result is returned as a JSON object containing the status and any additional data.
|
|
131
|
+
The result may include links to download specific result files.
|
|
268
132
|
|
|
269
133
|
Parameters
|
|
270
134
|
----------
|
|
@@ -277,7 +141,7 @@ class ServiceApiClient:
|
|
|
277
141
|
Returns
|
|
278
142
|
-------
|
|
279
143
|
GetResultResponse
|
|
280
|
-
|
|
144
|
+
The service execution result
|
|
281
145
|
|
|
282
146
|
Examples
|
|
283
147
|
--------
|
|
@@ -290,74 +154,16 @@ class ServiceApiClient:
|
|
|
290
154
|
id="id",
|
|
291
155
|
)
|
|
292
156
|
"""
|
|
293
|
-
_response = self.
|
|
294
|
-
|
|
295
|
-
method="GET",
|
|
296
|
-
request_options=request_options,
|
|
297
|
-
)
|
|
298
|
-
try:
|
|
299
|
-
if 200 <= _response.status_code < 300:
|
|
300
|
-
return typing.cast(
|
|
301
|
-
GetResultResponse,
|
|
302
|
-
parse_obj_as(
|
|
303
|
-
type_=GetResultResponse, # type: ignore
|
|
304
|
-
object_=_response.json(),
|
|
305
|
-
),
|
|
306
|
-
)
|
|
307
|
-
if _response.status_code == 401:
|
|
308
|
-
raise UnauthorizedError(
|
|
309
|
-
typing.cast(
|
|
310
|
-
typing.Optional[typing.Any],
|
|
311
|
-
parse_obj_as(
|
|
312
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
313
|
-
object_=_response.json(),
|
|
314
|
-
),
|
|
315
|
-
)
|
|
316
|
-
)
|
|
317
|
-
if _response.status_code == 403:
|
|
318
|
-
raise ForbiddenError(
|
|
319
|
-
typing.cast(
|
|
320
|
-
typing.Optional[typing.Any],
|
|
321
|
-
parse_obj_as(
|
|
322
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
323
|
-
object_=_response.json(),
|
|
324
|
-
),
|
|
325
|
-
)
|
|
326
|
-
)
|
|
327
|
-
if _response.status_code == 404:
|
|
328
|
-
raise NotFoundError(
|
|
329
|
-
typing.cast(
|
|
330
|
-
typing.Optional[typing.Any],
|
|
331
|
-
parse_obj_as(
|
|
332
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
333
|
-
object_=_response.json(),
|
|
334
|
-
),
|
|
335
|
-
)
|
|
336
|
-
)
|
|
337
|
-
if _response.status_code == 500:
|
|
338
|
-
raise InternalServerError(
|
|
339
|
-
typing.cast(
|
|
340
|
-
typing.Optional[typing.Any],
|
|
341
|
-
parse_obj_as(
|
|
342
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
343
|
-
object_=_response.json(),
|
|
344
|
-
),
|
|
345
|
-
)
|
|
346
|
-
)
|
|
347
|
-
_response_json = _response.json()
|
|
348
|
-
except JSONDecodeError:
|
|
349
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
350
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
157
|
+
_response = self._raw_client.get_result(id, request_options=request_options)
|
|
158
|
+
return _response.data
|
|
351
159
|
|
|
352
160
|
def get_result_file(
|
|
353
|
-
self,
|
|
354
|
-
id: str,
|
|
355
|
-
file: str,
|
|
356
|
-
*,
|
|
357
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
161
|
+
self, id: str, file: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
358
162
|
) -> typing.Iterator[bytes]:
|
|
359
163
|
"""
|
|
360
|
-
|
|
164
|
+
Retrieves a specific result file of a service execution.
|
|
165
|
+
The file name is provided in the path parameter.
|
|
166
|
+
The result file is returned as a binary stream.
|
|
361
167
|
|
|
362
168
|
Parameters
|
|
363
169
|
----------
|
|
@@ -370,77 +176,17 @@ class ServiceApiClient:
|
|
|
370
176
|
request_options : typing.Optional[RequestOptions]
|
|
371
177
|
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
372
178
|
|
|
373
|
-
|
|
374
|
-
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
375
181
|
typing.Iterator[bytes]
|
|
376
|
-
|
|
182
|
+
The content of a result file
|
|
377
183
|
"""
|
|
378
|
-
with self.
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
) as _response:
|
|
383
|
-
try:
|
|
384
|
-
if 200 <= _response.status_code < 300:
|
|
385
|
-
_chunk_size = (
|
|
386
|
-
request_options.get("chunk_size", None)
|
|
387
|
-
if request_options is not None
|
|
388
|
-
else None
|
|
389
|
-
)
|
|
390
|
-
for _chunk in _response.iter_bytes(chunk_size=_chunk_size):
|
|
391
|
-
yield _chunk
|
|
392
|
-
return
|
|
393
|
-
_response.read()
|
|
394
|
-
if _response.status_code == 401:
|
|
395
|
-
raise UnauthorizedError(
|
|
396
|
-
typing.cast(
|
|
397
|
-
typing.Optional[typing.Any],
|
|
398
|
-
parse_obj_as(
|
|
399
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
400
|
-
object_=_response.json(),
|
|
401
|
-
),
|
|
402
|
-
)
|
|
403
|
-
)
|
|
404
|
-
if _response.status_code == 403:
|
|
405
|
-
raise ForbiddenError(
|
|
406
|
-
typing.cast(
|
|
407
|
-
typing.Optional[typing.Any],
|
|
408
|
-
parse_obj_as(
|
|
409
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
410
|
-
object_=_response.json(),
|
|
411
|
-
),
|
|
412
|
-
)
|
|
413
|
-
)
|
|
414
|
-
if _response.status_code == 404:
|
|
415
|
-
raise NotFoundError(
|
|
416
|
-
typing.cast(
|
|
417
|
-
typing.Optional[typing.Any],
|
|
418
|
-
parse_obj_as(
|
|
419
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
420
|
-
object_=_response.json(),
|
|
421
|
-
),
|
|
422
|
-
)
|
|
423
|
-
)
|
|
424
|
-
if _response.status_code == 500:
|
|
425
|
-
raise InternalServerError(
|
|
426
|
-
typing.cast(
|
|
427
|
-
typing.Optional[typing.Any],
|
|
428
|
-
parse_obj_as(
|
|
429
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
430
|
-
object_=_response.json(),
|
|
431
|
-
),
|
|
432
|
-
)
|
|
433
|
-
)
|
|
434
|
-
_response_json = _response.json()
|
|
435
|
-
except JSONDecodeError:
|
|
436
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
437
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
438
|
-
|
|
439
|
-
def get_logs(
|
|
440
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
441
|
-
) -> typing.List[str]:
|
|
184
|
+
with self._raw_client.get_result_file(id, file, request_options=request_options) as r:
|
|
185
|
+
yield from r.data
|
|
186
|
+
|
|
187
|
+
def get_logs(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[str]:
|
|
442
188
|
"""
|
|
443
|
-
|
|
189
|
+
Returns a list of log entries for a service execution in chronological order, where the first entry is the oldest.
|
|
444
190
|
|
|
445
191
|
Parameters
|
|
446
192
|
----------
|
|
@@ -453,7 +199,7 @@ class ServiceApiClient:
|
|
|
453
199
|
Returns
|
|
454
200
|
-------
|
|
455
201
|
typing.List[str]
|
|
456
|
-
|
|
202
|
+
List of log entries
|
|
457
203
|
|
|
458
204
|
Examples
|
|
459
205
|
--------
|
|
@@ -466,70 +212,12 @@ class ServiceApiClient:
|
|
|
466
212
|
id="id",
|
|
467
213
|
)
|
|
468
214
|
"""
|
|
469
|
-
_response = self.
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
)
|
|
474
|
-
try:
|
|
475
|
-
if 200 <= _response.status_code < 300:
|
|
476
|
-
return typing.cast(
|
|
477
|
-
typing.List[str],
|
|
478
|
-
parse_obj_as(
|
|
479
|
-
type_=typing.List[str], # type: ignore
|
|
480
|
-
object_=_response.json(),
|
|
481
|
-
),
|
|
482
|
-
)
|
|
483
|
-
if _response.status_code == 401:
|
|
484
|
-
raise UnauthorizedError(
|
|
485
|
-
typing.cast(
|
|
486
|
-
typing.Optional[typing.Any],
|
|
487
|
-
parse_obj_as(
|
|
488
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
489
|
-
object_=_response.json(),
|
|
490
|
-
),
|
|
491
|
-
)
|
|
492
|
-
)
|
|
493
|
-
if _response.status_code == 403:
|
|
494
|
-
raise ForbiddenError(
|
|
495
|
-
typing.cast(
|
|
496
|
-
typing.Optional[typing.Any],
|
|
497
|
-
parse_obj_as(
|
|
498
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
499
|
-
object_=_response.json(),
|
|
500
|
-
),
|
|
501
|
-
)
|
|
502
|
-
)
|
|
503
|
-
if _response.status_code == 404:
|
|
504
|
-
raise NotFoundError(
|
|
505
|
-
typing.cast(
|
|
506
|
-
typing.Optional[typing.Any],
|
|
507
|
-
parse_obj_as(
|
|
508
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
509
|
-
object_=_response.json(),
|
|
510
|
-
),
|
|
511
|
-
)
|
|
512
|
-
)
|
|
513
|
-
if _response.status_code == 500:
|
|
514
|
-
raise InternalServerError(
|
|
515
|
-
typing.cast(
|
|
516
|
-
typing.Optional[typing.Any],
|
|
517
|
-
parse_obj_as(
|
|
518
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
519
|
-
object_=_response.json(),
|
|
520
|
-
),
|
|
521
|
-
)
|
|
522
|
-
)
|
|
523
|
-
_response_json = _response.json()
|
|
524
|
-
except JSONDecodeError:
|
|
525
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
526
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
527
|
-
|
|
528
|
-
def cancel(
|
|
529
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
530
|
-
) -> ServiceExecution:
|
|
215
|
+
_response = self._raw_client.get_logs(id, request_options=request_options)
|
|
216
|
+
return _response.data
|
|
217
|
+
|
|
218
|
+
def cancel_execution(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ServiceExecution:
|
|
531
219
|
"""
|
|
532
|
-
|
|
220
|
+
Cancel a pending or running service execution.
|
|
533
221
|
|
|
534
222
|
Parameters
|
|
535
223
|
----------
|
|
@@ -542,7 +230,7 @@ class ServiceApiClient:
|
|
|
542
230
|
Returns
|
|
543
231
|
-------
|
|
544
232
|
ServiceExecution
|
|
545
|
-
|
|
233
|
+
Service execution is cancelled
|
|
546
234
|
|
|
547
235
|
Examples
|
|
548
236
|
--------
|
|
@@ -551,79 +239,35 @@ class ServiceApiClient:
|
|
|
551
239
|
client = PlanqkServiceApi(
|
|
552
240
|
token="YOUR_TOKEN",
|
|
553
241
|
)
|
|
554
|
-
client.service_api.
|
|
242
|
+
client.service_api.cancel_execution(
|
|
555
243
|
id="id",
|
|
556
244
|
)
|
|
557
245
|
"""
|
|
558
|
-
_response = self.
|
|
559
|
-
|
|
560
|
-
method="PUT",
|
|
561
|
-
request_options=request_options,
|
|
562
|
-
)
|
|
563
|
-
try:
|
|
564
|
-
if 200 <= _response.status_code < 300:
|
|
565
|
-
return typing.cast(
|
|
566
|
-
ServiceExecution,
|
|
567
|
-
parse_obj_as(
|
|
568
|
-
type_=ServiceExecution, # type: ignore
|
|
569
|
-
object_=_response.json(),
|
|
570
|
-
),
|
|
571
|
-
)
|
|
572
|
-
if _response.status_code == 401:
|
|
573
|
-
raise UnauthorizedError(
|
|
574
|
-
typing.cast(
|
|
575
|
-
typing.Optional[typing.Any],
|
|
576
|
-
parse_obj_as(
|
|
577
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
578
|
-
object_=_response.json(),
|
|
579
|
-
),
|
|
580
|
-
)
|
|
581
|
-
)
|
|
582
|
-
if _response.status_code == 403:
|
|
583
|
-
raise ForbiddenError(
|
|
584
|
-
typing.cast(
|
|
585
|
-
typing.Optional[typing.Any],
|
|
586
|
-
parse_obj_as(
|
|
587
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
588
|
-
object_=_response.json(),
|
|
589
|
-
),
|
|
590
|
-
)
|
|
591
|
-
)
|
|
592
|
-
if _response.status_code == 404:
|
|
593
|
-
raise NotFoundError(
|
|
594
|
-
typing.cast(
|
|
595
|
-
typing.Optional[typing.Any],
|
|
596
|
-
parse_obj_as(
|
|
597
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
598
|
-
object_=_response.json(),
|
|
599
|
-
),
|
|
600
|
-
)
|
|
601
|
-
)
|
|
602
|
-
if _response.status_code == 500:
|
|
603
|
-
raise InternalServerError(
|
|
604
|
-
typing.cast(
|
|
605
|
-
typing.Optional[typing.Any],
|
|
606
|
-
parse_obj_as(
|
|
607
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
608
|
-
object_=_response.json(),
|
|
609
|
-
),
|
|
610
|
-
)
|
|
611
|
-
)
|
|
612
|
-
_response_json = _response.json()
|
|
613
|
-
except JSONDecodeError:
|
|
614
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
615
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
246
|
+
_response = self._raw_client.cancel_execution(id, request_options=request_options)
|
|
247
|
+
return _response.data
|
|
616
248
|
|
|
617
249
|
|
|
618
250
|
class AsyncServiceApiClient:
|
|
619
251
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
620
|
-
self.
|
|
252
|
+
self._raw_client = AsyncRawServiceApiClient(client_wrapper=client_wrapper)
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def with_raw_response(self) -> AsyncRawServiceApiClient:
|
|
256
|
+
"""
|
|
257
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
258
|
+
|
|
259
|
+
Returns
|
|
260
|
+
-------
|
|
261
|
+
AsyncRawServiceApiClient
|
|
262
|
+
"""
|
|
263
|
+
return self._raw_client
|
|
621
264
|
|
|
622
|
-
async def
|
|
265
|
+
async def get_service_executions(
|
|
623
266
|
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
624
|
-
) ->
|
|
267
|
+
) -> typing.List[ServiceExecution]:
|
|
625
268
|
"""
|
|
626
|
-
|
|
269
|
+
Retrieves a list of all service executions.
|
|
270
|
+
The response includes links to each service execution, allowing for further queries on their status and results.
|
|
627
271
|
|
|
628
272
|
Parameters
|
|
629
273
|
----------
|
|
@@ -632,8 +276,8 @@ class AsyncServiceApiClient:
|
|
|
632
276
|
|
|
633
277
|
Returns
|
|
634
278
|
-------
|
|
635
|
-
|
|
636
|
-
|
|
279
|
+
typing.List[ServiceExecution]
|
|
280
|
+
List of service executions
|
|
637
281
|
|
|
638
282
|
Examples
|
|
639
283
|
--------
|
|
@@ -647,42 +291,27 @@ class AsyncServiceApiClient:
|
|
|
647
291
|
|
|
648
292
|
|
|
649
293
|
async def main() -> None:
|
|
650
|
-
await client.service_api.
|
|
294
|
+
await client.service_api.get_service_executions()
|
|
651
295
|
|
|
652
296
|
|
|
653
297
|
asyncio.run(main())
|
|
654
298
|
"""
|
|
655
|
-
_response = await self.
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
try:
|
|
660
|
-
if 200 <= _response.status_code < 300:
|
|
661
|
-
return typing.cast(
|
|
662
|
-
HealthCheckResponse,
|
|
663
|
-
parse_obj_as(
|
|
664
|
-
type_=HealthCheckResponse, # type: ignore
|
|
665
|
-
object_=_response.json(),
|
|
666
|
-
),
|
|
667
|
-
)
|
|
668
|
-
_response_json = _response.json()
|
|
669
|
-
except JSONDecodeError:
|
|
670
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
671
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
672
|
-
|
|
673
|
-
async def execute(
|
|
299
|
+
_response = await self._raw_client.get_service_executions(request_options=request_options)
|
|
300
|
+
return _response.data
|
|
301
|
+
|
|
302
|
+
async def start_execution(
|
|
674
303
|
self,
|
|
675
304
|
*,
|
|
676
|
-
request: typing.Dict[str, typing.
|
|
305
|
+
request: typing.Dict[str, typing.Optional[typing.Any]],
|
|
677
306
|
request_options: typing.Optional[RequestOptions] = None,
|
|
678
307
|
) -> ServiceExecution:
|
|
679
308
|
"""
|
|
680
|
-
|
|
309
|
+
Starts a service execution, which in turn is processed asynchronously.
|
|
681
310
|
The location header of the response contains the URL which can be used to query the status and the result of the service execution.
|
|
682
311
|
|
|
683
312
|
Parameters
|
|
684
313
|
----------
|
|
685
|
-
request : typing.Dict[str, typing.
|
|
314
|
+
request : typing.Dict[str, typing.Optional[typing.Any]]
|
|
686
315
|
|
|
687
316
|
request_options : typing.Optional[RequestOptions]
|
|
688
317
|
Request-specific configuration.
|
|
@@ -690,7 +319,7 @@ class AsyncServiceApiClient:
|
|
|
690
319
|
Returns
|
|
691
320
|
-------
|
|
692
321
|
ServiceExecution
|
|
693
|
-
Service execution
|
|
322
|
+
Service execution is submitted
|
|
694
323
|
|
|
695
324
|
Examples
|
|
696
325
|
--------
|
|
@@ -704,88 +333,20 @@ class AsyncServiceApiClient:
|
|
|
704
333
|
|
|
705
334
|
|
|
706
335
|
async def main() -> None:
|
|
707
|
-
await client.service_api.
|
|
708
|
-
request={"key":
|
|
336
|
+
await client.service_api.start_execution(
|
|
337
|
+
request={"key": "value"},
|
|
709
338
|
)
|
|
710
339
|
|
|
711
340
|
|
|
712
341
|
asyncio.run(main())
|
|
713
342
|
"""
|
|
714
|
-
_response = await self.
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
omit=OMIT,
|
|
719
|
-
)
|
|
720
|
-
try:
|
|
721
|
-
if 200 <= _response.status_code < 300:
|
|
722
|
-
return typing.cast(
|
|
723
|
-
ServiceExecution,
|
|
724
|
-
parse_obj_as(
|
|
725
|
-
type_=ServiceExecution, # type: ignore
|
|
726
|
-
object_=_response.json(),
|
|
727
|
-
),
|
|
728
|
-
)
|
|
729
|
-
if _response.status_code == 400:
|
|
730
|
-
raise BadRequestError(
|
|
731
|
-
typing.cast(
|
|
732
|
-
typing.Optional[typing.Any],
|
|
733
|
-
parse_obj_as(
|
|
734
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
735
|
-
object_=_response.json(),
|
|
736
|
-
),
|
|
737
|
-
)
|
|
738
|
-
)
|
|
739
|
-
if _response.status_code == 401:
|
|
740
|
-
raise UnauthorizedError(
|
|
741
|
-
typing.cast(
|
|
742
|
-
typing.Optional[typing.Any],
|
|
743
|
-
parse_obj_as(
|
|
744
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
745
|
-
object_=_response.json(),
|
|
746
|
-
),
|
|
747
|
-
)
|
|
748
|
-
)
|
|
749
|
-
if _response.status_code == 403:
|
|
750
|
-
raise ForbiddenError(
|
|
751
|
-
typing.cast(
|
|
752
|
-
typing.Optional[typing.Any],
|
|
753
|
-
parse_obj_as(
|
|
754
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
755
|
-
object_=_response.json(),
|
|
756
|
-
),
|
|
757
|
-
)
|
|
758
|
-
)
|
|
759
|
-
if _response.status_code == 404:
|
|
760
|
-
raise NotFoundError(
|
|
761
|
-
typing.cast(
|
|
762
|
-
typing.Optional[typing.Any],
|
|
763
|
-
parse_obj_as(
|
|
764
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
765
|
-
object_=_response.json(),
|
|
766
|
-
),
|
|
767
|
-
)
|
|
768
|
-
)
|
|
769
|
-
if _response.status_code == 500:
|
|
770
|
-
raise InternalServerError(
|
|
771
|
-
typing.cast(
|
|
772
|
-
typing.Optional[typing.Any],
|
|
773
|
-
parse_obj_as(
|
|
774
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
775
|
-
object_=_response.json(),
|
|
776
|
-
),
|
|
777
|
-
)
|
|
778
|
-
)
|
|
779
|
-
_response_json = _response.json()
|
|
780
|
-
except JSONDecodeError:
|
|
781
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
782
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
783
|
-
|
|
784
|
-
async def get_status(
|
|
785
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
786
|
-
) -> ServiceExecution:
|
|
343
|
+
_response = await self._raw_client.start_execution(request=request, request_options=request_options)
|
|
344
|
+
return _response.data
|
|
345
|
+
|
|
346
|
+
async def get_status(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ServiceExecution:
|
|
787
347
|
"""
|
|
788
|
-
|
|
348
|
+
Retrieves the status of a service execution.
|
|
349
|
+
The status can be one of the following: UNKNOWN, PENDING, RUNNING, SUCCEEDED, CANCELLED, FAILED.
|
|
789
350
|
|
|
790
351
|
Parameters
|
|
791
352
|
----------
|
|
@@ -798,7 +359,7 @@ class AsyncServiceApiClient:
|
|
|
798
359
|
Returns
|
|
799
360
|
-------
|
|
800
361
|
ServiceExecution
|
|
801
|
-
|
|
362
|
+
A service execution
|
|
802
363
|
|
|
803
364
|
Examples
|
|
804
365
|
--------
|
|
@@ -819,70 +380,16 @@ class AsyncServiceApiClient:
|
|
|
819
380
|
|
|
820
381
|
asyncio.run(main())
|
|
821
382
|
"""
|
|
822
|
-
_response = await self.
|
|
823
|
-
|
|
824
|
-
method="GET",
|
|
825
|
-
request_options=request_options,
|
|
826
|
-
)
|
|
827
|
-
try:
|
|
828
|
-
if 200 <= _response.status_code < 300:
|
|
829
|
-
return typing.cast(
|
|
830
|
-
ServiceExecution,
|
|
831
|
-
parse_obj_as(
|
|
832
|
-
type_=ServiceExecution, # type: ignore
|
|
833
|
-
object_=_response.json(),
|
|
834
|
-
),
|
|
835
|
-
)
|
|
836
|
-
if _response.status_code == 401:
|
|
837
|
-
raise UnauthorizedError(
|
|
838
|
-
typing.cast(
|
|
839
|
-
typing.Optional[typing.Any],
|
|
840
|
-
parse_obj_as(
|
|
841
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
842
|
-
object_=_response.json(),
|
|
843
|
-
),
|
|
844
|
-
)
|
|
845
|
-
)
|
|
846
|
-
if _response.status_code == 403:
|
|
847
|
-
raise ForbiddenError(
|
|
848
|
-
typing.cast(
|
|
849
|
-
typing.Optional[typing.Any],
|
|
850
|
-
parse_obj_as(
|
|
851
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
852
|
-
object_=_response.json(),
|
|
853
|
-
),
|
|
854
|
-
)
|
|
855
|
-
)
|
|
856
|
-
if _response.status_code == 404:
|
|
857
|
-
raise NotFoundError(
|
|
858
|
-
typing.cast(
|
|
859
|
-
typing.Optional[typing.Any],
|
|
860
|
-
parse_obj_as(
|
|
861
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
862
|
-
object_=_response.json(),
|
|
863
|
-
),
|
|
864
|
-
)
|
|
865
|
-
)
|
|
866
|
-
if _response.status_code == 500:
|
|
867
|
-
raise InternalServerError(
|
|
868
|
-
typing.cast(
|
|
869
|
-
typing.Optional[typing.Any],
|
|
870
|
-
parse_obj_as(
|
|
871
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
872
|
-
object_=_response.json(),
|
|
873
|
-
),
|
|
874
|
-
)
|
|
875
|
-
)
|
|
876
|
-
_response_json = _response.json()
|
|
877
|
-
except JSONDecodeError:
|
|
878
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
879
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
383
|
+
_response = await self._raw_client.get_status(id, request_options=request_options)
|
|
384
|
+
return _response.data
|
|
880
385
|
|
|
881
386
|
async def get_result(
|
|
882
387
|
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
883
388
|
) -> GetResultResponse:
|
|
884
389
|
"""
|
|
885
|
-
|
|
390
|
+
Retrieves the result of a service execution.
|
|
391
|
+
The result is returned as a JSON object containing the status and any additional data.
|
|
392
|
+
The result may include links to download specific result files.
|
|
886
393
|
|
|
887
394
|
Parameters
|
|
888
395
|
----------
|
|
@@ -895,7 +402,7 @@ class AsyncServiceApiClient:
|
|
|
895
402
|
Returns
|
|
896
403
|
-------
|
|
897
404
|
GetResultResponse
|
|
898
|
-
|
|
405
|
+
The service execution result
|
|
899
406
|
|
|
900
407
|
Examples
|
|
901
408
|
--------
|
|
@@ -916,74 +423,16 @@ class AsyncServiceApiClient:
|
|
|
916
423
|
|
|
917
424
|
asyncio.run(main())
|
|
918
425
|
"""
|
|
919
|
-
_response = await self.
|
|
920
|
-
|
|
921
|
-
method="GET",
|
|
922
|
-
request_options=request_options,
|
|
923
|
-
)
|
|
924
|
-
try:
|
|
925
|
-
if 200 <= _response.status_code < 300:
|
|
926
|
-
return typing.cast(
|
|
927
|
-
GetResultResponse,
|
|
928
|
-
parse_obj_as(
|
|
929
|
-
type_=GetResultResponse, # type: ignore
|
|
930
|
-
object_=_response.json(),
|
|
931
|
-
),
|
|
932
|
-
)
|
|
933
|
-
if _response.status_code == 401:
|
|
934
|
-
raise UnauthorizedError(
|
|
935
|
-
typing.cast(
|
|
936
|
-
typing.Optional[typing.Any],
|
|
937
|
-
parse_obj_as(
|
|
938
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
939
|
-
object_=_response.json(),
|
|
940
|
-
),
|
|
941
|
-
)
|
|
942
|
-
)
|
|
943
|
-
if _response.status_code == 403:
|
|
944
|
-
raise ForbiddenError(
|
|
945
|
-
typing.cast(
|
|
946
|
-
typing.Optional[typing.Any],
|
|
947
|
-
parse_obj_as(
|
|
948
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
949
|
-
object_=_response.json(),
|
|
950
|
-
),
|
|
951
|
-
)
|
|
952
|
-
)
|
|
953
|
-
if _response.status_code == 404:
|
|
954
|
-
raise NotFoundError(
|
|
955
|
-
typing.cast(
|
|
956
|
-
typing.Optional[typing.Any],
|
|
957
|
-
parse_obj_as(
|
|
958
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
959
|
-
object_=_response.json(),
|
|
960
|
-
),
|
|
961
|
-
)
|
|
962
|
-
)
|
|
963
|
-
if _response.status_code == 500:
|
|
964
|
-
raise InternalServerError(
|
|
965
|
-
typing.cast(
|
|
966
|
-
typing.Optional[typing.Any],
|
|
967
|
-
parse_obj_as(
|
|
968
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
969
|
-
object_=_response.json(),
|
|
970
|
-
),
|
|
971
|
-
)
|
|
972
|
-
)
|
|
973
|
-
_response_json = _response.json()
|
|
974
|
-
except JSONDecodeError:
|
|
975
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
976
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
426
|
+
_response = await self._raw_client.get_result(id, request_options=request_options)
|
|
427
|
+
return _response.data
|
|
977
428
|
|
|
978
429
|
async def get_result_file(
|
|
979
|
-
self,
|
|
980
|
-
id: str,
|
|
981
|
-
file: str,
|
|
982
|
-
*,
|
|
983
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
430
|
+
self, id: str, file: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
984
431
|
) -> typing.AsyncIterator[bytes]:
|
|
985
432
|
"""
|
|
986
|
-
|
|
433
|
+
Retrieves a specific result file of a service execution.
|
|
434
|
+
The file name is provided in the path parameter.
|
|
435
|
+
The result file is returned as a binary stream.
|
|
987
436
|
|
|
988
437
|
Parameters
|
|
989
438
|
----------
|
|
@@ -996,77 +445,18 @@ class AsyncServiceApiClient:
|
|
|
996
445
|
request_options : typing.Optional[RequestOptions]
|
|
997
446
|
Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.
|
|
998
447
|
|
|
999
|
-
|
|
1000
|
-
|
|
448
|
+
Returns
|
|
449
|
+
-------
|
|
1001
450
|
typing.AsyncIterator[bytes]
|
|
1002
|
-
|
|
451
|
+
The content of a result file
|
|
1003
452
|
"""
|
|
1004
|
-
async with self.
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
try:
|
|
1010
|
-
if 200 <= _response.status_code < 300:
|
|
1011
|
-
_chunk_size = (
|
|
1012
|
-
request_options.get("chunk_size", None)
|
|
1013
|
-
if request_options is not None
|
|
1014
|
-
else None
|
|
1015
|
-
)
|
|
1016
|
-
async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size):
|
|
1017
|
-
yield _chunk
|
|
1018
|
-
return
|
|
1019
|
-
await _response.aread()
|
|
1020
|
-
if _response.status_code == 401:
|
|
1021
|
-
raise UnauthorizedError(
|
|
1022
|
-
typing.cast(
|
|
1023
|
-
typing.Optional[typing.Any],
|
|
1024
|
-
parse_obj_as(
|
|
1025
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1026
|
-
object_=_response.json(),
|
|
1027
|
-
),
|
|
1028
|
-
)
|
|
1029
|
-
)
|
|
1030
|
-
if _response.status_code == 403:
|
|
1031
|
-
raise ForbiddenError(
|
|
1032
|
-
typing.cast(
|
|
1033
|
-
typing.Optional[typing.Any],
|
|
1034
|
-
parse_obj_as(
|
|
1035
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1036
|
-
object_=_response.json(),
|
|
1037
|
-
),
|
|
1038
|
-
)
|
|
1039
|
-
)
|
|
1040
|
-
if _response.status_code == 404:
|
|
1041
|
-
raise NotFoundError(
|
|
1042
|
-
typing.cast(
|
|
1043
|
-
typing.Optional[typing.Any],
|
|
1044
|
-
parse_obj_as(
|
|
1045
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1046
|
-
object_=_response.json(),
|
|
1047
|
-
),
|
|
1048
|
-
)
|
|
1049
|
-
)
|
|
1050
|
-
if _response.status_code == 500:
|
|
1051
|
-
raise InternalServerError(
|
|
1052
|
-
typing.cast(
|
|
1053
|
-
typing.Optional[typing.Any],
|
|
1054
|
-
parse_obj_as(
|
|
1055
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1056
|
-
object_=_response.json(),
|
|
1057
|
-
),
|
|
1058
|
-
)
|
|
1059
|
-
)
|
|
1060
|
-
_response_json = _response.json()
|
|
1061
|
-
except JSONDecodeError:
|
|
1062
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1063
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1064
|
-
|
|
1065
|
-
async def get_logs(
|
|
1066
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1067
|
-
) -> typing.List[str]:
|
|
453
|
+
async with self._raw_client.get_result_file(id, file, request_options=request_options) as r:
|
|
454
|
+
async for _chunk in r.data:
|
|
455
|
+
yield _chunk
|
|
456
|
+
|
|
457
|
+
async def get_logs(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[str]:
|
|
1068
458
|
"""
|
|
1069
|
-
|
|
459
|
+
Returns a list of log entries for a service execution in chronological order, where the first entry is the oldest.
|
|
1070
460
|
|
|
1071
461
|
Parameters
|
|
1072
462
|
----------
|
|
@@ -1079,7 +469,7 @@ class AsyncServiceApiClient:
|
|
|
1079
469
|
Returns
|
|
1080
470
|
-------
|
|
1081
471
|
typing.List[str]
|
|
1082
|
-
|
|
472
|
+
List of log entries
|
|
1083
473
|
|
|
1084
474
|
Examples
|
|
1085
475
|
--------
|
|
@@ -1100,70 +490,14 @@ class AsyncServiceApiClient:
|
|
|
1100
490
|
|
|
1101
491
|
asyncio.run(main())
|
|
1102
492
|
"""
|
|
1103
|
-
_response = await self.
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
)
|
|
1108
|
-
try:
|
|
1109
|
-
if 200 <= _response.status_code < 300:
|
|
1110
|
-
return typing.cast(
|
|
1111
|
-
typing.List[str],
|
|
1112
|
-
parse_obj_as(
|
|
1113
|
-
type_=typing.List[str], # type: ignore
|
|
1114
|
-
object_=_response.json(),
|
|
1115
|
-
),
|
|
1116
|
-
)
|
|
1117
|
-
if _response.status_code == 401:
|
|
1118
|
-
raise UnauthorizedError(
|
|
1119
|
-
typing.cast(
|
|
1120
|
-
typing.Optional[typing.Any],
|
|
1121
|
-
parse_obj_as(
|
|
1122
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1123
|
-
object_=_response.json(),
|
|
1124
|
-
),
|
|
1125
|
-
)
|
|
1126
|
-
)
|
|
1127
|
-
if _response.status_code == 403:
|
|
1128
|
-
raise ForbiddenError(
|
|
1129
|
-
typing.cast(
|
|
1130
|
-
typing.Optional[typing.Any],
|
|
1131
|
-
parse_obj_as(
|
|
1132
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1133
|
-
object_=_response.json(),
|
|
1134
|
-
),
|
|
1135
|
-
)
|
|
1136
|
-
)
|
|
1137
|
-
if _response.status_code == 404:
|
|
1138
|
-
raise NotFoundError(
|
|
1139
|
-
typing.cast(
|
|
1140
|
-
typing.Optional[typing.Any],
|
|
1141
|
-
parse_obj_as(
|
|
1142
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1143
|
-
object_=_response.json(),
|
|
1144
|
-
),
|
|
1145
|
-
)
|
|
1146
|
-
)
|
|
1147
|
-
if _response.status_code == 500:
|
|
1148
|
-
raise InternalServerError(
|
|
1149
|
-
typing.cast(
|
|
1150
|
-
typing.Optional[typing.Any],
|
|
1151
|
-
parse_obj_as(
|
|
1152
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1153
|
-
object_=_response.json(),
|
|
1154
|
-
),
|
|
1155
|
-
)
|
|
1156
|
-
)
|
|
1157
|
-
_response_json = _response.json()
|
|
1158
|
-
except JSONDecodeError:
|
|
1159
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1160
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1161
|
-
|
|
1162
|
-
async def cancel(
|
|
493
|
+
_response = await self._raw_client.get_logs(id, request_options=request_options)
|
|
494
|
+
return _response.data
|
|
495
|
+
|
|
496
|
+
async def cancel_execution(
|
|
1163
497
|
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1164
498
|
) -> ServiceExecution:
|
|
1165
499
|
"""
|
|
1166
|
-
|
|
500
|
+
Cancel a pending or running service execution.
|
|
1167
501
|
|
|
1168
502
|
Parameters
|
|
1169
503
|
----------
|
|
@@ -1176,7 +510,7 @@ class AsyncServiceApiClient:
|
|
|
1176
510
|
Returns
|
|
1177
511
|
-------
|
|
1178
512
|
ServiceExecution
|
|
1179
|
-
|
|
513
|
+
Service execution is cancelled
|
|
1180
514
|
|
|
1181
515
|
Examples
|
|
1182
516
|
--------
|
|
@@ -1190,68 +524,12 @@ class AsyncServiceApiClient:
|
|
|
1190
524
|
|
|
1191
525
|
|
|
1192
526
|
async def main() -> None:
|
|
1193
|
-
await client.service_api.
|
|
527
|
+
await client.service_api.cancel_execution(
|
|
1194
528
|
id="id",
|
|
1195
529
|
)
|
|
1196
530
|
|
|
1197
531
|
|
|
1198
532
|
asyncio.run(main())
|
|
1199
533
|
"""
|
|
1200
|
-
_response = await self.
|
|
1201
|
-
|
|
1202
|
-
method="PUT",
|
|
1203
|
-
request_options=request_options,
|
|
1204
|
-
)
|
|
1205
|
-
try:
|
|
1206
|
-
if 200 <= _response.status_code < 300:
|
|
1207
|
-
return typing.cast(
|
|
1208
|
-
ServiceExecution,
|
|
1209
|
-
parse_obj_as(
|
|
1210
|
-
type_=ServiceExecution, # type: ignore
|
|
1211
|
-
object_=_response.json(),
|
|
1212
|
-
),
|
|
1213
|
-
)
|
|
1214
|
-
if _response.status_code == 401:
|
|
1215
|
-
raise UnauthorizedError(
|
|
1216
|
-
typing.cast(
|
|
1217
|
-
typing.Optional[typing.Any],
|
|
1218
|
-
parse_obj_as(
|
|
1219
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1220
|
-
object_=_response.json(),
|
|
1221
|
-
),
|
|
1222
|
-
)
|
|
1223
|
-
)
|
|
1224
|
-
if _response.status_code == 403:
|
|
1225
|
-
raise ForbiddenError(
|
|
1226
|
-
typing.cast(
|
|
1227
|
-
typing.Optional[typing.Any],
|
|
1228
|
-
parse_obj_as(
|
|
1229
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1230
|
-
object_=_response.json(),
|
|
1231
|
-
),
|
|
1232
|
-
)
|
|
1233
|
-
)
|
|
1234
|
-
if _response.status_code == 404:
|
|
1235
|
-
raise NotFoundError(
|
|
1236
|
-
typing.cast(
|
|
1237
|
-
typing.Optional[typing.Any],
|
|
1238
|
-
parse_obj_as(
|
|
1239
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1240
|
-
object_=_response.json(),
|
|
1241
|
-
),
|
|
1242
|
-
)
|
|
1243
|
-
)
|
|
1244
|
-
if _response.status_code == 500:
|
|
1245
|
-
raise InternalServerError(
|
|
1246
|
-
typing.cast(
|
|
1247
|
-
typing.Optional[typing.Any],
|
|
1248
|
-
parse_obj_as(
|
|
1249
|
-
type_=typing.Optional[typing.Any], # type: ignore
|
|
1250
|
-
object_=_response.json(),
|
|
1251
|
-
),
|
|
1252
|
-
)
|
|
1253
|
-
)
|
|
1254
|
-
_response_json = _response.json()
|
|
1255
|
-
except JSONDecodeError:
|
|
1256
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1257
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
534
|
+
_response = await self._raw_client.cancel_execution(id, request_options=request_options)
|
|
535
|
+
return _response.data
|