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.
Files changed (259) hide show
  1. crypticorn/__init__.py +3 -3
  2. crypticorn/auth/__init__.py +2 -0
  3. crypticorn/auth/client/__init__.py +112 -0
  4. crypticorn/auth/client/api/__init__.py +8 -0
  5. crypticorn/auth/client/api/admin_api.py +522 -0
  6. crypticorn/auth/client/api/auth_api.py +2089 -0
  7. crypticorn/auth/client/api/service_api.py +309 -0
  8. crypticorn/auth/client/api/user_api.py +2540 -0
  9. crypticorn/auth/client/api/wallet_api.py +1698 -0
  10. crypticorn/auth/client/api_client.py +758 -0
  11. crypticorn/auth/client/api_response.py +20 -0
  12. crypticorn/auth/client/configuration.py +584 -0
  13. crypticorn/auth/client/exceptions.py +220 -0
  14. crypticorn/auth/client/models/__init__.py +91 -0
  15. crypticorn/auth/client/models/add_wallet200_response.py +86 -0
  16. crypticorn/auth/client/models/add_wallet_request.py +107 -0
  17. crypticorn/auth/client/models/authorize_user200_response.py +107 -0
  18. crypticorn/auth/client/models/authorize_user200_response_auth.py +101 -0
  19. crypticorn/auth/client/models/authorize_user_request.py +96 -0
  20. crypticorn/auth/client/models/create_user_request.py +114 -0
  21. crypticorn/auth/client/models/list_wallets200_response.py +137 -0
  22. crypticorn/auth/client/models/list_wallets200_response_balances_inner.py +115 -0
  23. crypticorn/auth/client/models/list_wallets200_response_balances_inner_sale_round.py +115 -0
  24. crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet.py +168 -0
  25. crypticorn/auth/client/models/list_wallets200_response_balances_inner_wallet_vesting_wallets_inner.py +191 -0
  26. crypticorn/auth/client/models/list_wallets200_response_data_inner.py +102 -0
  27. crypticorn/auth/client/models/list_wallets200_response_user_value.py +118 -0
  28. crypticorn/auth/client/models/logout_default_response.py +108 -0
  29. crypticorn/auth/client/models/logout_default_response_issues_inner.py +83 -0
  30. crypticorn/auth/client/models/refresh_token_info200_response.py +97 -0
  31. crypticorn/auth/client/models/refresh_token_info200_response_user_session.py +105 -0
  32. crypticorn/auth/client/models/resend_verification_email_request.py +84 -0
  33. crypticorn/auth/client/models/revoke_user_tokens_request.py +83 -0
  34. crypticorn/auth/client/models/rotate_tokens200_response.py +110 -0
  35. crypticorn/auth/client/models/token_info200_response.py +97 -0
  36. crypticorn/auth/client/models/unlink_wallet_request.py +83 -0
  37. crypticorn/auth/client/models/update_user_request.py +93 -0
  38. crypticorn/auth/client/models/user_reset_password_request.py +87 -0
  39. crypticorn/auth/client/models/user_set_password_request.py +89 -0
  40. crypticorn/auth/client/models/verify200_response.py +110 -0
  41. crypticorn/auth/client/models/verify_email200_response.py +107 -0
  42. crypticorn/auth/client/models/verify_email200_response_auth.py +101 -0
  43. crypticorn/auth/client/models/verify_email200_response_auth_auth.py +110 -0
  44. crypticorn/auth/client/models/verify_email_request.py +83 -0
  45. crypticorn/auth/client/models/verify_wallet_request.py +91 -0
  46. crypticorn/auth/client/models/wallet_verified200_response.py +83 -0
  47. crypticorn/auth/client/models/whoami200_response.py +104 -0
  48. crypticorn/auth/client/rest.py +195 -0
  49. crypticorn/auth/main.py +45 -0
  50. crypticorn/client.py +46 -8
  51. crypticorn/common/__init__.py +5 -0
  52. crypticorn/common/auth.py +43 -0
  53. crypticorn/common/auth_client.py +163 -0
  54. crypticorn/common/errors.py +432 -0
  55. crypticorn/common/scopes.py +29 -0
  56. crypticorn/common/urls.py +25 -0
  57. crypticorn/hive/__init__.py +2 -1
  58. crypticorn/hive/client/__init__.py +57 -0
  59. crypticorn/hive/client/api/__init__.py +6 -0
  60. crypticorn/hive/client/api/data_api.py +594 -0
  61. crypticorn/hive/client/api/models_api.py +1680 -0
  62. crypticorn/hive/client/api/status_api.py +263 -0
  63. crypticorn/hive/client/api_client.py +758 -0
  64. crypticorn/hive/client/api_response.py +20 -0
  65. crypticorn/hive/client/configuration.py +612 -0
  66. crypticorn/hive/client/exceptions.py +220 -0
  67. crypticorn/hive/client/models/__init__.py +38 -0
  68. crypticorn/hive/client/models/coins.py +44 -0
  69. crypticorn/hive/client/models/data_download_response.py +113 -0
  70. crypticorn/hive/client/models/data_info.py +115 -0
  71. crypticorn/hive/client/models/data_value_value_value_inner.py +154 -0
  72. crypticorn/hive/client/models/data_version.py +35 -0
  73. crypticorn/hive/client/models/download_links.py +91 -0
  74. crypticorn/hive/client/models/evaluation.py +86 -0
  75. crypticorn/hive/client/models/evaluation_response.py +85 -0
  76. crypticorn/hive/client/models/feature_size.py +36 -0
  77. crypticorn/hive/client/models/http_validation_error.py +99 -0
  78. crypticorn/hive/client/models/model.py +133 -0
  79. crypticorn/hive/client/models/model_create.py +93 -0
  80. crypticorn/hive/client/models/model_status.py +35 -0
  81. crypticorn/hive/client/models/model_update.py +83 -0
  82. crypticorn/hive/client/models/target.py +36 -0
  83. crypticorn/hive/client/models/target_type.py +35 -0
  84. crypticorn/hive/client/models/validation_error.py +105 -0
  85. crypticorn/hive/client/models/validation_error_loc_inner.py +159 -0
  86. crypticorn/hive/client/py.typed +0 -0
  87. crypticorn/hive/client/rest.py +195 -0
  88. crypticorn/hive/main.py +27 -100
  89. crypticorn/klines/client/__init__.py +21 -7
  90. crypticorn/klines/client/api/__init__.py +0 -1
  91. crypticorn/klines/client/api/funding_rates_api.py +90 -79
  92. crypticorn/klines/client/api/health_check_api.py +29 -45
  93. crypticorn/klines/client/api/ohlcv_data_api.py +104 -87
  94. crypticorn/klines/client/api/symbols_api.py +36 -54
  95. crypticorn/klines/client/api/udf_api.py +228 -352
  96. crypticorn/klines/client/api_client.py +106 -148
  97. crypticorn/klines/client/api_response.py +2 -3
  98. crypticorn/klines/client/configuration.py +64 -50
  99. crypticorn/klines/client/exceptions.py +20 -16
  100. crypticorn/klines/client/models/__init__.py +21 -7
  101. crypticorn/klines/client/models/base_response_health_check_response.py +21 -15
  102. crypticorn/klines/client/models/base_response_list_funding_rate_response.py +21 -15
  103. crypticorn/klines/client/models/base_response_list_str.py +16 -14
  104. crypticorn/klines/client/models/base_response_ohlcv_response.py +21 -15
  105. crypticorn/klines/client/models/error_response.py +23 -15
  106. crypticorn/klines/client/models/exchange.py +11 -11
  107. crypticorn/klines/client/models/funding_rate_response.py +11 -11
  108. crypticorn/klines/client/models/health_check_response.py +14 -12
  109. crypticorn/klines/client/models/history_error_response.py +11 -11
  110. crypticorn/klines/client/models/history_no_data_response.py +16 -16
  111. crypticorn/klines/client/models/history_success_response.py +16 -16
  112. crypticorn/klines/client/models/http_validation_error.py +14 -10
  113. crypticorn/klines/client/models/market.py +2 -4
  114. crypticorn/klines/client/models/ohlcv_response.py +22 -15
  115. crypticorn/klines/client/models/resolution.py +5 -7
  116. crypticorn/klines/client/models/response_get_history_udf_history_get.py +71 -22
  117. crypticorn/klines/client/models/search_symbol_response.py +22 -15
  118. crypticorn/klines/client/models/sort_direction.py +2 -4
  119. crypticorn/klines/client/models/symbol_group_response.py +5 -9
  120. crypticorn/klines/client/models/symbol_info_response.py +40 -24
  121. crypticorn/klines/client/models/symbol_type.py +5 -10
  122. crypticorn/klines/client/models/timeframe.py +5 -7
  123. crypticorn/klines/client/models/udf_config_response.py +60 -21
  124. crypticorn/klines/client/models/validation_error.py +19 -13
  125. crypticorn/klines/client/models/validation_error_loc_inner.py +32 -11
  126. crypticorn/klines/client/rest.py +30 -41
  127. crypticorn/klines/main.py +52 -15
  128. crypticorn/pay/__init__.py +2 -0
  129. crypticorn/pay/client/__init__.py +52 -0
  130. crypticorn/pay/client/api/__init__.py +7 -0
  131. crypticorn/pay/client/api/now_payments_api.py +813 -0
  132. crypticorn/pay/client/api/payments_api.py +799 -0
  133. crypticorn/pay/client/api/products_api.py +891 -0
  134. crypticorn/pay/client/api/status_api.py +260 -0
  135. crypticorn/pay/client/api_client.py +758 -0
  136. crypticorn/pay/client/api_response.py +20 -0
  137. crypticorn/pay/client/configuration.py +612 -0
  138. crypticorn/pay/client/exceptions.py +220 -0
  139. crypticorn/pay/client/models/__init__.py +32 -0
  140. crypticorn/pay/client/models/api_status_res.py +83 -0
  141. crypticorn/pay/client/models/combined_payment_history.py +101 -0
  142. crypticorn/pay/client/models/create_invoice_req.py +188 -0
  143. crypticorn/pay/client/models/create_invoice_res.py +188 -0
  144. crypticorn/pay/client/models/currency.py +165 -0
  145. crypticorn/pay/client/models/estimate_price_req.py +91 -0
  146. crypticorn/pay/client/models/estimate_price_res.py +102 -0
  147. crypticorn/pay/client/models/get_currencies_res.py +99 -0
  148. crypticorn/pay/client/models/get_payment_status_res.py +222 -0
  149. crypticorn/pay/client/models/get_payments_list_res.py +109 -0
  150. crypticorn/pay/client/models/http_validation_error.py +99 -0
  151. crypticorn/pay/client/models/min_amount_req.py +124 -0
  152. crypticorn/pay/client/models/min_amount_res.py +105 -0
  153. crypticorn/pay/client/models/now_api_status_res.py +83 -0
  154. crypticorn/pay/client/models/now_create_invoice_req.py +188 -0
  155. crypticorn/pay/client/models/now_create_invoice_res.py +188 -0
  156. crypticorn/pay/client/models/now_fee_structure.py +104 -0
  157. crypticorn/pay/client/models/now_payment_model.py +124 -0
  158. crypticorn/pay/client/models/now_payment_status.py +42 -0
  159. crypticorn/pay/client/models/now_webhook_payload.py +181 -0
  160. crypticorn/pay/client/models/payment.py +231 -0
  161. crypticorn/pay/client/models/payment_status.py +40 -0
  162. crypticorn/pay/client/models/product.py +87 -0
  163. crypticorn/pay/client/models/product_model.py +119 -0
  164. crypticorn/pay/client/models/product_subs_model.py +108 -0
  165. crypticorn/pay/client/models/services.py +34 -0
  166. crypticorn/pay/client/models/unified_payment_model.py +112 -0
  167. crypticorn/pay/client/models/validation_error.py +105 -0
  168. crypticorn/pay/client/models/validation_error_loc_inner.py +159 -0
  169. crypticorn/pay/client/py.typed +0 -0
  170. crypticorn/pay/client/rest.py +195 -0
  171. crypticorn/pay/main.py +35 -0
  172. crypticorn/trade/client/__init__.py +9 -4
  173. crypticorn/trade/client/api/__init__.py +0 -1
  174. crypticorn/trade/client/api/api_keys_api.py +203 -304
  175. crypticorn/trade/client/api/bots_api.py +177 -250
  176. crypticorn/trade/client/api/exchanges_api.py +38 -57
  177. crypticorn/trade/client/api/futures_trading_panel_api.py +223 -321
  178. crypticorn/trade/client/api/notifications_api.py +247 -364
  179. crypticorn/trade/client/api/orders_api.py +44 -63
  180. crypticorn/trade/client/api/status_api.py +35 -53
  181. crypticorn/trade/client/api/strategies_api.py +852 -64
  182. crypticorn/trade/client/api/trading_actions_api.py +126 -203
  183. crypticorn/trade/client/api_client.py +115 -154
  184. crypticorn/trade/client/api_response.py +2 -3
  185. crypticorn/trade/client/configuration.py +128 -90
  186. crypticorn/trade/client/exceptions.py +21 -17
  187. crypticorn/trade/client/models/__init__.py +9 -4
  188. crypticorn/trade/client/models/action_model.py +114 -50
  189. crypticorn/trade/client/models/api_error_identifier.py +60 -51
  190. crypticorn/trade/client/models/api_error_level.py +37 -0
  191. crypticorn/trade/client/models/api_error_type.py +37 -0
  192. crypticorn/trade/client/models/api_key_model.py +49 -28
  193. crypticorn/trade/client/models/bot_model.py +76 -31
  194. crypticorn/trade/client/models/bot_status.py +37 -0
  195. crypticorn/trade/client/models/exchange.py +3 -5
  196. crypticorn/trade/client/models/execution_ids.py +14 -14
  197. crypticorn/trade/client/models/futures_balance.py +39 -23
  198. crypticorn/trade/client/models/futures_trading_action.py +98 -46
  199. crypticorn/trade/client/models/http_validation_error.py +15 -11
  200. crypticorn/trade/client/models/margin_mode.py +3 -5
  201. crypticorn/trade/client/models/market_type.py +3 -5
  202. crypticorn/trade/client/models/notification_model.py +60 -27
  203. crypticorn/trade/client/models/notification_type.py +4 -6
  204. crypticorn/trade/client/models/order_model.py +125 -65
  205. crypticorn/trade/client/models/order_status.py +6 -8
  206. crypticorn/trade/client/models/post_futures_action.py +16 -12
  207. crypticorn/trade/client/models/strategy_exchange_info.py +11 -12
  208. crypticorn/trade/client/models/strategy_model.py +66 -27
  209. crypticorn/trade/client/models/strategy_model_input.py +160 -0
  210. crypticorn/trade/client/models/strategy_model_output.py +160 -0
  211. crypticorn/trade/client/models/tpsl.py +35 -21
  212. crypticorn/trade/client/models/trading_action_type.py +5 -7
  213. crypticorn/trade/client/models/update_notification.py +17 -13
  214. crypticorn/trade/client/models/validation_error.py +20 -14
  215. crypticorn/trade/client/models/validation_error_loc_inner.py +33 -12
  216. crypticorn/trade/client/rest.py +108 -170
  217. crypticorn/trade/main.py +26 -19
  218. crypticorn-2.0.0.dist-info/METADATA +74 -0
  219. crypticorn-2.0.0.dist-info/RECORD +226 -0
  220. {crypticorn-1.0.2rc3.dist-info → crypticorn-2.0.0.dist-info}/WHEEL +1 -1
  221. crypticorn/hive/requirements.txt +0 -4
  222. crypticorn/hive/utils.py +0 -109
  223. crypticorn/klines/requirements.txt +0 -4
  224. crypticorn/klines/test/test_base_response_health_check_response.py +0 -56
  225. crypticorn/klines/test/test_base_response_list_funding_rate_response.py +0 -59
  226. crypticorn/klines/test/test_base_response_list_str.py +0 -56
  227. crypticorn/klines/test/test_base_response_ohlcv_response.py +0 -72
  228. crypticorn/klines/test/test_error_response.py +0 -57
  229. crypticorn/klines/test/test_exchange.py +0 -56
  230. crypticorn/klines/test/test_funding_rate_response.py +0 -56
  231. crypticorn/klines/test/test_funding_rates_api.py +0 -38
  232. crypticorn/klines/test/test_health_check_api.py +0 -38
  233. crypticorn/klines/test/test_health_check_response.py +0 -52
  234. crypticorn/klines/test/test_history_error_response.py +0 -53
  235. crypticorn/klines/test/test_history_no_data_response.py +0 -69
  236. crypticorn/klines/test/test_history_success_response.py +0 -87
  237. crypticorn/klines/test/test_http_validation_error.py +0 -58
  238. crypticorn/klines/test/test_market.py +0 -33
  239. crypticorn/klines/test/test_ohlcv_data_api.py +0 -38
  240. crypticorn/klines/test/test_ohlcv_response.py +0 -86
  241. crypticorn/klines/test/test_resolution.py +0 -33
  242. crypticorn/klines/test/test_response_get_history_udf_history_get.py +0 -89
  243. crypticorn/klines/test/test_search_symbol_response.py +0 -62
  244. crypticorn/klines/test/test_sort_direction.py +0 -33
  245. crypticorn/klines/test/test_symbol_group_response.py +0 -53
  246. crypticorn/klines/test/test_symbol_info_response.py +0 -84
  247. crypticorn/klines/test/test_symbol_type.py +0 -54
  248. crypticorn/klines/test/test_symbols_api.py +0 -38
  249. crypticorn/klines/test/test_timeframe.py +0 -33
  250. crypticorn/klines/test/test_udf_api.py +0 -80
  251. crypticorn/klines/test/test_udf_config_response.py +0 -95
  252. crypticorn/klines/test/test_validation_error.py +0 -60
  253. crypticorn/klines/test/test_validation_error_loc_inner.py +0 -50
  254. crypticorn/trade/requirements.txt +0 -4
  255. crypticorn-1.0.2rc3.dist-info/LICENSE.md +0 -19
  256. crypticorn-1.0.2rc3.dist-info/METADATA +0 -47
  257. crypticorn-1.0.2rc3.dist-info/RECORD +0 -128
  258. /crypticorn/{klines/test/__init__.py → auth/client/py.typed} +0 -0
  259. {crypticorn-1.0.2rc3.dist-info → crypticorn-2.0.0.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,612 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Payment API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.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
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": BearerAuthSetting,
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
+
172
+ :Example:
173
+
174
+ API Key Authentication Example.
175
+ Given the following security scheme in the OpenAPI specification:
176
+ components:
177
+ securitySchemes:
178
+ cookieAuth: # name for the security scheme
179
+ type: apiKey
180
+ in: cookie
181
+ name: JSESSIONID # cookie name
182
+
183
+ You can programmatically set the cookie:
184
+
185
+ conf = client.Configuration(
186
+ api_key={'cookieAuth': 'abc123'}
187
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
188
+ )
189
+
190
+ The following cookie will be added to the HTTP request:
191
+ Cookie: JSESSIONID abc123
192
+ """
193
+
194
+ _default: ClassVar[Optional[Self]] = None
195
+
196
+ def __init__(
197
+ self,
198
+ host: Optional[str] = None,
199
+ api_key: Optional[Dict[str, str]] = None,
200
+ api_key_prefix: Optional[Dict[str, str]] = None,
201
+ username: Optional[str] = None,
202
+ password: Optional[str] = None,
203
+ access_token: Optional[str] = None,
204
+ server_index: Optional[int] = None,
205
+ server_variables: Optional[ServerVariablesT] = None,
206
+ server_operation_index: Optional[Dict[int, int]] = None,
207
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]] = None,
208
+ ignore_operation_servers: bool = False,
209
+ ssl_ca_cert: Optional[str] = None,
210
+ retries: Optional[int] = None,
211
+ *,
212
+ debug: Optional[bool] = None,
213
+ ) -> None:
214
+ """Constructor"""
215
+ self._base_path = "http://localhost/v1/pay" if host is None else host
216
+ """Default Base url
217
+ """
218
+ self.server_index = 0 if server_index is None and host is None else server_index
219
+ self.server_operation_index = server_operation_index or {}
220
+ """Default server index
221
+ """
222
+ self.server_variables = server_variables or {}
223
+ self.server_operation_variables = server_operation_variables or {}
224
+ """Default server variables
225
+ """
226
+ self.ignore_operation_servers = ignore_operation_servers
227
+ """Ignore operation servers
228
+ """
229
+ self.temp_folder_path = None
230
+ """Temp file folder for downloading files
231
+ """
232
+ # Authentication Settings
233
+ self.api_key = {}
234
+ if api_key:
235
+ self.api_key = api_key
236
+ """dict to store API key(s)
237
+ """
238
+ self.api_key_prefix = {}
239
+ if api_key_prefix:
240
+ self.api_key_prefix = api_key_prefix
241
+ """dict to store API prefix (e.g. Bearer)
242
+ """
243
+ self.refresh_api_key_hook = None
244
+ """function hook to refresh API key if expired
245
+ """
246
+ self.username = username
247
+ """Username for HTTP basic authentication
248
+ """
249
+ self.password = password
250
+ """Password for HTTP basic authentication
251
+ """
252
+ self.access_token = access_token
253
+ """Access token
254
+ """
255
+ self.logger = {}
256
+ """Logging Settings
257
+ """
258
+ self.logger["package_logger"] = logging.getLogger("client")
259
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
260
+ self.logger_format = "%(asctime)s %(levelname)s %(message)s"
261
+ """Log format
262
+ """
263
+ self.logger_stream_handler = None
264
+ """Log stream handler
265
+ """
266
+ self.logger_file_handler: Optional[FileHandler] = None
267
+ """Log file handler
268
+ """
269
+ self.logger_file = None
270
+ """Debug file location
271
+ """
272
+ if debug is not None:
273
+ self.debug = debug
274
+ else:
275
+ self.__debug = False
276
+ """Debug switch
277
+ """
278
+
279
+ self.verify_ssl = True
280
+ """SSL/TLS verification
281
+ Set this to false to skip verifying SSL certificate when calling API
282
+ from https server.
283
+ """
284
+ self.ssl_ca_cert = ssl_ca_cert
285
+ """Set this to customize the certificate file to verify the peer.
286
+ """
287
+ self.cert_file = None
288
+ """client certificate file
289
+ """
290
+ self.key_file = None
291
+ """client key file
292
+ """
293
+ self.assert_hostname = None
294
+ """Set this to True/False to enable/disable SSL hostname verification.
295
+ """
296
+ self.tls_server_name = None
297
+ """SSL/TLS Server Name Indication (SNI)
298
+ Set this to the SNI value expected by the server.
299
+ """
300
+
301
+ self.connection_pool_maxsize = 100
302
+ """This value is passed to the aiohttp to limit simultaneous connections.
303
+ Default values is 100, None means no-limit.
304
+ """
305
+
306
+ self.proxy: Optional[str] = None
307
+ """Proxy URL
308
+ """
309
+ self.proxy_headers = None
310
+ """Proxy headers
311
+ """
312
+ self.safe_chars_for_path_param = ""
313
+ """Safe chars for path_param
314
+ """
315
+ self.retries = retries
316
+ """Adding retries to override urllib3 default value 3
317
+ """
318
+ # Enable client side validation
319
+ self.client_side_validation = True
320
+
321
+ self.socket_options = None
322
+ """Options to pass down to the underlying urllib3 socket
323
+ """
324
+
325
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
326
+ """datetime format
327
+ """
328
+
329
+ self.date_format = "%Y-%m-%d"
330
+ """date format
331
+ """
332
+
333
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
334
+ cls = self.__class__
335
+ result = cls.__new__(cls)
336
+ memo[id(self)] = result
337
+ for k, v in self.__dict__.items():
338
+ if k not in ("logger", "logger_file_handler"):
339
+ setattr(result, k, copy.deepcopy(v, memo))
340
+ # shallow copy of loggers
341
+ result.logger = copy.copy(self.logger)
342
+ # use setters to configure loggers
343
+ result.logger_file = self.logger_file
344
+ result.debug = self.debug
345
+ return result
346
+
347
+ def __setattr__(self, name: str, value: Any) -> None:
348
+ object.__setattr__(self, name, value)
349
+
350
+ @classmethod
351
+ def set_default(cls, default: Optional[Self]) -> None:
352
+ """Set default instance of configuration.
353
+
354
+ It stores default configuration, which can be
355
+ returned by get_default_copy method.
356
+
357
+ :param default: object of Configuration
358
+ """
359
+ cls._default = default
360
+
361
+ @classmethod
362
+ def get_default_copy(cls) -> Self:
363
+ """Deprecated. Please use `get_default` instead.
364
+
365
+ Deprecated. Please use `get_default` instead.
366
+
367
+ :return: The configuration object.
368
+ """
369
+ return cls.get_default()
370
+
371
+ @classmethod
372
+ def get_default(cls) -> Self:
373
+ """Return the default configuration.
374
+
375
+ This method returns newly created, based on default constructor,
376
+ object of Configuration class or returns a copy of default
377
+ configuration.
378
+
379
+ :return: The configuration object.
380
+ """
381
+ if cls._default is None:
382
+ cls._default = cls()
383
+ return cls._default
384
+
385
+ @property
386
+ def logger_file(self) -> Optional[str]:
387
+ """The logger file.
388
+
389
+ If the logger_file is None, then add stream handler and remove file
390
+ handler. Otherwise, add file handler and remove stream handler.
391
+
392
+ :param value: The logger_file path.
393
+ :type: str
394
+ """
395
+ return self.__logger_file
396
+
397
+ @logger_file.setter
398
+ def logger_file(self, value: Optional[str]) -> None:
399
+ """The logger file.
400
+
401
+ If the logger_file is None, then add stream handler and remove file
402
+ handler. Otherwise, add file handler and remove stream handler.
403
+
404
+ :param value: The logger_file path.
405
+ :type: str
406
+ """
407
+ self.__logger_file = value
408
+ if self.__logger_file:
409
+ # If set logging file,
410
+ # then add file handler and remove stream handler.
411
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
412
+ self.logger_file_handler.setFormatter(self.logger_formatter)
413
+ for _, logger in self.logger.items():
414
+ logger.addHandler(self.logger_file_handler)
415
+
416
+ @property
417
+ def debug(self) -> bool:
418
+ """Debug status
419
+
420
+ :param value: The debug status, True or False.
421
+ :type: bool
422
+ """
423
+ return self.__debug
424
+
425
+ @debug.setter
426
+ def debug(self, value: bool) -> None:
427
+ """Debug status
428
+
429
+ :param value: The debug status, True or False.
430
+ :type: bool
431
+ """
432
+ self.__debug = value
433
+ if self.__debug:
434
+ # if debug status is True, turn on debug logging
435
+ for _, logger in self.logger.items():
436
+ logger.setLevel(logging.DEBUG)
437
+ # turn on httplib debug
438
+ httplib.HTTPConnection.debuglevel = 1
439
+ else:
440
+ # if debug status is False, turn off debug logging,
441
+ # setting log level to default `logging.WARNING`
442
+ for _, logger in self.logger.items():
443
+ logger.setLevel(logging.WARNING)
444
+ # turn off httplib debug
445
+ httplib.HTTPConnection.debuglevel = 0
446
+
447
+ @property
448
+ def logger_format(self) -> str:
449
+ """The logger format.
450
+
451
+ The logger_formatter will be updated when sets logger_format.
452
+
453
+ :param value: The format string.
454
+ :type: str
455
+ """
456
+ return self.__logger_format
457
+
458
+ @logger_format.setter
459
+ def logger_format(self, value: str) -> None:
460
+ """The logger format.
461
+
462
+ The logger_formatter will be updated when sets logger_format.
463
+
464
+ :param value: The format string.
465
+ :type: str
466
+ """
467
+ self.__logger_format = value
468
+ self.logger_formatter = logging.Formatter(self.__logger_format)
469
+
470
+ def get_api_key_with_prefix(
471
+ self, identifier: str, alias: Optional[str] = None
472
+ ) -> Optional[str]:
473
+ """Gets API key (with prefix if set).
474
+
475
+ :param identifier: The identifier of apiKey.
476
+ :param alias: The alternative identifier of apiKey.
477
+ :return: The token for api key authentication.
478
+ """
479
+ if self.refresh_api_key_hook is not None:
480
+ self.refresh_api_key_hook(self)
481
+ key = self.api_key.get(
482
+ identifier, self.api_key.get(alias) if alias is not None else None
483
+ )
484
+ if key:
485
+ prefix = self.api_key_prefix.get(identifier)
486
+ if prefix:
487
+ return "%s %s" % (prefix, key)
488
+ else:
489
+ return key
490
+
491
+ return None
492
+
493
+ def get_basic_auth_token(self) -> Optional[str]:
494
+ """Gets HTTP basic authentication header (string).
495
+
496
+ :return: The token for basic HTTP authentication.
497
+ """
498
+ username = ""
499
+ if self.username is not None:
500
+ username = self.username
501
+ password = ""
502
+ if self.password is not None:
503
+ password = self.password
504
+ return urllib3.util.make_headers(basic_auth=username + ":" + password).get(
505
+ "authorization"
506
+ )
507
+
508
+ def auth_settings(self) -> AuthSettings:
509
+ """Gets Auth Settings dict for api client.
510
+
511
+ :return: The Auth Settings information dict.
512
+ """
513
+ auth: AuthSettings = {}
514
+ if self.access_token is not None:
515
+ auth["HTTPBearer"] = {
516
+ "type": "bearer",
517
+ "in": "header",
518
+ "key": "Authorization",
519
+ "value": "Bearer " + self.access_token,
520
+ }
521
+ if "APIKeyHeader" in self.api_key:
522
+ auth["APIKeyHeader"] = {
523
+ "type": "api_key",
524
+ "in": "header",
525
+ "key": "X-API-Key",
526
+ "value": self.get_api_key_with_prefix(
527
+ "APIKeyHeader",
528
+ ),
529
+ }
530
+ return auth
531
+
532
+ def to_debug_report(self) -> str:
533
+ """Gets the essential information for debugging.
534
+
535
+ :return: The report for debugging.
536
+ """
537
+ return (
538
+ "Python SDK Debug Report:\n"
539
+ "OS: {env}\n"
540
+ "Python Version: {pyversion}\n"
541
+ "Version of the API: 0.1.0\n"
542
+ "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version)
543
+ )
544
+
545
+ def get_host_settings(self) -> List[HostSetting]:
546
+ """Gets an array of host settings
547
+
548
+ :return: An array of host settings
549
+ """
550
+ return [
551
+ {
552
+ "url": "http://localhost/v1/pay",
553
+ "description": "No description provided",
554
+ }
555
+ ]
556
+
557
+ def get_host_from_settings(
558
+ self,
559
+ index: Optional[int],
560
+ variables: Optional[ServerVariablesT] = None,
561
+ servers: Optional[List[HostSetting]] = None,
562
+ ) -> str:
563
+ """Gets host URL based on the index and variables
564
+ :param index: array index of the host settings
565
+ :param variables: hash of variable and the corresponding value
566
+ :param servers: an array of host settings or None
567
+ :return: URL based on host settings
568
+ """
569
+ if index is None:
570
+ return self._base_path
571
+
572
+ variables = {} if variables is None else variables
573
+ servers = self.get_host_settings() if servers is None else servers
574
+
575
+ try:
576
+ server = servers[index]
577
+ except IndexError:
578
+ raise ValueError(
579
+ "Invalid index {0} when selecting the host settings. "
580
+ "Must be less than {1}".format(index, len(servers))
581
+ )
582
+
583
+ url = server["url"]
584
+
585
+ # go through variables and replace placeholders
586
+ for variable_name, variable in server.get("variables", {}).items():
587
+ used_value = variables.get(variable_name, variable["default_value"])
588
+
589
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
590
+ raise ValueError(
591
+ "The variable `{0}` in the host URL has invalid value "
592
+ "{1}. Must be {2}.".format(
593
+ variable_name, variables[variable_name], variable["enum_values"]
594
+ )
595
+ )
596
+
597
+ url = url.replace("{" + variable_name + "}", used_value)
598
+
599
+ return url
600
+
601
+ @property
602
+ def host(self) -> str:
603
+ """Return generated host."""
604
+ return self.get_host_from_settings(
605
+ self.server_index, variables=self.server_variables
606
+ )
607
+
608
+ @host.setter
609
+ def host(self, value: str) -> None:
610
+ """Fix base path."""
611
+ self._base_path = value
612
+ self.server_index = None