everysk-lib 1.10.2__cp312-cp312-win_amd64.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.
- everysk/__init__.py +30 -0
- everysk/_version.py +683 -0
- everysk/api/__init__.py +61 -0
- everysk/api/api_requestor.py +167 -0
- everysk/api/api_resources/__init__.py +23 -0
- everysk/api/api_resources/api_resource.py +371 -0
- everysk/api/api_resources/calculation.py +779 -0
- everysk/api/api_resources/custom_index.py +42 -0
- everysk/api/api_resources/datastore.py +81 -0
- everysk/api/api_resources/file.py +42 -0
- everysk/api/api_resources/market_data.py +223 -0
- everysk/api/api_resources/parser.py +66 -0
- everysk/api/api_resources/portfolio.py +43 -0
- everysk/api/api_resources/private_security.py +42 -0
- everysk/api/api_resources/report.py +65 -0
- everysk/api/api_resources/report_template.py +39 -0
- everysk/api/api_resources/tests.py +115 -0
- everysk/api/api_resources/worker_execution.py +64 -0
- everysk/api/api_resources/workflow.py +65 -0
- everysk/api/api_resources/workflow_execution.py +93 -0
- everysk/api/api_resources/workspace.py +42 -0
- everysk/api/http_client.py +63 -0
- everysk/api/tests.py +32 -0
- everysk/api/utils.py +262 -0
- everysk/config.py +451 -0
- everysk/core/_tests/serialize/test_json.py +336 -0
- everysk/core/_tests/serialize/test_orjson.py +295 -0
- everysk/core/_tests/serialize/test_pickle.py +48 -0
- everysk/core/cloud_function/main.py +78 -0
- everysk/core/cloud_function/tests.py +86 -0
- everysk/core/compress.py +245 -0
- everysk/core/datetime/__init__.py +12 -0
- everysk/core/datetime/calendar.py +144 -0
- everysk/core/datetime/date.py +424 -0
- everysk/core/datetime/date_expression.py +299 -0
- everysk/core/datetime/date_mixin.py +1475 -0
- everysk/core/datetime/date_settings.py +30 -0
- everysk/core/datetime/datetime.py +713 -0
- everysk/core/exceptions.py +435 -0
- everysk/core/fields.py +1176 -0
- everysk/core/firestore.py +555 -0
- everysk/core/fixtures/_settings.py +29 -0
- everysk/core/fixtures/other/_settings.py +18 -0
- everysk/core/fixtures/user_agents.json +88 -0
- everysk/core/http.py +691 -0
- everysk/core/lists.py +92 -0
- everysk/core/log.py +709 -0
- everysk/core/number.py +37 -0
- everysk/core/object.py +1469 -0
- everysk/core/redis.py +1021 -0
- everysk/core/retry.py +51 -0
- everysk/core/serialize.py +674 -0
- everysk/core/sftp.py +414 -0
- everysk/core/signing.py +53 -0
- everysk/core/slack.py +127 -0
- everysk/core/string.py +199 -0
- everysk/core/tests.py +240 -0
- everysk/core/threads.py +199 -0
- everysk/core/undefined.py +70 -0
- everysk/core/unittests.py +73 -0
- everysk/core/workers.py +241 -0
- everysk/sdk/__init__.py +23 -0
- everysk/sdk/base.py +98 -0
- everysk/sdk/brutils/cnpj.py +391 -0
- everysk/sdk/brutils/cnpj_pd.py +129 -0
- everysk/sdk/engines/__init__.py +26 -0
- everysk/sdk/engines/cache.py +185 -0
- everysk/sdk/engines/compliance.py +37 -0
- everysk/sdk/engines/cryptography.py +69 -0
- everysk/sdk/engines/expression.cp312-win_amd64.pyd +0 -0
- everysk/sdk/engines/expression.pyi +55 -0
- everysk/sdk/engines/helpers.cp312-win_amd64.pyd +0 -0
- everysk/sdk/engines/helpers.pyi +26 -0
- everysk/sdk/engines/lock.py +120 -0
- everysk/sdk/engines/market_data.py +244 -0
- everysk/sdk/engines/settings.py +19 -0
- everysk/sdk/entities/__init__.py +23 -0
- everysk/sdk/entities/base.py +784 -0
- everysk/sdk/entities/base_list.py +131 -0
- everysk/sdk/entities/custom_index/base.py +209 -0
- everysk/sdk/entities/custom_index/settings.py +29 -0
- everysk/sdk/entities/datastore/base.py +160 -0
- everysk/sdk/entities/datastore/settings.py +17 -0
- everysk/sdk/entities/fields.py +375 -0
- everysk/sdk/entities/file/base.py +215 -0
- everysk/sdk/entities/file/settings.py +63 -0
- everysk/sdk/entities/portfolio/base.py +248 -0
- everysk/sdk/entities/portfolio/securities.py +241 -0
- everysk/sdk/entities/portfolio/security.py +580 -0
- everysk/sdk/entities/portfolio/settings.py +97 -0
- everysk/sdk/entities/private_security/base.py +226 -0
- everysk/sdk/entities/private_security/settings.py +17 -0
- everysk/sdk/entities/query.py +603 -0
- everysk/sdk/entities/report/base.py +214 -0
- everysk/sdk/entities/report/settings.py +23 -0
- everysk/sdk/entities/script.py +310 -0
- everysk/sdk/entities/secrets/base.py +128 -0
- everysk/sdk/entities/secrets/script.py +119 -0
- everysk/sdk/entities/secrets/settings.py +17 -0
- everysk/sdk/entities/settings.py +48 -0
- everysk/sdk/entities/tags.py +174 -0
- everysk/sdk/entities/worker_execution/base.py +307 -0
- everysk/sdk/entities/worker_execution/settings.py +63 -0
- everysk/sdk/entities/workflow_execution/base.py +113 -0
- everysk/sdk/entities/workflow_execution/settings.py +32 -0
- everysk/sdk/entities/workspace/base.py +99 -0
- everysk/sdk/entities/workspace/settings.py +27 -0
- everysk/sdk/settings.py +67 -0
- everysk/sdk/tests.py +105 -0
- everysk/sdk/worker_base.py +47 -0
- everysk/server/__init__.py +9 -0
- everysk/server/applications.py +63 -0
- everysk/server/endpoints.py +516 -0
- everysk/server/example_api.py +69 -0
- everysk/server/middlewares.py +80 -0
- everysk/server/requests.py +62 -0
- everysk/server/responses.py +119 -0
- everysk/server/routing.py +64 -0
- everysk/server/settings.py +36 -0
- everysk/server/tests.py +36 -0
- everysk/settings.py +98 -0
- everysk/sql/__init__.py +9 -0
- everysk/sql/connection.py +232 -0
- everysk/sql/model.py +376 -0
- everysk/sql/query.py +417 -0
- everysk/sql/row_factory.py +63 -0
- everysk/sql/settings.py +49 -0
- everysk/sql/utils.py +129 -0
- everysk/tests.py +23 -0
- everysk/utils.py +81 -0
- everysk/version.py +15 -0
- everysk_lib-1.10.2.dist-info/.gitignore +5 -0
- everysk_lib-1.10.2.dist-info/METADATA +326 -0
- everysk_lib-1.10.2.dist-info/RECORD +137 -0
- everysk_lib-1.10.2.dist-info/WHEEL +5 -0
- everysk_lib-1.10.2.dist-info/licenses/LICENSE.txt +9 -0
- everysk_lib-1.10.2.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2023 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from collections.abc import Iterable
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from everysk.core.exceptions import FieldValueError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
###############################################################################
|
|
17
|
+
# EntityList Class Implementation
|
|
18
|
+
###############################################################################
|
|
19
|
+
class EntityList(list):
|
|
20
|
+
"""
|
|
21
|
+
A list subclass with validation capabilities.
|
|
22
|
+
|
|
23
|
+
This class extends the standard Python list and adds validation for the values
|
|
24
|
+
added or inserted into it.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
min_size (int): The minimum allowed size for the list (default is None).
|
|
28
|
+
max_size (int): The maximum allowed size for the list (default is None).
|
|
29
|
+
|
|
30
|
+
Example:
|
|
31
|
+
To create a custom list with validation capabilities:
|
|
32
|
+
my_list = EntityList()
|
|
33
|
+
"""
|
|
34
|
+
min_size: int | None = None
|
|
35
|
+
max_size: int | None = None
|
|
36
|
+
|
|
37
|
+
def __init__(self, *args) -> None:
|
|
38
|
+
"""
|
|
39
|
+
Initialize the EntityList.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
*args: Optional initial elements to populate the list.
|
|
43
|
+
|
|
44
|
+
Example:
|
|
45
|
+
To create an EntityList with initial elements:
|
|
46
|
+
my_list = EntityList([1, 2, 3])
|
|
47
|
+
"""
|
|
48
|
+
if args:
|
|
49
|
+
try:
|
|
50
|
+
args = ([self._validate(item) for item in args[0]], )
|
|
51
|
+
except TypeError:
|
|
52
|
+
raise FieldValueError('Unsupported format.') from TypeError
|
|
53
|
+
super().__init__(*args)
|
|
54
|
+
|
|
55
|
+
def __setitem__(self, index: int, value: Any) -> None:
|
|
56
|
+
"""
|
|
57
|
+
Set an item in the list with validation.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
index (int): The index at which to set the value.
|
|
61
|
+
value: The value to be set.
|
|
62
|
+
"""
|
|
63
|
+
value = self._validate(value)
|
|
64
|
+
return super().__setitem__(index, value)
|
|
65
|
+
|
|
66
|
+
def insert(self, __index: int, __object: Any) -> None:
|
|
67
|
+
"""
|
|
68
|
+
Insert an object at a specified index with validation.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
__index (int): The index at which to insert the object.
|
|
72
|
+
__object: The object to be inserted.
|
|
73
|
+
"""
|
|
74
|
+
__object = self._validate(__object)
|
|
75
|
+
return super().insert(__index, __object)
|
|
76
|
+
|
|
77
|
+
def append(self, __object: Any) -> None:
|
|
78
|
+
"""
|
|
79
|
+
Append an object to the list with validation.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
__object: The object to be appended.
|
|
83
|
+
"""
|
|
84
|
+
__object = self._validate(__object)
|
|
85
|
+
return super().append(__object)
|
|
86
|
+
|
|
87
|
+
def extend(self, __iterable: Iterable) -> None:
|
|
88
|
+
"""
|
|
89
|
+
Extend the list with values from an iterable with validation.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
__iterable (Iterable): An iterable containing values to be added to the list.
|
|
93
|
+
"""
|
|
94
|
+
for value in __iterable:
|
|
95
|
+
value = self._validate(value)
|
|
96
|
+
return super().extend(__iterable)
|
|
97
|
+
|
|
98
|
+
def _validate(self, value: Any) -> Any:
|
|
99
|
+
"""
|
|
100
|
+
Validate a value.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
value: The value to be validated.
|
|
104
|
+
|
|
105
|
+
Raises:
|
|
106
|
+
NotImplementedError: This method should be overridden in subclasses.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
The validated value.
|
|
110
|
+
"""
|
|
111
|
+
raise NotImplementedError()
|
|
112
|
+
|
|
113
|
+
def to_native(self, add_class_path: str | None = None, recursion: bool = False) -> Any:
|
|
114
|
+
"""
|
|
115
|
+
Converts the object to the specified Python type.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
add_class_path (str | None, optional): The class path to add when converting the object. Defaults to None.
|
|
119
|
+
recursion (bool, optional): Indicates whether to recursively convert nested objects. Defaults to False.
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
object: The converted object.
|
|
123
|
+
|
|
124
|
+
"""
|
|
125
|
+
return self.to_list(add_class_path=add_class_path, recursion=recursion)
|
|
126
|
+
|
|
127
|
+
def to_list(self, add_class_path: bool = False, recursion: bool = False) -> list[dict]: # pylint: disable=unused-argument
|
|
128
|
+
"""
|
|
129
|
+
Convert the Securities collection to a list of dictionaries.
|
|
130
|
+
"""
|
|
131
|
+
return list(self)
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2023 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from everysk.config import settings
|
|
11
|
+
from everysk.core.fields import ListField, StrField, FloatField, ChoiceField
|
|
12
|
+
from everysk.core.exceptions import SDKValueError
|
|
13
|
+
from everysk.sdk.entities.base import BaseEntity, ScriptMetaClass
|
|
14
|
+
from everysk.sdk.entities.query import Query
|
|
15
|
+
from everysk.sdk.entities.script import Script
|
|
16
|
+
from everysk.sdk.entities.fields import CurrencyField, EntityNameField, EntityDescriptionField, EntityTagsField
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
###############################################################################
|
|
20
|
+
# CustomIndex Class Implementation
|
|
21
|
+
###############################################################################
|
|
22
|
+
class CustomIndex(BaseEntity, metaclass=ScriptMetaClass):
|
|
23
|
+
"""
|
|
24
|
+
This class represents a custom index entity object.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
script (Script): The script object associated to the entity.
|
|
28
|
+
_orderable_attributes (ListField): The list of orderable attributes.
|
|
29
|
+
symbol (StrField): The symbol of the custom index.
|
|
30
|
+
id (StrField): The id of the custom index.
|
|
31
|
+
data (ListField): The data of the custom index.
|
|
32
|
+
|
|
33
|
+
periodicity (ChoiceField): The periodicity of the custom index.
|
|
34
|
+
data_type (ChoiceField): The data type of the custom index.
|
|
35
|
+
currency (CurrencyField): The currency of the custom index.
|
|
36
|
+
base_price (FloatField): The base price of the custom index.
|
|
37
|
+
|
|
38
|
+
description (EntityDescriptionField): The description of the custom index.
|
|
39
|
+
name (EntityNameField): The name of the custom index.
|
|
40
|
+
tags (EntityTagsField): The tags of the custom index.
|
|
41
|
+
|
|
42
|
+
created_on (DateTimeField): The creation date of the custom index.
|
|
43
|
+
updated_on (DateTimeField): The last update date of the custom index.
|
|
44
|
+
version (IntField): The version of the custom index.
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
>>> from everysk.sdk.entities.custom_index.base import CustomIndex
|
|
48
|
+
>>> custom_index = CustomIndex(
|
|
49
|
+
symbol='CUSTOM:INDEX',
|
|
50
|
+
data=[...],
|
|
51
|
+
periodicity='M',
|
|
52
|
+
data_type='PRICE',
|
|
53
|
+
currency='USD',
|
|
54
|
+
base_price=100,
|
|
55
|
+
description='Custom index description',
|
|
56
|
+
name='Custom index name',
|
|
57
|
+
tags=['tag1', 'tag2']
|
|
58
|
+
)
|
|
59
|
+
>>> custom_index.save()
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
script: Script
|
|
63
|
+
_orderable_attributes = ListField(default=['created_on', 'updated_on', 'name'], readonly=True)
|
|
64
|
+
|
|
65
|
+
symbol = StrField(regex=settings.CUSTOM_INDEX_SYMBOL_REGEX, min_size=settings.CUSTOM_INDEX_SYMBOL_MIN_SIZE, max_size=settings.CUSTOM_INDEX_SYMBOL_MAX_SIZE, required_lazy=True, empty_is_none=True)
|
|
66
|
+
|
|
67
|
+
data = ListField(min_size=settings.CUSTOM_INDEX_MIN_DATA_BLOB, required_lazy=True)
|
|
68
|
+
|
|
69
|
+
periodicity = ChoiceField(default=None, choices=(settings.CUSTOM_INDEX_PERIODICITY_MONTHLY, settings.CUSTOM_INDEX_PERIODICITY_DAILY, None), required_lazy=True)
|
|
70
|
+
data_type = ChoiceField(default=None, choices=(settings.CUSTOM_INDEX_DATA_TYPE_PRICE, settings.CUSTOM_INDEX_DATA_TYPE_RETURN, settings.CUSTOM_INDEX_DATA_TYPE_RETURN_100, None), required_lazy=True)
|
|
71
|
+
currency = CurrencyField()
|
|
72
|
+
base_price = FloatField(min_size=settings.CUSTOM_INDEX_BASE_PRICE_MIN_VAL, max_size=settings.CUSTOM_INDEX_BASE_PRICE_MAX_VAL)
|
|
73
|
+
|
|
74
|
+
description = EntityDescriptionField()
|
|
75
|
+
name = EntityNameField()
|
|
76
|
+
tags = EntityTagsField()
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def id(self) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Returns the id of the custom index. The id is a alias for the symbol.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
str: The id of the custom index.
|
|
85
|
+
|
|
86
|
+
Example:
|
|
87
|
+
>>> custom_index = CustomIndex(symbol='CUSTOM:INDEX')
|
|
88
|
+
>>> custom_index.id
|
|
89
|
+
'CUSTOM:INDEX'
|
|
90
|
+
"""
|
|
91
|
+
return self.symbol
|
|
92
|
+
|
|
93
|
+
@id.setter
|
|
94
|
+
def id(self, value: str) -> None:
|
|
95
|
+
"""
|
|
96
|
+
Sets the id of the custom index. The id is a alias for the symbol.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
value (str): The id of the custom index.
|
|
100
|
+
|
|
101
|
+
Example:
|
|
102
|
+
>>> custom_index = CustomIndex()
|
|
103
|
+
>>> custom_index.id = 'CUSTOM:INDEX'
|
|
104
|
+
>>> custom_index.symbol
|
|
105
|
+
'CUSTOM:INDEX'
|
|
106
|
+
>>> custom_index.id
|
|
107
|
+
'CUSTOM:INDEX'
|
|
108
|
+
"""
|
|
109
|
+
self.symbol = value
|
|
110
|
+
|
|
111
|
+
def validate(self) -> bool:
|
|
112
|
+
"""
|
|
113
|
+
This method validates the entity object and raises an exception if it is not
|
|
114
|
+
valid. The validation is performed by calling the `validate` method of each field
|
|
115
|
+
of the entity.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
self (Self): The entity object to be validated.
|
|
119
|
+
|
|
120
|
+
Raises:
|
|
121
|
+
FieldValueError: If the entity object is not valid.
|
|
122
|
+
RequiredFieldError: If a required field is missing.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
bool: True if the entity object is valid, False otherwise.
|
|
126
|
+
|
|
127
|
+
Example:
|
|
128
|
+
>>> custom_index = CustomIndex(symbol='CUSTOM:INDEX', name='Custom index name', ...)
|
|
129
|
+
>>> custom_index.validate()
|
|
130
|
+
True
|
|
131
|
+
"""
|
|
132
|
+
return self.get_response(self_obj=self)
|
|
133
|
+
|
|
134
|
+
def _pre_validate(self):
|
|
135
|
+
pass
|
|
136
|
+
|
|
137
|
+
def _pos_validate(self):
|
|
138
|
+
self.created_on = None
|
|
139
|
+
self.updated_on = None
|
|
140
|
+
|
|
141
|
+
def _check_query(self, query: Query) -> bool:
|
|
142
|
+
"""
|
|
143
|
+
Check the query object.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
query (Query): The query object.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
Query: The query object.
|
|
150
|
+
"""
|
|
151
|
+
return True
|
|
152
|
+
|
|
153
|
+
def _check_entity_to_query(self) -> bool:
|
|
154
|
+
"""
|
|
155
|
+
Check the entity object to query.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
bool: True if the entity object is valid.
|
|
159
|
+
"""
|
|
160
|
+
if self.name and self.tags:
|
|
161
|
+
raise SDKValueError("Can't filter by Name and Tags at the same time")
|
|
162
|
+
|
|
163
|
+
return True
|
|
164
|
+
|
|
165
|
+
def _mount_query(self, query: Query) -> Query:
|
|
166
|
+
"""
|
|
167
|
+
Mount the query object.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
query (Query): The query object.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
Query: The query object.
|
|
174
|
+
"""
|
|
175
|
+
if self.name is not None:
|
|
176
|
+
query = query.where('name', self.name)
|
|
177
|
+
if self.tags:
|
|
178
|
+
query = query.where('tags', self.tags)
|
|
179
|
+
|
|
180
|
+
return query
|
|
181
|
+
|
|
182
|
+
@staticmethod
|
|
183
|
+
def get_id_prefix() -> str:
|
|
184
|
+
"""
|
|
185
|
+
Returns the prefix of the custom index id field value.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
str: The prefix of the custom index id field value.
|
|
189
|
+
|
|
190
|
+
Example:
|
|
191
|
+
>>> from everysk.sdk.custom_index.base import CustomIndex
|
|
192
|
+
>>> CustomIndex.get_id_prefix()
|
|
193
|
+
'CUSTOM:'
|
|
194
|
+
"""
|
|
195
|
+
return settings.CUSTOM_INDEX_SYMBOL_PREFIX
|
|
196
|
+
|
|
197
|
+
@classmethod
|
|
198
|
+
def modify_many(cls, entity_id_list: list[str], overwrites: dict | list[dict]) -> list:
|
|
199
|
+
"""
|
|
200
|
+
The custom index does not support the modify_many method.
|
|
201
|
+
"""
|
|
202
|
+
raise NotImplementedError()
|
|
203
|
+
|
|
204
|
+
@classmethod
|
|
205
|
+
def clone_many(cls, entity_id_list: list[str], overwrites: dict | list[dict]) -> list:
|
|
206
|
+
"""
|
|
207
|
+
The custom index does not support the clone_many method.
|
|
208
|
+
"""
|
|
209
|
+
raise NotImplementedError()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2023 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from everysk.core.fields import StrField, IntField, FloatField, RegexField
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
CUSTOM_INDEX_SYMBOL_REGEX = RegexField(default=r'^CUSTOM:[A-Z0-9_]*$', readonly=True)
|
|
14
|
+
CUSTOM_INDEX_SYMBOL_PREFIX = StrField(default='CUSTOM:', readonly=True)
|
|
15
|
+
|
|
16
|
+
CUSTOM_INDEX_SYMBOL_MIN_SIZE = IntField(default=8, readonly=True) # len(CUSTOM_INDEX_SYMBOL_PREFIX) + 1
|
|
17
|
+
CUSTOM_INDEX_SYMBOL_MAX_SIZE = IntField(default=107, readonly=True) # len(CUSTOM_INDEX_SYMBOL_PREFIX) + 100
|
|
18
|
+
|
|
19
|
+
CUSTOM_INDEX_MIN_DATA_BLOB = IntField(default=1, readonly=True)
|
|
20
|
+
|
|
21
|
+
CUSTOM_INDEX_BASE_PRICE_MIN_VAL = FloatField(default=-9999999999999.99, readonly=True)
|
|
22
|
+
CUSTOM_INDEX_BASE_PRICE_MAX_VAL = FloatField(default=+9999999999999.99, readonly=True)
|
|
23
|
+
|
|
24
|
+
CUSTOM_INDEX_DATA_TYPE_PRICE = StrField(default='PRICE', readonly=True)
|
|
25
|
+
CUSTOM_INDEX_DATA_TYPE_RETURN = StrField(default='RETURN', readonly=True)
|
|
26
|
+
CUSTOM_INDEX_DATA_TYPE_RETURN_100 = StrField(default='RETURN_100', readonly=True)
|
|
27
|
+
|
|
28
|
+
CUSTOM_INDEX_PERIODICITY_MONTHLY = StrField(default='M', readonly=True)
|
|
29
|
+
CUSTOM_INDEX_PERIODICITY_DAILY = StrField(default='D', readonly=True)
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2023 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from everysk.config import settings
|
|
13
|
+
from everysk.core.exceptions import RequiredError, FieldValueError
|
|
14
|
+
from everysk.core.fields import ListField, StrField
|
|
15
|
+
from everysk.core.serialize import dumps
|
|
16
|
+
|
|
17
|
+
from everysk.sdk.entities.base import BaseEntity, ScriptMetaClass
|
|
18
|
+
from everysk.sdk.entities.fields import EntityNameField, EntityDescriptionField, EntityLinkUIDField, EntityWorkspaceField, EntityDateTimeField, EntityTagsField
|
|
19
|
+
from everysk.sdk.entities.script import Script
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
###############################################################################
|
|
23
|
+
# Datastore Class Implementation
|
|
24
|
+
###############################################################################
|
|
25
|
+
class Datastore(BaseEntity, metaclass=ScriptMetaClass):
|
|
26
|
+
"""
|
|
27
|
+
This class represents a datastore entity object and provides methods to validate
|
|
28
|
+
and manage the entity object's data.
|
|
29
|
+
|
|
30
|
+
Attributes:
|
|
31
|
+
script (Script): The script object associated with the datastore.
|
|
32
|
+
id (StrField): The unique identifier of the datastore.
|
|
33
|
+
workspace (EntityWorkspaceField): The workspace of the datastore.
|
|
34
|
+
name (EntityNameField): The name of the datastore.
|
|
35
|
+
tags (EntityTagsField): The tags of the datastore.
|
|
36
|
+
description (EntityDescriptionField): The description of the datastore.
|
|
37
|
+
link_uid (EntityLinkUIDField): The link UID of the datastore.
|
|
38
|
+
date (EntityDateTimeField): The date associated with the datastore.
|
|
39
|
+
data (Any): The data associated with the datastore.
|
|
40
|
+
level (StrField): The level of the datastore.
|
|
41
|
+
|
|
42
|
+
version (StrField): The version of the datastore.
|
|
43
|
+
created_on (DateTimeField): The created on date of the datastore.
|
|
44
|
+
updated_on (DateTimeField): The updated on date of the datastore.
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
>>> from everysk.sdk.entities.datastore.base import Datastore
|
|
48
|
+
>>> datastore = Datastore()
|
|
49
|
+
>>> datastore.id = 'dats_12345678'
|
|
50
|
+
>>> datastore.name = 'My Datastore'
|
|
51
|
+
>>> datastore.tags = ['tag1', 'tag2']
|
|
52
|
+
>>> datastore.description = 'This is a sample datastore.'
|
|
53
|
+
>>> datastore.workspace = 'my_workspace'
|
|
54
|
+
>>> datastore.date = DateTime.fromisoformat('20220101')
|
|
55
|
+
>>> datastore.level = '1'
|
|
56
|
+
>>> datastore.data = {'key1': 'value1', 'key2': 'value2'}
|
|
57
|
+
>>> datastore.create()
|
|
58
|
+
>>> print(datastore)
|
|
59
|
+
{
|
|
60
|
+
'id': 'dats_12345678',
|
|
61
|
+
'name': 'My Datastore',
|
|
62
|
+
'description': 'This is a sample datastore.',
|
|
63
|
+
'tags': ['tag1', 'tag2'],
|
|
64
|
+
'link_uid': None,
|
|
65
|
+
'workspace': 'my_workspace',
|
|
66
|
+
'date': '20220101',
|
|
67
|
+
'level': '1',
|
|
68
|
+
'data': {'key1': 'value1', 'key2': 'value2'},
|
|
69
|
+
'version': 'v1',
|
|
70
|
+
'created_on': '2021-01-01T00:00:00.000000Z',
|
|
71
|
+
'updated_on': '2021-01-01T00:00:00.000000Z',
|
|
72
|
+
}
|
|
73
|
+
"""
|
|
74
|
+
script: Script = None
|
|
75
|
+
_orderable_attributes = ListField(default=['date', 'created_on', 'updated_on', 'name'], readonly=True)
|
|
76
|
+
|
|
77
|
+
id = StrField(regex=settings.DATASTORE_ID_REGEX, max_size=settings.DATASTORE_ID_MAX_SIZE, required_lazy=True, empty_is_none=True)
|
|
78
|
+
|
|
79
|
+
name = EntityNameField()
|
|
80
|
+
description = EntityDescriptionField()
|
|
81
|
+
tags = EntityTagsField()
|
|
82
|
+
link_uid = EntityLinkUIDField()
|
|
83
|
+
workspace = EntityWorkspaceField()
|
|
84
|
+
|
|
85
|
+
date = EntityDateTimeField()
|
|
86
|
+
level = StrField(min_size=1, max_size=settings.DATASTORE_LEVEL_MAX_LENGTH)
|
|
87
|
+
|
|
88
|
+
data: Any = None
|
|
89
|
+
|
|
90
|
+
def __init__(self, data=None, **kwargs) -> None:
|
|
91
|
+
super().__init__(data=data, **kwargs)
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def get_id_prefix() -> str:
|
|
95
|
+
"""
|
|
96
|
+
Returns the prefix of the datastore id field value.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
str: The prefix of the datastore id field value.
|
|
100
|
+
|
|
101
|
+
Example:
|
|
102
|
+
>>> Datastore.get_id_prefix()
|
|
103
|
+
'dats_'
|
|
104
|
+
|
|
105
|
+
Notes:
|
|
106
|
+
The prefix is typically used to distinguish datastore IDs from other types of IDs
|
|
107
|
+
"""
|
|
108
|
+
return settings.DATASTORE_ID_PREFIX
|
|
109
|
+
|
|
110
|
+
def validate_type_data(self) -> bool:
|
|
111
|
+
"""
|
|
112
|
+
Validates the 'data' attribute of the Datastore entity to ensure it is not None and contains valid JSON data.
|
|
113
|
+
|
|
114
|
+
Raises:
|
|
115
|
+
RequiredError: If the 'data' attribute is None.
|
|
116
|
+
FieldValueError: If the 'data' attribute is not valid JSON.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
bool: True if validation succeeds.
|
|
120
|
+
|
|
121
|
+
Example:
|
|
122
|
+
>>> datastore = Datastore()
|
|
123
|
+
>>> datastore.data = {'key1': 'value1', 'key2': 'value2'}
|
|
124
|
+
>>> datastore.validate_type_data() # Validation succeeds
|
|
125
|
+
True
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
if self.data is None:
|
|
129
|
+
raise RequiredError('The data attribute is required')
|
|
130
|
+
|
|
131
|
+
try:
|
|
132
|
+
dumps(self.data)
|
|
133
|
+
except Exception as exc: # pylint: disable=broad-except
|
|
134
|
+
raise FieldValueError('Datastore data is not a valid json') from exc
|
|
135
|
+
|
|
136
|
+
return True
|
|
137
|
+
|
|
138
|
+
def validate(self) -> bool:
|
|
139
|
+
"""
|
|
140
|
+
This method validates the entity object and raises an exception if it is not
|
|
141
|
+
valid. The validation is performed by calling the `validate` method of each field
|
|
142
|
+
of the entity.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
self (Self): The entity object to be validated.
|
|
146
|
+
|
|
147
|
+
Raises:
|
|
148
|
+
FieldValueError: If the entity object is not valid.
|
|
149
|
+
RequiredFieldError: If a required field is missing.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
bool: True if the entity object is valid, False otherwise.
|
|
153
|
+
|
|
154
|
+
Example:
|
|
155
|
+
>>> entity = Entity()
|
|
156
|
+
>>> entity.validate()
|
|
157
|
+
True
|
|
158
|
+
"""
|
|
159
|
+
self.validate_type_data()
|
|
160
|
+
return self.get_response(self_obj=self)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
###############################################################################
|
|
2
|
+
#
|
|
3
|
+
# (C) Copyright 2023 EVERYSK TECHNOLOGIES
|
|
4
|
+
#
|
|
5
|
+
# This is an unpublished work containing confidential and proprietary
|
|
6
|
+
# information of EVERYSK TECHNOLOGIES. Disclosure, use, or reproduction
|
|
7
|
+
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
|
+
#
|
|
9
|
+
###############################################################################
|
|
10
|
+
from everysk.core.fields import StrField, IntField, RegexField
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
DATASTORE_ID_REGEX = RegexField(default=r'^dats_[a-zA-Z0-9]', readonly=True)
|
|
14
|
+
DATASTORE_ID_PREFIX = StrField(default='dats_', readonly=True)
|
|
15
|
+
DATASTORE_ID_MAX_SIZE = IntField(default=30, readonly=True)
|
|
16
|
+
|
|
17
|
+
DATASTORE_LEVEL_MAX_LENGTH = IntField(default=32, readonly=True)
|