@planqk/planqk-service-sdk 2.6.2 → 2.8.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/dist/sdk/BaseClient.d.ts +26 -0
- package/dist/sdk/{api/resources/serviceApi/types/GetResultResponse.js → BaseClient.js} +1 -3
- package/dist/sdk/Client.d.ts +4 -22
- package/dist/sdk/Client.js +2 -4
- package/dist/sdk/api/index.d.ts +1 -1
- package/dist/sdk/api/index.js +1 -1
- package/dist/sdk/api/resources/index.d.ts +0 -1
- package/dist/sdk/api/resources/index.js +0 -4
- package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +9 -26
- package/dist/sdk/api/resources/serviceApi/client/Client.js +43 -27
- package/dist/sdk/api/resources/serviceApi/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceApi/index.js +0 -1
- package/dist/sdk/api/types/HalLink.d.ts +0 -3
- package/dist/sdk/api/types/HalLink.js +1 -3
- package/dist/sdk/api/types/LogEntry.d.ts +19 -0
- package/dist/sdk/api/types/LogEntry.js +15 -0
- package/dist/sdk/api/types/RequestBody.d.ts +1 -0
- package/dist/sdk/api/types/RequestBody.js +3 -0
- package/dist/sdk/api/types/ResultResponse.d.ts +15 -0
- package/dist/sdk/api/types/ResultResponse.js +3 -0
- package/dist/sdk/api/types/ServiceExecution.d.ts +1 -4
- package/dist/sdk/api/types/ServiceExecution.js +1 -3
- package/dist/sdk/api/types/index.d.ts +3 -0
- package/dist/sdk/api/types/index.js +3 -0
- package/dist/sdk/core/auth/AuthProvider.d.ts +4 -0
- package/dist/sdk/core/auth/AuthProvider.js +2 -0
- package/dist/sdk/core/auth/AuthRequest.d.ts +9 -0
- package/dist/sdk/core/auth/AuthRequest.js +2 -0
- package/dist/sdk/core/auth/BasicAuth.js +2 -1
- package/dist/sdk/core/auth/index.d.ts +2 -0
- package/dist/sdk/core/fetcher/APIResponse.d.ts +1 -1
- package/dist/sdk/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/sdk/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/sdk/core/fetcher/EndpointMetadata.js +2 -0
- package/dist/sdk/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/sdk/core/fetcher/EndpointSupplier.js +13 -0
- package/dist/sdk/core/fetcher/Fetcher.d.ts +6 -4
- package/dist/sdk/core/fetcher/Fetcher.js +3 -3
- package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +1 -1
- package/dist/sdk/core/fetcher/index.d.ts +7 -5
- package/dist/sdk/core/fetcher/index.js +7 -5
- package/dist/sdk/core/fetcher/requestWithRetries.js +44 -8
- package/dist/sdk/core/headers.d.ts +2 -3
- package/dist/sdk/core/url/join.js +23 -3
- package/dist/sdk/environments.d.ts +0 -3
- package/dist/sdk/environments.js +1 -3
- package/dist/sdk/errors/PlanqkServiceApiError.d.ts +0 -3
- package/dist/sdk/errors/PlanqkServiceApiError.js +1 -3
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +0 -3
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +1 -3
- package/dist/sdk/index.d.ts +1 -0
- package/fern/fern.config.json +1 -1
- package/fern/generators.yml +6 -4
- package/fern/openapi/openapi.yml +115 -80
- package/package.json +1 -1
- package/planqk/service/_version.py +1 -1
- package/planqk/service/client.py +3 -3
- package/planqk/service/sdk/__init__.py +61 -8
- package/planqk/service/sdk/client.py +27 -7
- package/planqk/service/sdk/core/__init__.py +80 -20
- package/planqk/service/sdk/core/client_wrapper.py +8 -6
- package/planqk/service/sdk/core/force_multipart.py +4 -2
- package/planqk/service/sdk/core/http_response.py +1 -1
- package/planqk/service/sdk/core/http_sse/__init__.py +42 -0
- package/planqk/service/sdk/core/http_sse/_api.py +112 -0
- package/planqk/service/sdk/core/http_sse/_decoders.py +61 -0
- package/planqk/service/sdk/core/http_sse/_exceptions.py +7 -0
- package/planqk/service/sdk/core/http_sse/_models.py +17 -0
- package/planqk/service/sdk/core/pydantic_utilities.py +5 -2
- package/planqk/service/sdk/core/unchecked_base_model.py +341 -0
- package/planqk/service/sdk/service_api/__init__.py +0 -3
- package/planqk/service/sdk/service_api/client.py +17 -21
- package/planqk/service/sdk/service_api/raw_client.py +36 -40
- package/planqk/service/sdk/types/__init__.py +57 -4
- package/planqk/service/sdk/types/hal_link.py +3 -2
- package/planqk/service/sdk/types/log_entry.py +35 -0
- package/planqk/service/sdk/types/log_entry_severity.py +5 -0
- package/planqk/service/sdk/types/request_body.py +5 -0
- package/planqk/service/sdk/types/result_response.py +27 -0
- package/planqk/service/sdk/{service_api/types/get_result_response_embedded.py → types/result_response_embedded.py} +4 -3
- package/planqk/service/sdk/{service_api/types/get_result_response_links.py → types/result_response_links.py} +4 -3
- package/planqk/service/sdk/types/service_execution.py +3 -2
- package/pyproject.toml +1 -1
- package/requirements-dev.txt +59 -43
- package/requirements.txt +6 -6
- package/src/index.test.ts +10 -0
- package/src/sdk/BaseClient.ts +30 -0
- package/src/sdk/Client.ts +6 -23
- package/src/sdk/api/index.ts +1 -1
- package/src/sdk/api/resources/index.ts +0 -1
- package/src/sdk/api/resources/serviceApi/client/Client.ts +87 -82
- package/src/sdk/api/resources/serviceApi/index.ts +0 -1
- package/src/sdk/api/types/HalLink.ts +1 -3
- package/src/sdk/api/types/LogEntry.ts +22 -0
- package/src/sdk/api/types/RequestBody.ts +3 -0
- package/src/sdk/api/types/ResultResponse.ts +20 -0
- package/src/sdk/api/types/ServiceExecution.ts +2 -4
- package/src/sdk/api/types/index.ts +3 -0
- package/src/sdk/core/auth/AuthProvider.ts +5 -0
- package/src/sdk/core/auth/AuthRequest.ts +9 -0
- package/src/sdk/core/auth/BasicAuth.ts +2 -1
- package/src/sdk/core/auth/index.ts +2 -0
- package/src/sdk/core/fetcher/APIResponse.ts +1 -1
- package/src/sdk/core/fetcher/BinaryResponse.ts +1 -1
- package/src/sdk/core/fetcher/EndpointMetadata.ts +13 -0
- package/src/sdk/core/fetcher/EndpointSupplier.ts +14 -0
- package/src/sdk/core/fetcher/Fetcher.ts +8 -6
- package/src/sdk/core/fetcher/HttpResponsePromise.ts +1 -1
- package/src/sdk/core/fetcher/index.ts +7 -5
- package/src/sdk/core/fetcher/requestWithRetries.ts +49 -9
- package/src/sdk/core/headers.ts +8 -10
- package/src/sdk/core/url/join.ts +28 -3
- package/src/sdk/environments.ts +1 -3
- package/src/sdk/errors/PlanqkServiceApiError.ts +1 -3
- package/src/sdk/errors/PlanqkServiceApiTimeoutError.ts +1 -3
- package/src/sdk/index.ts +1 -0
- package/uv.lock +77 -47
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +0 -18
- package/dist/sdk/api/resources/serviceApi/types/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceApi/types/index.js +0 -17
- package/planqk/service/sdk/service_api/types/__init__.py +0 -9
- package/planqk/service/sdk/service_api/types/get_result_response.py +0 -26
- package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +0 -22
- package/src/sdk/api/resources/serviceApi/types/index.ts +0 -1
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import inspect
|
|
5
|
+
import typing
|
|
6
|
+
import uuid
|
|
7
|
+
|
|
8
|
+
import pydantic
|
|
9
|
+
import typing_extensions
|
|
10
|
+
from .pydantic_utilities import (
|
|
11
|
+
IS_PYDANTIC_V2,
|
|
12
|
+
ModelField,
|
|
13
|
+
UniversalBaseModel,
|
|
14
|
+
get_args,
|
|
15
|
+
get_origin,
|
|
16
|
+
is_literal_type,
|
|
17
|
+
is_union,
|
|
18
|
+
parse_date,
|
|
19
|
+
parse_datetime,
|
|
20
|
+
parse_obj_as,
|
|
21
|
+
)
|
|
22
|
+
from .serialization import get_field_to_alias_mapping
|
|
23
|
+
from pydantic_core import PydanticUndefined
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class UnionMetadata:
|
|
27
|
+
discriminant: str
|
|
28
|
+
|
|
29
|
+
def __init__(self, *, discriminant: str) -> None:
|
|
30
|
+
self.discriminant = discriminant
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Model = typing.TypeVar("Model", bound=pydantic.BaseModel)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class UncheckedBaseModel(UniversalBaseModel):
|
|
37
|
+
if IS_PYDANTIC_V2:
|
|
38
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2
|
|
39
|
+
else:
|
|
40
|
+
|
|
41
|
+
class Config:
|
|
42
|
+
extra = pydantic.Extra.allow
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def model_construct(
|
|
46
|
+
cls: typing.Type["Model"],
|
|
47
|
+
_fields_set: typing.Optional[typing.Set[str]] = None,
|
|
48
|
+
**values: typing.Any,
|
|
49
|
+
) -> "Model":
|
|
50
|
+
# Fallback construct function to the specified override below.
|
|
51
|
+
return cls.construct(_fields_set=_fields_set, **values)
|
|
52
|
+
|
|
53
|
+
# Allow construct to not validate model
|
|
54
|
+
# Implementation taken from: https://github.com/pydantic/pydantic/issues/1168#issuecomment-817742836
|
|
55
|
+
@classmethod
|
|
56
|
+
def construct(
|
|
57
|
+
cls: typing.Type["Model"],
|
|
58
|
+
_fields_set: typing.Optional[typing.Set[str]] = None,
|
|
59
|
+
**values: typing.Any,
|
|
60
|
+
) -> "Model":
|
|
61
|
+
m = cls.__new__(cls)
|
|
62
|
+
fields_values = {}
|
|
63
|
+
|
|
64
|
+
if _fields_set is None:
|
|
65
|
+
_fields_set = set(values.keys())
|
|
66
|
+
|
|
67
|
+
fields = _get_model_fields(cls)
|
|
68
|
+
populate_by_name = _get_is_populate_by_name(cls)
|
|
69
|
+
field_aliases = get_field_to_alias_mapping(cls)
|
|
70
|
+
|
|
71
|
+
for name, field in fields.items():
|
|
72
|
+
# Key here is only used to pull data from the values dict
|
|
73
|
+
# you should always use the NAME of the field to for field_values, etc.
|
|
74
|
+
# because that's how the object is constructed from a pydantic perspective
|
|
75
|
+
key = field.alias
|
|
76
|
+
if (key is None or field.alias == name) and name in field_aliases:
|
|
77
|
+
key = field_aliases[name]
|
|
78
|
+
|
|
79
|
+
if key is None or (key not in values and populate_by_name): # Added this to allow population by field name
|
|
80
|
+
key = name
|
|
81
|
+
|
|
82
|
+
if key in values:
|
|
83
|
+
if IS_PYDANTIC_V2:
|
|
84
|
+
type_ = field.annotation # type: ignore # Pydantic v2
|
|
85
|
+
else:
|
|
86
|
+
type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore # Pydantic < v1.10.15
|
|
87
|
+
|
|
88
|
+
fields_values[name] = (
|
|
89
|
+
construct_type(object_=values[key], type_=type_) if type_ is not None else values[key]
|
|
90
|
+
)
|
|
91
|
+
_fields_set.add(name)
|
|
92
|
+
else:
|
|
93
|
+
default = _get_field_default(field)
|
|
94
|
+
fields_values[name] = default
|
|
95
|
+
|
|
96
|
+
# If the default values are non-null act like they've been set
|
|
97
|
+
# This effectively allows exclude_unset to work like exclude_none where
|
|
98
|
+
# the latter passes through intentionally set none values.
|
|
99
|
+
if default != None and default != PydanticUndefined:
|
|
100
|
+
_fields_set.add(name)
|
|
101
|
+
|
|
102
|
+
# Add extras back in
|
|
103
|
+
extras = {}
|
|
104
|
+
pydantic_alias_fields = [field.alias for field in fields.values()]
|
|
105
|
+
internal_alias_fields = list(field_aliases.values())
|
|
106
|
+
for key, value in values.items():
|
|
107
|
+
# If the key is not a field by name, nor an alias to a field, then it's extra
|
|
108
|
+
if (key not in pydantic_alias_fields and key not in internal_alias_fields) and key not in fields:
|
|
109
|
+
if IS_PYDANTIC_V2:
|
|
110
|
+
extras[key] = value
|
|
111
|
+
else:
|
|
112
|
+
_fields_set.add(key)
|
|
113
|
+
fields_values[key] = value
|
|
114
|
+
|
|
115
|
+
object.__setattr__(m, "__dict__", fields_values)
|
|
116
|
+
|
|
117
|
+
if IS_PYDANTIC_V2:
|
|
118
|
+
object.__setattr__(m, "__pydantic_private__", None)
|
|
119
|
+
object.__setattr__(m, "__pydantic_extra__", extras)
|
|
120
|
+
object.__setattr__(m, "__pydantic_fields_set__", _fields_set)
|
|
121
|
+
else:
|
|
122
|
+
object.__setattr__(m, "__fields_set__", _fields_set)
|
|
123
|
+
m._init_private_attributes() # type: ignore # Pydantic v1
|
|
124
|
+
return m
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _validate_collection_items_compatible(collection: typing.Any, target_type: typing.Type[typing.Any]) -> bool:
|
|
128
|
+
"""
|
|
129
|
+
Validate that all items in a collection are compatible with the target type.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
collection: The collection to validate (list, set, or dict values)
|
|
133
|
+
target_type: The target type to validate against
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
True if all items are compatible, False otherwise
|
|
137
|
+
"""
|
|
138
|
+
if inspect.isclass(target_type) and issubclass(target_type, pydantic.BaseModel):
|
|
139
|
+
for item in collection:
|
|
140
|
+
try:
|
|
141
|
+
# Try to validate the item against the target type
|
|
142
|
+
if isinstance(item, dict):
|
|
143
|
+
parse_obj_as(target_type, item)
|
|
144
|
+
else:
|
|
145
|
+
# If it's not a dict, it might already be the right type
|
|
146
|
+
if not isinstance(item, target_type):
|
|
147
|
+
return False
|
|
148
|
+
except Exception:
|
|
149
|
+
return False
|
|
150
|
+
return True
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], object_: typing.Any) -> typing.Any:
|
|
154
|
+
inner_types = get_args(union_type)
|
|
155
|
+
if typing.Any in inner_types:
|
|
156
|
+
return object_
|
|
157
|
+
|
|
158
|
+
for inner_type in inner_types:
|
|
159
|
+
# Handle lists of objects that need parsing
|
|
160
|
+
if get_origin(inner_type) is list and isinstance(object_, list):
|
|
161
|
+
list_inner_type = get_args(inner_type)[0]
|
|
162
|
+
try:
|
|
163
|
+
if inspect.isclass(list_inner_type) and issubclass(list_inner_type, pydantic.BaseModel):
|
|
164
|
+
# Validate that all items in the list are compatible with the target type
|
|
165
|
+
if _validate_collection_items_compatible(object_, list_inner_type):
|
|
166
|
+
parsed_list = [parse_obj_as(object_=item, type_=list_inner_type) for item in object_]
|
|
167
|
+
return parsed_list
|
|
168
|
+
except Exception:
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
try:
|
|
172
|
+
if inspect.isclass(inner_type) and issubclass(inner_type, pydantic.BaseModel):
|
|
173
|
+
# Attempt a validated parse until one works
|
|
174
|
+
return parse_obj_as(inner_type, object_)
|
|
175
|
+
except Exception:
|
|
176
|
+
continue
|
|
177
|
+
|
|
178
|
+
# If none of the types work, just return the first successful cast
|
|
179
|
+
for inner_type in inner_types:
|
|
180
|
+
try:
|
|
181
|
+
return construct_type(object_=object_, type_=inner_type)
|
|
182
|
+
except Exception:
|
|
183
|
+
continue
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any:
|
|
187
|
+
base_type = get_origin(type_) or type_
|
|
188
|
+
union_type = type_
|
|
189
|
+
if base_type == typing_extensions.Annotated: # type: ignore[comparison-overlap]
|
|
190
|
+
union_type = get_args(type_)[0]
|
|
191
|
+
annotated_metadata = get_args(type_)[1:]
|
|
192
|
+
for metadata in annotated_metadata:
|
|
193
|
+
if isinstance(metadata, UnionMetadata):
|
|
194
|
+
try:
|
|
195
|
+
# Cast to the correct type, based on the discriminant
|
|
196
|
+
for inner_type in get_args(union_type):
|
|
197
|
+
try:
|
|
198
|
+
objects_discriminant = getattr(object_, metadata.discriminant)
|
|
199
|
+
except:
|
|
200
|
+
objects_discriminant = object_[metadata.discriminant]
|
|
201
|
+
if inner_type.__fields__[metadata.discriminant].default == objects_discriminant:
|
|
202
|
+
return construct_type(object_=object_, type_=inner_type)
|
|
203
|
+
except Exception:
|
|
204
|
+
# Allow to fall through to our regular union handling
|
|
205
|
+
pass
|
|
206
|
+
return _convert_undiscriminated_union_type(union_type, object_)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any:
|
|
210
|
+
"""
|
|
211
|
+
Here we are essentially creating the same `construct` method in spirit as the above, but for all types, not just
|
|
212
|
+
Pydantic models.
|
|
213
|
+
The idea is to essentially attempt to coerce object_ to type_ (recursively)
|
|
214
|
+
"""
|
|
215
|
+
# Short circuit when dealing with optionals, don't try to coerces None to a type
|
|
216
|
+
if object_ is None:
|
|
217
|
+
return None
|
|
218
|
+
|
|
219
|
+
base_type = get_origin(type_) or type_
|
|
220
|
+
is_annotated = base_type == typing_extensions.Annotated # type: ignore[comparison-overlap]
|
|
221
|
+
maybe_annotation_members = get_args(type_)
|
|
222
|
+
is_annotated_union = is_annotated and is_union(get_origin(maybe_annotation_members[0]))
|
|
223
|
+
|
|
224
|
+
if base_type == typing.Any: # type: ignore[comparison-overlap]
|
|
225
|
+
return object_
|
|
226
|
+
|
|
227
|
+
if base_type == dict:
|
|
228
|
+
if not isinstance(object_, typing.Mapping):
|
|
229
|
+
return object_
|
|
230
|
+
|
|
231
|
+
key_type, items_type = get_args(type_)
|
|
232
|
+
d = {
|
|
233
|
+
construct_type(object_=key, type_=key_type): construct_type(object_=item, type_=items_type)
|
|
234
|
+
for key, item in object_.items()
|
|
235
|
+
}
|
|
236
|
+
return d
|
|
237
|
+
|
|
238
|
+
if base_type == list:
|
|
239
|
+
if not isinstance(object_, list):
|
|
240
|
+
return object_
|
|
241
|
+
|
|
242
|
+
inner_type = get_args(type_)[0]
|
|
243
|
+
return [construct_type(object_=entry, type_=inner_type) for entry in object_]
|
|
244
|
+
|
|
245
|
+
if base_type == set:
|
|
246
|
+
if not isinstance(object_, set) and not isinstance(object_, list):
|
|
247
|
+
return object_
|
|
248
|
+
|
|
249
|
+
inner_type = get_args(type_)[0]
|
|
250
|
+
return {construct_type(object_=entry, type_=inner_type) for entry in object_}
|
|
251
|
+
|
|
252
|
+
if is_union(base_type) or is_annotated_union:
|
|
253
|
+
return _convert_union_type(type_, object_)
|
|
254
|
+
|
|
255
|
+
# Cannot do an `issubclass` with a literal type, let's also just confirm we have a class before this call
|
|
256
|
+
if (
|
|
257
|
+
object_ is not None
|
|
258
|
+
and not is_literal_type(type_)
|
|
259
|
+
and (
|
|
260
|
+
(inspect.isclass(base_type) and issubclass(base_type, pydantic.BaseModel))
|
|
261
|
+
or (
|
|
262
|
+
is_annotated
|
|
263
|
+
and inspect.isclass(maybe_annotation_members[0])
|
|
264
|
+
and issubclass(maybe_annotation_members[0], pydantic.BaseModel)
|
|
265
|
+
)
|
|
266
|
+
)
|
|
267
|
+
):
|
|
268
|
+
if IS_PYDANTIC_V2:
|
|
269
|
+
return type_.model_construct(**object_)
|
|
270
|
+
else:
|
|
271
|
+
return type_.construct(**object_)
|
|
272
|
+
|
|
273
|
+
if base_type == dt.datetime:
|
|
274
|
+
try:
|
|
275
|
+
return parse_datetime(object_)
|
|
276
|
+
except Exception:
|
|
277
|
+
return object_
|
|
278
|
+
|
|
279
|
+
if base_type == dt.date:
|
|
280
|
+
try:
|
|
281
|
+
return parse_date(object_)
|
|
282
|
+
except Exception:
|
|
283
|
+
return object_
|
|
284
|
+
|
|
285
|
+
if base_type == uuid.UUID:
|
|
286
|
+
try:
|
|
287
|
+
return uuid.UUID(object_)
|
|
288
|
+
except Exception:
|
|
289
|
+
return object_
|
|
290
|
+
|
|
291
|
+
if base_type == int:
|
|
292
|
+
try:
|
|
293
|
+
return int(object_)
|
|
294
|
+
except Exception:
|
|
295
|
+
return object_
|
|
296
|
+
|
|
297
|
+
if base_type == bool:
|
|
298
|
+
try:
|
|
299
|
+
if isinstance(object_, str):
|
|
300
|
+
stringified_object = object_.lower()
|
|
301
|
+
return stringified_object == "true" or stringified_object == "1"
|
|
302
|
+
|
|
303
|
+
return bool(object_)
|
|
304
|
+
except Exception:
|
|
305
|
+
return object_
|
|
306
|
+
|
|
307
|
+
return object_
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def _get_is_populate_by_name(model: typing.Type["Model"]) -> bool:
|
|
311
|
+
if IS_PYDANTIC_V2:
|
|
312
|
+
return model.model_config.get("populate_by_name", False) # type: ignore # Pydantic v2
|
|
313
|
+
return model.__config__.allow_population_by_field_name # type: ignore # Pydantic v1
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo]
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
# Pydantic V1 swapped the typing of __fields__'s values from ModelField to FieldInfo
|
|
320
|
+
# And so we try to handle both V1 cases, as well as V2 (FieldInfo from model.model_fields)
|
|
321
|
+
def _get_model_fields(
|
|
322
|
+
model: typing.Type["Model"],
|
|
323
|
+
) -> typing.Mapping[str, PydanticField]:
|
|
324
|
+
if IS_PYDANTIC_V2:
|
|
325
|
+
return model.model_fields # type: ignore # Pydantic v2
|
|
326
|
+
else:
|
|
327
|
+
return model.__fields__ # type: ignore # Pydantic v1
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def _get_field_default(field: PydanticField) -> typing.Any:
|
|
331
|
+
try:
|
|
332
|
+
value = field.get_default() # type: ignore # Pydantic < v1.10.15
|
|
333
|
+
except:
|
|
334
|
+
value = field.default
|
|
335
|
+
if IS_PYDANTIC_V2:
|
|
336
|
+
from pydantic_core import PydanticUndefined
|
|
337
|
+
|
|
338
|
+
if value == PydanticUndefined:
|
|
339
|
+
return None
|
|
340
|
+
return value
|
|
341
|
+
return value
|
|
@@ -4,9 +4,11 @@ import typing
|
|
|
4
4
|
|
|
5
5
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
6
|
from ..core.request_options import RequestOptions
|
|
7
|
+
from ..types.log_entry import LogEntry
|
|
8
|
+
from ..types.request_body import RequestBody
|
|
9
|
+
from ..types.result_response import ResultResponse
|
|
7
10
|
from ..types.service_execution import ServiceExecution
|
|
8
11
|
from .raw_client import AsyncRawServiceApiClient, RawServiceApiClient
|
|
9
|
-
from .types.get_result_response import GetResultResponse
|
|
10
12
|
|
|
11
13
|
# this is used as the default value for optional parameters
|
|
12
14
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -57,10 +59,7 @@ class ServiceApiClient:
|
|
|
57
59
|
return _response.data
|
|
58
60
|
|
|
59
61
|
def start_execution(
|
|
60
|
-
self,
|
|
61
|
-
*,
|
|
62
|
-
request: typing.Dict[str, typing.Optional[typing.Any]],
|
|
63
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
62
|
+
self, *, request: RequestBody, request_options: typing.Optional[RequestOptions] = None
|
|
64
63
|
) -> ServiceExecution:
|
|
65
64
|
"""
|
|
66
65
|
Starts a service execution, which in turn is processed asynchronously.
|
|
@@ -68,7 +67,7 @@ class ServiceApiClient:
|
|
|
68
67
|
|
|
69
68
|
Parameters
|
|
70
69
|
----------
|
|
71
|
-
request :
|
|
70
|
+
request : RequestBody
|
|
72
71
|
|
|
73
72
|
request_options : typing.Optional[RequestOptions]
|
|
74
73
|
Request-specific configuration.
|
|
@@ -124,7 +123,7 @@ class ServiceApiClient:
|
|
|
124
123
|
_response = self._raw_client.get_status(id, request_options=request_options)
|
|
125
124
|
return _response.data
|
|
126
125
|
|
|
127
|
-
def get_result(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) ->
|
|
126
|
+
def get_result(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ResultResponse:
|
|
128
127
|
"""
|
|
129
128
|
Retrieves the result of a service execution.
|
|
130
129
|
The result is returned as a JSON object containing the status and any additional data.
|
|
@@ -140,7 +139,7 @@ class ServiceApiClient:
|
|
|
140
139
|
|
|
141
140
|
Returns
|
|
142
141
|
-------
|
|
143
|
-
|
|
142
|
+
ResultResponse
|
|
144
143
|
The service execution result
|
|
145
144
|
|
|
146
145
|
Examples
|
|
@@ -184,7 +183,7 @@ class ServiceApiClient:
|
|
|
184
183
|
with self._raw_client.get_result_file(id, file, request_options=request_options) as r:
|
|
185
184
|
yield from r.data
|
|
186
185
|
|
|
187
|
-
def get_logs(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[
|
|
186
|
+
def get_logs(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[LogEntry]:
|
|
188
187
|
"""
|
|
189
188
|
Returns a list of log entries for a service execution in chronological order, where the first entry is the oldest.
|
|
190
189
|
|
|
@@ -198,7 +197,7 @@ class ServiceApiClient:
|
|
|
198
197
|
|
|
199
198
|
Returns
|
|
200
199
|
-------
|
|
201
|
-
typing.List[
|
|
200
|
+
typing.List[LogEntry]
|
|
202
201
|
List of log entries
|
|
203
202
|
|
|
204
203
|
Examples
|
|
@@ -300,10 +299,7 @@ class AsyncServiceApiClient:
|
|
|
300
299
|
return _response.data
|
|
301
300
|
|
|
302
301
|
async def start_execution(
|
|
303
|
-
self,
|
|
304
|
-
*,
|
|
305
|
-
request: typing.Dict[str, typing.Optional[typing.Any]],
|
|
306
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
302
|
+
self, *, request: RequestBody, request_options: typing.Optional[RequestOptions] = None
|
|
307
303
|
) -> ServiceExecution:
|
|
308
304
|
"""
|
|
309
305
|
Starts a service execution, which in turn is processed asynchronously.
|
|
@@ -311,7 +307,7 @@ class AsyncServiceApiClient:
|
|
|
311
307
|
|
|
312
308
|
Parameters
|
|
313
309
|
----------
|
|
314
|
-
request :
|
|
310
|
+
request : RequestBody
|
|
315
311
|
|
|
316
312
|
request_options : typing.Optional[RequestOptions]
|
|
317
313
|
Request-specific configuration.
|
|
@@ -383,9 +379,7 @@ class AsyncServiceApiClient:
|
|
|
383
379
|
_response = await self._raw_client.get_status(id, request_options=request_options)
|
|
384
380
|
return _response.data
|
|
385
381
|
|
|
386
|
-
async def get_result(
|
|
387
|
-
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
388
|
-
) -> GetResultResponse:
|
|
382
|
+
async def get_result(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> ResultResponse:
|
|
389
383
|
"""
|
|
390
384
|
Retrieves the result of a service execution.
|
|
391
385
|
The result is returned as a JSON object containing the status and any additional data.
|
|
@@ -401,7 +395,7 @@ class AsyncServiceApiClient:
|
|
|
401
395
|
|
|
402
396
|
Returns
|
|
403
397
|
-------
|
|
404
|
-
|
|
398
|
+
ResultResponse
|
|
405
399
|
The service execution result
|
|
406
400
|
|
|
407
401
|
Examples
|
|
@@ -454,7 +448,9 @@ class AsyncServiceApiClient:
|
|
|
454
448
|
async for _chunk in r.data:
|
|
455
449
|
yield _chunk
|
|
456
450
|
|
|
457
|
-
async def get_logs(
|
|
451
|
+
async def get_logs(
|
|
452
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
453
|
+
) -> typing.List[LogEntry]:
|
|
458
454
|
"""
|
|
459
455
|
Returns a list of log entries for a service execution in chronological order, where the first entry is the oldest.
|
|
460
456
|
|
|
@@ -468,7 +464,7 @@ class AsyncServiceApiClient:
|
|
|
468
464
|
|
|
469
465
|
Returns
|
|
470
466
|
-------
|
|
471
|
-
typing.List[
|
|
467
|
+
typing.List[LogEntry]
|
|
472
468
|
List of log entries
|
|
473
469
|
|
|
474
470
|
Examples
|