crypticorn 2.4.6__py3-none-any.whl → 2.4.7__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.
- crypticorn/common/auth.py +7 -9
- crypticorn/common/errors.py +5 -0
- crypticorn/common/utils.py +15 -5
- crypticorn/klines/main.py +10 -5
- crypticorn/metrics/main.py +5 -4
- crypticorn/trade/client/__init__.py +6 -8
- crypticorn/trade/client/api/__init__.py +1 -0
- crypticorn/trade/client/api/api_keys_api.py +273 -167
- crypticorn/trade/client/api/bots_api.py +226 -140
- crypticorn/trade/client/api/exchanges_api.py +51 -31
- crypticorn/trade/client/api/futures_trading_panel_api.py +272 -169
- crypticorn/trade/client/api/notifications_api.py +323 -200
- crypticorn/trade/client/api/orders_api.py +60 -40
- crypticorn/trade/client/api/status_api.py +49 -31
- crypticorn/trade/client/api/strategies_api.py +223 -137
- crypticorn/trade/client/api/trading_actions_api.py +170 -106
- crypticorn/trade/client/api_client.py +153 -111
- crypticorn/trade/client/api_response.py +3 -2
- crypticorn/trade/client/configuration.py +115 -128
- crypticorn/trade/client/exceptions.py +21 -25
- crypticorn/trade/client/models/__init__.py +6 -8
- crypticorn/trade/client/models/action_model.py +54 -108
- crypticorn/trade/client/models/api_error_identifier.py +72 -76
- crypticorn/trade/client/models/api_error_level.py +11 -9
- crypticorn/trade/client/models/api_error_type.py +11 -9
- crypticorn/trade/client/models/bot_model.py +36 -57
- crypticorn/trade/client/models/bot_status.py +11 -9
- crypticorn/trade/client/models/exchange.py +9 -7
- crypticorn/trade/client/models/exchange_key_model.py +34 -44
- crypticorn/trade/client/models/execution_ids.py +18 -18
- crypticorn/trade/client/models/futures_balance.py +27 -43
- crypticorn/trade/client/models/futures_trading_action.py +50 -102
- crypticorn/trade/client/models/http_validation_error.py +15 -19
- crypticorn/trade/client/models/margin_mode.py +9 -7
- crypticorn/trade/client/models/market_type.py +9 -7
- crypticorn/trade/client/models/notification_model.py +32 -52
- crypticorn/trade/client/models/order_model.py +72 -112
- crypticorn/trade/client/models/order_status.py +12 -10
- crypticorn/trade/client/models/post_futures_action.py +16 -20
- crypticorn/trade/client/models/strategy_exchange_info.py +16 -15
- crypticorn/trade/client/models/strategy_model_input.py +33 -61
- crypticorn/trade/client/models/strategy_model_output.py +33 -61
- crypticorn/trade/client/models/tpsl.py +25 -39
- crypticorn/trade/client/models/trading_action_type.py +11 -9
- crypticorn/trade/client/models/validation_error.py +18 -24
- crypticorn/trade/client/models/validation_error_loc_inner.py +16 -37
- crypticorn/trade/client/rest.py +38 -23
- {crypticorn-2.4.6.dist-info → crypticorn-2.4.7.dist-info}/METADATA +8 -2
- {crypticorn-2.4.6.dist-info → crypticorn-2.4.7.dist-info}/RECORD +52 -52
- {crypticorn-2.4.6.dist-info → crypticorn-2.4.7.dist-info}/WHEEL +0 -0
- {crypticorn-2.4.6.dist-info → crypticorn-2.4.7.dist-info}/entry_points.txt +0 -0
- {crypticorn-2.4.6.dist-info → crypticorn-2.4.7.dist-info}/top_level.txt +0 -0
@@ -1,14 +1,14 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
"""
|
4
|
-
Trading API
|
4
|
+
Trading API
|
5
5
|
|
6
|
-
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
7
7
|
|
8
|
-
The version of the OpenAPI document: 0.1.0
|
9
|
-
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
10
10
|
|
11
|
-
Do not edit the class manually.
|
11
|
+
Do not edit the class manually.
|
12
12
|
""" # noqa: E501
|
13
13
|
|
14
14
|
|
@@ -37,12 +37,11 @@ from crypticorn.trade.client.exceptions import (
|
|
37
37
|
UnauthorizedException,
|
38
38
|
ForbiddenException,
|
39
39
|
NotFoundException,
|
40
|
-
ServiceException
|
40
|
+
ServiceException
|
41
41
|
)
|
42
42
|
|
43
43
|
RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
|
44
44
|
|
45
|
-
|
46
45
|
class ApiClient:
|
47
46
|
"""Generic API client for OpenAPI client library builds.
|
48
47
|
|
@@ -61,20 +60,24 @@ class ApiClient:
|
|
61
60
|
|
62
61
|
PRIMITIVE_TYPES = (float, bool, bytes, str, int)
|
63
62
|
NATIVE_TYPES_MAPPING = {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
'int': int,
|
64
|
+
'long': int, # TODO remove as only py3 is supported?
|
65
|
+
'float': float,
|
66
|
+
'str': str,
|
67
|
+
'bool': bool,
|
68
|
+
'date': datetime.date,
|
69
|
+
'datetime': datetime.datetime,
|
70
|
+
'decimal': decimal.Decimal,
|
71
|
+
'object': object,
|
73
72
|
}
|
74
73
|
_pool = None
|
75
74
|
|
76
75
|
def __init__(
|
77
|
-
self,
|
76
|
+
self,
|
77
|
+
configuration=None,
|
78
|
+
header_name=None,
|
79
|
+
header_value=None,
|
80
|
+
cookie=None
|
78
81
|
) -> None:
|
79
82
|
# use default configuration if none is provided
|
80
83
|
if configuration is None:
|
@@ -87,7 +90,7 @@ class ApiClient:
|
|
87
90
|
self.default_headers[header_name] = header_value
|
88
91
|
self.cookie = cookie
|
89
92
|
# Set default User-Agent.
|
90
|
-
self.user_agent =
|
93
|
+
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
|
91
94
|
self.client_side_validation = configuration.client_side_validation
|
92
95
|
|
93
96
|
async def __aenter__(self):
|
@@ -102,15 +105,16 @@ class ApiClient:
|
|
102
105
|
@property
|
103
106
|
def user_agent(self):
|
104
107
|
"""User agent for this API client"""
|
105
|
-
return self.default_headers[
|
108
|
+
return self.default_headers['User-Agent']
|
106
109
|
|
107
110
|
@user_agent.setter
|
108
111
|
def user_agent(self, value):
|
109
|
-
self.default_headers[
|
112
|
+
self.default_headers['User-Agent'] = value
|
110
113
|
|
111
114
|
def set_default_header(self, header_name, header_value):
|
112
115
|
self.default_headers[header_name] = header_value
|
113
116
|
|
117
|
+
|
114
118
|
_default = None
|
115
119
|
|
116
120
|
@classmethod
|
@@ -146,12 +150,12 @@ class ApiClient:
|
|
146
150
|
header_params=None,
|
147
151
|
body=None,
|
148
152
|
post_params=None,
|
149
|
-
files=None,
|
150
|
-
auth_settings=None,
|
153
|
+
files=None, auth_settings=None,
|
151
154
|
collection_formats=None,
|
152
155
|
_host=None,
|
153
|
-
_request_auth=None
|
156
|
+
_request_auth=None
|
154
157
|
) -> RequestSerialized:
|
158
|
+
|
155
159
|
"""Builds the HTTP request params needed by the request.
|
156
160
|
:param method: Method to call.
|
157
161
|
:param resource_path: Path to method endpoint.
|
@@ -180,28 +184,35 @@ class ApiClient:
|
|
180
184
|
header_params = header_params or {}
|
181
185
|
header_params.update(self.default_headers)
|
182
186
|
if self.cookie:
|
183
|
-
header_params[
|
187
|
+
header_params['Cookie'] = self.cookie
|
184
188
|
if header_params:
|
185
189
|
header_params = self.sanitize_for_serialization(header_params)
|
186
190
|
header_params = dict(
|
187
|
-
self.parameters_to_tuples(header_params,
|
191
|
+
self.parameters_to_tuples(header_params,collection_formats)
|
188
192
|
)
|
189
193
|
|
190
194
|
# path parameters
|
191
195
|
if path_params:
|
192
196
|
path_params = self.sanitize_for_serialization(path_params)
|
193
|
-
path_params = self.parameters_to_tuples(
|
197
|
+
path_params = self.parameters_to_tuples(
|
198
|
+
path_params,
|
199
|
+
collection_formats
|
200
|
+
)
|
194
201
|
for k, v in path_params:
|
195
202
|
# specified safe chars, encode everything
|
196
203
|
resource_path = resource_path.replace(
|
197
|
-
|
204
|
+
'{%s}' % k,
|
205
|
+
quote(str(v), safe=config.safe_chars_for_path_param)
|
198
206
|
)
|
199
207
|
|
200
208
|
# post parameters
|
201
209
|
if post_params or files:
|
202
210
|
post_params = post_params if post_params else []
|
203
211
|
post_params = self.sanitize_for_serialization(post_params)
|
204
|
-
post_params = self.parameters_to_tuples(
|
212
|
+
post_params = self.parameters_to_tuples(
|
213
|
+
post_params,
|
214
|
+
collection_formats
|
215
|
+
)
|
205
216
|
if files:
|
206
217
|
post_params.extend(self.files_parameters(files))
|
207
218
|
|
@@ -213,7 +224,7 @@ class ApiClient:
|
|
213
224
|
resource_path,
|
214
225
|
method,
|
215
226
|
body,
|
216
|
-
request_auth=_request_auth
|
227
|
+
request_auth=_request_auth
|
217
228
|
)
|
218
229
|
|
219
230
|
# body
|
@@ -230,11 +241,15 @@ class ApiClient:
|
|
230
241
|
# query parameters
|
231
242
|
if query_params:
|
232
243
|
query_params = self.sanitize_for_serialization(query_params)
|
233
|
-
url_query = self.parameters_to_url_query(
|
244
|
+
url_query = self.parameters_to_url_query(
|
245
|
+
query_params,
|
246
|
+
collection_formats
|
247
|
+
)
|
234
248
|
url += "?" + url_query
|
235
249
|
|
236
250
|
return method, url, header_params, body, post_params
|
237
251
|
|
252
|
+
|
238
253
|
async def call_api(
|
239
254
|
self,
|
240
255
|
method,
|
@@ -242,7 +257,7 @@ class ApiClient:
|
|
242
257
|
header_params=None,
|
243
258
|
body=None,
|
244
259
|
post_params=None,
|
245
|
-
_request_timeout=None
|
260
|
+
_request_timeout=None
|
246
261
|
) -> rest.RESTResponse:
|
247
262
|
"""Makes the HTTP request (synchronous)
|
248
263
|
:param method: Method to call.
|
@@ -259,12 +274,10 @@ class ApiClient:
|
|
259
274
|
try:
|
260
275
|
# perform request and return response
|
261
276
|
response_data = await self.rest_client.request(
|
262
|
-
method,
|
263
|
-
url,
|
277
|
+
method, url,
|
264
278
|
headers=header_params,
|
265
|
-
body=body,
|
266
|
-
|
267
|
-
_request_timeout=_request_timeout,
|
279
|
+
body=body, post_params=post_params,
|
280
|
+
_request_timeout=_request_timeout
|
268
281
|
)
|
269
282
|
|
270
283
|
except ApiException as e:
|
@@ -275,7 +288,7 @@ class ApiClient:
|
|
275
288
|
def response_deserialize(
|
276
289
|
self,
|
277
290
|
response_data: rest.RESTResponse,
|
278
|
-
response_types_map: Optional[Dict[str, ApiResponseT]]
|
291
|
+
response_types_map: Optional[Dict[str, ApiResponseT]]=None
|
279
292
|
) -> ApiResponse[ApiResponseT]:
|
280
293
|
"""Deserializes response into an object.
|
281
294
|
:param response_data: RESTResponse object to be deserialized.
|
@@ -287,15 +300,9 @@ class ApiClient:
|
|
287
300
|
assert response_data.data is not None, msg
|
288
301
|
|
289
302
|
response_type = response_types_map.get(str(response_data.status), None)
|
290
|
-
if (
|
291
|
-
not response_type
|
292
|
-
and isinstance(response_data.status, int)
|
293
|
-
and 100 <= response_data.status <= 599
|
294
|
-
):
|
303
|
+
if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599:
|
295
304
|
# if not found, look for '1XX', '2XX', etc.
|
296
|
-
response_type = response_types_map.get(
|
297
|
-
str(response_data.status)[0] + "XX", None
|
298
|
-
)
|
305
|
+
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None)
|
299
306
|
|
300
307
|
# deserialize response data
|
301
308
|
response_text = None
|
@@ -307,14 +314,12 @@ class ApiClient:
|
|
307
314
|
return_data = self.__deserialize_file(response_data)
|
308
315
|
elif response_type is not None:
|
309
316
|
match = None
|
310
|
-
content_type = response_data.getheader(
|
317
|
+
content_type = response_data.getheader('content-type')
|
311
318
|
if content_type is not None:
|
312
319
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
313
320
|
encoding = match.group(1) if match else "utf-8"
|
314
321
|
response_text = response_data.data.decode(encoding)
|
315
|
-
return_data = self.deserialize(
|
316
|
-
response_text, response_type, content_type
|
317
|
-
)
|
322
|
+
return_data = self.deserialize(response_text, response_type, content_type)
|
318
323
|
finally:
|
319
324
|
if not 200 <= response_data.status <= 299:
|
320
325
|
raise ApiException.from_response(
|
@@ -324,10 +329,10 @@ class ApiClient:
|
|
324
329
|
)
|
325
330
|
|
326
331
|
return ApiResponse(
|
327
|
-
status_code=response_data.status,
|
328
|
-
data=return_data,
|
329
|
-
headers=response_data.getheaders(),
|
330
|
-
raw_data=response_data.data
|
332
|
+
status_code = response_data.status,
|
333
|
+
data = return_data,
|
334
|
+
headers = response_data.getheaders(),
|
335
|
+
raw_data = response_data.data
|
331
336
|
)
|
332
337
|
|
333
338
|
def sanitize_for_serialization(self, obj):
|
@@ -355,9 +360,13 @@ class ApiClient:
|
|
355
360
|
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
356
361
|
return obj
|
357
362
|
elif isinstance(obj, list):
|
358
|
-
return [
|
363
|
+
return [
|
364
|
+
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
365
|
+
]
|
359
366
|
elif isinstance(obj, tuple):
|
360
|
-
return tuple(
|
367
|
+
return tuple(
|
368
|
+
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
369
|
+
)
|
361
370
|
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
362
371
|
return obj.isoformat()
|
363
372
|
elif isinstance(obj, decimal.Decimal):
|
@@ -371,18 +380,17 @@ class ApiClient:
|
|
371
380
|
# and attributes which value is not None.
|
372
381
|
# Convert attribute name to json key in
|
373
382
|
# model definition for request.
|
374
|
-
if hasattr(obj,
|
383
|
+
if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')):
|
375
384
|
obj_dict = obj.to_dict()
|
376
385
|
else:
|
377
386
|
obj_dict = obj.__dict__
|
378
387
|
|
379
388
|
return {
|
380
|
-
key: self.sanitize_for_serialization(val)
|
389
|
+
key: self.sanitize_for_serialization(val)
|
390
|
+
for key, val in obj_dict.items()
|
381
391
|
}
|
382
392
|
|
383
|
-
def deserialize(
|
384
|
-
self, response_text: str, response_type: str, content_type: Optional[str]
|
385
|
-
):
|
393
|
+
def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
|
386
394
|
"""Deserializes response into an object.
|
387
395
|
|
388
396
|
:param response: RESTResponse object to be deserialized.
|
@@ -399,20 +407,17 @@ class ApiClient:
|
|
399
407
|
data = json.loads(response_text)
|
400
408
|
except ValueError:
|
401
409
|
data = response_text
|
402
|
-
elif re.match(
|
403
|
-
r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)",
|
404
|
-
content_type,
|
405
|
-
re.IGNORECASE,
|
406
|
-
):
|
410
|
+
elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE):
|
407
411
|
if response_text == "":
|
408
412
|
data = ""
|
409
413
|
else:
|
410
414
|
data = json.loads(response_text)
|
411
|
-
elif re.match(r
|
415
|
+
elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE):
|
412
416
|
data = response_text
|
413
417
|
else:
|
414
418
|
raise ApiException(
|
415
|
-
status=0,
|
419
|
+
status=0,
|
420
|
+
reason="Unsupported content type: {0}".format(content_type)
|
416
421
|
)
|
417
422
|
|
418
423
|
return self.__deserialize(data, response_type)
|
@@ -429,17 +434,19 @@ class ApiClient:
|
|
429
434
|
return None
|
430
435
|
|
431
436
|
if isinstance(klass, str):
|
432
|
-
if klass.startswith(
|
433
|
-
m = re.match(r
|
437
|
+
if klass.startswith('List['):
|
438
|
+
m = re.match(r'List\[(.*)]', klass)
|
434
439
|
assert m is not None, "Malformed List type definition"
|
435
440
|
sub_kls = m.group(1)
|
436
|
-
return [self.__deserialize(sub_data, sub_kls)
|
441
|
+
return [self.__deserialize(sub_data, sub_kls)
|
442
|
+
for sub_data in data]
|
437
443
|
|
438
|
-
if klass.startswith(
|
439
|
-
m = re.match(r
|
444
|
+
if klass.startswith('Dict['):
|
445
|
+
m = re.match(r'Dict\[([^,]*), (.*)]', klass)
|
440
446
|
assert m is not None, "Malformed Dict type definition"
|
441
447
|
sub_kls = m.group(2)
|
442
|
-
return {k: self.__deserialize(v, sub_kls)
|
448
|
+
return {k: self.__deserialize(v, sub_kls)
|
449
|
+
for k, v in data.items()}
|
443
450
|
|
444
451
|
# convert str to class
|
445
452
|
if klass in self.NATIVE_TYPES_MAPPING:
|
@@ -475,18 +482,19 @@ class ApiClient:
|
|
475
482
|
for k, v in params.items() if isinstance(params, dict) else params:
|
476
483
|
if k in collection_formats:
|
477
484
|
collection_format = collection_formats[k]
|
478
|
-
if collection_format ==
|
485
|
+
if collection_format == 'multi':
|
479
486
|
new_params.extend((k, value) for value in v)
|
480
487
|
else:
|
481
|
-
if collection_format ==
|
482
|
-
delimiter =
|
483
|
-
elif collection_format ==
|
484
|
-
delimiter =
|
485
|
-
elif collection_format ==
|
486
|
-
delimiter =
|
488
|
+
if collection_format == 'ssv':
|
489
|
+
delimiter = ' '
|
490
|
+
elif collection_format == 'tsv':
|
491
|
+
delimiter = '\t'
|
492
|
+
elif collection_format == 'pipes':
|
493
|
+
delimiter = '|'
|
487
494
|
else: # csv is the default
|
488
|
-
delimiter =
|
489
|
-
new_params.append(
|
495
|
+
delimiter = ','
|
496
|
+
new_params.append(
|
497
|
+
(k, delimiter.join(str(value) for value in v)))
|
490
498
|
else:
|
491
499
|
new_params.append((k, v))
|
492
500
|
return new_params
|
@@ -511,17 +519,17 @@ class ApiClient:
|
|
511
519
|
|
512
520
|
if k in collection_formats:
|
513
521
|
collection_format = collection_formats[k]
|
514
|
-
if collection_format ==
|
522
|
+
if collection_format == 'multi':
|
515
523
|
new_params.extend((k, quote(str(value))) for value in v)
|
516
524
|
else:
|
517
|
-
if collection_format ==
|
518
|
-
delimiter =
|
519
|
-
elif collection_format ==
|
520
|
-
delimiter =
|
521
|
-
elif collection_format ==
|
522
|
-
delimiter =
|
525
|
+
if collection_format == 'ssv':
|
526
|
+
delimiter = ' '
|
527
|
+
elif collection_format == 'tsv':
|
528
|
+
delimiter = '\t'
|
529
|
+
elif collection_format == 'pipes':
|
530
|
+
delimiter = '|'
|
523
531
|
else: # csv is the default
|
524
|
-
delimiter =
|
532
|
+
delimiter = ','
|
525
533
|
new_params.append(
|
526
534
|
(k, delimiter.join(quote(str(value)) for value in v))
|
527
535
|
)
|
@@ -542,7 +550,7 @@ class ApiClient:
|
|
542
550
|
params = []
|
543
551
|
for k, v in files.items():
|
544
552
|
if isinstance(v, str):
|
545
|
-
with open(v,
|
553
|
+
with open(v, 'rb') as f:
|
546
554
|
filename = os.path.basename(f.name)
|
547
555
|
filedata = f.read()
|
548
556
|
elif isinstance(v, bytes):
|
@@ -556,8 +564,13 @@ class ApiClient:
|
|
556
564
|
continue
|
557
565
|
else:
|
558
566
|
raise ValueError("Unsupported file value")
|
559
|
-
mimetype =
|
560
|
-
|
567
|
+
mimetype = (
|
568
|
+
mimetypes.guess_type(filename)[0]
|
569
|
+
or 'application/octet-stream'
|
570
|
+
)
|
571
|
+
params.append(
|
572
|
+
tuple([k, tuple([filename, filedata, mimetype])])
|
573
|
+
)
|
561
574
|
return params
|
562
575
|
|
563
576
|
def select_header_accept(self, accepts: List[str]) -> Optional[str]:
|
@@ -570,7 +583,7 @@ class ApiClient:
|
|
570
583
|
return None
|
571
584
|
|
572
585
|
for accept in accepts:
|
573
|
-
if re.search(
|
586
|
+
if re.search('json', accept, re.IGNORECASE):
|
574
587
|
return accept
|
575
588
|
|
576
589
|
return accepts[0]
|
@@ -585,7 +598,7 @@ class ApiClient:
|
|
585
598
|
return None
|
586
599
|
|
587
600
|
for content_type in content_types:
|
588
|
-
if re.search(
|
601
|
+
if re.search('json', content_type, re.IGNORECASE):
|
589
602
|
return content_type
|
590
603
|
|
591
604
|
return content_types[0]
|
@@ -598,7 +611,7 @@ class ApiClient:
|
|
598
611
|
resource_path,
|
599
612
|
method,
|
600
613
|
body,
|
601
|
-
request_auth=None
|
614
|
+
request_auth=None
|
602
615
|
) -> None:
|
603
616
|
"""Updates header and query params based on authentication setting.
|
604
617
|
|
@@ -617,18 +630,34 @@ class ApiClient:
|
|
617
630
|
|
618
631
|
if request_auth:
|
619
632
|
self._apply_auth_params(
|
620
|
-
headers,
|
633
|
+
headers,
|
634
|
+
queries,
|
635
|
+
resource_path,
|
636
|
+
method,
|
637
|
+
body,
|
638
|
+
request_auth
|
621
639
|
)
|
622
640
|
else:
|
623
641
|
for auth in auth_settings:
|
624
642
|
auth_setting = self.configuration.auth_settings().get(auth)
|
625
643
|
if auth_setting:
|
626
644
|
self._apply_auth_params(
|
627
|
-
headers,
|
645
|
+
headers,
|
646
|
+
queries,
|
647
|
+
resource_path,
|
648
|
+
method,
|
649
|
+
body,
|
650
|
+
auth_setting
|
628
651
|
)
|
629
652
|
|
630
653
|
def _apply_auth_params(
|
631
|
-
self,
|
654
|
+
self,
|
655
|
+
headers,
|
656
|
+
queries,
|
657
|
+
resource_path,
|
658
|
+
method,
|
659
|
+
body,
|
660
|
+
auth_setting
|
632
661
|
) -> None:
|
633
662
|
"""Updates the request parameters based on a single auth_setting
|
634
663
|
|
@@ -640,15 +669,17 @@ class ApiClient:
|
|
640
669
|
The object type is the return value of sanitize_for_serialization().
|
641
670
|
:param auth_setting: auth settings for the endpoint
|
642
671
|
"""
|
643
|
-
if auth_setting[
|
644
|
-
headers[
|
645
|
-
elif auth_setting[
|
646
|
-
if auth_setting[
|
647
|
-
headers[auth_setting[
|
648
|
-
elif auth_setting[
|
649
|
-
queries.append((auth_setting[
|
672
|
+
if auth_setting['in'] == 'cookie':
|
673
|
+
headers['Cookie'] = auth_setting['value']
|
674
|
+
elif auth_setting['in'] == 'header':
|
675
|
+
if auth_setting['type'] != 'http-signature':
|
676
|
+
headers[auth_setting['key']] = auth_setting['value']
|
677
|
+
elif auth_setting['in'] == 'query':
|
678
|
+
queries.append((auth_setting['key'], auth_setting['value']))
|
650
679
|
else:
|
651
|
-
raise ApiValueError(
|
680
|
+
raise ApiValueError(
|
681
|
+
'Authentication token must be in `query` or `header`'
|
682
|
+
)
|
652
683
|
|
653
684
|
def __deserialize_file(self, response):
|
654
685
|
"""Deserializes body to file
|
@@ -668,7 +699,10 @@ class ApiClient:
|
|
668
699
|
|
669
700
|
content_disposition = response.getheader("Content-Disposition")
|
670
701
|
if content_disposition:
|
671
|
-
m = re.search(
|
702
|
+
m = re.search(
|
703
|
+
r'filename=[\'"]?([^\'"\s]+)[\'"]?',
|
704
|
+
content_disposition
|
705
|
+
)
|
672
706
|
assert m is not None, "Unexpected 'content-disposition' header value"
|
673
707
|
filename = m.group(1)
|
674
708
|
path = os.path.join(os.path.dirname(path), filename)
|
@@ -712,7 +746,8 @@ class ApiClient:
|
|
712
746
|
return string
|
713
747
|
except ValueError:
|
714
748
|
raise rest.ApiException(
|
715
|
-
status=0,
|
749
|
+
status=0,
|
750
|
+
reason="Failed to parse `{0}` as date object".format(string)
|
716
751
|
)
|
717
752
|
|
718
753
|
def __deserialize_datetime(self, string):
|
@@ -730,7 +765,10 @@ class ApiClient:
|
|
730
765
|
except ValueError:
|
731
766
|
raise rest.ApiException(
|
732
767
|
status=0,
|
733
|
-
reason=(
|
768
|
+
reason=(
|
769
|
+
"Failed to parse `{0}` as datetime object"
|
770
|
+
.format(string)
|
771
|
+
)
|
734
772
|
)
|
735
773
|
|
736
774
|
def __deserialize_enum(self, data, klass):
|
@@ -744,7 +782,11 @@ class ApiClient:
|
|
744
782
|
return klass(data)
|
745
783
|
except ValueError:
|
746
784
|
raise rest.ApiException(
|
747
|
-
status=0,
|
785
|
+
status=0,
|
786
|
+
reason=(
|
787
|
+
"Failed to parse `{0}` as `{1}`"
|
788
|
+
.format(data, klass)
|
789
|
+
)
|
748
790
|
)
|
749
791
|
|
750
792
|
def __deserialize_model(self, data, klass):
|
@@ -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
|
+
}
|