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
@@ -37,11 +37,12 @@ from crypticorn.klines.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,7 +87,7 @@ 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
93
|
def __enter__(self):
|
@@ -102,16 +99,15 @@ class ApiClient:
|
|
102
99
|
@property
|
103
100
|
def user_agent(self):
|
104
101
|
"""User agent for this API client"""
|
105
|
-
return self.default_headers[
|
102
|
+
return self.default_headers["User-Agent"]
|
106
103
|
|
107
104
|
@user_agent.setter
|
108
105
|
def user_agent(self, value):
|
109
|
-
self.default_headers[
|
106
|
+
self.default_headers["User-Agent"] = value
|
110
107
|
|
111
108
|
def set_default_header(self, header_name, header_value):
|
112
109
|
self.default_headers[header_name] = header_value
|
113
110
|
|
114
|
-
|
115
111
|
_default = None
|
116
112
|
|
117
113
|
@classmethod
|
@@ -147,12 +143,12 @@ class ApiClient:
|
|
147
143
|
header_params=None,
|
148
144
|
body=None,
|
149
145
|
post_params=None,
|
150
|
-
files=None,
|
146
|
+
files=None,
|
147
|
+
auth_settings=None,
|
151
148
|
collection_formats=None,
|
152
149
|
_host=None,
|
153
|
-
_request_auth=None
|
150
|
+
_request_auth=None,
|
154
151
|
) -> RequestSerialized:
|
155
|
-
|
156
152
|
"""Builds the HTTP request params needed by the request.
|
157
153
|
:param method: Method to call.
|
158
154
|
:param resource_path: Path to method endpoint.
|
@@ -181,35 +177,28 @@ class ApiClient:
|
|
181
177
|
header_params = header_params or {}
|
182
178
|
header_params.update(self.default_headers)
|
183
179
|
if self.cookie:
|
184
|
-
header_params[
|
180
|
+
header_params["Cookie"] = self.cookie
|
185
181
|
if header_params:
|
186
182
|
header_params = self.sanitize_for_serialization(header_params)
|
187
183
|
header_params = dict(
|
188
|
-
self.parameters_to_tuples(header_params,collection_formats)
|
184
|
+
self.parameters_to_tuples(header_params, collection_formats)
|
189
185
|
)
|
190
186
|
|
191
187
|
# path parameters
|
192
188
|
if path_params:
|
193
189
|
path_params = self.sanitize_for_serialization(path_params)
|
194
|
-
path_params = self.parameters_to_tuples(
|
195
|
-
path_params,
|
196
|
-
collection_formats
|
197
|
-
)
|
190
|
+
path_params = self.parameters_to_tuples(path_params, collection_formats)
|
198
191
|
for k, v in path_params:
|
199
192
|
# specified safe chars, encode everything
|
200
193
|
resource_path = resource_path.replace(
|
201
|
-
|
202
|
-
quote(str(v), safe=config.safe_chars_for_path_param)
|
194
|
+
"{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param)
|
203
195
|
)
|
204
196
|
|
205
197
|
# post parameters
|
206
198
|
if post_params or files:
|
207
199
|
post_params = post_params if post_params else []
|
208
200
|
post_params = self.sanitize_for_serialization(post_params)
|
209
|
-
post_params = self.parameters_to_tuples(
|
210
|
-
post_params,
|
211
|
-
collection_formats
|
212
|
-
)
|
201
|
+
post_params = self.parameters_to_tuples(post_params, collection_formats)
|
213
202
|
if files:
|
214
203
|
post_params.extend(self.files_parameters(files))
|
215
204
|
|
@@ -221,7 +210,7 @@ class ApiClient:
|
|
221
210
|
resource_path,
|
222
211
|
method,
|
223
212
|
body,
|
224
|
-
request_auth=_request_auth
|
213
|
+
request_auth=_request_auth,
|
225
214
|
)
|
226
215
|
|
227
216
|
# body
|
@@ -238,15 +227,11 @@ class ApiClient:
|
|
238
227
|
# query parameters
|
239
228
|
if query_params:
|
240
229
|
query_params = self.sanitize_for_serialization(query_params)
|
241
|
-
url_query = self.parameters_to_url_query(
|
242
|
-
query_params,
|
243
|
-
collection_formats
|
244
|
-
)
|
230
|
+
url_query = self.parameters_to_url_query(query_params, collection_formats)
|
245
231
|
url += "?" + url_query
|
246
232
|
|
247
233
|
return method, url, header_params, body, post_params
|
248
234
|
|
249
|
-
|
250
235
|
def call_api(
|
251
236
|
self,
|
252
237
|
method,
|
@@ -254,7 +239,7 @@ class ApiClient:
|
|
254
239
|
header_params=None,
|
255
240
|
body=None,
|
256
241
|
post_params=None,
|
257
|
-
_request_timeout=None
|
242
|
+
_request_timeout=None,
|
258
243
|
) -> rest.RESTResponse:
|
259
244
|
"""Makes the HTTP request (synchronous)
|
260
245
|
:param method: Method to call.
|
@@ -271,10 +256,12 @@ class ApiClient:
|
|
271
256
|
try:
|
272
257
|
# perform request and return response
|
273
258
|
response_data = self.rest_client.request(
|
274
|
-
method,
|
259
|
+
method,
|
260
|
+
url,
|
275
261
|
headers=header_params,
|
276
|
-
body=body,
|
277
|
-
|
262
|
+
body=body,
|
263
|
+
post_params=post_params,
|
264
|
+
_request_timeout=_request_timeout,
|
278
265
|
)
|
279
266
|
|
280
267
|
except ApiException as e:
|
@@ -285,7 +272,7 @@ class ApiClient:
|
|
285
272
|
def response_deserialize(
|
286
273
|
self,
|
287
274
|
response_data: rest.RESTResponse,
|
288
|
-
response_types_map: Optional[Dict[str, ApiResponseT]]=None
|
275
|
+
response_types_map: Optional[Dict[str, ApiResponseT]] = None,
|
289
276
|
) -> ApiResponse[ApiResponseT]:
|
290
277
|
"""Deserializes response into an object.
|
291
278
|
:param response_data: RESTResponse object to be deserialized.
|
@@ -297,9 +284,15 @@ class ApiClient:
|
|
297
284
|
assert response_data.data is not None, msg
|
298
285
|
|
299
286
|
response_type = response_types_map.get(str(response_data.status), None)
|
300
|
-
if
|
287
|
+
if (
|
288
|
+
not response_type
|
289
|
+
and isinstance(response_data.status, int)
|
290
|
+
and 100 <= response_data.status <= 599
|
291
|
+
):
|
301
292
|
# if not found, look for '1XX', '2XX', etc.
|
302
|
-
response_type = response_types_map.get(
|
293
|
+
response_type = response_types_map.get(
|
294
|
+
str(response_data.status)[0] + "XX", None
|
295
|
+
)
|
303
296
|
|
304
297
|
# deserialize response data
|
305
298
|
response_text = None
|
@@ -311,12 +304,14 @@ class ApiClient:
|
|
311
304
|
return_data = self.__deserialize_file(response_data)
|
312
305
|
elif response_type is not None:
|
313
306
|
match = None
|
314
|
-
content_type = response_data.getheader(
|
307
|
+
content_type = response_data.getheader("content-type")
|
315
308
|
if content_type is not None:
|
316
309
|
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
317
310
|
encoding = match.group(1) if match else "utf-8"
|
318
311
|
response_text = response_data.data.decode(encoding)
|
319
|
-
return_data = self.deserialize(
|
312
|
+
return_data = self.deserialize(
|
313
|
+
response_text, response_type, content_type
|
314
|
+
)
|
320
315
|
finally:
|
321
316
|
if not 200 <= response_data.status <= 299:
|
322
317
|
raise ApiException.from_response(
|
@@ -326,10 +321,10 @@ class ApiClient:
|
|
326
321
|
)
|
327
322
|
|
328
323
|
return ApiResponse(
|
329
|
-
status_code
|
330
|
-
data
|
331
|
-
headers
|
332
|
-
raw_data
|
324
|
+
status_code=response_data.status,
|
325
|
+
data=return_data,
|
326
|
+
headers=response_data.getheaders(),
|
327
|
+
raw_data=response_data.data,
|
333
328
|
)
|
334
329
|
|
335
330
|
def sanitize_for_serialization(self, obj):
|
@@ -357,13 +352,9 @@ class ApiClient:
|
|
357
352
|
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
358
353
|
return obj
|
359
354
|
elif isinstance(obj, list):
|
360
|
-
return [
|
361
|
-
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
362
|
-
]
|
355
|
+
return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
|
363
356
|
elif isinstance(obj, tuple):
|
364
|
-
return tuple(
|
365
|
-
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
366
|
-
)
|
357
|
+
return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj)
|
367
358
|
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
368
359
|
return obj.isoformat()
|
369
360
|
elif isinstance(obj, decimal.Decimal):
|
@@ -377,17 +368,18 @@ class ApiClient:
|
|
377
368
|
# and attributes which value is not None.
|
378
369
|
# Convert attribute name to json key in
|
379
370
|
# model definition for request.
|
380
|
-
if hasattr(obj,
|
371
|
+
if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")):
|
381
372
|
obj_dict = obj.to_dict()
|
382
373
|
else:
|
383
374
|
obj_dict = obj.__dict__
|
384
375
|
|
385
376
|
return {
|
386
|
-
key: self.sanitize_for_serialization(val)
|
387
|
-
for key, val in obj_dict.items()
|
377
|
+
key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()
|
388
378
|
}
|
389
379
|
|
390
|
-
def deserialize(
|
380
|
+
def deserialize(
|
381
|
+
self, response_text: str, response_type: str, content_type: Optional[str]
|
382
|
+
):
|
391
383
|
"""Deserializes response into an object.
|
392
384
|
|
393
385
|
:param response: RESTResponse object to be deserialized.
|
@@ -404,17 +396,20 @@ class ApiClient:
|
|
404
396
|
data = json.loads(response_text)
|
405
397
|
except ValueError:
|
406
398
|
data = response_text
|
407
|
-
elif re.match(
|
399
|
+
elif re.match(
|
400
|
+
r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)",
|
401
|
+
content_type,
|
402
|
+
re.IGNORECASE,
|
403
|
+
):
|
408
404
|
if response_text == "":
|
409
405
|
data = ""
|
410
406
|
else:
|
411
407
|
data = json.loads(response_text)
|
412
|
-
elif re.match(r
|
408
|
+
elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
|
413
409
|
data = response_text
|
414
410
|
else:
|
415
411
|
raise ApiException(
|
416
|
-
status=0,
|
417
|
-
reason="Unsupported content type: {0}".format(content_type)
|
412
|
+
status=0, reason="Unsupported content type: {0}".format(content_type)
|
418
413
|
)
|
419
414
|
|
420
415
|
return self.__deserialize(data, response_type)
|
@@ -431,19 +426,17 @@ class ApiClient:
|
|
431
426
|
return None
|
432
427
|
|
433
428
|
if isinstance(klass, str):
|
434
|
-
if klass.startswith(
|
435
|
-
m = re.match(r
|
429
|
+
if klass.startswith("List["):
|
430
|
+
m = re.match(r"List\[(.*)]", klass)
|
436
431
|
assert m is not None, "Malformed List type definition"
|
437
432
|
sub_kls = m.group(1)
|
438
|
-
return [self.__deserialize(sub_data, sub_kls)
|
439
|
-
for sub_data in data]
|
433
|
+
return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
|
440
434
|
|
441
|
-
if klass.startswith(
|
442
|
-
m = re.match(r
|
435
|
+
if klass.startswith("Dict["):
|
436
|
+
m = re.match(r"Dict\[([^,]*), (.*)]", klass)
|
443
437
|
assert m is not None, "Malformed Dict type definition"
|
444
438
|
sub_kls = m.group(2)
|
445
|
-
return {k: self.__deserialize(v, sub_kls)
|
446
|
-
for k, v in data.items()}
|
439
|
+
return {k: self.__deserialize(v, sub_kls) for k, v in data.items()}
|
447
440
|
|
448
441
|
# convert str to class
|
449
442
|
if klass in self.NATIVE_TYPES_MAPPING:
|
@@ -479,19 +472,18 @@ class ApiClient:
|
|
479
472
|
for k, v in params.items() if isinstance(params, dict) else params:
|
480
473
|
if k in collection_formats:
|
481
474
|
collection_format = collection_formats[k]
|
482
|
-
if collection_format ==
|
475
|
+
if collection_format == "multi":
|
483
476
|
new_params.extend((k, value) for value in v)
|
484
477
|
else:
|
485
|
-
if collection_format ==
|
486
|
-
delimiter =
|
487
|
-
elif collection_format ==
|
488
|
-
delimiter =
|
489
|
-
elif collection_format ==
|
490
|
-
delimiter =
|
478
|
+
if collection_format == "ssv":
|
479
|
+
delimiter = " "
|
480
|
+
elif collection_format == "tsv":
|
481
|
+
delimiter = "\t"
|
482
|
+
elif collection_format == "pipes":
|
483
|
+
delimiter = "|"
|
491
484
|
else: # csv is the default
|
492
|
-
delimiter =
|
493
|
-
new_params.append(
|
494
|
-
(k, delimiter.join(str(value) for value in v)))
|
485
|
+
delimiter = ","
|
486
|
+
new_params.append((k, delimiter.join(str(value) for value in v)))
|
495
487
|
else:
|
496
488
|
new_params.append((k, v))
|
497
489
|
return new_params
|
@@ -516,17 +508,17 @@ class ApiClient:
|
|
516
508
|
|
517
509
|
if k in collection_formats:
|
518
510
|
collection_format = collection_formats[k]
|
519
|
-
if collection_format ==
|
511
|
+
if collection_format == "multi":
|
520
512
|
new_params.extend((k, quote(str(value))) for value in v)
|
521
513
|
else:
|
522
|
-
if collection_format ==
|
523
|
-
delimiter =
|
524
|
-
elif collection_format ==
|
525
|
-
delimiter =
|
526
|
-
elif collection_format ==
|
527
|
-
delimiter =
|
514
|
+
if collection_format == "ssv":
|
515
|
+
delimiter = " "
|
516
|
+
elif collection_format == "tsv":
|
517
|
+
delimiter = "\t"
|
518
|
+
elif collection_format == "pipes":
|
519
|
+
delimiter = "|"
|
528
520
|
else: # csv is the default
|
529
|
-
delimiter =
|
521
|
+
delimiter = ","
|
530
522
|
new_params.append(
|
531
523
|
(k, delimiter.join(quote(str(value)) for value in v))
|
532
524
|
)
|
@@ -547,7 +539,7 @@ class ApiClient:
|
|
547
539
|
params = []
|
548
540
|
for k, v in files.items():
|
549
541
|
if isinstance(v, str):
|
550
|
-
with open(v,
|
542
|
+
with open(v, "rb") as f:
|
551
543
|
filename = os.path.basename(f.name)
|
552
544
|
filedata = f.read()
|
553
545
|
elif isinstance(v, bytes):
|
@@ -561,13 +553,8 @@ class ApiClient:
|
|
561
553
|
continue
|
562
554
|
else:
|
563
555
|
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
|
-
)
|
556
|
+
mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"
|
557
|
+
params.append(tuple([k, tuple([filename, filedata, mimetype])]))
|
571
558
|
return params
|
572
559
|
|
573
560
|
def select_header_accept(self, accepts: List[str]) -> Optional[str]:
|
@@ -580,7 +567,7 @@ class ApiClient:
|
|
580
567
|
return None
|
581
568
|
|
582
569
|
for accept in accepts:
|
583
|
-
if re.search(
|
570
|
+
if re.search("json", accept, re.IGNORECASE):
|
584
571
|
return accept
|
585
572
|
|
586
573
|
return accepts[0]
|
@@ -595,7 +582,7 @@ class ApiClient:
|
|
595
582
|
return None
|
596
583
|
|
597
584
|
for content_type in content_types:
|
598
|
-
if re.search(
|
585
|
+
if re.search("json", content_type, re.IGNORECASE):
|
599
586
|
return content_type
|
600
587
|
|
601
588
|
return content_types[0]
|
@@ -608,7 +595,7 @@ class ApiClient:
|
|
608
595
|
resource_path,
|
609
596
|
method,
|
610
597
|
body,
|
611
|
-
request_auth=None
|
598
|
+
request_auth=None,
|
612
599
|
) -> None:
|
613
600
|
"""Updates header and query params based on authentication setting.
|
614
601
|
|
@@ -627,34 +614,18 @@ class ApiClient:
|
|
627
614
|
|
628
615
|
if request_auth:
|
629
616
|
self._apply_auth_params(
|
630
|
-
headers,
|
631
|
-
queries,
|
632
|
-
resource_path,
|
633
|
-
method,
|
634
|
-
body,
|
635
|
-
request_auth
|
617
|
+
headers, queries, resource_path, method, body, request_auth
|
636
618
|
)
|
637
619
|
else:
|
638
620
|
for auth in auth_settings:
|
639
621
|
auth_setting = self.configuration.auth_settings().get(auth)
|
640
622
|
if auth_setting:
|
641
623
|
self._apply_auth_params(
|
642
|
-
headers,
|
643
|
-
queries,
|
644
|
-
resource_path,
|
645
|
-
method,
|
646
|
-
body,
|
647
|
-
auth_setting
|
624
|
+
headers, queries, resource_path, method, body, auth_setting
|
648
625
|
)
|
649
626
|
|
650
627
|
def _apply_auth_params(
|
651
|
-
self,
|
652
|
-
headers,
|
653
|
-
queries,
|
654
|
-
resource_path,
|
655
|
-
method,
|
656
|
-
body,
|
657
|
-
auth_setting
|
628
|
+
self, headers, queries, resource_path, method, body, auth_setting
|
658
629
|
) -> None:
|
659
630
|
"""Updates the request parameters based on a single auth_setting
|
660
631
|
|
@@ -666,17 +637,15 @@ class ApiClient:
|
|
666
637
|
The object type is the return value of sanitize_for_serialization().
|
667
638
|
:param auth_setting: auth settings for the endpoint
|
668
639
|
"""
|
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[
|
640
|
+
if auth_setting["in"] == "cookie":
|
641
|
+
headers["Cookie"] = auth_setting["value"]
|
642
|
+
elif auth_setting["in"] == "header":
|
643
|
+
if auth_setting["type"] != "http-signature":
|
644
|
+
headers[auth_setting["key"]] = auth_setting["value"]
|
645
|
+
elif auth_setting["in"] == "query":
|
646
|
+
queries.append((auth_setting["key"], auth_setting["value"]))
|
676
647
|
else:
|
677
|
-
raise ApiValueError(
|
678
|
-
'Authentication token must be in `query` or `header`'
|
679
|
-
)
|
648
|
+
raise ApiValueError("Authentication token must be in `query` or `header`")
|
680
649
|
|
681
650
|
def __deserialize_file(self, response):
|
682
651
|
"""Deserializes body to file
|
@@ -696,10 +665,7 @@ class ApiClient:
|
|
696
665
|
|
697
666
|
content_disposition = response.getheader("Content-Disposition")
|
698
667
|
if content_disposition:
|
699
|
-
m = re.search(
|
700
|
-
r'filename=[\'"]?([^\'"\s]+)[\'"]?',
|
701
|
-
content_disposition
|
702
|
-
)
|
668
|
+
m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition)
|
703
669
|
assert m is not None, "Unexpected 'content-disposition' header value"
|
704
670
|
filename = m.group(1)
|
705
671
|
path = os.path.join(os.path.dirname(path), filename)
|
@@ -743,8 +709,7 @@ class ApiClient:
|
|
743
709
|
return string
|
744
710
|
except ValueError:
|
745
711
|
raise rest.ApiException(
|
746
|
-
status=0,
|
747
|
-
reason="Failed to parse `{0}` as date object".format(string)
|
712
|
+
status=0, reason="Failed to parse `{0}` as date object".format(string)
|
748
713
|
)
|
749
714
|
|
750
715
|
def __deserialize_datetime(self, string):
|
@@ -762,10 +727,7 @@ class ApiClient:
|
|
762
727
|
except ValueError:
|
763
728
|
raise rest.ApiException(
|
764
729
|
status=0,
|
765
|
-
reason=(
|
766
|
-
"Failed to parse `{0}` as datetime object"
|
767
|
-
.format(string)
|
768
|
-
)
|
730
|
+
reason=("Failed to parse `{0}` as datetime object".format(string)),
|
769
731
|
)
|
770
732
|
|
771
733
|
def __deserialize_enum(self, data, klass):
|
@@ -779,11 +741,7 @@ class ApiClient:
|
|
779
741
|
return klass(data)
|
780
742
|
except ValueError:
|
781
743
|
raise rest.ApiException(
|
782
|
-
status=0,
|
783
|
-
reason=(
|
784
|
-
"Failed to parse `{0}` as `{1}`"
|
785
|
-
.format(data, klass)
|
786
|
-
)
|
744
|
+
status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass))
|
787
745
|
)
|
788
746
|
|
789
747
|
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}
|