crypticorn 2.17.0rc3__py3-none-any.whl → 2.17.0rc5__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 (137) hide show
  1. crypticorn/auth/client/api/admin_api.py +0 -2
  2. crypticorn/auth/client/api/auth_api.py +0 -4
  3. crypticorn/auth/client/api/service_api.py +0 -4
  4. crypticorn/auth/client/api/user_api.py +0 -4
  5. crypticorn/auth/client/api/wallet_api.py +0 -4
  6. crypticorn/auth/client/api_client.py +0 -5
  7. crypticorn/auth/client/models/add_wallet_request.py +1 -1
  8. crypticorn/auth/client/models/authorize_user_request.py +1 -1
  9. crypticorn/auth/client/models/create_api_key_request.py +1 -1
  10. crypticorn/auth/client/models/create_user_request.py +1 -1
  11. crypticorn/auth/client/models/get_api_keys200_response_inner.py +1 -1
  12. crypticorn/auth/client/models/list_wallets200_response_balances_inner_sale_round.py +1 -1
  13. crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet.py +1 -1
  14. crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet_vesting_wallets_inner.py +1 -1
  15. crypticorn/auth/client/models/list_wallets200_response_data_inner.py +1 -1
  16. crypticorn/auth/client/models/logout_default_response.py +1 -1
  17. crypticorn/auth/client/models/oauth_callback200_response_user.py +1 -1
  18. crypticorn/auth/client/models/refresh_token_info200_response_user_session.py +1 -1
  19. crypticorn/auth/client/models/rotate_tokens200_response.py +1 -1
  20. crypticorn/auth/client/models/token_info200_response.py +1 -1
  21. crypticorn/auth/client/models/update_user_request.py +1 -1
  22. crypticorn/auth/client/models/user_by_username200_response.py +1 -1
  23. crypticorn/auth/client/models/verify200_response.py +1 -1
  24. crypticorn/auth/client/models/verify_email200_response_auth.py +1 -1
  25. crypticorn/auth/client/models/verify_email200_response_auth_auth.py +1 -1
  26. crypticorn/auth/client/models/whoami200_response.py +1 -1
  27. crypticorn/cli/init.py +1 -1
  28. crypticorn/cli/templates/.env.docker.temp +3 -0
  29. crypticorn/cli/templates/.env.example.temp +4 -0
  30. crypticorn/client.py +0 -1
  31. crypticorn/common/auth.py +5 -16
  32. crypticorn/common/decorators.py +1 -2
  33. crypticorn/common/enums.py +0 -2
  34. crypticorn/common/metrics.py +1 -1
  35. crypticorn/common/middleware.py +0 -1
  36. crypticorn/common/pagination.py +135 -22
  37. crypticorn/common/utils.py +1 -2
  38. crypticorn/dex/__init__.py +6 -0
  39. crypticorn/dex/client/__init__.py +49 -0
  40. crypticorn/dex/client/api/__init__.py +6 -0
  41. crypticorn/dex/client/api/admin_api.py +3046 -0
  42. crypticorn/dex/client/api/signals_api.py +1821 -0
  43. crypticorn/dex/client/api/status_api.py +907 -0
  44. crypticorn/dex/client/api_client.py +753 -0
  45. crypticorn/dex/client/api_response.py +20 -0
  46. crypticorn/dex/client/configuration.py +620 -0
  47. crypticorn/dex/client/exceptions.py +220 -0
  48. crypticorn/dex/client/models/__init__.py +30 -0
  49. crypticorn/dex/client/models/api_error_identifier.py +121 -0
  50. crypticorn/dex/client/models/api_error_level.py +37 -0
  51. crypticorn/dex/client/models/api_error_type.py +37 -0
  52. crypticorn/dex/client/models/exception_detail.py +117 -0
  53. crypticorn/dex/client/models/log_level.py +38 -0
  54. crypticorn/dex/client/models/paginated_response_signal_with_token.py +134 -0
  55. crypticorn/dex/client/models/risk.py +86 -0
  56. crypticorn/dex/client/models/signal_overview_stats.py +156 -0
  57. crypticorn/dex/client/models/signal_volume.py +84 -0
  58. crypticorn/dex/client/models/signal_with_token.py +163 -0
  59. crypticorn/dex/client/models/token_data.py +127 -0
  60. crypticorn/dex/client/models/token_detail.py +116 -0
  61. crypticorn/dex/client/py.typed +0 -0
  62. crypticorn/dex/client/rest.py +217 -0
  63. crypticorn/dex/main.py +1 -0
  64. crypticorn/hive/client/api/admin_api.py +0 -3
  65. crypticorn/hive/client/api/data_api.py +0 -4
  66. crypticorn/hive/client/api/models_api.py +1 -4
  67. crypticorn/hive/client/api/status_api.py +0 -3
  68. crypticorn/hive/client/api_client.py +0 -5
  69. crypticorn/hive/client/models/coin_info.py +1 -1
  70. crypticorn/hive/client/models/exception_detail.py +1 -1
  71. crypticorn/hive/client/models/target_info.py +1 -1
  72. crypticorn/hive/utils.py +2 -2
  73. crypticorn/klines/client/api/admin_api.py +0 -3
  74. crypticorn/klines/client/api/change_in_timeframe_api.py +0 -4
  75. crypticorn/klines/client/api/funding_rates_api.py +0 -4
  76. crypticorn/klines/client/api/ohlcv_data_api.py +0 -4
  77. crypticorn/klines/client/api/status_api.py +0 -3
  78. crypticorn/klines/client/api/symbols_api.py +0 -4
  79. crypticorn/klines/client/api/udf_api.py +0 -2
  80. crypticorn/klines/client/api_client.py +0 -5
  81. crypticorn/klines/client/models/exception_detail.py +1 -1
  82. crypticorn/klines/client/models/ohlcv.py +1 -1
  83. crypticorn/klines/client/models/symbol_group.py +1 -1
  84. crypticorn/klines/client/models/udf_config.py +1 -1
  85. crypticorn/metrics/client/api/admin_api.py +0 -3
  86. crypticorn/metrics/client/api/exchanges_api.py +0 -4
  87. crypticorn/metrics/client/api/indicators_api.py +0 -4
  88. crypticorn/metrics/client/api/logs_api.py +0 -4
  89. crypticorn/metrics/client/api/marketcap_api.py +0 -4
  90. crypticorn/metrics/client/api/markets_api.py +0 -4
  91. crypticorn/metrics/client/api/quote_currencies_api.py +0 -4
  92. crypticorn/metrics/client/api/status_api.py +0 -3
  93. crypticorn/metrics/client/api/tokens_api.py +0 -2
  94. crypticorn/metrics/client/api_client.py +0 -5
  95. crypticorn/metrics/client/models/exception_detail.py +1 -1
  96. crypticorn/metrics/client/models/exchange_mapping.py +1 -1
  97. crypticorn/metrics/client/models/marketcap_ranking.py +1 -1
  98. crypticorn/metrics/client/models/marketcap_symbol_ranking.py +1 -1
  99. crypticorn/metrics/client/models/ohlcv.py +1 -1
  100. crypticorn/pay/client/api/admin_api.py +0 -3
  101. crypticorn/pay/client/api/now_payments_api.py +0 -4
  102. crypticorn/pay/client/api/payments_api.py +0 -4
  103. crypticorn/pay/client/api/products_api.py +0 -4
  104. crypticorn/pay/client/api/status_api.py +0 -3
  105. crypticorn/pay/client/api_client.py +0 -5
  106. crypticorn/pay/client/models/exception_detail.py +1 -1
  107. crypticorn/pay/client/models/now_create_invoice_req.py +1 -1
  108. crypticorn/pay/client/models/now_create_invoice_res.py +1 -1
  109. crypticorn/pay/client/models/product.py +1 -1
  110. crypticorn/pay/client/models/product_create.py +1 -1
  111. crypticorn/pay/client/models/product_update.py +1 -1
  112. crypticorn/trade/client/__init__.py +5 -0
  113. crypticorn/trade/client/api/admin_api.py +22 -23
  114. crypticorn/trade/client/api/bots_api.py +4712 -168
  115. crypticorn/trade/client/api/orders_api.py +220 -106
  116. crypticorn/trade/client/configuration.py +2 -2
  117. crypticorn/trade/client/models/__init__.py +5 -0
  118. crypticorn/trade/client/models/bot.py +7 -18
  119. crypticorn/trade/client/models/bot_create.py +17 -1
  120. crypticorn/trade/client/models/bot_update.py +17 -1
  121. crypticorn/trade/client/models/exchange_key_create.py +17 -1
  122. crypticorn/trade/client/models/exchange_key_update.py +17 -1
  123. crypticorn/trade/client/models/notification.py +17 -1
  124. crypticorn/trade/client/models/notification_create.py +17 -1
  125. crypticorn/trade/client/models/notification_update.py +17 -1
  126. crypticorn/trade/client/models/orders_count.py +88 -0
  127. crypticorn/trade/client/models/paginated_response_order.py +134 -0
  128. crypticorn/trade/client/models/pn_l.py +95 -0
  129. crypticorn/trade/client/models/strategy.py +17 -1
  130. crypticorn/trade/client/models/strategy_create.py +17 -1
  131. crypticorn/trade/client/models/strategy_update.py +17 -1
  132. {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc5.dist-info}/METADATA +1 -1
  133. {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc5.dist-info}/RECORD +137 -106
  134. {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc5.dist-info}/WHEEL +0 -0
  135. {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc5.dist-info}/entry_points.txt +0 -0
  136. {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc5.dist-info}/licenses/LICENSE +0 -0
  137. {crypticorn-2.17.0rc3.dist-info → crypticorn-2.17.0rc5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,20 @@
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
+
10
+ class ApiResponse(BaseModel, Generic[T]):
11
+ """
12
+ API response object
13
+ """
14
+
15
+ status_code: StrictInt = Field(description="HTTP status code")
16
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
17
+ data: T = Field(description="Deserialized data given the data type")
18
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
19
+
20
+ model_config = {"arbitrary_types_allowed": True}
@@ -0,0 +1,620 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ DEX AI API
5
+
6
+ API for DEX AI
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 sys
20
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
21
+ from typing_extensions import NotRequired, Self
22
+
23
+ import urllib3
24
+
25
+
26
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
27
+ "multipleOf",
28
+ "maximum",
29
+ "exclusiveMaximum",
30
+ "minimum",
31
+ "exclusiveMinimum",
32
+ "maxLength",
33
+ "minLength",
34
+ "pattern",
35
+ "maxItems",
36
+ "minItems",
37
+ }
38
+
39
+ ServerVariablesT = Dict[str, str]
40
+
41
+ GenericAuthSetting = TypedDict(
42
+ "GenericAuthSetting",
43
+ {
44
+ "type": str,
45
+ "in": str,
46
+ "key": str,
47
+ "value": str,
48
+ },
49
+ )
50
+
51
+
52
+ OAuth2AuthSetting = TypedDict(
53
+ "OAuth2AuthSetting",
54
+ {
55
+ "type": Literal["oauth2"],
56
+ "in": Literal["header"],
57
+ "key": Literal["Authorization"],
58
+ "value": str,
59
+ },
60
+ )
61
+
62
+
63
+ APIKeyAuthSetting = TypedDict(
64
+ "APIKeyAuthSetting",
65
+ {
66
+ "type": Literal["api_key"],
67
+ "in": str,
68
+ "key": str,
69
+ "value": Optional[str],
70
+ },
71
+ )
72
+
73
+
74
+ BasicAuthSetting = TypedDict(
75
+ "BasicAuthSetting",
76
+ {
77
+ "type": Literal["basic"],
78
+ "in": Literal["header"],
79
+ "key": Literal["Authorization"],
80
+ "value": Optional[str],
81
+ },
82
+ )
83
+
84
+
85
+ BearerFormatAuthSetting = TypedDict(
86
+ "BearerFormatAuthSetting",
87
+ {
88
+ "type": Literal["bearer"],
89
+ "in": Literal["header"],
90
+ "format": Literal["JWT"],
91
+ "key": Literal["Authorization"],
92
+ "value": str,
93
+ },
94
+ )
95
+
96
+
97
+ BearerAuthSetting = TypedDict(
98
+ "BearerAuthSetting",
99
+ {
100
+ "type": Literal["bearer"],
101
+ "in": Literal["header"],
102
+ "key": Literal["Authorization"],
103
+ "value": str,
104
+ },
105
+ )
106
+
107
+
108
+ HTTPSignatureAuthSetting = TypedDict(
109
+ "HTTPSignatureAuthSetting",
110
+ {
111
+ "type": Literal["http-signature"],
112
+ "in": Literal["header"],
113
+ "key": Literal["Authorization"],
114
+ "value": None,
115
+ },
116
+ )
117
+
118
+
119
+ AuthSettings = TypedDict(
120
+ "AuthSettings",
121
+ {
122
+ "HTTPBearer": BearerFormatAuthSetting,
123
+ "APIKeyHeader": APIKeyAuthSetting,
124
+ },
125
+ total=False,
126
+ )
127
+
128
+
129
+ class HostSettingVariable(TypedDict):
130
+ description: str
131
+ default_value: str
132
+ enum_values: List[str]
133
+
134
+
135
+ class HostSetting(TypedDict):
136
+ url: str
137
+ description: str
138
+ variables: NotRequired[Dict[str, HostSettingVariable]]
139
+
140
+
141
+ class Configuration:
142
+ """This class contains various settings of the API client.
143
+
144
+ :param host: Base url.
145
+ :param ignore_operation_servers
146
+ Boolean to ignore operation servers for the API client.
147
+ Config will use `host` as the base url regardless of the operation servers.
148
+ :param api_key: Dict to store API key(s).
149
+ Each entry in the dict specifies an API key.
150
+ The dict key is the name of the security scheme in the OAS specification.
151
+ The dict value is the API key secret.
152
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
153
+ The dict key is the name of the security scheme in the OAS specification.
154
+ The dict value is an API key prefix when generating the auth data.
155
+ :param username: Username for HTTP basic authentication.
156
+ :param password: Password for HTTP basic authentication.
157
+ :param access_token: Access token.
158
+ :param server_index: Index to servers configuration.
159
+ :param server_variables: Mapping with string values to replace variables in
160
+ templated server configuration. The validation of enums is performed for
161
+ variables with defined enum values before.
162
+ :param server_operation_index: Mapping from operation ID to an index to server
163
+ configuration.
164
+ :param server_operation_variables: Mapping from operation ID to a mapping with
165
+ string values to replace variables in templated server configuration.
166
+ The validation of enums is performed for variables with defined enum
167
+ values before.
168
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
169
+ in PEM format.
170
+ :param retries: Number of retries for API requests.
171
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
172
+ in PEM (str) or DER (bytes) format.
173
+
174
+ :Example:
175
+
176
+ API Key Authentication Example.
177
+ Given the following security scheme in the OpenAPI specification:
178
+ components:
179
+ securitySchemes:
180
+ cookieAuth: # name for the security scheme
181
+ type: apiKey
182
+ in: cookie
183
+ name: JSESSIONID # cookie name
184
+
185
+ You can programmatically set the cookie:
186
+
187
+ conf = client.Configuration(
188
+ api_key={'cookieAuth': 'abc123'}
189
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
190
+ )
191
+
192
+ The following cookie will be added to the HTTP request:
193
+ Cookie: JSESSIONID abc123
194
+ """
195
+
196
+ _default: ClassVar[Optional[Self]] = None
197
+
198
+ def __init__(
199
+ self,
200
+ host: Optional[str] = None,
201
+ api_key: Optional[Dict[str, str]] = None,
202
+ api_key_prefix: Optional[Dict[str, str]] = None,
203
+ username: Optional[str] = None,
204
+ password: Optional[str] = None,
205
+ access_token: Optional[str] = None,
206
+ server_index: Optional[int] = None,
207
+ server_variables: Optional[ServerVariablesT] = None,
208
+ server_operation_index: Optional[Dict[int, int]] = None,
209
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]] = None,
210
+ ignore_operation_servers: bool = False,
211
+ ssl_ca_cert: Optional[str] = None,
212
+ retries: Optional[int] = None,
213
+ ca_cert_data: Optional[Union[str, bytes]] = None,
214
+ *,
215
+ debug: Optional[bool] = None,
216
+ ) -> None:
217
+ """Constructor"""
218
+ self._base_path = "http://localhost/v1/dex" if host is None else host
219
+ """Default Base url
220
+ """
221
+ self.server_index = 0 if server_index is None and host is None else server_index
222
+ self.server_operation_index = server_operation_index or {}
223
+ """Default server index
224
+ """
225
+ self.server_variables = server_variables or {}
226
+ self.server_operation_variables = server_operation_variables or {}
227
+ """Default server variables
228
+ """
229
+ self.ignore_operation_servers = ignore_operation_servers
230
+ """Ignore operation servers
231
+ """
232
+ self.temp_folder_path = None
233
+ """Temp file folder for downloading files
234
+ """
235
+ # Authentication Settings
236
+ self.api_key = {}
237
+ if api_key:
238
+ self.api_key = api_key
239
+ """dict to store API key(s)
240
+ """
241
+ self.api_key_prefix = {}
242
+ if api_key_prefix:
243
+ self.api_key_prefix = api_key_prefix
244
+ """dict to store API prefix (e.g. Bearer)
245
+ """
246
+ self.refresh_api_key_hook = None
247
+ """function hook to refresh API key if expired
248
+ """
249
+ self.username = username
250
+ """Username for HTTP basic authentication
251
+ """
252
+ self.password = password
253
+ """Password for HTTP basic authentication
254
+ """
255
+ self.access_token = access_token
256
+ """Access token
257
+ """
258
+ self.logger = {}
259
+ """Logging Settings
260
+ """
261
+ self.logger["package_logger"] = logging.getLogger("client")
262
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
263
+ self.logger_format = "%(asctime)s %(levelname)s %(message)s"
264
+ """Log format
265
+ """
266
+ self.logger_stream_handler = None
267
+ """Log stream handler
268
+ """
269
+ self.logger_file_handler: Optional[FileHandler] = None
270
+ """Log file handler
271
+ """
272
+ self.logger_file = None
273
+ """Debug file location
274
+ """
275
+ if debug is not None:
276
+ self.debug = debug
277
+ else:
278
+ self.__debug = False
279
+ """Debug switch
280
+ """
281
+
282
+ self.verify_ssl = True
283
+ """SSL/TLS verification
284
+ Set this to false to skip verifying SSL certificate when calling API
285
+ from https server.
286
+ """
287
+ self.ssl_ca_cert = ssl_ca_cert
288
+ """Set this to customize the certificate file to verify the peer.
289
+ """
290
+ self.ca_cert_data = ca_cert_data
291
+ """Set this to verify the peer using PEM (str) or DER (bytes)
292
+ certificate data.
293
+ """
294
+ self.cert_file = None
295
+ """client certificate file
296
+ """
297
+ self.key_file = None
298
+ """client key file
299
+ """
300
+ self.assert_hostname = None
301
+ """Set this to True/False to enable/disable SSL hostname verification.
302
+ """
303
+ self.tls_server_name = None
304
+ """SSL/TLS Server Name Indication (SNI)
305
+ Set this to the SNI value expected by the server.
306
+ """
307
+
308
+ self.connection_pool_maxsize = 100
309
+ """This value is passed to the aiohttp to limit simultaneous connections.
310
+ Default values is 100, None means no-limit.
311
+ """
312
+
313
+ self.proxy: Optional[str] = None
314
+ """Proxy URL
315
+ """
316
+ self.proxy_headers = None
317
+ """Proxy headers
318
+ """
319
+ self.safe_chars_for_path_param = ""
320
+ """Safe chars for path_param
321
+ """
322
+ self.retries = retries
323
+ """Adding retries to override urllib3 default value 3
324
+ """
325
+ # Enable client side validation
326
+ self.client_side_validation = True
327
+
328
+ self.socket_options = None
329
+ """Options to pass down to the underlying urllib3 socket
330
+ """
331
+
332
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
333
+ """datetime format
334
+ """
335
+
336
+ self.date_format = "%Y-%m-%d"
337
+ """date format
338
+ """
339
+
340
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
341
+ cls = self.__class__
342
+ result = cls.__new__(cls)
343
+ memo[id(self)] = result
344
+ for k, v in self.__dict__.items():
345
+ if k not in ("logger", "logger_file_handler"):
346
+ setattr(result, k, copy.deepcopy(v, memo))
347
+ # shallow copy of loggers
348
+ result.logger = copy.copy(self.logger)
349
+ # use setters to configure loggers
350
+ result.logger_file = self.logger_file
351
+ result.debug = self.debug
352
+ return result
353
+
354
+ def __setattr__(self, name: str, value: Any) -> None:
355
+ object.__setattr__(self, name, value)
356
+
357
+ @classmethod
358
+ def set_default(cls, default: Optional[Self]) -> None:
359
+ """Set default instance of configuration.
360
+
361
+ It stores default configuration, which can be
362
+ returned by get_default_copy method.
363
+
364
+ :param default: object of Configuration
365
+ """
366
+ cls._default = default
367
+
368
+ @classmethod
369
+ def get_default_copy(cls) -> Self:
370
+ """Deprecated. Please use `get_default` instead.
371
+
372
+ Deprecated. Please use `get_default` instead.
373
+
374
+ :return: The configuration object.
375
+ """
376
+ return cls.get_default()
377
+
378
+ @classmethod
379
+ def get_default(cls) -> Self:
380
+ """Return the default configuration.
381
+
382
+ This method returns newly created, based on default constructor,
383
+ object of Configuration class or returns a copy of default
384
+ configuration.
385
+
386
+ :return: The configuration object.
387
+ """
388
+ if cls._default is None:
389
+ cls._default = cls()
390
+ return cls._default
391
+
392
+ @property
393
+ def logger_file(self) -> Optional[str]:
394
+ """The logger file.
395
+
396
+ If the logger_file is None, then add stream handler and remove file
397
+ handler. Otherwise, add file handler and remove stream handler.
398
+
399
+ :param value: The logger_file path.
400
+ :type: str
401
+ """
402
+ return self.__logger_file
403
+
404
+ @logger_file.setter
405
+ def logger_file(self, value: Optional[str]) -> None:
406
+ """The logger file.
407
+
408
+ If the logger_file is None, then add stream handler and remove file
409
+ handler. Otherwise, add file handler and remove stream handler.
410
+
411
+ :param value: The logger_file path.
412
+ :type: str
413
+ """
414
+ self.__logger_file = value
415
+ if self.__logger_file:
416
+ # If set logging file,
417
+ # then add file handler and remove stream handler.
418
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
419
+ self.logger_file_handler.setFormatter(self.logger_formatter)
420
+ for _, logger in self.logger.items():
421
+ logger.addHandler(self.logger_file_handler)
422
+
423
+ @property
424
+ def debug(self) -> bool:
425
+ """Debug status
426
+
427
+ :param value: The debug status, True or False.
428
+ :type: bool
429
+ """
430
+ return self.__debug
431
+
432
+ @debug.setter
433
+ def debug(self, value: bool) -> None:
434
+ """Debug status
435
+
436
+ :param value: The debug status, True or False.
437
+ :type: bool
438
+ """
439
+ self.__debug = value
440
+ if self.__debug:
441
+ # if debug status is True, turn on debug logging
442
+ for _, logger in self.logger.items():
443
+ logger.setLevel(logging.DEBUG)
444
+ # turn on httplib debug
445
+ httplib.HTTPConnection.debuglevel = 1
446
+ else:
447
+ # if debug status is False, turn off debug logging,
448
+ # setting log level to default `logging.WARNING`
449
+ for _, logger in self.logger.items():
450
+ logger.setLevel(logging.WARNING)
451
+ # turn off httplib debug
452
+ httplib.HTTPConnection.debuglevel = 0
453
+
454
+ @property
455
+ def logger_format(self) -> str:
456
+ """The logger format.
457
+
458
+ The logger_formatter will be updated when sets logger_format.
459
+
460
+ :param value: The format string.
461
+ :type: str
462
+ """
463
+ return self.__logger_format
464
+
465
+ @logger_format.setter
466
+ def logger_format(self, value: str) -> None:
467
+ """The logger format.
468
+
469
+ The logger_formatter will be updated when sets logger_format.
470
+
471
+ :param value: The format string.
472
+ :type: str
473
+ """
474
+ self.__logger_format = value
475
+ self.logger_formatter = logging.Formatter(self.__logger_format)
476
+
477
+ def get_api_key_with_prefix(
478
+ self, identifier: str, alias: Optional[str] = None
479
+ ) -> Optional[str]:
480
+ """Gets API key (with prefix if set).
481
+
482
+ :param identifier: The identifier of apiKey.
483
+ :param alias: The alternative identifier of apiKey.
484
+ :return: The token for api key authentication.
485
+ """
486
+ if self.refresh_api_key_hook is not None:
487
+ self.refresh_api_key_hook(self)
488
+ key = self.api_key.get(
489
+ identifier, self.api_key.get(alias) if alias is not None else None
490
+ )
491
+ if key:
492
+ prefix = self.api_key_prefix.get(identifier)
493
+ if prefix:
494
+ return "%s %s" % (prefix, key)
495
+ else:
496
+ return key
497
+
498
+ return None
499
+
500
+ def get_basic_auth_token(self) -> Optional[str]:
501
+ """Gets HTTP basic authentication header (string).
502
+
503
+ :return: The token for basic HTTP authentication.
504
+ """
505
+ username = ""
506
+ if self.username is not None:
507
+ username = self.username
508
+ password = ""
509
+ if self.password is not None:
510
+ password = self.password
511
+ return urllib3.util.make_headers(basic_auth=username + ":" + password).get(
512
+ "authorization"
513
+ )
514
+
515
+ def auth_settings(self) -> AuthSettings:
516
+ """Gets Auth Settings dict for api client.
517
+
518
+ :return: The Auth Settings information dict.
519
+ """
520
+ auth: AuthSettings = {}
521
+ if self.access_token is not None:
522
+ auth["HTTPBearer"] = {
523
+ "type": "bearer",
524
+ "in": "header",
525
+ "format": "JWT",
526
+ "key": "Authorization",
527
+ "value": "Bearer " + self.access_token,
528
+ }
529
+ if "APIKeyHeader" in self.api_key:
530
+ auth["APIKeyHeader"] = {
531
+ "type": "api_key",
532
+ "in": "header",
533
+ "key": "X-API-Key",
534
+ "value": self.get_api_key_with_prefix(
535
+ "APIKeyHeader",
536
+ ),
537
+ }
538
+ return auth
539
+
540
+ def to_debug_report(self) -> str:
541
+ """Gets the essential information for debugging.
542
+
543
+ :return: The report for debugging.
544
+ """
545
+ return (
546
+ "Python SDK Debug Report:\n"
547
+ "OS: {env}\n"
548
+ "Python Version: {pyversion}\n"
549
+ "Version of the API: 1.0.0\n"
550
+ "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version)
551
+ )
552
+
553
+ def get_host_settings(self) -> List[HostSetting]:
554
+ """Gets an array of host settings
555
+
556
+ :return: An array of host settings
557
+ """
558
+ return [
559
+ {
560
+ "url": "http://localhost/v1/dex",
561
+ "description": "No description provided",
562
+ }
563
+ ]
564
+
565
+ def get_host_from_settings(
566
+ self,
567
+ index: Optional[int],
568
+ variables: Optional[ServerVariablesT] = None,
569
+ servers: Optional[List[HostSetting]] = None,
570
+ ) -> str:
571
+ """Gets host URL based on the index and variables
572
+ :param index: array index of the host settings
573
+ :param variables: hash of variable and the corresponding value
574
+ :param servers: an array of host settings or None
575
+ :return: URL based on host settings
576
+ """
577
+ if index is None:
578
+ return self._base_path
579
+
580
+ variables = {} if variables is None else variables
581
+ servers = self.get_host_settings() if servers is None else servers
582
+
583
+ try:
584
+ server = servers[index]
585
+ except IndexError:
586
+ raise ValueError(
587
+ "Invalid index {0} when selecting the host settings. "
588
+ "Must be less than {1}".format(index, len(servers))
589
+ )
590
+
591
+ url = server["url"]
592
+
593
+ # go through variables and replace placeholders
594
+ for variable_name, variable in server.get("variables", {}).items():
595
+ used_value = variables.get(variable_name, variable["default_value"])
596
+
597
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
598
+ raise ValueError(
599
+ "The variable `{0}` in the host URL has invalid value "
600
+ "{1}. Must be {2}.".format(
601
+ variable_name, variables[variable_name], variable["enum_values"]
602
+ )
603
+ )
604
+
605
+ url = url.replace("{" + variable_name + "}", used_value)
606
+
607
+ return url
608
+
609
+ @property
610
+ def host(self) -> str:
611
+ """Return generated host."""
612
+ return self.get_host_from_settings(
613
+ self.server_index, variables=self.server_variables
614
+ )
615
+
616
+ @host.setter
617
+ def host(self, value: str) -> None:
618
+ """Fix base path."""
619
+ self._base_path = value
620
+ self.server_index = None