crypticorn 2.4.6__py3-none-any.whl → 2.5.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 (35) hide show
  1. crypticorn/cli/init.py +7 -4
  2. crypticorn/common/__init__.py +1 -0
  3. crypticorn/common/auth.py +11 -9
  4. crypticorn/common/errors.py +26 -0
  5. crypticorn/common/exceptions.py +83 -0
  6. crypticorn/common/utils.py +23 -6
  7. crypticorn/klines/client/__init__.py +10 -3
  8. crypticorn/klines/client/api/__init__.py +1 -0
  9. crypticorn/klines/client/api/change_in_timeframe_api.py +331 -0
  10. crypticorn/klines/client/api/funding_rates_api.py +13 -13
  11. crypticorn/klines/client/api/health_check_api.py +8 -8
  12. crypticorn/klines/client/api/ohlcv_data_api.py +38 -26
  13. crypticorn/klines/client/api/symbols_api.py +26 -20
  14. crypticorn/klines/client/api/udf_api.py +229 -229
  15. crypticorn/klines/client/api_client.py +8 -5
  16. crypticorn/klines/client/configuration.py +80 -37
  17. crypticorn/klines/client/models/__init__.py +9 -3
  18. crypticorn/klines/client/models/base_response_list_change_in_timeframe_response.py +123 -0
  19. crypticorn/klines/client/models/change_in_timeframe_response.py +86 -0
  20. crypticorn/klines/client/models/market_type.py +35 -0
  21. crypticorn/klines/client/models/response_get_udf_history.py +198 -0
  22. crypticorn/klines/client/rest.py +111 -159
  23. crypticorn/klines/main.py +37 -22
  24. crypticorn/metrics/main.py +42 -42
  25. crypticorn/pay/client/__init__.py +0 -3
  26. crypticorn/pay/client/api/now_payments_api.py +1 -53
  27. crypticorn/pay/client/models/__init__.py +0 -3
  28. crypticorn/pay/client/models/payment.py +3 -3
  29. crypticorn/pay/client/models/scope.py +6 -1
  30. crypticorn/trade/client/models/exchange_key_model.py +2 -1
  31. {crypticorn-2.4.6.dist-info → crypticorn-2.5.0.dist-info}/METADATA +8 -2
  32. {crypticorn-2.4.6.dist-info → crypticorn-2.5.0.dist-info}/RECORD +35 -29
  33. {crypticorn-2.4.6.dist-info → crypticorn-2.5.0.dist-info}/WHEEL +1 -1
  34. {crypticorn-2.4.6.dist-info → crypticorn-2.5.0.dist-info}/entry_points.txt +0 -0
  35. {crypticorn-2.4.6.dist-info → crypticorn-2.5.0.dist-info}/top_level.txt +0 -0
@@ -90,11 +90,14 @@ class ApiClient:
90
90
  self.user_agent = "OpenAPI-Generator/1.0.0/python"
91
91
  self.client_side_validation = configuration.client_side_validation
92
92
 
93
- def __enter__(self):
93
+ async def __aenter__(self):
94
94
  return self
95
95
 
96
- def __exit__(self, exc_type, exc_value, traceback):
97
- pass
96
+ async def __aexit__(self, exc_type, exc_value, traceback):
97
+ await self.close()
98
+
99
+ async def close(self):
100
+ await self.rest_client.close()
98
101
 
99
102
  @property
100
103
  def user_agent(self):
@@ -232,7 +235,7 @@ class ApiClient:
232
235
 
233
236
  return method, url, header_params, body, post_params
234
237
 
235
- def call_api(
238
+ async def call_api(
236
239
  self,
237
240
  method,
238
241
  url,
@@ -255,7 +258,7 @@ class ApiClient:
255
258
 
256
259
  try:
257
260
  # perform request and return response
258
- response_data = self.rest_client.request(
261
+ response_data = await self.rest_client.request(
259
262
  method,
260
263
  url,
261
264
  headers=header_params,
@@ -16,9 +16,8 @@ import copy
16
16
  import http.client as httplib
17
17
  import logging
18
18
  from logging import FileHandler
19
- import multiprocessing
20
19
  import sys
21
- from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
20
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
22
21
  from typing_extensions import NotRequired, Self
23
22
 
24
23
  import urllib3
@@ -119,7 +118,10 @@ HTTPSignatureAuthSetting = TypedDict(
119
118
 
120
119
  AuthSettings = TypedDict(
121
120
  "AuthSettings",
122
- {},
121
+ {
122
+ "HTTPBearer": BearerFormatAuthSetting,
123
+ "APIKeyHeader": APIKeyAuthSetting,
124
+ },
123
125
  total=False,
124
126
  )
125
127
 
@@ -139,34 +141,56 @@ class HostSetting(TypedDict):
139
141
  class Configuration:
140
142
  """This class contains various settings of the API client.
141
143
 
142
- :param host: Base url.
143
- :param ignore_operation_servers
144
- Boolean to ignore operation servers for the API client.
145
- Config will use `host` as the base url regardless of the operation servers.
146
- :param api_key: Dict to store API key(s).
147
- Each entry in the dict specifies an API key.
148
- The dict key is the name of the security scheme in the OAS specification.
149
- The dict value is the API key secret.
150
- :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
151
- The dict key is the name of the security scheme in the OAS specification.
152
- The dict value is an API key prefix when generating the auth data.
153
- :param username: Username for HTTP basic authentication.
154
- :param password: Password for HTTP basic authentication.
155
- :param access_token: Access token.
156
- :param server_index: Index to servers configuration.
157
- :param server_variables: Mapping with string values to replace variables in
158
- templated server configuration. The validation of enums is performed for
159
- variables with defined enum values before.
160
- :param server_operation_index: Mapping from operation ID to an index to server
161
- configuration.
162
- :param server_operation_variables: Mapping from operation ID to a mapping with
163
- string values to replace variables in templated server configuration.
164
- The validation of enums is performed for variables with defined enum
165
- values before.
166
- :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
167
- in PEM format.
168
- :param retries: Number of retries for API requests.
169
-
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
170
194
  """
171
195
 
172
196
  _default: ClassVar[Optional[Self]] = None
@@ -186,6 +210,7 @@ class Configuration:
186
210
  ignore_operation_servers: bool = False,
187
211
  ssl_ca_cert: Optional[str] = None,
188
212
  retries: Optional[int] = None,
213
+ ca_cert_data: Optional[Union[str, bytes]] = None,
189
214
  *,
190
215
  debug: Optional[bool] = None,
191
216
  ) -> None:
@@ -262,6 +287,10 @@ class Configuration:
262
287
  self.ssl_ca_cert = ssl_ca_cert
263
288
  """Set this to customize the certificate file to verify the peer.
264
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
+ """
265
294
  self.cert_file = None
266
295
  """client certificate file
267
296
  """
@@ -276,12 +305,9 @@ class Configuration:
276
305
  Set this to the SNI value expected by the server.
277
306
  """
278
307
 
279
- self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
280
- """urllib3 connection pool's maximum number of connections saved
281
- per pool. urllib3 uses 1 connection as default value, but this is
282
- not the best value when you are making a lot of possibly parallel
283
- requests to the same host, which is often the case here.
284
- cpu_count * 5 is used as default value to increase performance.
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.
285
311
  """
286
312
 
287
313
  self.proxy: Optional[str] = None
@@ -492,6 +518,23 @@ class Configuration:
492
518
  :return: The Auth Settings information dict.
493
519
  """
494
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
+ }
495
538
  return auth
496
539
 
497
540
  def to_debug_report(self) -> str:
@@ -17,6 +17,9 @@ Do not edit the class manually.
17
17
  from crypticorn.klines.client.models.base_response_health_check_response import (
18
18
  BaseResponseHealthCheckResponse,
19
19
  )
20
+ from crypticorn.klines.client.models.base_response_list_change_in_timeframe_response import (
21
+ BaseResponseListChangeInTimeframeResponse,
22
+ )
20
23
  from crypticorn.klines.client.models.base_response_list_funding_rate_response import (
21
24
  BaseResponseListFundingRateResponse,
22
25
  )
@@ -24,6 +27,9 @@ from crypticorn.klines.client.models.base_response_list_str import BaseResponseL
24
27
  from crypticorn.klines.client.models.base_response_ohlcv_response import (
25
28
  BaseResponseOHLCVResponse,
26
29
  )
30
+ from crypticorn.klines.client.models.change_in_timeframe_response import (
31
+ ChangeInTimeframeResponse,
32
+ )
27
33
  from crypticorn.klines.client.models.error_response import ErrorResponse
28
34
  from crypticorn.klines.client.models.exchange import Exchange
29
35
  from crypticorn.klines.client.models.funding_rate_response import FundingRateResponse
@@ -36,11 +42,11 @@ from crypticorn.klines.client.models.history_no_data_response import (
36
42
  from crypticorn.klines.client.models.history_success_response import (
37
43
  HistorySuccessResponse,
38
44
  )
39
- from crypticorn.klines.client.models.market import Market
45
+ from crypticorn.klines.client.models.market_type import MarketType
40
46
  from crypticorn.klines.client.models.ohlcv_response import OHLCVResponse
41
47
  from crypticorn.klines.client.models.resolution import Resolution
42
- from crypticorn.klines.client.models.response_get_history_udf_history_get import (
43
- ResponseGetHistoryUdfHistoryGet,
48
+ from crypticorn.klines.client.models.response_get_udf_history import (
49
+ ResponseGetUdfHistory,
44
50
  )
45
51
  from crypticorn.klines.client.models.search_symbol_response import SearchSymbolResponse
46
52
  from crypticorn.klines.client.models.sort_direction import SortDirection
@@ -0,0 +1,123 @@
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
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from crypticorn.klines.client.models.change_in_timeframe_response import (
24
+ ChangeInTimeframeResponse,
25
+ )
26
+ from typing import Optional, Set
27
+ from typing_extensions import Self
28
+
29
+
30
+ class BaseResponseListChangeInTimeframeResponse(BaseModel):
31
+ """
32
+ BaseResponseListChangeInTimeframeResponse
33
+ """ # noqa: E501
34
+
35
+ success: Optional[StrictBool] = True
36
+ message: Optional[StrictStr] = None
37
+ data: Optional[List[ChangeInTimeframeResponse]] = None
38
+ timestamp: Optional[datetime] = None
39
+ __properties: ClassVar[List[str]] = ["success", "message", "data", "timestamp"]
40
+
41
+ model_config = ConfigDict(
42
+ populate_by_name=True,
43
+ validate_assignment=True,
44
+ protected_namespaces=(),
45
+ )
46
+
47
+ def to_str(self) -> str:
48
+ """Returns the string representation of the model using alias"""
49
+ return pprint.pformat(self.model_dump(by_alias=True))
50
+
51
+ def to_json(self) -> str:
52
+ """Returns the JSON representation of the model using alias"""
53
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
+ return json.dumps(self.to_dict())
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of BaseResponseListChangeInTimeframeResponse from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([])
72
+
73
+ _dict = self.model_dump(
74
+ by_alias=True,
75
+ exclude=excluded_fields,
76
+ exclude_none=True,
77
+ )
78
+ # override the default output from pydantic by calling `to_dict()` of each item in data (list)
79
+ _items = []
80
+ if self.data:
81
+ for _item_data in self.data:
82
+ if _item_data:
83
+ _items.append(_item_data.to_dict())
84
+ _dict["data"] = _items
85
+ # set to None if message (nullable) is None
86
+ # and model_fields_set contains the field
87
+ if self.message is None and "message" in self.model_fields_set:
88
+ _dict["message"] = None
89
+
90
+ # set to None if data (nullable) is None
91
+ # and model_fields_set contains the field
92
+ if self.data is None and "data" in self.model_fields_set:
93
+ _dict["data"] = None
94
+
95
+ return _dict
96
+
97
+ @classmethod
98
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
99
+ """Create an instance of BaseResponseListChangeInTimeframeResponse from a dict"""
100
+ if obj is None:
101
+ return None
102
+
103
+ if not isinstance(obj, dict):
104
+ return cls.model_validate(obj)
105
+
106
+ _obj = cls.model_validate(
107
+ {
108
+ "success": (
109
+ obj.get("success") if obj.get("success") is not None else True
110
+ ),
111
+ "message": obj.get("message"),
112
+ "data": (
113
+ [
114
+ ChangeInTimeframeResponse.from_dict(_item)
115
+ for _item in obj["data"]
116
+ ]
117
+ if obj.get("data") is not None
118
+ else None
119
+ ),
120
+ "timestamp": obj.get("timestamp"),
121
+ }
122
+ )
123
+ return _obj
@@ -0,0 +1,86 @@
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
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Union
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+
26
+ class ChangeInTimeframeResponse(BaseModel):
27
+ """
28
+ ChangeInTimeframeResponse
29
+ """ # noqa: E501
30
+
31
+ pair: StrictStr
32
+ change: Union[StrictFloat, StrictInt]
33
+ __properties: ClassVar[List[str]] = ["pair", "change"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of ChangeInTimeframeResponse from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ return _dict
73
+
74
+ @classmethod
75
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
+ """Create an instance of ChangeInTimeframeResponse from a dict"""
77
+ if obj is None:
78
+ return None
79
+
80
+ if not isinstance(obj, dict):
81
+ return cls.model_validate(obj)
82
+
83
+ _obj = cls.model_validate(
84
+ {"pair": obj.get("pair"), "change": obj.get("change")}
85
+ )
86
+ return _obj
@@ -0,0 +1,35 @@
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
+ from __future__ import annotations
16
+ import json
17
+ from enum import Enum
18
+ from typing_extensions import Self
19
+
20
+
21
+ class MarketType(str, Enum):
22
+ """
23
+ Market types
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ SPOT = "spot"
30
+ FUTURES = "futures"
31
+
32
+ @classmethod
33
+ def from_json(cls, json_str: str) -> Self:
34
+ """Create an instance of MarketType from a JSON string"""
35
+ return cls(json.loads(json_str))
@@ -0,0 +1,198 @@
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
+ from __future__ import annotations
16
+ from inspect import getfullargspec
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from pydantic import (
21
+ BaseModel,
22
+ ConfigDict,
23
+ Field,
24
+ StrictStr,
25
+ ValidationError,
26
+ field_validator,
27
+ )
28
+ from typing import Optional
29
+ from crypticorn.klines.client.models.history_error_response import HistoryErrorResponse
30
+ from crypticorn.klines.client.models.history_no_data_response import (
31
+ HistoryNoDataResponse,
32
+ )
33
+ from crypticorn.klines.client.models.history_success_response import (
34
+ HistorySuccessResponse,
35
+ )
36
+ from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
37
+ from typing_extensions import Literal, Self
38
+ from pydantic import Field
39
+
40
+ RESPONSEGETUDFHISTORY_ANY_OF_SCHEMAS = [
41
+ "HistoryErrorResponse",
42
+ "HistoryNoDataResponse",
43
+ "HistorySuccessResponse",
44
+ ]
45
+
46
+
47
+ class ResponseGetUdfHistory(BaseModel):
48
+ """
49
+ ResponseGetUdfHistory
50
+ """
51
+
52
+ # data type: HistorySuccessResponse
53
+ anyof_schema_1_validator: Optional[HistorySuccessResponse] = None
54
+ # data type: HistoryNoDataResponse
55
+ anyof_schema_2_validator: Optional[HistoryNoDataResponse] = None
56
+ # data type: HistoryErrorResponse
57
+ anyof_schema_3_validator: Optional[HistoryErrorResponse] = None
58
+ if TYPE_CHECKING:
59
+ actual_instance: Optional[
60
+ Union[HistoryErrorResponse, HistoryNoDataResponse, HistorySuccessResponse]
61
+ ] = None
62
+ else:
63
+ actual_instance: Any = None
64
+ any_of_schemas: Set[str] = {
65
+ "HistoryErrorResponse",
66
+ "HistoryNoDataResponse",
67
+ "HistorySuccessResponse",
68
+ }
69
+
70
+ model_config = {
71
+ "validate_assignment": True,
72
+ "protected_namespaces": (),
73
+ }
74
+
75
+ def __init__(self, *args, **kwargs) -> None:
76
+ if args:
77
+ if len(args) > 1:
78
+ raise ValueError(
79
+ "If a position argument is used, only 1 is allowed to set `actual_instance`"
80
+ )
81
+ if kwargs:
82
+ raise ValueError(
83
+ "If a position argument is used, keyword arguments cannot be used."
84
+ )
85
+ super().__init__(actual_instance=args[0])
86
+ else:
87
+ super().__init__(**kwargs)
88
+
89
+ @field_validator("actual_instance")
90
+ def actual_instance_must_validate_anyof(cls, v):
91
+ instance = ResponseGetUdfHistory.model_construct()
92
+ error_messages = []
93
+ # validate data type: HistorySuccessResponse
94
+ if not isinstance(v, HistorySuccessResponse):
95
+ error_messages.append(
96
+ f"Error! Input type `{type(v)}` is not `HistorySuccessResponse`"
97
+ )
98
+ else:
99
+ return v
100
+
101
+ # validate data type: HistoryNoDataResponse
102
+ if not isinstance(v, HistoryNoDataResponse):
103
+ error_messages.append(
104
+ f"Error! Input type `{type(v)}` is not `HistoryNoDataResponse`"
105
+ )
106
+ else:
107
+ return v
108
+
109
+ # validate data type: HistoryErrorResponse
110
+ if not isinstance(v, HistoryErrorResponse):
111
+ error_messages.append(
112
+ f"Error! Input type `{type(v)}` is not `HistoryErrorResponse`"
113
+ )
114
+ else:
115
+ return v
116
+
117
+ if error_messages:
118
+ # no match
119
+ raise ValueError(
120
+ "No match found when setting the actual_instance in ResponseGetUdfHistory with anyOf schemas: HistoryErrorResponse, HistoryNoDataResponse, HistorySuccessResponse. Details: "
121
+ + ", ".join(error_messages)
122
+ )
123
+ else:
124
+ return v
125
+
126
+ @classmethod
127
+ def from_dict(cls, obj: Dict[str, Any]) -> Self:
128
+ return cls.from_json(json.dumps(obj))
129
+
130
+ @classmethod
131
+ def from_json(cls, json_str: str) -> Self:
132
+ """Returns the object represented by the json string"""
133
+ instance = cls.model_construct()
134
+ error_messages = []
135
+ # anyof_schema_1_validator: Optional[HistorySuccessResponse] = None
136
+ try:
137
+ instance.actual_instance = HistorySuccessResponse.from_json(json_str)
138
+ return instance
139
+ except (ValidationError, ValueError) as e:
140
+ error_messages.append(str(e))
141
+ # anyof_schema_2_validator: Optional[HistoryNoDataResponse] = None
142
+ try:
143
+ instance.actual_instance = HistoryNoDataResponse.from_json(json_str)
144
+ return instance
145
+ except (ValidationError, ValueError) as e:
146
+ error_messages.append(str(e))
147
+ # anyof_schema_3_validator: Optional[HistoryErrorResponse] = None
148
+ try:
149
+ instance.actual_instance = HistoryErrorResponse.from_json(json_str)
150
+ return instance
151
+ except (ValidationError, ValueError) as e:
152
+ error_messages.append(str(e))
153
+
154
+ if error_messages:
155
+ # no match
156
+ raise ValueError(
157
+ "No match found when deserializing the JSON string into ResponseGetUdfHistory with anyOf schemas: HistoryErrorResponse, HistoryNoDataResponse, HistorySuccessResponse. Details: "
158
+ + ", ".join(error_messages)
159
+ )
160
+ else:
161
+ return instance
162
+
163
+ def to_json(self) -> str:
164
+ """Returns the JSON representation of the actual instance"""
165
+ if self.actual_instance is None:
166
+ return "null"
167
+
168
+ if hasattr(self.actual_instance, "to_json") and callable(
169
+ self.actual_instance.to_json
170
+ ):
171
+ return self.actual_instance.to_json()
172
+ else:
173
+ return json.dumps(self.actual_instance)
174
+
175
+ def to_dict(
176
+ self,
177
+ ) -> Optional[
178
+ Union[
179
+ Dict[str, Any],
180
+ HistoryErrorResponse,
181
+ HistoryNoDataResponse,
182
+ HistorySuccessResponse,
183
+ ]
184
+ ]:
185
+ """Returns the dict representation of the actual instance"""
186
+ if self.actual_instance is None:
187
+ return None
188
+
189
+ if hasattr(self.actual_instance, "to_dict") and callable(
190
+ self.actual_instance.to_dict
191
+ ):
192
+ return self.actual_instance.to_dict()
193
+ else:
194
+ return self.actual_instance
195
+
196
+ def to_str(self) -> str:
197
+ """Returns the string representation of the actual instance"""
198
+ return pprint.pformat(self.model_dump())