crypticorn 1.0.1__py3-none-any.whl → 1.0.2rc2__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.
Files changed (132) hide show
  1. crypticorn/__init__.py +3 -3
  2. crypticorn/client.py +722 -0
  3. crypticorn/hive/__init__.py +1 -0
  4. crypticorn/{api.py → hive/main.py} +6 -6
  5. crypticorn/hive/requirements.txt +4 -0
  6. crypticorn/{utils.py → hive/utils.py} +2 -2
  7. crypticorn/klines/__init__.py +2 -0
  8. crypticorn/klines/client/__init__.py +62 -0
  9. crypticorn/klines/client/api/__init__.py +9 -0
  10. crypticorn/klines/client/api/funding_rates_api.py +362 -0
  11. crypticorn/klines/client/api/health_check_api.py +281 -0
  12. crypticorn/klines/client/api/ohlcv_data_api.py +409 -0
  13. crypticorn/klines/client/api/symbols_api.py +308 -0
  14. crypticorn/klines/client/api/udf_api.py +1929 -0
  15. crypticorn/klines/client/api_client.py +797 -0
  16. crypticorn/klines/client/api_response.py +21 -0
  17. crypticorn/klines/client/configuration.py +565 -0
  18. crypticorn/klines/client/exceptions.py +216 -0
  19. crypticorn/klines/client/models/__init__.py +41 -0
  20. crypticorn/klines/client/models/base_response_health_check_response.py +108 -0
  21. crypticorn/klines/client/models/base_response_list_funding_rate_response.py +112 -0
  22. crypticorn/klines/client/models/base_response_list_str.py +104 -0
  23. crypticorn/klines/client/models/base_response_ohlcv_response.py +108 -0
  24. crypticorn/klines/client/models/error_response.py +101 -0
  25. crypticorn/{models/deleted.py → klines/client/models/exchange.py} +15 -11
  26. crypticorn/klines/client/models/funding_rate_response.py +92 -0
  27. crypticorn/klines/client/models/health_check_response.py +89 -0
  28. crypticorn/{models/create_api_key_response.py → klines/client/models/history_error_response.py} +12 -22
  29. crypticorn/klines/client/models/history_no_data_response.py +99 -0
  30. crypticorn/klines/client/models/history_success_response.py +99 -0
  31. crypticorn/klines/client/models/http_validation_error.py +95 -0
  32. crypticorn/klines/client/models/market.py +37 -0
  33. crypticorn/klines/client/models/ohlcv_response.py +98 -0
  34. crypticorn/klines/client/models/resolution.py +40 -0
  35. crypticorn/klines/client/models/response_get_history_udf_history_get.py +149 -0
  36. crypticorn/klines/client/models/search_symbol_response.py +97 -0
  37. crypticorn/klines/client/models/sort_direction.py +37 -0
  38. crypticorn/{models/futures_balance_error.py → klines/client/models/symbol_group_response.py} +12 -14
  39. crypticorn/klines/client/models/symbol_info_response.py +115 -0
  40. crypticorn/{models/id.py → klines/client/models/symbol_type.py} +13 -11
  41. crypticorn/klines/client/models/timeframe.py +40 -0
  42. crypticorn/klines/client/models/udf_config_response.py +121 -0
  43. crypticorn/klines/client/models/validation_error.py +99 -0
  44. crypticorn/{models/get_futures_balance200_response_inner.py → klines/client/models/validation_error_loc_inner.py} +39 -35
  45. crypticorn/klines/client/py.typed +0 -0
  46. crypticorn/klines/client/rest.py +257 -0
  47. crypticorn/klines/main.py +42 -0
  48. crypticorn/klines/requirements.txt +4 -0
  49. crypticorn/klines/test/__init__.py +0 -0
  50. crypticorn/klines/test/test_base_response_health_check_response.py +56 -0
  51. crypticorn/klines/test/test_base_response_list_funding_rate_response.py +59 -0
  52. crypticorn/klines/test/test_base_response_list_str.py +56 -0
  53. crypticorn/klines/test/test_base_response_ohlcv_response.py +72 -0
  54. crypticorn/klines/test/test_error_response.py +57 -0
  55. crypticorn/klines/test/test_exchange.py +56 -0
  56. crypticorn/klines/test/test_funding_rate_response.py +56 -0
  57. crypticorn/klines/test/test_funding_rates_api.py +38 -0
  58. crypticorn/klines/test/test_health_check_api.py +38 -0
  59. crypticorn/klines/test/test_health_check_response.py +52 -0
  60. crypticorn/klines/test/test_history_error_response.py +53 -0
  61. crypticorn/klines/test/test_history_no_data_response.py +69 -0
  62. crypticorn/klines/test/test_history_success_response.py +87 -0
  63. crypticorn/klines/test/test_http_validation_error.py +58 -0
  64. crypticorn/klines/test/test_market.py +33 -0
  65. crypticorn/klines/test/test_ohlcv_data_api.py +38 -0
  66. crypticorn/klines/test/test_ohlcv_response.py +86 -0
  67. crypticorn/klines/test/test_resolution.py +33 -0
  68. crypticorn/klines/test/test_response_get_history_udf_history_get.py +89 -0
  69. crypticorn/klines/test/test_search_symbol_response.py +62 -0
  70. crypticorn/klines/test/test_sort_direction.py +33 -0
  71. crypticorn/klines/test/test_symbol_group_response.py +53 -0
  72. crypticorn/klines/test/test_symbol_info_response.py +84 -0
  73. crypticorn/klines/test/test_symbol_type.py +54 -0
  74. crypticorn/klines/test/test_symbols_api.py +38 -0
  75. crypticorn/klines/test/test_timeframe.py +33 -0
  76. crypticorn/klines/test/test_udf_api.py +80 -0
  77. crypticorn/klines/test/test_udf_config_response.py +95 -0
  78. crypticorn/klines/test/test_validation_error.py +60 -0
  79. crypticorn/klines/test/test_validation_error_loc_inner.py +50 -0
  80. crypticorn/trade/__init__.py +2 -0
  81. crypticorn/trade/client/__init__.py +63 -0
  82. crypticorn/trade/client/api/__init__.py +13 -0
  83. crypticorn/trade/client/api/api_keys_api.py +1468 -0
  84. crypticorn/trade/client/api/bots_api.py +1211 -0
  85. crypticorn/trade/client/api/exchanges_api.py +297 -0
  86. crypticorn/trade/client/api/futures_trading_panel_api.py +1463 -0
  87. crypticorn/trade/client/api/notifications_api.py +1767 -0
  88. crypticorn/trade/client/api/orders_api.py +331 -0
  89. crypticorn/trade/client/api/status_api.py +278 -0
  90. crypticorn/trade/client/api/strategies_api.py +331 -0
  91. crypticorn/trade/client/api/trading_actions_api.py +898 -0
  92. crypticorn/trade/client/api_client.py +797 -0
  93. crypticorn/trade/client/api_response.py +21 -0
  94. crypticorn/trade/client/configuration.py +574 -0
  95. crypticorn/trade/client/exceptions.py +216 -0
  96. crypticorn/trade/client/models/__init__.py +38 -0
  97. crypticorn/{models → trade/client/models}/action_model.py +17 -20
  98. crypticorn/{models → trade/client/models}/api_error_identifier.py +3 -1
  99. crypticorn/{models → trade/client/models}/api_key_model.py +5 -8
  100. crypticorn/{models → trade/client/models}/bot_model.py +15 -11
  101. crypticorn/{models → trade/client/models}/futures_trading_action.py +12 -12
  102. crypticorn/{models → trade/client/models}/http_validation_error.py +1 -1
  103. crypticorn/{models → trade/client/models}/notification_model.py +8 -6
  104. crypticorn/{models → trade/client/models}/order_model.py +12 -15
  105. crypticorn/{models → trade/client/models}/post_futures_action.py +1 -1
  106. crypticorn/{models → trade/client/models}/strategy_exchange_info.py +1 -1
  107. crypticorn/{models → trade/client/models}/strategy_model.py +6 -2
  108. crypticorn/{models → trade/client/models}/validation_error.py +1 -1
  109. crypticorn/trade/client/py.typed +0 -0
  110. crypticorn/trade/client/rest.py +257 -0
  111. crypticorn/trade/main.py +39 -0
  112. crypticorn/trade/requirements.txt +4 -0
  113. crypticorn-1.0.2rc2.dist-info/METADATA +47 -0
  114. crypticorn-1.0.2rc2.dist-info/RECORD +128 -0
  115. {crypticorn-1.0.1.dist-info → crypticorn-1.0.2rc2.dist-info}/WHEEL +1 -1
  116. crypticorn/models/__init__.py +0 -31
  117. crypticorn/models/modified.py +0 -87
  118. crypticorn-1.0.1.dist-info/METADATA +0 -40
  119. crypticorn-1.0.1.dist-info/RECORD +0 -38
  120. /crypticorn/{models → trade/client/models}/exchange.py +0 -0
  121. /crypticorn/{models → trade/client/models}/execution_ids.py +0 -0
  122. /crypticorn/{models → trade/client/models}/futures_balance.py +0 -0
  123. /crypticorn/{models → trade/client/models}/margin_mode.py +0 -0
  124. /crypticorn/{models → trade/client/models}/market_type.py +0 -0
  125. /crypticorn/{models → trade/client/models}/notification_type.py +0 -0
  126. /crypticorn/{models → trade/client/models}/order_status.py +0 -0
  127. /crypticorn/{models → trade/client/models}/tpsl.py +0 -0
  128. /crypticorn/{models → trade/client/models}/trading_action_type.py +0 -0
  129. /crypticorn/{models → trade/client/models}/update_notification.py +0 -0
  130. /crypticorn/{models → trade/client/models}/validation_error_loc_inner.py +0 -0
  131. {crypticorn-1.0.1.dist-info → crypticorn-1.0.2rc2.dist-info}/LICENSE.md +0 -0
  132. {crypticorn-1.0.1.dist-info → crypticorn-1.0.2rc2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,565 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Klines Service API
5
+
6
+ API for retrieving OHLCV data, funding rates, and symbol information from Binance. ## WebSocket Support Connect to `/ws` to receive real-time OHLCV updates. Example subscription message: ```json { \"action\": \"subscribe\", \"market\": \"spot\", \"symbol\": \"BTCUSDT\", \"timeframe\": \"15m\" } ```
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ import copy
16
+ import http.client as httplib
17
+ import logging
18
+ from logging import FileHandler
19
+ import multiprocessing
20
+ import sys
21
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
22
+ from typing_extensions import NotRequired, Self
23
+
24
+ import urllib3
25
+
26
+
27
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
28
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
29
+ 'minimum', 'exclusiveMinimum', 'maxLength',
30
+ 'minLength', 'pattern', 'maxItems', 'minItems'
31
+ }
32
+
33
+ ServerVariablesT = Dict[str, str]
34
+
35
+ GenericAuthSetting = TypedDict(
36
+ "GenericAuthSetting",
37
+ {
38
+ "type": str,
39
+ "in": str,
40
+ "key": str,
41
+ "value": str,
42
+ },
43
+ )
44
+
45
+
46
+ OAuth2AuthSetting = TypedDict(
47
+ "OAuth2AuthSetting",
48
+ {
49
+ "type": Literal["oauth2"],
50
+ "in": Literal["header"],
51
+ "key": Literal["Authorization"],
52
+ "value": str,
53
+ },
54
+ )
55
+
56
+
57
+ APIKeyAuthSetting = TypedDict(
58
+ "APIKeyAuthSetting",
59
+ {
60
+ "type": Literal["api_key"],
61
+ "in": str,
62
+ "key": str,
63
+ "value": Optional[str],
64
+ },
65
+ )
66
+
67
+
68
+ BasicAuthSetting = TypedDict(
69
+ "BasicAuthSetting",
70
+ {
71
+ "type": Literal["basic"],
72
+ "in": Literal["header"],
73
+ "key": Literal["Authorization"],
74
+ "value": Optional[str],
75
+ },
76
+ )
77
+
78
+
79
+ BearerFormatAuthSetting = TypedDict(
80
+ "BearerFormatAuthSetting",
81
+ {
82
+ "type": Literal["bearer"],
83
+ "in": Literal["header"],
84
+ "format": Literal["JWT"],
85
+ "key": Literal["Authorization"],
86
+ "value": str,
87
+ },
88
+ )
89
+
90
+
91
+ BearerAuthSetting = TypedDict(
92
+ "BearerAuthSetting",
93
+ {
94
+ "type": Literal["bearer"],
95
+ "in": Literal["header"],
96
+ "key": Literal["Authorization"],
97
+ "value": str,
98
+ },
99
+ )
100
+
101
+
102
+ HTTPSignatureAuthSetting = TypedDict(
103
+ "HTTPSignatureAuthSetting",
104
+ {
105
+ "type": Literal["http-signature"],
106
+ "in": Literal["header"],
107
+ "key": Literal["Authorization"],
108
+ "value": None,
109
+ },
110
+ )
111
+
112
+
113
+ AuthSettings = TypedDict(
114
+ "AuthSettings",
115
+ {
116
+ },
117
+ total=False,
118
+ )
119
+
120
+
121
+ class HostSettingVariable(TypedDict):
122
+ description: str
123
+ default_value: str
124
+ enum_values: List[str]
125
+
126
+
127
+ class HostSetting(TypedDict):
128
+ url: str
129
+ description: str
130
+ variables: NotRequired[Dict[str, HostSettingVariable]]
131
+
132
+
133
+ class Configuration:
134
+ """This class contains various settings of the API client.
135
+
136
+ :param host: Base url.
137
+ :param ignore_operation_servers
138
+ Boolean to ignore operation servers for the API client.
139
+ Config will use `host` as the base url regardless of the operation servers.
140
+ :param api_key: Dict to store API key(s).
141
+ Each entry in the dict specifies an API key.
142
+ The dict key is the name of the security scheme in the OAS specification.
143
+ The dict value is the API key secret.
144
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
145
+ The dict key is the name of the security scheme in the OAS specification.
146
+ The dict value is an API key prefix when generating the auth data.
147
+ :param username: Username for HTTP basic authentication.
148
+ :param password: Password for HTTP basic authentication.
149
+ :param access_token: Access token.
150
+ :param server_index: Index to servers configuration.
151
+ :param server_variables: Mapping with string values to replace variables in
152
+ templated server configuration. The validation of enums is performed for
153
+ variables with defined enum values before.
154
+ :param server_operation_index: Mapping from operation ID to an index to server
155
+ configuration.
156
+ :param server_operation_variables: Mapping from operation ID to a mapping with
157
+ string values to replace variables in templated server configuration.
158
+ The validation of enums is performed for variables with defined enum
159
+ values before.
160
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
161
+ in PEM format.
162
+ :param retries: Number of retries for API requests.
163
+
164
+ """
165
+
166
+ _default: ClassVar[Optional[Self]] = None
167
+
168
+ def __init__(
169
+ self,
170
+ host: Optional[str]=None,
171
+ api_key: Optional[Dict[str, str]]=None,
172
+ api_key_prefix: Optional[Dict[str, str]]=None,
173
+ username: Optional[str]=None,
174
+ password: Optional[str]=None,
175
+ access_token: Optional[str]=None,
176
+ server_index: Optional[int]=None,
177
+ server_variables: Optional[ServerVariablesT]=None,
178
+ server_operation_index: Optional[Dict[int, int]]=None,
179
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
180
+ ignore_operation_servers: bool=False,
181
+ ssl_ca_cert: Optional[str]=None,
182
+ retries: Optional[int] = None,
183
+ *,
184
+ debug: Optional[bool] = None,
185
+ ) -> None:
186
+ """Constructor
187
+ """
188
+ self._base_path = "http://api.crypticorn.dev/v1/klines" if host is None else host
189
+ """Default Base url
190
+ """
191
+ self.server_index = 0 if server_index is None and host is None else server_index
192
+ self.server_operation_index = server_operation_index or {}
193
+ """Default server index
194
+ """
195
+ self.server_variables = server_variables or {}
196
+ self.server_operation_variables = server_operation_variables or {}
197
+ """Default server variables
198
+ """
199
+ self.ignore_operation_servers = ignore_operation_servers
200
+ """Ignore operation servers
201
+ """
202
+ self.temp_folder_path = None
203
+ """Temp file folder for downloading files
204
+ """
205
+ # Authentication Settings
206
+ self.api_key = {}
207
+ if api_key:
208
+ self.api_key = api_key
209
+ """dict to store API key(s)
210
+ """
211
+ self.api_key_prefix = {}
212
+ if api_key_prefix:
213
+ self.api_key_prefix = api_key_prefix
214
+ """dict to store API prefix (e.g. Bearer)
215
+ """
216
+ self.refresh_api_key_hook = None
217
+ """function hook to refresh API key if expired
218
+ """
219
+ self.username = username
220
+ """Username for HTTP basic authentication
221
+ """
222
+ self.password = password
223
+ """Password for HTTP basic authentication
224
+ """
225
+ self.access_token = access_token
226
+ """Access token
227
+ """
228
+ self.logger = {}
229
+ """Logging Settings
230
+ """
231
+ self.logger["package_logger"] = logging.getLogger("client")
232
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
233
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
234
+ """Log format
235
+ """
236
+ self.logger_stream_handler = None
237
+ """Log stream handler
238
+ """
239
+ self.logger_file_handler: Optional[FileHandler] = None
240
+ """Log file handler
241
+ """
242
+ self.logger_file = None
243
+ """Debug file location
244
+ """
245
+ if debug is not None:
246
+ self.debug = debug
247
+ else:
248
+ self.__debug = False
249
+ """Debug switch
250
+ """
251
+
252
+ self.verify_ssl = True
253
+ """SSL/TLS verification
254
+ Set this to false to skip verifying SSL certificate when calling API
255
+ from https server.
256
+ """
257
+ self.ssl_ca_cert = ssl_ca_cert
258
+ """Set this to customize the certificate file to verify the peer.
259
+ """
260
+ self.cert_file = None
261
+ """client certificate file
262
+ """
263
+ self.key_file = None
264
+ """client key file
265
+ """
266
+ self.assert_hostname = None
267
+ """Set this to True/False to enable/disable SSL hostname verification.
268
+ """
269
+ self.tls_server_name = None
270
+ """SSL/TLS Server Name Indication (SNI)
271
+ Set this to the SNI value expected by the server.
272
+ """
273
+
274
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
275
+ """urllib3 connection pool's maximum number of connections saved
276
+ per pool. urllib3 uses 1 connection as default value, but this is
277
+ not the best value when you are making a lot of possibly parallel
278
+ requests to the same host, which is often the case here.
279
+ cpu_count * 5 is used as default value to increase performance.
280
+ """
281
+
282
+ self.proxy: Optional[str] = None
283
+ """Proxy URL
284
+ """
285
+ self.proxy_headers = None
286
+ """Proxy headers
287
+ """
288
+ self.safe_chars_for_path_param = ''
289
+ """Safe chars for path_param
290
+ """
291
+ self.retries = retries
292
+ """Adding retries to override urllib3 default value 3
293
+ """
294
+ # Enable client side validation
295
+ self.client_side_validation = True
296
+
297
+ self.socket_options = None
298
+ """Options to pass down to the underlying urllib3 socket
299
+ """
300
+
301
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
302
+ """datetime format
303
+ """
304
+
305
+ self.date_format = "%Y-%m-%d"
306
+ """date format
307
+ """
308
+
309
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
310
+ cls = self.__class__
311
+ result = cls.__new__(cls)
312
+ memo[id(self)] = result
313
+ for k, v in self.__dict__.items():
314
+ if k not in ('logger', 'logger_file_handler'):
315
+ setattr(result, k, copy.deepcopy(v, memo))
316
+ # shallow copy of loggers
317
+ result.logger = copy.copy(self.logger)
318
+ # use setters to configure loggers
319
+ result.logger_file = self.logger_file
320
+ result.debug = self.debug
321
+ return result
322
+
323
+ def __setattr__(self, name: str, value: Any) -> None:
324
+ object.__setattr__(self, name, value)
325
+
326
+ @classmethod
327
+ def set_default(cls, default: Optional[Self]) -> None:
328
+ """Set default instance of configuration.
329
+
330
+ It stores default configuration, which can be
331
+ returned by get_default_copy method.
332
+
333
+ :param default: object of Configuration
334
+ """
335
+ cls._default = default
336
+
337
+ @classmethod
338
+ def get_default_copy(cls) -> Self:
339
+ """Deprecated. Please use `get_default` instead.
340
+
341
+ Deprecated. Please use `get_default` instead.
342
+
343
+ :return: The configuration object.
344
+ """
345
+ return cls.get_default()
346
+
347
+ @classmethod
348
+ def get_default(cls) -> Self:
349
+ """Return the default configuration.
350
+
351
+ This method returns newly created, based on default constructor,
352
+ object of Configuration class or returns a copy of default
353
+ configuration.
354
+
355
+ :return: The configuration object.
356
+ """
357
+ if cls._default is None:
358
+ cls._default = cls()
359
+ return cls._default
360
+
361
+ @property
362
+ def logger_file(self) -> Optional[str]:
363
+ """The logger file.
364
+
365
+ If the logger_file is None, then add stream handler and remove file
366
+ handler. Otherwise, add file handler and remove stream handler.
367
+
368
+ :param value: The logger_file path.
369
+ :type: str
370
+ """
371
+ return self.__logger_file
372
+
373
+ @logger_file.setter
374
+ def logger_file(self, value: Optional[str]) -> None:
375
+ """The logger file.
376
+
377
+ If the logger_file is None, then add stream handler and remove file
378
+ handler. Otherwise, add file handler and remove stream handler.
379
+
380
+ :param value: The logger_file path.
381
+ :type: str
382
+ """
383
+ self.__logger_file = value
384
+ if self.__logger_file:
385
+ # If set logging file,
386
+ # then add file handler and remove stream handler.
387
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
388
+ self.logger_file_handler.setFormatter(self.logger_formatter)
389
+ for _, logger in self.logger.items():
390
+ logger.addHandler(self.logger_file_handler)
391
+
392
+ @property
393
+ def debug(self) -> bool:
394
+ """Debug status
395
+
396
+ :param value: The debug status, True or False.
397
+ :type: bool
398
+ """
399
+ return self.__debug
400
+
401
+ @debug.setter
402
+ def debug(self, value: bool) -> None:
403
+ """Debug status
404
+
405
+ :param value: The debug status, True or False.
406
+ :type: bool
407
+ """
408
+ self.__debug = value
409
+ if self.__debug:
410
+ # if debug status is True, turn on debug logging
411
+ for _, logger in self.logger.items():
412
+ logger.setLevel(logging.DEBUG)
413
+ # turn on httplib debug
414
+ httplib.HTTPConnection.debuglevel = 1
415
+ else:
416
+ # if debug status is False, turn off debug logging,
417
+ # setting log level to default `logging.WARNING`
418
+ for _, logger in self.logger.items():
419
+ logger.setLevel(logging.WARNING)
420
+ # turn off httplib debug
421
+ httplib.HTTPConnection.debuglevel = 0
422
+
423
+ @property
424
+ def logger_format(self) -> str:
425
+ """The logger format.
426
+
427
+ The logger_formatter will be updated when sets logger_format.
428
+
429
+ :param value: The format string.
430
+ :type: str
431
+ """
432
+ return self.__logger_format
433
+
434
+ @logger_format.setter
435
+ def logger_format(self, value: str) -> None:
436
+ """The logger format.
437
+
438
+ The logger_formatter will be updated when sets logger_format.
439
+
440
+ :param value: The format string.
441
+ :type: str
442
+ """
443
+ self.__logger_format = value
444
+ self.logger_formatter = logging.Formatter(self.__logger_format)
445
+
446
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
447
+ """Gets API key (with prefix if set).
448
+
449
+ :param identifier: The identifier of apiKey.
450
+ :param alias: The alternative identifier of apiKey.
451
+ :return: The token for api key authentication.
452
+ """
453
+ if self.refresh_api_key_hook is not None:
454
+ self.refresh_api_key_hook(self)
455
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
456
+ if key:
457
+ prefix = self.api_key_prefix.get(identifier)
458
+ if prefix:
459
+ return "%s %s" % (prefix, key)
460
+ else:
461
+ return key
462
+
463
+ return None
464
+
465
+ def get_basic_auth_token(self) -> Optional[str]:
466
+ """Gets HTTP basic authentication header (string).
467
+
468
+ :return: The token for basic HTTP authentication.
469
+ """
470
+ username = ""
471
+ if self.username is not None:
472
+ username = self.username
473
+ password = ""
474
+ if self.password is not None:
475
+ password = self.password
476
+ return urllib3.util.make_headers(
477
+ basic_auth=username + ':' + password
478
+ ).get('authorization')
479
+
480
+ def auth_settings(self)-> AuthSettings:
481
+ """Gets Auth Settings dict for api client.
482
+
483
+ :return: The Auth Settings information dict.
484
+ """
485
+ auth: AuthSettings = {}
486
+ return auth
487
+
488
+ def to_debug_report(self) -> str:
489
+ """Gets the essential information for debugging.
490
+
491
+ :return: The report for debugging.
492
+ """
493
+ return "Python SDK Debug Report:\n"\
494
+ "OS: {env}\n"\
495
+ "Python Version: {pyversion}\n"\
496
+ "Version of the API: 1.0.0\n"\
497
+ "SDK Package Version: 1.0.0".\
498
+ format(env=sys.platform, pyversion=sys.version)
499
+
500
+ def get_host_settings(self) -> List[HostSetting]:
501
+ """Gets an array of host settings
502
+
503
+ :return: An array of host settings
504
+ """
505
+ return [
506
+ {
507
+ 'url': "http://api.crypticorn.dev/v1/klines",
508
+ 'description': "No description provided",
509
+ }
510
+ ]
511
+
512
+ def get_host_from_settings(
513
+ self,
514
+ index: Optional[int],
515
+ variables: Optional[ServerVariablesT]=None,
516
+ servers: Optional[List[HostSetting]]=None,
517
+ ) -> str:
518
+ """Gets host URL based on the index and variables
519
+ :param index: array index of the host settings
520
+ :param variables: hash of variable and the corresponding value
521
+ :param servers: an array of host settings or None
522
+ :return: URL based on host settings
523
+ """
524
+ if index is None:
525
+ return self._base_path
526
+
527
+ variables = {} if variables is None else variables
528
+ servers = self.get_host_settings() if servers is None else servers
529
+
530
+ try:
531
+ server = servers[index]
532
+ except IndexError:
533
+ raise ValueError(
534
+ "Invalid index {0} when selecting the host settings. "
535
+ "Must be less than {1}".format(index, len(servers)))
536
+
537
+ url = server['url']
538
+
539
+ # go through variables and replace placeholders
540
+ for variable_name, variable in server.get('variables', {}).items():
541
+ used_value = variables.get(
542
+ variable_name, variable['default_value'])
543
+
544
+ if 'enum_values' in variable \
545
+ and used_value not in variable['enum_values']:
546
+ raise ValueError(
547
+ "The variable `{0}` in the host URL has invalid value "
548
+ "{1}. Must be {2}.".format(
549
+ variable_name, variables[variable_name],
550
+ variable['enum_values']))
551
+
552
+ url = url.replace("{" + variable_name + "}", used_value)
553
+
554
+ return url
555
+
556
+ @property
557
+ def host(self) -> str:
558
+ """Return generated host."""
559
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
560
+
561
+ @host.setter
562
+ def host(self, value: str) -> None:
563
+ """Fix base path."""
564
+ self._base_path = value
565
+ self.server_index = None