daytona_api_client 0.21.3a0__py3-none-any.whl → 0.21.4a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of daytona_api_client might be problematic. Click here for more details.
- daytona_api_client/api/__init__.py +1 -0
- daytona_api_client/api/api_keys_api.py +328 -171
- daytona_api_client/api/docker_registry_api.py +463 -239
- daytona_api_client/api/object_storage_api.py +63 -33
- daytona_api_client/api/organizations_api.py +1582 -612
- daytona_api_client/api/preview_api.py +175 -71
- daytona_api_client/api/runners_api.py +195 -67
- daytona_api_client/api/sandbox_api.py +909 -499
- daytona_api_client/api/snapshots_api.py +482 -253
- daytona_api_client/api/toolbox_api.py +2684 -1410
- daytona_api_client/api/users_api.py +526 -184
- daytona_api_client/api/volumes_api.py +332 -180
- daytona_api_client/api/workspace_api.py +909 -499
- daytona_api_client/api_client.py +192 -90
- daytona_api_client/api_response.py +3 -2
- daytona_api_client/configuration.py +52 -55
- daytona_api_client/exceptions.py +16 -15
- daytona_api_client/models/account_provider.py +11 -9
- daytona_api_client/models/api_key_list.py +21 -40
- daytona_api_client/models/api_key_response.py +19 -38
- daytona_api_client/models/build_info.py +15 -22
- daytona_api_client/models/command.py +13 -12
- daytona_api_client/models/completion_context.py +11 -11
- daytona_api_client/models/completion_item.py +17 -28
- daytona_api_client/models/completion_list.py +12 -17
- daytona_api_client/models/create_api_key.py +17 -32
- daytona_api_client/models/create_build_info.py +13 -17
- daytona_api_client/models/create_docker_registry.py +18 -21
- daytona_api_client/models/create_linked_account.py +11 -9
- daytona_api_client/models/create_organization.py +10 -9
- daytona_api_client/models/create_organization_invitation.py +17 -24
- daytona_api_client/models/create_organization_quota.py +19 -32
- daytona_api_client/models/create_organization_role.py +15 -28
- daytona_api_client/models/create_runner.py +26 -41
- daytona_api_client/models/create_sandbox.py +39 -76
- daytona_api_client/models/create_session_request.py +10 -9
- daytona_api_client/models/create_snapshot.py +22 -39
- daytona_api_client/models/create_user.py +19 -26
- daytona_api_client/models/create_volume.py +10 -9
- daytona_api_client/models/create_workspace.py +38 -73
- daytona_api_client/models/docker_registry.py +21 -33
- daytona_api_client/models/execute_request.py +13 -12
- daytona_api_client/models/execute_response.py +11 -9
- daytona_api_client/models/file_info.py +17 -20
- daytona_api_client/models/file_status.py +13 -16
- daytona_api_client/models/git_add_request.py +11 -9
- daytona_api_client/models/git_branch_request.py +11 -9
- daytona_api_client/models/git_checkout_request.py +11 -9
- daytona_api_client/models/git_clone_request.py +15 -18
- daytona_api_client/models/git_commit_info.py +14 -17
- daytona_api_client/models/git_commit_request.py +13 -16
- daytona_api_client/models/git_commit_response.py +10 -9
- daytona_api_client/models/git_delete_branch_request.py +11 -9
- daytona_api_client/models/git_repo_request.py +12 -11
- daytona_api_client/models/git_status.py +15 -20
- daytona_api_client/models/list_branch_response.py +10 -9
- daytona_api_client/models/lsp_completion_params.py +16 -19
- daytona_api_client/models/lsp_document_request.py +12 -11
- daytona_api_client/models/lsp_location.py +12 -12
- daytona_api_client/models/lsp_server_request.py +11 -9
- daytona_api_client/models/lsp_symbol.py +13 -16
- daytona_api_client/models/match.py +12 -9
- daytona_api_client/models/organization.py +20 -34
- daytona_api_client/models/organization_invitation.py +27 -44
- daytona_api_client/models/organization_role.py +21 -46
- daytona_api_client/models/organization_suspension.py +11 -9
- daytona_api_client/models/organization_user.py +22 -36
- daytona_api_client/models/paginated_snapshots_dto.py +14 -19
- daytona_api_client/models/port_preview_url.py +11 -9
- daytona_api_client/models/position.py +11 -9
- daytona_api_client/models/project_dir_response.py +10 -9
- daytona_api_client/models/range.py +13 -16
- daytona_api_client/models/registry_push_access_dto.py +15 -18
- daytona_api_client/models/replace_request.py +12 -11
- daytona_api_client/models/replace_result.py +12 -9
- daytona_api_client/models/sandbox.py +49 -95
- daytona_api_client/models/sandbox_info.py +13 -18
- daytona_api_client/models/sandbox_labels.py +10 -9
- daytona_api_client/models/sandbox_state.py +18 -16
- daytona_api_client/models/sandbox_volume.py +11 -9
- daytona_api_client/models/search_files_response.py +10 -9
- daytona_api_client/models/session.py +13 -18
- daytona_api_client/models/session_execute_request.py +14 -19
- daytona_api_client/models/session_execute_response.py +13 -14
- daytona_api_client/models/set_snapshot_general_status_dto.py +10 -9
- daytona_api_client/models/snapshot_dto.py +34 -58
- daytona_api_client/models/snapshot_state.py +12 -10
- daytona_api_client/models/storage_access_dto.py +16 -26
- daytona_api_client/models/toggle_state.py +10 -9
- daytona_api_client/models/update_assigned_organization_roles.py +10 -9
- daytona_api_client/models/update_docker_registry.py +12 -11
- daytona_api_client/models/update_organization_invitation.py +15 -16
- daytona_api_client/models/update_organization_member_role.py +12 -11
- daytona_api_client/models/update_organization_quota.py +28 -41
- daytona_api_client/models/update_organization_role.py +15 -28
- daytona_api_client/models/usage_overview.py +17 -28
- daytona_api_client/models/user.py +14 -19
- daytona_api_client/models/user_public_key.py +11 -9
- daytona_api_client/models/volume_dto.py +20 -32
- daytona_api_client/models/volume_state.py +9 -7
- daytona_api_client/models/workspace.py +58 -113
- daytona_api_client/rest.py +77 -26
- {daytona_api_client-0.21.3a0.dist-info → daytona_api_client-0.21.4a0.dist-info}/METADATA +1 -1
- daytona_api_client-0.21.4a0.dist-info/RECORD +117 -0
- daytona_api_client-0.21.3a0.dist-info/RECORD +0 -117
- {daytona_api_client-0.21.3a0.dist-info → daytona_api_client-0.21.4a0.dist-info}/WHEEL +0 -0
- {daytona_api_client-0.21.3a0.dist-info → daytona_api_client-0.21.4a0.dist-info}/top_level.txt +0 -0
daytona_api_client/api_client.py
CHANGED
|
@@ -38,12 +38,11 @@ from daytona_api_client.exceptions import (
|
|
|
38
38
|
UnauthorizedException,
|
|
39
39
|
ForbiddenException,
|
|
40
40
|
NotFoundException,
|
|
41
|
-
ServiceException
|
|
41
|
+
ServiceException
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
|
|
45
45
|
|
|
46
|
-
|
|
47
46
|
class ApiClient:
|
|
48
47
|
"""Generic API client for OpenAPI client library builds.
|
|
49
48
|
|
|
@@ -62,19 +61,25 @@ class ApiClient:
|
|
|
62
61
|
|
|
63
62
|
PRIMITIVE_TYPES = (float, bool, bytes, str, int)
|
|
64
63
|
NATIVE_TYPES_MAPPING = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
'int': int,
|
|
65
|
+
'long': int, # TODO remove as only py3 is supported?
|
|
66
|
+
'float': float,
|
|
67
|
+
'str': str,
|
|
68
|
+
'bool': bool,
|
|
69
|
+
'date': datetime.date,
|
|
70
|
+
'datetime': datetime.datetime,
|
|
71
|
+
'decimal': decimal.Decimal,
|
|
72
|
+
'object': object,
|
|
74
73
|
}
|
|
75
74
|
_pool = None
|
|
76
75
|
|
|
77
|
-
def __init__(
|
|
76
|
+
def __init__(
|
|
77
|
+
self,
|
|
78
|
+
configuration=None,
|
|
79
|
+
header_name=None,
|
|
80
|
+
header_value=None,
|
|
81
|
+
cookie=None
|
|
82
|
+
) -> None:
|
|
78
83
|
# use default configuration if none is provided
|
|
79
84
|
if configuration is None:
|
|
80
85
|
configuration = Configuration.get_default()
|
|
@@ -86,7 +91,7 @@ class ApiClient:
|
|
|
86
91
|
self.default_headers[header_name] = header_value
|
|
87
92
|
self.cookie = cookie
|
|
88
93
|
# Set default User-Agent.
|
|
89
|
-
self.user_agent =
|
|
94
|
+
self.user_agent = 'OpenAPI-Generator/0.0.0-dev/python'
|
|
90
95
|
self.client_side_validation = configuration.client_side_validation
|
|
91
96
|
|
|
92
97
|
def __enter__(self):
|
|
@@ -98,15 +103,16 @@ class ApiClient:
|
|
|
98
103
|
@property
|
|
99
104
|
def user_agent(self):
|
|
100
105
|
"""User agent for this API client"""
|
|
101
|
-
return self.default_headers[
|
|
106
|
+
return self.default_headers['User-Agent']
|
|
102
107
|
|
|
103
108
|
@user_agent.setter
|
|
104
109
|
def user_agent(self, value):
|
|
105
|
-
self.default_headers[
|
|
110
|
+
self.default_headers['User-Agent'] = value
|
|
106
111
|
|
|
107
112
|
def set_default_header(self, header_name, header_value):
|
|
108
113
|
self.default_headers[header_name] = header_value
|
|
109
114
|
|
|
115
|
+
|
|
110
116
|
_default = None
|
|
111
117
|
|
|
112
118
|
@classmethod
|
|
@@ -142,12 +148,12 @@ class ApiClient:
|
|
|
142
148
|
header_params=None,
|
|
143
149
|
body=None,
|
|
144
150
|
post_params=None,
|
|
145
|
-
files=None,
|
|
146
|
-
auth_settings=None,
|
|
151
|
+
files=None, auth_settings=None,
|
|
147
152
|
collection_formats=None,
|
|
148
153
|
_host=None,
|
|
149
|
-
_request_auth=None
|
|
154
|
+
_request_auth=None
|
|
150
155
|
) -> RequestSerialized:
|
|
156
|
+
|
|
151
157
|
"""Builds the HTTP request params needed by the request.
|
|
152
158
|
:param method: Method to call.
|
|
153
159
|
:param resource_path: Path to method endpoint.
|
|
@@ -176,30 +182,47 @@ class ApiClient:
|
|
|
176
182
|
header_params = header_params or {}
|
|
177
183
|
header_params.update(self.default_headers)
|
|
178
184
|
if self.cookie:
|
|
179
|
-
header_params[
|
|
185
|
+
header_params['Cookie'] = self.cookie
|
|
180
186
|
if header_params:
|
|
181
187
|
header_params = self.sanitize_for_serialization(header_params)
|
|
182
|
-
header_params = dict(
|
|
188
|
+
header_params = dict(
|
|
189
|
+
self.parameters_to_tuples(header_params,collection_formats)
|
|
190
|
+
)
|
|
183
191
|
|
|
184
192
|
# path parameters
|
|
185
193
|
if path_params:
|
|
186
194
|
path_params = self.sanitize_for_serialization(path_params)
|
|
187
|
-
path_params = self.parameters_to_tuples(
|
|
195
|
+
path_params = self.parameters_to_tuples(
|
|
196
|
+
path_params,
|
|
197
|
+
collection_formats
|
|
198
|
+
)
|
|
188
199
|
for k, v in path_params:
|
|
189
200
|
# specified safe chars, encode everything
|
|
190
|
-
resource_path = resource_path.replace(
|
|
201
|
+
resource_path = resource_path.replace(
|
|
202
|
+
'{%s}' % k,
|
|
203
|
+
quote(str(v), safe=config.safe_chars_for_path_param)
|
|
204
|
+
)
|
|
191
205
|
|
|
192
206
|
# post parameters
|
|
193
207
|
if post_params or files:
|
|
194
208
|
post_params = post_params if post_params else []
|
|
195
209
|
post_params = self.sanitize_for_serialization(post_params)
|
|
196
|
-
post_params = self.parameters_to_tuples(
|
|
210
|
+
post_params = self.parameters_to_tuples(
|
|
211
|
+
post_params,
|
|
212
|
+
collection_formats
|
|
213
|
+
)
|
|
197
214
|
if files:
|
|
198
215
|
post_params.extend(self.files_parameters(files))
|
|
199
216
|
|
|
200
217
|
# auth setting
|
|
201
218
|
self.update_params_for_auth(
|
|
202
|
-
header_params,
|
|
219
|
+
header_params,
|
|
220
|
+
query_params,
|
|
221
|
+
auth_settings,
|
|
222
|
+
resource_path,
|
|
223
|
+
method,
|
|
224
|
+
body,
|
|
225
|
+
request_auth=_request_auth
|
|
203
226
|
)
|
|
204
227
|
|
|
205
228
|
# body
|
|
@@ -216,13 +239,23 @@ class ApiClient:
|
|
|
216
239
|
# query parameters
|
|
217
240
|
if query_params:
|
|
218
241
|
query_params = self.sanitize_for_serialization(query_params)
|
|
219
|
-
url_query = self.parameters_to_url_query(
|
|
242
|
+
url_query = self.parameters_to_url_query(
|
|
243
|
+
query_params,
|
|
244
|
+
collection_formats
|
|
245
|
+
)
|
|
220
246
|
url += "?" + url_query
|
|
221
247
|
|
|
222
248
|
return method, url, header_params, body, post_params
|
|
223
249
|
|
|
250
|
+
|
|
224
251
|
def call_api(
|
|
225
|
-
self,
|
|
252
|
+
self,
|
|
253
|
+
method,
|
|
254
|
+
url,
|
|
255
|
+
header_params=None,
|
|
256
|
+
body=None,
|
|
257
|
+
post_params=None,
|
|
258
|
+
_request_timeout=None
|
|
226
259
|
) -> rest.RESTResponse:
|
|
227
260
|
"""Makes the HTTP request (synchronous)
|
|
228
261
|
:param method: Method to call.
|
|
@@ -239,12 +272,10 @@ class ApiClient:
|
|
|
239
272
|
try:
|
|
240
273
|
# perform request and return response
|
|
241
274
|
response_data = self.rest_client.request(
|
|
242
|
-
method,
|
|
243
|
-
url,
|
|
275
|
+
method, url,
|
|
244
276
|
headers=header_params,
|
|
245
|
-
body=body,
|
|
246
|
-
|
|
247
|
-
_request_timeout=_request_timeout,
|
|
277
|
+
body=body, post_params=post_params,
|
|
278
|
+
_request_timeout=_request_timeout
|
|
248
279
|
)
|
|
249
280
|
|
|
250
281
|
except ApiException as e:
|
|
@@ -253,7 +284,9 @@ class ApiClient:
|
|
|
253
284
|
return response_data
|
|
254
285
|
|
|
255
286
|
def response_deserialize(
|
|
256
|
-
self,
|
|
287
|
+
self,
|
|
288
|
+
response_data: rest.RESTResponse,
|
|
289
|
+
response_types_map: Optional[Dict[str, ApiResponseT]]=None
|
|
257
290
|
) -> ApiResponse[ApiResponseT]:
|
|
258
291
|
"""Deserializes response into an object.
|
|
259
292
|
:param response_data: RESTResponse object to be deserialized.
|
|
@@ -279,7 +312,7 @@ class ApiClient:
|
|
|
279
312
|
return_data = self.__deserialize_file(response_data)
|
|
280
313
|
elif response_type is not None:
|
|
281
314
|
match = None
|
|
282
|
-
content_type = response_data.getheader(
|
|
315
|
+
content_type = response_data.getheader('content-type')
|
|
283
316
|
if content_type is not None:
|
|
284
317
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
|
285
318
|
encoding = match.group(1) if match else "utf-8"
|
|
@@ -294,10 +327,10 @@ class ApiClient:
|
|
|
294
327
|
)
|
|
295
328
|
|
|
296
329
|
return ApiResponse(
|
|
297
|
-
status_code=response_data.status,
|
|
298
|
-
data=return_data,
|
|
299
|
-
headers=response_data.getheaders(),
|
|
300
|
-
raw_data=response_data.data
|
|
330
|
+
status_code = response_data.status,
|
|
331
|
+
data = return_data,
|
|
332
|
+
headers = response_data.getheaders(),
|
|
333
|
+
raw_data = response_data.data
|
|
301
334
|
)
|
|
302
335
|
|
|
303
336
|
def sanitize_for_serialization(self, obj):
|
|
@@ -325,9 +358,13 @@ class ApiClient:
|
|
|
325
358
|
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
|
326
359
|
return obj
|
|
327
360
|
elif isinstance(obj, list):
|
|
328
|
-
return [
|
|
361
|
+
return [
|
|
362
|
+
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
|
363
|
+
]
|
|
329
364
|
elif isinstance(obj, tuple):
|
|
330
|
-
return tuple(
|
|
365
|
+
return tuple(
|
|
366
|
+
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
|
367
|
+
)
|
|
331
368
|
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
|
332
369
|
return obj.isoformat()
|
|
333
370
|
elif isinstance(obj, decimal.Decimal):
|
|
@@ -341,12 +378,15 @@ class ApiClient:
|
|
|
341
378
|
# and attributes which value is not None.
|
|
342
379
|
# Convert attribute name to json key in
|
|
343
380
|
# model definition for request.
|
|
344
|
-
if hasattr(obj,
|
|
381
|
+
if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')):
|
|
345
382
|
obj_dict = obj.to_dict()
|
|
346
383
|
else:
|
|
347
384
|
obj_dict = obj.__dict__
|
|
348
385
|
|
|
349
|
-
return {
|
|
386
|
+
return {
|
|
387
|
+
key: self.sanitize_for_serialization(val)
|
|
388
|
+
for key, val in obj_dict.items()
|
|
389
|
+
}
|
|
350
390
|
|
|
351
391
|
def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
|
|
352
392
|
"""Deserializes response into an object.
|
|
@@ -365,15 +405,18 @@ class ApiClient:
|
|
|
365
405
|
data = json.loads(response_text)
|
|
366
406
|
except ValueError:
|
|
367
407
|
data = response_text
|
|
368
|
-
elif re.match(r
|
|
408
|
+
elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE):
|
|
369
409
|
if response_text == "":
|
|
370
410
|
data = ""
|
|
371
411
|
else:
|
|
372
412
|
data = json.loads(response_text)
|
|
373
|
-
elif re.match(r
|
|
413
|
+
elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE):
|
|
374
414
|
data = response_text
|
|
375
415
|
else:
|
|
376
|
-
raise ApiException(
|
|
416
|
+
raise ApiException(
|
|
417
|
+
status=0,
|
|
418
|
+
reason="Unsupported content type: {0}".format(content_type)
|
|
419
|
+
)
|
|
377
420
|
|
|
378
421
|
return self.__deserialize(data, response_type)
|
|
379
422
|
|
|
@@ -389,17 +432,19 @@ class ApiClient:
|
|
|
389
432
|
return None
|
|
390
433
|
|
|
391
434
|
if isinstance(klass, str):
|
|
392
|
-
if klass.startswith(
|
|
393
|
-
m = re.match(r
|
|
435
|
+
if klass.startswith('List['):
|
|
436
|
+
m = re.match(r'List\[(.*)]', klass)
|
|
394
437
|
assert m is not None, "Malformed List type definition"
|
|
395
438
|
sub_kls = m.group(1)
|
|
396
|
-
return [self.__deserialize(sub_data, sub_kls)
|
|
439
|
+
return [self.__deserialize(sub_data, sub_kls)
|
|
440
|
+
for sub_data in data]
|
|
397
441
|
|
|
398
|
-
if klass.startswith(
|
|
399
|
-
m = re.match(r
|
|
442
|
+
if klass.startswith('Dict['):
|
|
443
|
+
m = re.match(r'Dict\[([^,]*), (.*)]', klass)
|
|
400
444
|
assert m is not None, "Malformed Dict type definition"
|
|
401
445
|
sub_kls = m.group(2)
|
|
402
|
-
return {k: self.__deserialize(v, sub_kls)
|
|
446
|
+
return {k: self.__deserialize(v, sub_kls)
|
|
447
|
+
for k, v in data.items()}
|
|
403
448
|
|
|
404
449
|
# convert str to class
|
|
405
450
|
if klass in self.NATIVE_TYPES_MAPPING:
|
|
@@ -435,18 +480,19 @@ class ApiClient:
|
|
|
435
480
|
for k, v in params.items() if isinstance(params, dict) else params:
|
|
436
481
|
if k in collection_formats:
|
|
437
482
|
collection_format = collection_formats[k]
|
|
438
|
-
if collection_format ==
|
|
483
|
+
if collection_format == 'multi':
|
|
439
484
|
new_params.extend((k, value) for value in v)
|
|
440
485
|
else:
|
|
441
|
-
if collection_format ==
|
|
442
|
-
delimiter =
|
|
443
|
-
elif collection_format ==
|
|
444
|
-
delimiter =
|
|
445
|
-
elif collection_format ==
|
|
446
|
-
delimiter =
|
|
486
|
+
if collection_format == 'ssv':
|
|
487
|
+
delimiter = ' '
|
|
488
|
+
elif collection_format == 'tsv':
|
|
489
|
+
delimiter = '\t'
|
|
490
|
+
elif collection_format == 'pipes':
|
|
491
|
+
delimiter = '|'
|
|
447
492
|
else: # csv is the default
|
|
448
|
-
delimiter =
|
|
449
|
-
new_params.append(
|
|
493
|
+
delimiter = ','
|
|
494
|
+
new_params.append(
|
|
495
|
+
(k, delimiter.join(str(value) for value in v)))
|
|
450
496
|
else:
|
|
451
497
|
new_params.append((k, v))
|
|
452
498
|
return new_params
|
|
@@ -471,18 +517,20 @@ class ApiClient:
|
|
|
471
517
|
|
|
472
518
|
if k in collection_formats:
|
|
473
519
|
collection_format = collection_formats[k]
|
|
474
|
-
if collection_format ==
|
|
520
|
+
if collection_format == 'multi':
|
|
475
521
|
new_params.extend((k, quote(str(value))) for value in v)
|
|
476
522
|
else:
|
|
477
|
-
if collection_format ==
|
|
478
|
-
delimiter =
|
|
479
|
-
elif collection_format ==
|
|
480
|
-
delimiter =
|
|
481
|
-
elif collection_format ==
|
|
482
|
-
delimiter =
|
|
523
|
+
if collection_format == 'ssv':
|
|
524
|
+
delimiter = ' '
|
|
525
|
+
elif collection_format == 'tsv':
|
|
526
|
+
delimiter = '\t'
|
|
527
|
+
elif collection_format == 'pipes':
|
|
528
|
+
delimiter = '|'
|
|
483
529
|
else: # csv is the default
|
|
484
|
-
delimiter =
|
|
485
|
-
new_params.append(
|
|
530
|
+
delimiter = ','
|
|
531
|
+
new_params.append(
|
|
532
|
+
(k, delimiter.join(quote(str(value)) for value in v))
|
|
533
|
+
)
|
|
486
534
|
else:
|
|
487
535
|
new_params.append((k, quote(str(v))))
|
|
488
536
|
|
|
@@ -500,7 +548,7 @@ class ApiClient:
|
|
|
500
548
|
params = []
|
|
501
549
|
for k, v in files.items():
|
|
502
550
|
if isinstance(v, str):
|
|
503
|
-
with open(v,
|
|
551
|
+
with open(v, 'rb') as f:
|
|
504
552
|
filename = os.path.basename(f.name)
|
|
505
553
|
filedata = f.read()
|
|
506
554
|
elif isinstance(v, bytes):
|
|
@@ -514,8 +562,13 @@ class ApiClient:
|
|
|
514
562
|
continue
|
|
515
563
|
else:
|
|
516
564
|
raise ValueError("Unsupported file value")
|
|
517
|
-
mimetype =
|
|
518
|
-
|
|
565
|
+
mimetype = (
|
|
566
|
+
mimetypes.guess_type(filename)[0]
|
|
567
|
+
or 'application/octet-stream'
|
|
568
|
+
)
|
|
569
|
+
params.append(
|
|
570
|
+
tuple([k, tuple([filename, filedata, mimetype])])
|
|
571
|
+
)
|
|
519
572
|
return params
|
|
520
573
|
|
|
521
574
|
def select_header_accept(self, accepts: List[str]) -> Optional[str]:
|
|
@@ -528,7 +581,7 @@ class ApiClient:
|
|
|
528
581
|
return None
|
|
529
582
|
|
|
530
583
|
for accept in accepts:
|
|
531
|
-
if re.search(
|
|
584
|
+
if re.search('json', accept, re.IGNORECASE):
|
|
532
585
|
return accept
|
|
533
586
|
|
|
534
587
|
return accepts[0]
|
|
@@ -543,13 +596,20 @@ class ApiClient:
|
|
|
543
596
|
return None
|
|
544
597
|
|
|
545
598
|
for content_type in content_types:
|
|
546
|
-
if re.search(
|
|
599
|
+
if re.search('json', content_type, re.IGNORECASE):
|
|
547
600
|
return content_type
|
|
548
601
|
|
|
549
602
|
return content_types[0]
|
|
550
603
|
|
|
551
604
|
def update_params_for_auth(
|
|
552
|
-
self,
|
|
605
|
+
self,
|
|
606
|
+
headers,
|
|
607
|
+
queries,
|
|
608
|
+
auth_settings,
|
|
609
|
+
resource_path,
|
|
610
|
+
method,
|
|
611
|
+
body,
|
|
612
|
+
request_auth=None
|
|
553
613
|
) -> None:
|
|
554
614
|
"""Updates header and query params based on authentication setting.
|
|
555
615
|
|
|
@@ -567,14 +627,36 @@ class ApiClient:
|
|
|
567
627
|
return
|
|
568
628
|
|
|
569
629
|
if request_auth:
|
|
570
|
-
self._apply_auth_params(
|
|
630
|
+
self._apply_auth_params(
|
|
631
|
+
headers,
|
|
632
|
+
queries,
|
|
633
|
+
resource_path,
|
|
634
|
+
method,
|
|
635
|
+
body,
|
|
636
|
+
request_auth
|
|
637
|
+
)
|
|
571
638
|
else:
|
|
572
639
|
for auth in auth_settings:
|
|
573
640
|
auth_setting = self.configuration.auth_settings().get(auth)
|
|
574
641
|
if auth_setting:
|
|
575
|
-
self._apply_auth_params(
|
|
576
|
-
|
|
577
|
-
|
|
642
|
+
self._apply_auth_params(
|
|
643
|
+
headers,
|
|
644
|
+
queries,
|
|
645
|
+
resource_path,
|
|
646
|
+
method,
|
|
647
|
+
body,
|
|
648
|
+
auth_setting
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
def _apply_auth_params(
|
|
652
|
+
self,
|
|
653
|
+
headers,
|
|
654
|
+
queries,
|
|
655
|
+
resource_path,
|
|
656
|
+
method,
|
|
657
|
+
body,
|
|
658
|
+
auth_setting
|
|
659
|
+
) -> None:
|
|
578
660
|
"""Updates the request parameters based on a single auth_setting
|
|
579
661
|
|
|
580
662
|
:param headers: Header parameters dict to be updated.
|
|
@@ -585,15 +667,17 @@ class ApiClient:
|
|
|
585
667
|
The object type is the return value of sanitize_for_serialization().
|
|
586
668
|
:param auth_setting: auth settings for the endpoint
|
|
587
669
|
"""
|
|
588
|
-
if auth_setting[
|
|
589
|
-
headers[
|
|
590
|
-
elif auth_setting[
|
|
591
|
-
if auth_setting[
|
|
592
|
-
headers[auth_setting[
|
|
593
|
-
elif auth_setting[
|
|
594
|
-
queries.append((auth_setting[
|
|
670
|
+
if auth_setting['in'] == 'cookie':
|
|
671
|
+
headers['Cookie'] = auth_setting['value']
|
|
672
|
+
elif auth_setting['in'] == 'header':
|
|
673
|
+
if auth_setting['type'] != 'http-signature':
|
|
674
|
+
headers[auth_setting['key']] = auth_setting['value']
|
|
675
|
+
elif auth_setting['in'] == 'query':
|
|
676
|
+
queries.append((auth_setting['key'], auth_setting['value']))
|
|
595
677
|
else:
|
|
596
|
-
raise ApiValueError(
|
|
678
|
+
raise ApiValueError(
|
|
679
|
+
'Authentication token must be in `query` or `header`'
|
|
680
|
+
)
|
|
597
681
|
|
|
598
682
|
def __deserialize_file(self, response):
|
|
599
683
|
"""Deserializes body to file
|
|
@@ -613,7 +697,10 @@ class ApiClient:
|
|
|
613
697
|
|
|
614
698
|
content_disposition = response.getheader("Content-Disposition")
|
|
615
699
|
if content_disposition:
|
|
616
|
-
m = re.search(
|
|
700
|
+
m = re.search(
|
|
701
|
+
r'filename=[\'"]?([^\'"\s]+)[\'"]?',
|
|
702
|
+
content_disposition
|
|
703
|
+
)
|
|
617
704
|
assert m is not None, "Unexpected 'content-disposition' header value"
|
|
618
705
|
filename = m.group(1)
|
|
619
706
|
path = os.path.join(os.path.dirname(path), filename)
|
|
@@ -656,7 +743,10 @@ class ApiClient:
|
|
|
656
743
|
except ImportError:
|
|
657
744
|
return string
|
|
658
745
|
except ValueError:
|
|
659
|
-
raise rest.ApiException(
|
|
746
|
+
raise rest.ApiException(
|
|
747
|
+
status=0,
|
|
748
|
+
reason="Failed to parse `{0}` as date object".format(string)
|
|
749
|
+
)
|
|
660
750
|
|
|
661
751
|
def __deserialize_datetime(self, string):
|
|
662
752
|
"""Deserializes string to datetime.
|
|
@@ -671,7 +761,13 @@ class ApiClient:
|
|
|
671
761
|
except ImportError:
|
|
672
762
|
return string
|
|
673
763
|
except ValueError:
|
|
674
|
-
raise rest.ApiException(
|
|
764
|
+
raise rest.ApiException(
|
|
765
|
+
status=0,
|
|
766
|
+
reason=(
|
|
767
|
+
"Failed to parse `{0}` as datetime object"
|
|
768
|
+
.format(string)
|
|
769
|
+
)
|
|
770
|
+
)
|
|
675
771
|
|
|
676
772
|
def __deserialize_enum(self, data, klass):
|
|
677
773
|
"""Deserializes primitive type to enum.
|
|
@@ -683,7 +779,13 @@ class ApiClient:
|
|
|
683
779
|
try:
|
|
684
780
|
return klass(data)
|
|
685
781
|
except ValueError:
|
|
686
|
-
raise rest.ApiException(
|
|
782
|
+
raise rest.ApiException(
|
|
783
|
+
status=0,
|
|
784
|
+
reason=(
|
|
785
|
+
"Failed to parse `{0}` as `{1}`"
|
|
786
|
+
.format(data, klass)
|
|
787
|
+
)
|
|
788
|
+
)
|
|
687
789
|
|
|
688
790
|
def __deserialize_model(self, data, klass):
|
|
689
791
|
"""Deserializes list or dict to model.
|
|
@@ -6,7 +6,6 @@ from pydantic import Field, StrictInt, StrictBytes, BaseModel
|
|
|
6
6
|
|
|
7
7
|
T = TypeVar("T")
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
class ApiResponse(BaseModel, Generic[T]):
|
|
11
10
|
"""
|
|
12
11
|
API response object
|
|
@@ -17,4 +16,6 @@ class ApiResponse(BaseModel, Generic[T]):
|
|
|
17
16
|
data: T = Field(description="Deserialized data given the data type")
|
|
18
17
|
raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
|
|
19
18
|
|
|
20
|
-
model_config = {
|
|
19
|
+
model_config = {
|
|
20
|
+
"arbitrary_types_allowed": True
|
|
21
|
+
}
|