crypticorn 1.0.2rc3__py3-none-any.whl → 2.0.0__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/__init__.py +3 -3
- crypticorn/auth/__init__.py +2 -0
- crypticorn/auth/client/__init__.py +112 -0
- crypticorn/auth/client/api/__init__.py +8 -0
- crypticorn/auth/client/api/admin_api.py +522 -0
- crypticorn/auth/client/api/auth_api.py +2089 -0
- crypticorn/auth/client/api/service_api.py +309 -0
- crypticorn/auth/client/api/user_api.py +2540 -0
- crypticorn/auth/client/api/wallet_api.py +1698 -0
- crypticorn/auth/client/api_client.py +758 -0
- crypticorn/auth/client/api_response.py +20 -0
- crypticorn/auth/client/configuration.py +584 -0
- crypticorn/auth/client/exceptions.py +220 -0
- crypticorn/auth/client/models/__init__.py +91 -0
- crypticorn/auth/client/models/add_wallet200_response.py +86 -0
- crypticorn/auth/client/models/add_wallet_request.py +107 -0
- crypticorn/auth/client/models/authorize_user200_response.py +107 -0
- crypticorn/auth/client/models/authorize_user200_response_auth.py +101 -0
- crypticorn/auth/client/models/authorize_user_request.py +96 -0
- crypticorn/auth/client/models/create_user_request.py +114 -0
- crypticorn/auth/client/models/list_wallets200_response.py +137 -0
- crypticorn/auth/client/models/list_wallets200_response_balances_inner.py +115 -0
- crypticorn/auth/client/models/list_wallets200_response_balances_inner_sale_round.py +115 -0
- crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet.py +168 -0
- crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet_vesting_wallets_inner.py +191 -0
- crypticorn/auth/client/models/list_wallets200_response_data_inner.py +102 -0
- crypticorn/auth/client/models/list_wallets200_response_user_value.py +118 -0
- crypticorn/auth/client/models/logout_default_response.py +108 -0
- crypticorn/auth/client/models/logout_default_response_issues_inner.py +83 -0
- crypticorn/auth/client/models/refresh_token_info200_response.py +97 -0
- crypticorn/auth/client/models/refresh_token_info200_response_user_session.py +105 -0
- crypticorn/auth/client/models/resend_verification_email_request.py +84 -0
- crypticorn/auth/client/models/revoke_user_tokens_request.py +83 -0
- crypticorn/auth/client/models/rotate_tokens200_response.py +110 -0
- crypticorn/auth/client/models/token_info200_response.py +97 -0
- crypticorn/auth/client/models/unlink_wallet_request.py +83 -0
- crypticorn/auth/client/models/update_user_request.py +93 -0
- crypticorn/auth/client/models/user_reset_password_request.py +87 -0
- crypticorn/auth/client/models/user_set_password_request.py +89 -0
- crypticorn/auth/client/models/verify200_response.py +110 -0
- crypticorn/auth/client/models/verify_email200_response.py +107 -0
- crypticorn/auth/client/models/verify_email200_response_auth.py +101 -0
- crypticorn/auth/client/models/verify_email200_response_auth_auth.py +110 -0
- crypticorn/auth/client/models/verify_email_request.py +83 -0
- crypticorn/auth/client/models/verify_wallet_request.py +91 -0
- crypticorn/auth/client/models/wallet_verified200_response.py +83 -0
- crypticorn/auth/client/models/whoami200_response.py +104 -0
- crypticorn/auth/client/rest.py +195 -0
- crypticorn/auth/main.py +45 -0
- crypticorn/client.py +46 -8
- crypticorn/common/__init__.py +5 -0
- crypticorn/common/auth.py +43 -0
- crypticorn/common/auth_client.py +163 -0
- crypticorn/common/errors.py +432 -0
- crypticorn/common/scopes.py +29 -0
- crypticorn/common/urls.py +25 -0
- crypticorn/hive/__init__.py +2 -1
- crypticorn/hive/client/__init__.py +57 -0
- crypticorn/hive/client/api/__init__.py +6 -0
- crypticorn/hive/client/api/data_api.py +594 -0
- crypticorn/hive/client/api/models_api.py +1680 -0
- crypticorn/hive/client/api/status_api.py +263 -0
- crypticorn/hive/client/api_client.py +758 -0
- crypticorn/hive/client/api_response.py +20 -0
- crypticorn/hive/client/configuration.py +612 -0
- crypticorn/hive/client/exceptions.py +220 -0
- crypticorn/hive/client/models/__init__.py +38 -0
- crypticorn/hive/client/models/coins.py +44 -0
- crypticorn/hive/client/models/data_download_response.py +113 -0
- crypticorn/hive/client/models/data_info.py +115 -0
- crypticorn/hive/client/models/data_value_value_value_inner.py +154 -0
- crypticorn/hive/client/models/data_version.py +35 -0
- crypticorn/hive/client/models/download_links.py +91 -0
- crypticorn/hive/client/models/evaluation.py +86 -0
- crypticorn/hive/client/models/evaluation_response.py +85 -0
- crypticorn/hive/client/models/feature_size.py +36 -0
- crypticorn/hive/client/models/http_validation_error.py +99 -0
- crypticorn/hive/client/models/model.py +133 -0
- crypticorn/hive/client/models/model_create.py +93 -0
- crypticorn/hive/client/models/model_status.py +35 -0
- crypticorn/hive/client/models/model_update.py +83 -0
- crypticorn/hive/client/models/target.py +36 -0
- crypticorn/hive/client/models/target_type.py +35 -0
- crypticorn/hive/client/models/validation_error.py +105 -0
- crypticorn/hive/client/models/validation_error_loc_inner.py +159 -0
- crypticorn/hive/client/py.typed +0 -0
- crypticorn/hive/client/rest.py +195 -0
- crypticorn/hive/main.py +27 -100
- crypticorn/klines/client/__init__.py +21 -7
- crypticorn/klines/client/api/__init__.py +0 -1
- crypticorn/klines/client/api/funding_rates_api.py +90 -79
- crypticorn/klines/client/api/health_check_api.py +29 -45
- crypticorn/klines/client/api/ohlcv_data_api.py +104 -87
- crypticorn/klines/client/api/symbols_api.py +36 -54
- crypticorn/klines/client/api/udf_api.py +228 -352
- crypticorn/klines/client/api_client.py +106 -148
- crypticorn/klines/client/api_response.py +2 -3
- crypticorn/klines/client/configuration.py +64 -50
- crypticorn/klines/client/exceptions.py +20 -16
- crypticorn/klines/client/models/__init__.py +21 -7
- crypticorn/klines/client/models/base_response_health_check_response.py +21 -15
- crypticorn/klines/client/models/base_response_list_funding_rate_response.py +21 -15
- crypticorn/klines/client/models/base_response_list_str.py +16 -14
- crypticorn/klines/client/models/base_response_ohlcv_response.py +21 -15
- crypticorn/klines/client/models/error_response.py +23 -15
- crypticorn/klines/client/models/exchange.py +11 -11
- crypticorn/klines/client/models/funding_rate_response.py +11 -11
- crypticorn/klines/client/models/health_check_response.py +14 -12
- crypticorn/klines/client/models/history_error_response.py +11 -11
- crypticorn/klines/client/models/history_no_data_response.py +16 -16
- crypticorn/klines/client/models/history_success_response.py +16 -16
- crypticorn/klines/client/models/http_validation_error.py +14 -10
- crypticorn/klines/client/models/market.py +2 -4
- crypticorn/klines/client/models/ohlcv_response.py +22 -15
- crypticorn/klines/client/models/resolution.py +5 -7
- crypticorn/klines/client/models/response_get_history_udf_history_get.py +71 -22
- crypticorn/klines/client/models/search_symbol_response.py +22 -15
- crypticorn/klines/client/models/sort_direction.py +2 -4
- crypticorn/klines/client/models/symbol_group_response.py +5 -9
- crypticorn/klines/client/models/symbol_info_response.py +40 -24
- crypticorn/klines/client/models/symbol_type.py +5 -10
- crypticorn/klines/client/models/timeframe.py +5 -7
- crypticorn/klines/client/models/udf_config_response.py +60 -21
- crypticorn/klines/client/models/validation_error.py +19 -13
- crypticorn/klines/client/models/validation_error_loc_inner.py +32 -11
- crypticorn/klines/client/rest.py +30 -41
- crypticorn/klines/main.py +52 -15
- crypticorn/pay/__init__.py +2 -0
- crypticorn/pay/client/__init__.py +52 -0
- crypticorn/pay/client/api/__init__.py +7 -0
- crypticorn/pay/client/api/now_payments_api.py +813 -0
- crypticorn/pay/client/api/payments_api.py +799 -0
- crypticorn/pay/client/api/products_api.py +891 -0
- crypticorn/pay/client/api/status_api.py +260 -0
- crypticorn/pay/client/api_client.py +758 -0
- crypticorn/pay/client/api_response.py +20 -0
- crypticorn/pay/client/configuration.py +612 -0
- crypticorn/pay/client/exceptions.py +220 -0
- crypticorn/pay/client/models/__init__.py +32 -0
- crypticorn/pay/client/models/api_status_res.py +83 -0
- crypticorn/pay/client/models/combined_payment_history.py +101 -0
- crypticorn/pay/client/models/create_invoice_req.py +188 -0
- crypticorn/pay/client/models/create_invoice_res.py +188 -0
- crypticorn/pay/client/models/currency.py +165 -0
- crypticorn/pay/client/models/estimate_price_req.py +91 -0
- crypticorn/pay/client/models/estimate_price_res.py +102 -0
- crypticorn/pay/client/models/get_currencies_res.py +99 -0
- crypticorn/pay/client/models/get_payment_status_res.py +222 -0
- crypticorn/pay/client/models/get_payments_list_res.py +109 -0
- crypticorn/pay/client/models/http_validation_error.py +99 -0
- crypticorn/pay/client/models/min_amount_req.py +124 -0
- crypticorn/pay/client/models/min_amount_res.py +105 -0
- crypticorn/pay/client/models/now_api_status_res.py +83 -0
- crypticorn/pay/client/models/now_create_invoice_req.py +188 -0
- crypticorn/pay/client/models/now_create_invoice_res.py +188 -0
- crypticorn/pay/client/models/now_fee_structure.py +104 -0
- crypticorn/pay/client/models/now_payment_model.py +124 -0
- crypticorn/pay/client/models/now_payment_status.py +42 -0
- crypticorn/pay/client/models/now_webhook_payload.py +181 -0
- crypticorn/pay/client/models/payment.py +231 -0
- crypticorn/pay/client/models/payment_status.py +40 -0
- crypticorn/pay/client/models/product.py +87 -0
- crypticorn/pay/client/models/product_model.py +119 -0
- crypticorn/pay/client/models/product_subs_model.py +108 -0
- crypticorn/pay/client/models/services.py +34 -0
- crypticorn/pay/client/models/unified_payment_model.py +112 -0
- crypticorn/pay/client/models/validation_error.py +105 -0
- crypticorn/pay/client/models/validation_error_loc_inner.py +159 -0
- crypticorn/pay/client/py.typed +0 -0
- crypticorn/pay/client/rest.py +195 -0
- crypticorn/pay/main.py +35 -0
- crypticorn/trade/client/__init__.py +9 -4
- crypticorn/trade/client/api/__init__.py +0 -1
- crypticorn/trade/client/api/api_keys_api.py +203 -304
- crypticorn/trade/client/api/bots_api.py +177 -250
- crypticorn/trade/client/api/exchanges_api.py +38 -57
- crypticorn/trade/client/api/futures_trading_panel_api.py +223 -321
- crypticorn/trade/client/api/notifications_api.py +247 -364
- crypticorn/trade/client/api/orders_api.py +44 -63
- crypticorn/trade/client/api/status_api.py +35 -53
- crypticorn/trade/client/api/strategies_api.py +852 -64
- crypticorn/trade/client/api/trading_actions_api.py +126 -203
- crypticorn/trade/client/api_client.py +115 -154
- crypticorn/trade/client/api_response.py +2 -3
- crypticorn/trade/client/configuration.py +128 -90
- crypticorn/trade/client/exceptions.py +21 -17
- crypticorn/trade/client/models/__init__.py +9 -4
- crypticorn/trade/client/models/action_model.py +114 -50
- crypticorn/trade/client/models/api_error_identifier.py +60 -51
- crypticorn/trade/client/models/api_error_level.py +37 -0
- crypticorn/trade/client/models/api_error_type.py +37 -0
- crypticorn/trade/client/models/api_key_model.py +49 -28
- crypticorn/trade/client/models/bot_model.py +76 -31
- crypticorn/trade/client/models/bot_status.py +37 -0
- crypticorn/trade/client/models/exchange.py +3 -5
- crypticorn/trade/client/models/execution_ids.py +14 -14
- crypticorn/trade/client/models/futures_balance.py +39 -23
- crypticorn/trade/client/models/futures_trading_action.py +98 -46
- crypticorn/trade/client/models/http_validation_error.py +15 -11
- crypticorn/trade/client/models/margin_mode.py +3 -5
- crypticorn/trade/client/models/market_type.py +3 -5
- crypticorn/trade/client/models/notification_model.py +60 -27
- crypticorn/trade/client/models/notification_type.py +4 -6
- crypticorn/trade/client/models/order_model.py +125 -65
- crypticorn/trade/client/models/order_status.py +6 -8
- crypticorn/trade/client/models/post_futures_action.py +16 -12
- crypticorn/trade/client/models/strategy_exchange_info.py +11 -12
- crypticorn/trade/client/models/strategy_model.py +66 -27
- crypticorn/trade/client/models/strategy_model_input.py +160 -0
- crypticorn/trade/client/models/strategy_model_output.py +160 -0
- crypticorn/trade/client/models/tpsl.py +35 -21
- crypticorn/trade/client/models/trading_action_type.py +5 -7
- crypticorn/trade/client/models/update_notification.py +17 -13
- crypticorn/trade/client/models/validation_error.py +20 -14
- crypticorn/trade/client/models/validation_error_loc_inner.py +33 -12
- crypticorn/trade/client/rest.py +108 -170
- crypticorn/trade/main.py +26 -19
- crypticorn-2.0.0.dist-info/METADATA +74 -0
- crypticorn-2.0.0.dist-info/RECORD +226 -0
- {crypticorn-1.0.2rc3.dist-info → crypticorn-2.0.0.dist-info}/WHEEL +1 -1
- crypticorn/hive/requirements.txt +0 -4
- crypticorn/hive/utils.py +0 -109
- crypticorn/klines/requirements.txt +0 -4
- crypticorn/klines/test/test_base_response_health_check_response.py +0 -56
- crypticorn/klines/test/test_base_response_list_funding_rate_response.py +0 -59
- crypticorn/klines/test/test_base_response_list_str.py +0 -56
- crypticorn/klines/test/test_base_response_ohlcv_response.py +0 -72
- crypticorn/klines/test/test_error_response.py +0 -57
- crypticorn/klines/test/test_exchange.py +0 -56
- crypticorn/klines/test/test_funding_rate_response.py +0 -56
- crypticorn/klines/test/test_funding_rates_api.py +0 -38
- crypticorn/klines/test/test_health_check_api.py +0 -38
- crypticorn/klines/test/test_health_check_response.py +0 -52
- crypticorn/klines/test/test_history_error_response.py +0 -53
- crypticorn/klines/test/test_history_no_data_response.py +0 -69
- crypticorn/klines/test/test_history_success_response.py +0 -87
- crypticorn/klines/test/test_http_validation_error.py +0 -58
- crypticorn/klines/test/test_market.py +0 -33
- crypticorn/klines/test/test_ohlcv_data_api.py +0 -38
- crypticorn/klines/test/test_ohlcv_response.py +0 -86
- crypticorn/klines/test/test_resolution.py +0 -33
- crypticorn/klines/test/test_response_get_history_udf_history_get.py +0 -89
- crypticorn/klines/test/test_search_symbol_response.py +0 -62
- crypticorn/klines/test/test_sort_direction.py +0 -33
- crypticorn/klines/test/test_symbol_group_response.py +0 -53
- crypticorn/klines/test/test_symbol_info_response.py +0 -84
- crypticorn/klines/test/test_symbol_type.py +0 -54
- crypticorn/klines/test/test_symbols_api.py +0 -38
- crypticorn/klines/test/test_timeframe.py +0 -33
- crypticorn/klines/test/test_udf_api.py +0 -80
- crypticorn/klines/test/test_udf_config_response.py +0 -95
- crypticorn/klines/test/test_validation_error.py +0 -60
- crypticorn/klines/test/test_validation_error_loc_inner.py +0 -50
- crypticorn/trade/requirements.txt +0 -4
- crypticorn-1.0.2rc3.dist-info/LICENSE.md +0 -19
- crypticorn-1.0.2rc3.dist-info/METADATA +0 -47
- crypticorn-1.0.2rc3.dist-info/RECORD +0 -128
- /crypticorn/{klines/test/__init__.py → auth/client/py.typed} +0 -0
- {crypticorn-1.0.2rc3.dist-info → crypticorn-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
"""
|
4
|
-
|
4
|
+
Trading API
|
5
5
|
|
6
6
|
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
7
7
|
|
@@ -37,11 +37,12 @@ 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
|
+
|
45
46
|
class ApiClient:
|
46
47
|
"""Generic API client for OpenAPI client library builds.
|
47
48
|
|
@@ -60,24 +61,20 @@ class ApiClient:
|
|
60
61
|
|
61
62
|
PRIMITIVE_TYPES = (float, bool, bytes, str, int)
|
62
63
|
NATIVE_TYPES_MAPPING = {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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,
|
72
73
|
}
|
73
74
|
_pool = None
|
74
75
|
|
75
76
|
def __init__(
|
76
|
-
self,
|
77
|
-
configuration=None,
|
78
|
-
header_name=None,
|
79
|
-
header_value=None,
|
80
|
-
cookie=None
|
77
|
+
self, configuration=None, header_name=None, header_value=None, cookie=None
|
81
78
|
) -> None:
|
82
79
|
# use default configuration if none is provided
|
83
80
|
if configuration is None:
|
@@ -90,28 +87,30 @@ class ApiClient:
|
|
90
87
|
self.default_headers[header_name] = header_value
|
91
88
|
self.cookie = cookie
|
92
89
|
# Set default User-Agent.
|
93
|
-
self.user_agent =
|
90
|
+
self.user_agent = "OpenAPI-Generator/1.0.0/python"
|
94
91
|
self.client_side_validation = configuration.client_side_validation
|
95
92
|
|
96
|
-
def
|
93
|
+
async def __aenter__(self):
|
97
94
|
return self
|
98
95
|
|
99
|
-
def
|
100
|
-
|
96
|
+
async def __aexit__(self, exc_type, exc_value, traceback):
|
97
|
+
await self.close()
|
98
|
+
|
99
|
+
async def close(self):
|
100
|
+
await self.rest_client.close()
|
101
101
|
|
102
102
|
@property
|
103
103
|
def user_agent(self):
|
104
104
|
"""User agent for this API client"""
|
105
|
-
return self.default_headers[
|
105
|
+
return self.default_headers["User-Agent"]
|
106
106
|
|
107
107
|
@user_agent.setter
|
108
108
|
def user_agent(self, value):
|
109
|
-
self.default_headers[
|
109
|
+
self.default_headers["User-Agent"] = value
|
110
110
|
|
111
111
|
def set_default_header(self, header_name, header_value):
|
112
112
|
self.default_headers[header_name] = header_value
|
113
113
|
|
114
|
-
|
115
114
|
_default = None
|
116
115
|
|
117
116
|
@classmethod
|
@@ -147,12 +146,12 @@ class ApiClient:
|
|
147
146
|
header_params=None,
|
148
147
|
body=None,
|
149
148
|
post_params=None,
|
150
|
-
files=None,
|
149
|
+
files=None,
|
150
|
+
auth_settings=None,
|
151
151
|
collection_formats=None,
|
152
152
|
_host=None,
|
153
|
-
_request_auth=None
|
153
|
+
_request_auth=None,
|
154
154
|
) -> RequestSerialized:
|
155
|
-
|
156
155
|
"""Builds the HTTP request params needed by the request.
|
157
156
|
:param method: Method to call.
|
158
157
|
:param resource_path: Path to method endpoint.
|
@@ -181,35 +180,28 @@ class ApiClient:
|
|
181
180
|
header_params = header_params or {}
|
182
181
|
header_params.update(self.default_headers)
|
183
182
|
if self.cookie:
|
184
|
-
header_params[
|
183
|
+
header_params["Cookie"] = self.cookie
|
185
184
|
if header_params:
|
186
185
|
header_params = self.sanitize_for_serialization(header_params)
|
187
186
|
header_params = dict(
|
188
|
-
self.parameters_to_tuples(header_params,collection_formats)
|
187
|
+
self.parameters_to_tuples(header_params, collection_formats)
|
189
188
|
)
|
190
189
|
|
191
190
|
# path parameters
|
192
191
|
if path_params:
|
193
192
|
path_params = self.sanitize_for_serialization(path_params)
|
194
|
-
path_params = self.parameters_to_tuples(
|
195
|
-
path_params,
|
196
|
-
collection_formats
|
197
|
-
)
|
193
|
+
path_params = self.parameters_to_tuples(path_params, collection_formats)
|
198
194
|
for k, v in path_params:
|
199
195
|
# specified safe chars, encode everything
|
200
196
|
resource_path = resource_path.replace(
|
201
|
-
|
202
|
-
quote(str(v), safe=config.safe_chars_for_path_param)
|
197
|
+
"{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param)
|
203
198
|
)
|
204
199
|
|
205
200
|
# post parameters
|
206
201
|
if post_params or files:
|
207
202
|
post_params = post_params if post_params else []
|
208
203
|
post_params = self.sanitize_for_serialization(post_params)
|
209
|
-
post_params = self.parameters_to_tuples(
|
210
|
-
post_params,
|
211
|
-
collection_formats
|
212
|
-
)
|
204
|
+
post_params = self.parameters_to_tuples(post_params, collection_formats)
|
213
205
|
if files:
|
214
206
|
post_params.extend(self.files_parameters(files))
|
215
207
|
|
@@ -221,7 +213,7 @@ class ApiClient:
|
|
221
213
|
resource_path,
|
222
214
|
method,
|
223
215
|
body,
|
224
|
-
request_auth=_request_auth
|
216
|
+
request_auth=_request_auth,
|
225
217
|
)
|
226
218
|
|
227
219
|
# body
|
@@ -238,23 +230,19 @@ class ApiClient:
|
|
238
230
|
# query parameters
|
239
231
|
if query_params:
|
240
232
|
query_params = self.sanitize_for_serialization(query_params)
|
241
|
-
url_query = self.parameters_to_url_query(
|
242
|
-
query_params,
|
243
|
-
collection_formats
|
244
|
-
)
|
233
|
+
url_query = self.parameters_to_url_query(query_params, collection_formats)
|
245
234
|
url += "?" + url_query
|
246
235
|
|
247
236
|
return method, url, header_params, body, post_params
|
248
237
|
|
249
|
-
|
250
|
-
def call_api(
|
238
|
+
async def call_api(
|
251
239
|
self,
|
252
240
|
method,
|
253
241
|
url,
|
254
242
|
header_params=None,
|
255
243
|
body=None,
|
256
244
|
post_params=None,
|
257
|
-
_request_timeout=None
|
245
|
+
_request_timeout=None,
|
258
246
|
) -> rest.RESTResponse:
|
259
247
|
"""Makes the HTTP request (synchronous)
|
260
248
|
:param method: Method to call.
|
@@ -270,11 +258,13 @@ class ApiClient:
|
|
270
258
|
|
271
259
|
try:
|
272
260
|
# perform request and return response
|
273
|
-
response_data = self.rest_client.request(
|
274
|
-
method,
|
261
|
+
response_data = await self.rest_client.request(
|
262
|
+
method,
|
263
|
+
url,
|
275
264
|
headers=header_params,
|
276
|
-
body=body,
|
277
|
-
|
265
|
+
body=body,
|
266
|
+
post_params=post_params,
|
267
|
+
_request_timeout=_request_timeout,
|
278
268
|
)
|
279
269
|
|
280
270
|
except ApiException as e:
|
@@ -285,7 +275,7 @@ class ApiClient:
|
|
285
275
|
def response_deserialize(
|
286
276
|
self,
|
287
277
|
response_data: rest.RESTResponse,
|
288
|
-
response_types_map: Optional[Dict[str, ApiResponseT]]=None
|
278
|
+
response_types_map: Optional[Dict[str, ApiResponseT]] = None,
|
289
279
|
) -> ApiResponse[ApiResponseT]:
|
290
280
|
"""Deserializes response into an object.
|
291
281
|
:param response_data: RESTResponse object to be deserialized.
|
@@ -297,9 +287,15 @@ class ApiClient:
|
|
297
287
|
assert response_data.data is not None, msg
|
298
288
|
|
299
289
|
response_type = response_types_map.get(str(response_data.status), None)
|
300
|
-
if
|
290
|
+
if (
|
291
|
+
not response_type
|
292
|
+
and isinstance(response_data.status, int)
|
293
|
+
and 100 <= response_data.status <= 599
|
294
|
+
):
|
301
295
|
# if not found, look for '1XX', '2XX', etc.
|
302
|
-
response_type = response_types_map.get(
|
296
|
+
response_type = response_types_map.get(
|
297
|
+
str(response_data.status)[0] + "XX", None
|
298
|
+
)
|
303
299
|
|
304
300
|
# deserialize response data
|
305
301
|
response_text = None
|
@@ -311,12 +307,14 @@ class ApiClient:
|
|
311
307
|
return_data = self.__deserialize_file(response_data)
|
312
308
|
elif response_type is not None:
|
313
309
|
match = None
|
314
|
-
content_type = response_data.getheader(
|
310
|
+
content_type = response_data.getheader("content-type")
|
315
311
|
if content_type is not None:
|
316
312
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
317
313
|
encoding = match.group(1) if match else "utf-8"
|
318
314
|
response_text = response_data.data.decode(encoding)
|
319
|
-
return_data = self.deserialize(
|
315
|
+
return_data = self.deserialize(
|
316
|
+
response_text, response_type, content_type
|
317
|
+
)
|
320
318
|
finally:
|
321
319
|
if not 200 <= response_data.status <= 299:
|
322
320
|
raise ApiException.from_response(
|
@@ -326,10 +324,10 @@ class ApiClient:
|
|
326
324
|
)
|
327
325
|
|
328
326
|
return ApiResponse(
|
329
|
-
status_code
|
330
|
-
data
|
331
|
-
headers
|
332
|
-
raw_data
|
327
|
+
status_code=response_data.status,
|
328
|
+
data=return_data,
|
329
|
+
headers=response_data.getheaders(),
|
330
|
+
raw_data=response_data.data,
|
333
331
|
)
|
334
332
|
|
335
333
|
def sanitize_for_serialization(self, obj):
|
@@ -357,13 +355,9 @@ class ApiClient:
|
|
357
355
|
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
358
356
|
return obj
|
359
357
|
elif isinstance(obj, list):
|
360
|
-
return [
|
361
|
-
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
362
|
-
]
|
358
|
+
return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
|
363
359
|
elif isinstance(obj, tuple):
|
364
|
-
return tuple(
|
365
|
-
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
366
|
-
)
|
360
|
+
return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj)
|
367
361
|
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
368
362
|
return obj.isoformat()
|
369
363
|
elif isinstance(obj, decimal.Decimal):
|
@@ -377,17 +371,18 @@ class ApiClient:
|
|
377
371
|
# and attributes which value is not None.
|
378
372
|
# Convert attribute name to json key in
|
379
373
|
# model definition for request.
|
380
|
-
if hasattr(obj,
|
374
|
+
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")):
|
381
375
|
obj_dict = obj.to_dict()
|
382
376
|
else:
|
383
377
|
obj_dict = obj.__dict__
|
384
378
|
|
385
379
|
return {
|
386
|
-
key: self.sanitize_for_serialization(val)
|
387
|
-
for key, val in obj_dict.items()
|
380
|
+
key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()
|
388
381
|
}
|
389
382
|
|
390
|
-
def deserialize(
|
383
|
+
def deserialize(
|
384
|
+
self, response_text: str, response_type: str, content_type: Optional[str]
|
385
|
+
):
|
391
386
|
"""Deserializes response into an object.
|
392
387
|
|
393
388
|
:param response: RESTResponse object to be deserialized.
|
@@ -404,17 +399,20 @@ class ApiClient:
|
|
404
399
|
data = json.loads(response_text)
|
405
400
|
except ValueError:
|
406
401
|
data = response_text
|
407
|
-
elif re.match(
|
402
|
+
elif re.match(
|
403
|
+
r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)",
|
404
|
+
content_type,
|
405
|
+
re.IGNORECASE,
|
406
|
+
):
|
408
407
|
if response_text == "":
|
409
408
|
data = ""
|
410
409
|
else:
|
411
410
|
data = json.loads(response_text)
|
412
|
-
elif re.match(r
|
411
|
+
elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
|
413
412
|
data = response_text
|
414
413
|
else:
|
415
414
|
raise ApiException(
|
416
|
-
status=0,
|
417
|
-
reason="Unsupported content type: {0}".format(content_type)
|
415
|
+
status=0, reason="Unsupported content type: {0}".format(content_type)
|
418
416
|
)
|
419
417
|
|
420
418
|
return self.__deserialize(data, response_type)
|
@@ -431,19 +429,17 @@ class ApiClient:
|
|
431
429
|
return None
|
432
430
|
|
433
431
|
if isinstance(klass, str):
|
434
|
-
if klass.startswith(
|
435
|
-
m = re.match(r
|
432
|
+
if klass.startswith("List["):
|
433
|
+
m = re.match(r"List\[(.*)]", klass)
|
436
434
|
assert m is not None, "Malformed List type definition"
|
437
435
|
sub_kls = m.group(1)
|
438
|
-
return [self.__deserialize(sub_data, sub_kls)
|
439
|
-
for sub_data in data]
|
436
|
+
return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
|
440
437
|
|
441
|
-
if klass.startswith(
|
442
|
-
m = re.match(r
|
438
|
+
if klass.startswith("Dict["):
|
439
|
+
m = re.match(r"Dict\[([^,]*), (.*)]", klass)
|
443
440
|
assert m is not None, "Malformed Dict type definition"
|
444
441
|
sub_kls = m.group(2)
|
445
|
-
return {k: self.__deserialize(v, sub_kls)
|
446
|
-
for k, v in data.items()}
|
442
|
+
return {k: self.__deserialize(v, sub_kls) for k, v in data.items()}
|
447
443
|
|
448
444
|
# convert str to class
|
449
445
|
if klass in self.NATIVE_TYPES_MAPPING:
|
@@ -479,19 +475,18 @@ class ApiClient:
|
|
479
475
|
for k, v in params.items() if isinstance(params, dict) else params:
|
480
476
|
if k in collection_formats:
|
481
477
|
collection_format = collection_formats[k]
|
482
|
-
if collection_format ==
|
478
|
+
if collection_format == "multi":
|
483
479
|
new_params.extend((k, value) for value in v)
|
484
480
|
else:
|
485
|
-
if collection_format ==
|
486
|
-
delimiter =
|
487
|
-
elif collection_format ==
|
488
|
-
delimiter =
|
489
|
-
elif collection_format ==
|
490
|
-
delimiter =
|
481
|
+
if collection_format == "ssv":
|
482
|
+
delimiter = " "
|
483
|
+
elif collection_format == "tsv":
|
484
|
+
delimiter = "\t"
|
485
|
+
elif collection_format == "pipes":
|
486
|
+
delimiter = "|"
|
491
487
|
else: # csv is the default
|
492
|
-
delimiter =
|
493
|
-
new_params.append(
|
494
|
-
(k, delimiter.join(str(value) for value in v)))
|
488
|
+
delimiter = ","
|
489
|
+
new_params.append((k, delimiter.join(str(value) for value in v)))
|
495
490
|
else:
|
496
491
|
new_params.append((k, v))
|
497
492
|
return new_params
|
@@ -516,17 +511,17 @@ class ApiClient:
|
|
516
511
|
|
517
512
|
if k in collection_formats:
|
518
513
|
collection_format = collection_formats[k]
|
519
|
-
if collection_format ==
|
514
|
+
if collection_format == "multi":
|
520
515
|
new_params.extend((k, quote(str(value))) for value in v)
|
521
516
|
else:
|
522
|
-
if collection_format ==
|
523
|
-
delimiter =
|
524
|
-
elif collection_format ==
|
525
|
-
delimiter =
|
526
|
-
elif collection_format ==
|
527
|
-
delimiter =
|
517
|
+
if collection_format == "ssv":
|
518
|
+
delimiter = " "
|
519
|
+
elif collection_format == "tsv":
|
520
|
+
delimiter = "\t"
|
521
|
+
elif collection_format == "pipes":
|
522
|
+
delimiter = "|"
|
528
523
|
else: # csv is the default
|
529
|
-
delimiter =
|
524
|
+
delimiter = ","
|
530
525
|
new_params.append(
|
531
526
|
(k, delimiter.join(quote(str(value)) for value in v))
|
532
527
|
)
|
@@ -547,7 +542,7 @@ class ApiClient:
|
|
547
542
|
params = []
|
548
543
|
for k, v in files.items():
|
549
544
|
if isinstance(v, str):
|
550
|
-
with open(v,
|
545
|
+
with open(v, "rb") as f:
|
551
546
|
filename = os.path.basename(f.name)
|
552
547
|
filedata = f.read()
|
553
548
|
elif isinstance(v, bytes):
|
@@ -561,13 +556,8 @@ class ApiClient:
|
|
561
556
|
continue
|
562
557
|
else:
|
563
558
|
raise ValueError("Unsupported file value")
|
564
|
-
mimetype = (
|
565
|
-
|
566
|
-
or 'application/octet-stream'
|
567
|
-
)
|
568
|
-
params.append(
|
569
|
-
tuple([k, tuple([filename, filedata, mimetype])])
|
570
|
-
)
|
559
|
+
mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"
|
560
|
+
params.append(tuple([k, tuple([filename, filedata, mimetype])]))
|
571
561
|
return params
|
572
562
|
|
573
563
|
def select_header_accept(self, accepts: List[str]) -> Optional[str]:
|
@@ -580,7 +570,7 @@ class ApiClient:
|
|
580
570
|
return None
|
581
571
|
|
582
572
|
for accept in accepts:
|
583
|
-
if re.search(
|
573
|
+
if re.search("json", accept, re.IGNORECASE):
|
584
574
|
return accept
|
585
575
|
|
586
576
|
return accepts[0]
|
@@ -595,7 +585,7 @@ class ApiClient:
|
|
595
585
|
return None
|
596
586
|
|
597
587
|
for content_type in content_types:
|
598
|
-
if re.search(
|
588
|
+
if re.search("json", content_type, re.IGNORECASE):
|
599
589
|
return content_type
|
600
590
|
|
601
591
|
return content_types[0]
|
@@ -608,7 +598,7 @@ class ApiClient:
|
|
608
598
|
resource_path,
|
609
599
|
method,
|
610
600
|
body,
|
611
|
-
request_auth=None
|
601
|
+
request_auth=None,
|
612
602
|
) -> None:
|
613
603
|
"""Updates header and query params based on authentication setting.
|
614
604
|
|
@@ -627,34 +617,18 @@ class ApiClient:
|
|
627
617
|
|
628
618
|
if request_auth:
|
629
619
|
self._apply_auth_params(
|
630
|
-
headers,
|
631
|
-
queries,
|
632
|
-
resource_path,
|
633
|
-
method,
|
634
|
-
body,
|
635
|
-
request_auth
|
620
|
+
headers, queries, resource_path, method, body, request_auth
|
636
621
|
)
|
637
622
|
else:
|
638
623
|
for auth in auth_settings:
|
639
624
|
auth_setting = self.configuration.auth_settings().get(auth)
|
640
625
|
if auth_setting:
|
641
626
|
self._apply_auth_params(
|
642
|
-
headers,
|
643
|
-
queries,
|
644
|
-
resource_path,
|
645
|
-
method,
|
646
|
-
body,
|
647
|
-
auth_setting
|
627
|
+
headers, queries, resource_path, method, body, auth_setting
|
648
628
|
)
|
649
629
|
|
650
630
|
def _apply_auth_params(
|
651
|
-
self,
|
652
|
-
headers,
|
653
|
-
queries,
|
654
|
-
resource_path,
|
655
|
-
method,
|
656
|
-
body,
|
657
|
-
auth_setting
|
631
|
+
self, headers, queries, resource_path, method, body, auth_setting
|
658
632
|
) -> None:
|
659
633
|
"""Updates the request parameters based on a single auth_setting
|
660
634
|
|
@@ -666,17 +640,15 @@ class ApiClient:
|
|
666
640
|
The object type is the return value of sanitize_for_serialization().
|
667
641
|
:param auth_setting: auth settings for the endpoint
|
668
642
|
"""
|
669
|
-
if auth_setting[
|
670
|
-
headers[
|
671
|
-
elif auth_setting[
|
672
|
-
if auth_setting[
|
673
|
-
headers[auth_setting[
|
674
|
-
elif auth_setting[
|
675
|
-
queries.append((auth_setting[
|
643
|
+
if auth_setting["in"] == "cookie":
|
644
|
+
headers["Cookie"] = auth_setting["value"]
|
645
|
+
elif auth_setting["in"] == "header":
|
646
|
+
if auth_setting["type"] != "http-signature":
|
647
|
+
headers[auth_setting["key"]] = auth_setting["value"]
|
648
|
+
elif auth_setting["in"] == "query":
|
649
|
+
queries.append((auth_setting["key"], auth_setting["value"]))
|
676
650
|
else:
|
677
|
-
raise ApiValueError(
|
678
|
-
'Authentication token must be in `query` or `header`'
|
679
|
-
)
|
651
|
+
raise ApiValueError("Authentication token must be in `query` or `header`")
|
680
652
|
|
681
653
|
def __deserialize_file(self, response):
|
682
654
|
"""Deserializes body to file
|
@@ -696,10 +668,7 @@ class ApiClient:
|
|
696
668
|
|
697
669
|
content_disposition = response.getheader("Content-Disposition")
|
698
670
|
if content_disposition:
|
699
|
-
m = re.search(
|
700
|
-
r'filename=[\'"]?([^\'"\s]+)[\'"]?',
|
701
|
-
content_disposition
|
702
|
-
)
|
671
|
+
m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition)
|
703
672
|
assert m is not None, "Unexpected 'content-disposition' header value"
|
704
673
|
filename = m.group(1)
|
705
674
|
path = os.path.join(os.path.dirname(path), filename)
|
@@ -743,8 +712,7 @@ class ApiClient:
|
|
743
712
|
return string
|
744
713
|
except ValueError:
|
745
714
|
raise rest.ApiException(
|
746
|
-
status=0,
|
747
|
-
reason="Failed to parse `{0}` as date object".format(string)
|
715
|
+
status=0, reason="Failed to parse `{0}` as date object".format(string)
|
748
716
|
)
|
749
717
|
|
750
718
|
def __deserialize_datetime(self, string):
|
@@ -762,10 +730,7 @@ class ApiClient:
|
|
762
730
|
except ValueError:
|
763
731
|
raise rest.ApiException(
|
764
732
|
status=0,
|
765
|
-
reason=(
|
766
|
-
"Failed to parse `{0}` as datetime object"
|
767
|
-
.format(string)
|
768
|
-
)
|
733
|
+
reason=("Failed to parse `{0}` as datetime object".format(string)),
|
769
734
|
)
|
770
735
|
|
771
736
|
def __deserialize_enum(self, data, klass):
|
@@ -779,11 +744,7 @@ class ApiClient:
|
|
779
744
|
return klass(data)
|
780
745
|
except ValueError:
|
781
746
|
raise rest.ApiException(
|
782
|
-
status=0,
|
783
|
-
reason=(
|
784
|
-
"Failed to parse `{0}` as `{1}`"
|
785
|
-
.format(data, klass)
|
786
|
-
)
|
747
|
+
status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass))
|
787
748
|
)
|
788
749
|
|
789
750
|
def __deserialize_model(self, data, klass):
|
@@ -6,6 +6,7 @@ from pydantic import Field, StrictInt, StrictBytes, BaseModel
|
|
6
6
|
|
7
7
|
T = TypeVar("T")
|
8
8
|
|
9
|
+
|
9
10
|
class ApiResponse(BaseModel, Generic[T]):
|
10
11
|
"""
|
11
12
|
API response object
|
@@ -16,6 +17,4 @@ class ApiResponse(BaseModel, Generic[T]):
|
|
16
17
|
data: T = Field(description="Deserialized data given the data type")
|
17
18
|
raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
|
18
19
|
|
19
|
-
model_config = {
|
20
|
-
"arbitrary_types_allowed": True
|
21
|
-
}
|
20
|
+
model_config = {"arbitrary_types_allowed": True}
|