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.
Files changed (137) hide show
  1. everysk/__init__.py +30 -0
  2. everysk/_version.py +683 -0
  3. everysk/api/__init__.py +61 -0
  4. everysk/api/api_requestor.py +167 -0
  5. everysk/api/api_resources/__init__.py +23 -0
  6. everysk/api/api_resources/api_resource.py +371 -0
  7. everysk/api/api_resources/calculation.py +779 -0
  8. everysk/api/api_resources/custom_index.py +42 -0
  9. everysk/api/api_resources/datastore.py +81 -0
  10. everysk/api/api_resources/file.py +42 -0
  11. everysk/api/api_resources/market_data.py +223 -0
  12. everysk/api/api_resources/parser.py +66 -0
  13. everysk/api/api_resources/portfolio.py +43 -0
  14. everysk/api/api_resources/private_security.py +42 -0
  15. everysk/api/api_resources/report.py +65 -0
  16. everysk/api/api_resources/report_template.py +39 -0
  17. everysk/api/api_resources/tests.py +115 -0
  18. everysk/api/api_resources/worker_execution.py +64 -0
  19. everysk/api/api_resources/workflow.py +65 -0
  20. everysk/api/api_resources/workflow_execution.py +93 -0
  21. everysk/api/api_resources/workspace.py +42 -0
  22. everysk/api/http_client.py +63 -0
  23. everysk/api/tests.py +32 -0
  24. everysk/api/utils.py +262 -0
  25. everysk/config.py +451 -0
  26. everysk/core/_tests/serialize/test_json.py +336 -0
  27. everysk/core/_tests/serialize/test_orjson.py +295 -0
  28. everysk/core/_tests/serialize/test_pickle.py +48 -0
  29. everysk/core/cloud_function/main.py +78 -0
  30. everysk/core/cloud_function/tests.py +86 -0
  31. everysk/core/compress.py +245 -0
  32. everysk/core/datetime/__init__.py +12 -0
  33. everysk/core/datetime/calendar.py +144 -0
  34. everysk/core/datetime/date.py +424 -0
  35. everysk/core/datetime/date_expression.py +299 -0
  36. everysk/core/datetime/date_mixin.py +1475 -0
  37. everysk/core/datetime/date_settings.py +30 -0
  38. everysk/core/datetime/datetime.py +713 -0
  39. everysk/core/exceptions.py +435 -0
  40. everysk/core/fields.py +1176 -0
  41. everysk/core/firestore.py +555 -0
  42. everysk/core/fixtures/_settings.py +29 -0
  43. everysk/core/fixtures/other/_settings.py +18 -0
  44. everysk/core/fixtures/user_agents.json +88 -0
  45. everysk/core/http.py +691 -0
  46. everysk/core/lists.py +92 -0
  47. everysk/core/log.py +709 -0
  48. everysk/core/number.py +37 -0
  49. everysk/core/object.py +1469 -0
  50. everysk/core/redis.py +1021 -0
  51. everysk/core/retry.py +51 -0
  52. everysk/core/serialize.py +674 -0
  53. everysk/core/sftp.py +414 -0
  54. everysk/core/signing.py +53 -0
  55. everysk/core/slack.py +127 -0
  56. everysk/core/string.py +199 -0
  57. everysk/core/tests.py +240 -0
  58. everysk/core/threads.py +199 -0
  59. everysk/core/undefined.py +70 -0
  60. everysk/core/unittests.py +73 -0
  61. everysk/core/workers.py +241 -0
  62. everysk/sdk/__init__.py +23 -0
  63. everysk/sdk/base.py +98 -0
  64. everysk/sdk/brutils/cnpj.py +391 -0
  65. everysk/sdk/brutils/cnpj_pd.py +129 -0
  66. everysk/sdk/engines/__init__.py +26 -0
  67. everysk/sdk/engines/cache.py +185 -0
  68. everysk/sdk/engines/compliance.py +37 -0
  69. everysk/sdk/engines/cryptography.py +69 -0
  70. everysk/sdk/engines/expression.cp312-win_amd64.pyd +0 -0
  71. everysk/sdk/engines/expression.pyi +55 -0
  72. everysk/sdk/engines/helpers.cp312-win_amd64.pyd +0 -0
  73. everysk/sdk/engines/helpers.pyi +26 -0
  74. everysk/sdk/engines/lock.py +120 -0
  75. everysk/sdk/engines/market_data.py +244 -0
  76. everysk/sdk/engines/settings.py +19 -0
  77. everysk/sdk/entities/__init__.py +23 -0
  78. everysk/sdk/entities/base.py +784 -0
  79. everysk/sdk/entities/base_list.py +131 -0
  80. everysk/sdk/entities/custom_index/base.py +209 -0
  81. everysk/sdk/entities/custom_index/settings.py +29 -0
  82. everysk/sdk/entities/datastore/base.py +160 -0
  83. everysk/sdk/entities/datastore/settings.py +17 -0
  84. everysk/sdk/entities/fields.py +375 -0
  85. everysk/sdk/entities/file/base.py +215 -0
  86. everysk/sdk/entities/file/settings.py +63 -0
  87. everysk/sdk/entities/portfolio/base.py +248 -0
  88. everysk/sdk/entities/portfolio/securities.py +241 -0
  89. everysk/sdk/entities/portfolio/security.py +580 -0
  90. everysk/sdk/entities/portfolio/settings.py +97 -0
  91. everysk/sdk/entities/private_security/base.py +226 -0
  92. everysk/sdk/entities/private_security/settings.py +17 -0
  93. everysk/sdk/entities/query.py +603 -0
  94. everysk/sdk/entities/report/base.py +214 -0
  95. everysk/sdk/entities/report/settings.py +23 -0
  96. everysk/sdk/entities/script.py +310 -0
  97. everysk/sdk/entities/secrets/base.py +128 -0
  98. everysk/sdk/entities/secrets/script.py +119 -0
  99. everysk/sdk/entities/secrets/settings.py +17 -0
  100. everysk/sdk/entities/settings.py +48 -0
  101. everysk/sdk/entities/tags.py +174 -0
  102. everysk/sdk/entities/worker_execution/base.py +307 -0
  103. everysk/sdk/entities/worker_execution/settings.py +63 -0
  104. everysk/sdk/entities/workflow_execution/base.py +113 -0
  105. everysk/sdk/entities/workflow_execution/settings.py +32 -0
  106. everysk/sdk/entities/workspace/base.py +99 -0
  107. everysk/sdk/entities/workspace/settings.py +27 -0
  108. everysk/sdk/settings.py +67 -0
  109. everysk/sdk/tests.py +105 -0
  110. everysk/sdk/worker_base.py +47 -0
  111. everysk/server/__init__.py +9 -0
  112. everysk/server/applications.py +63 -0
  113. everysk/server/endpoints.py +516 -0
  114. everysk/server/example_api.py +69 -0
  115. everysk/server/middlewares.py +80 -0
  116. everysk/server/requests.py +62 -0
  117. everysk/server/responses.py +119 -0
  118. everysk/server/routing.py +64 -0
  119. everysk/server/settings.py +36 -0
  120. everysk/server/tests.py +36 -0
  121. everysk/settings.py +98 -0
  122. everysk/sql/__init__.py +9 -0
  123. everysk/sql/connection.py +232 -0
  124. everysk/sql/model.py +376 -0
  125. everysk/sql/query.py +417 -0
  126. everysk/sql/row_factory.py +63 -0
  127. everysk/sql/settings.py +49 -0
  128. everysk/sql/utils.py +129 -0
  129. everysk/tests.py +23 -0
  130. everysk/utils.py +81 -0
  131. everysk/version.py +15 -0
  132. everysk_lib-1.10.2.dist-info/.gitignore +5 -0
  133. everysk_lib-1.10.2.dist-info/METADATA +326 -0
  134. everysk_lib-1.10.2.dist-info/RECORD +137 -0
  135. everysk_lib-1.10.2.dist-info/WHEEL +5 -0
  136. everysk_lib-1.10.2.dist-info/licenses/LICENSE.txt +9 -0
  137. everysk_lib-1.10.2.dist-info/top_level.txt +2 -0
@@ -0,0 +1,115 @@
1
+ ###############################################################################
2
+ #
3
+ # (C) Copyright 2025 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
+ # pylint: disable=unused-import
11
+
12
+ ###########################################
13
+ # API RESOURCE
14
+ ###########################################
15
+ from everysk.api.api_resources._tests.api_resource import APIResourceTestCase as EveryskLibAPIResourceTestCase
16
+
17
+ ###########################################
18
+ # FILE
19
+ ###########################################
20
+ from everysk.api.api_resources._tests.file import APIFileTestCase as EveryskLibAPIFileTestCase
21
+
22
+ ###########################################
23
+ # CUSTOM INDEX
24
+ ###########################################
25
+ from everysk.api.api_resources._tests.custom_index import APICustomIndexTestCase as EveryskLibAPICustomIndexTestCase
26
+
27
+ ###########################################
28
+ # PRIVATE SECURITY
29
+ ###########################################
30
+ from everysk.api.api_resources._tests.private_security import APIPrivateSecurityTestCase as EveryskLibAPIPrivateSecurityTestCase
31
+
32
+ ###########################################
33
+ # WORKSPACE
34
+ ###########################################
35
+ from everysk.api.api_resources._tests.workspace import APIWorkspaceTestCase as EveryskLibAPIWorkspaceTestCase
36
+
37
+ ###########################################
38
+ # REPORT TEMPLATE
39
+ ###########################################
40
+ from everysk.api.api_resources._tests.report_template import APIReportTemplateTestCase as EveryskLibAPIReportTemplateTestCase
41
+
42
+ ###########################################
43
+ # PORTFOLIO
44
+ ###########################################
45
+ from everysk.api.api_resources._tests.portfolio import APIPortfolioTestCase as EveryskLibAPIPortfolioTestCase
46
+
47
+ ###########################################
48
+ # DATASTORE
49
+ ###########################################
50
+ from everysk.api.api_resources._tests.datastore import APIDatastoreTestCase as EveryskLibAPIDatastoreTestCase
51
+
52
+ ###########################################
53
+ # WORKER EXECUTION
54
+ ###########################################
55
+ from everysk.api.api_resources._tests.worker_execution import APIWorkerExecutionTestCase as EveryskLibAPIWorkerExecutionTestCase
56
+
57
+ ###########################################
58
+ # PARSER
59
+ ###########################################
60
+ from everysk.api.api_resources._tests.parser import APIParserTestCase as EveryskLibAPIParserTestCase
61
+
62
+ ###########################################
63
+ # WORKFLOW EXECUTION
64
+ ###########################################
65
+ from everysk.api.api_resources._tests.workflow_execution import APIWorkflowExecutionTestCase as EveryskLibAPIWorkflowExecutionTestCase
66
+
67
+ ###########################################
68
+ # WORKFLOW
69
+ ###########################################
70
+ from everysk.api.api_resources._tests.workflow import APIWorkflowTestCase as EveryskLibAPIWorkflowTestCase
71
+
72
+ ###########################################
73
+ # CALCULATION
74
+ ###########################################
75
+ from everysk.api.api_resources._tests.calculation import APICalculationTestCase as EveryskLibAPICalculationTestCase
76
+
77
+ ###########################################
78
+ # MARKET DATA
79
+ ###########################################
80
+ from everysk.api.api_resources._tests.market_data import APIMarketDataTestCase as EveryskLibAPIMarketDataTestCase
81
+
82
+ ###########################################
83
+ # REPORT
84
+ ###########################################
85
+ from everysk.api.api_resources._tests.report import APIReportTestCase as EveryskLibAPIReportTestCase
86
+
87
+ ###########################################
88
+ # RETRIEVABLE API
89
+ ###########################################
90
+ from everysk.api.api_resources._tests.api_resource import RetrievableAPIResourceTestCase as EveryskLibRetrievableAPIResourceTestCase
91
+
92
+ ###########################################
93
+ # LISTABLE API
94
+ ###########################################
95
+ from everysk.api.api_resources._tests.api_resource import ListableAPIResourceTestCase as EveryskLibListableAPIResourceTestCase
96
+
97
+ ###########################################
98
+ # CREATABLE API
99
+ ###########################################
100
+ from everysk.api.api_resources._tests.api_resource import CreatableAPIResourceTestCase as EveryskLibCreatableAPIResourceTestCase
101
+
102
+ ###########################################
103
+ # FILTERABLE API
104
+ ###########################################
105
+ from everysk.api.api_resources._tests.api_resource import FilterableAPIResourceTestCase as EveryskLibFilterableAPIResourceTestCase
106
+
107
+ ###########################################
108
+ # UPDATABLE API
109
+ ###########################################
110
+ from everysk.api.api_resources._tests.api_resource import UpdatableAPIResourceTestCase as EveryskLibUpdatableAPIResourceTestCase
111
+
112
+ ###########################################
113
+ # DELETABLE API
114
+ ###########################################
115
+ from everysk.api.api_resources._tests.api_resource import DeletableAPIResourceTestCase as EveryskLibDeletableAPIResourceTestCase
@@ -0,0 +1,64 @@
1
+ ###############################################################################
2
+ #
3
+ # (C) Copyright 2025 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
+
11
+ ###############################################################################
12
+ # Imports
13
+ ###############################################################################
14
+ from everysk.api.api_resources.api_resource import (
15
+ RetrievableAPIResource,
16
+ ListableAPIResource,
17
+ DeletableAPIResource
18
+ )
19
+ from everysk.api import utils
20
+
21
+ ###############################################################################
22
+ # Worker Execution Implementation
23
+ ###############################################################################
24
+ class WorkerExecution(
25
+ RetrievableAPIResource,
26
+ ListableAPIResource,
27
+ DeletableAPIResource
28
+ ):
29
+
30
+ @classmethod
31
+ def retrieve(cls, **kwargs):
32
+ """
33
+ Retrieves details of a single worker execution or a list of worker executions based on the provided arguments.
34
+ This class method sends a GET request to the API to retrieve a worker execution.
35
+
36
+ Args:
37
+ worker_execution_id (str, optional):
38
+ The ID of the worker execution to retrieve. If specified, the method
39
+ returns details for this specific worker execution. If omitted, the
40
+ method may return a list of worker executions based on other filters.
41
+
42
+ workflow_execution_id (str, optional):
43
+ The ID of the workflow execution to fetch the worker executions for.
44
+ This argument is considered only if 'worker_execution_id' is not provided.
45
+
46
+ with_result (bool, optional):
47
+ Indicates whether to include detailed results in the response. The default
48
+ behavior depends on the context of the request (detailed for a single execution,
49
+ summary for a list).
50
+
51
+ Returns:
52
+ WorkerExecution: An instance of the WorkerExecution class
53
+
54
+ Example:
55
+ # Retrieve details for a specific worker execution
56
+ >>> worker_execution = WorkerExecution.retrieve(worker_execution_id='12345')
57
+
58
+ # Retrieve a list of worker executions for a specific workflow execution
59
+ >>> worker_executions = WorkerExecution.retrieve(workflow_execution_id='67890')
60
+ """
61
+ api_req = utils.create_api_requestor(kwargs)
62
+ url = f'/workflows{cls.class_url()}'
63
+ response = api_req.get(url, kwargs)
64
+ return utils.to_object(WorkerExecution, kwargs, response)
@@ -0,0 +1,65 @@
1
+ ###############################################################################
2
+ #
3
+ # (C) Copyright 2025 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
+
11
+ ###############################################################################
12
+ # Imports
13
+ ###############################################################################
14
+ from everysk.api.api_resources.api_resource import (
15
+ RetrievableAPIResource,
16
+ ListableAPIResource,
17
+ DeletableAPIResource,
18
+ CreateableAPIResource,
19
+ UpdateableAPIResource
20
+ )
21
+ from everysk.api.api_resources.workflow_execution import WorkflowExecution
22
+ from everysk.api import utils
23
+
24
+ ###############################################################################
25
+ # Workflow Implementation
26
+ ###############################################################################
27
+ class Workflow(
28
+ RetrievableAPIResource,
29
+ ListableAPIResource,
30
+ DeletableAPIResource,
31
+ CreateableAPIResource,
32
+ UpdateableAPIResource
33
+ ):
34
+
35
+ @classmethod
36
+ def run(cls, id, **kwargs):
37
+ """
38
+ Executes a workflow based on the provided ID, and any additional keyword arguments provided.
39
+ This method constructs an API request to trigger the execution of a specific workflow. It uses the
40
+ `create_api_requestor` function to establish API communication, constructs the appropriate URL,
41
+ and sends a POST request to initiate the workflow execution.
42
+
43
+ Args:
44
+ id (str):
45
+ The identifier of the workflow to be executed.
46
+
47
+ **kwargs:
48
+ Additional keyword arguments passed for the API request customization.
49
+
50
+ Returns:
51
+ WorkflowExecution: An instance of WorkflowExecution
52
+
53
+ Example:
54
+ >>> from everysk.api.api_resources.workflow import Workflow
55
+ >>> response = Workflow.run('12345', param1='value1', param2='value2')
56
+ >>> print(response)
57
+ """
58
+ api_req = utils.create_api_requestor(kwargs)
59
+ url = f'{cls.class_url()}/{id}/run'
60
+ response = api_req.post(url, kwargs)
61
+ extra_keys = None
62
+
63
+ if kwargs.get('synchronous', None):
64
+ extra_keys = ['result']
65
+ return utils.to_object(WorkflowExecution, kwargs, response, extra_keys=extra_keys)
@@ -0,0 +1,93 @@
1
+ ###############################################################################
2
+ #
3
+ # (C) Copyright 2025 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
+
11
+ ###############################################################################
12
+ # Imports
13
+ ###############################################################################
14
+ from everysk.api.api_resources.api_resource import (
15
+ RetrievableAPIResource,
16
+ ListableAPIResource,
17
+ DeletableAPIResource
18
+ )
19
+ from everysk.api import utils
20
+ from .worker_execution import WorkerExecution
21
+
22
+ ###############################################################################
23
+ # Workflow Execution Implementation
24
+ ###############################################################################
25
+ class WorkflowExecution(
26
+ RetrievableAPIResource,
27
+ ListableAPIResource,
28
+ DeletableAPIResource
29
+ ):
30
+
31
+ @classmethod
32
+ def retrieve(cls, workflow_id, **kwargs):
33
+ """
34
+ Retrieves a single workflow execution or a paginated list of workflow executions associated with a given workflow ID.
35
+ When a specific workflow execution ID is provided, details for that execution are returned. Without an execution ID,
36
+ the method returns a paginated list of all executions for the workflow.
37
+ If `workflow_execution_id` is not provided, pagination parameters (`page_size` and `page_token`) can be used to
38
+ navigate through a potentially large set of workflow executions.
39
+
40
+ Args:
41
+ workflow_id (str):
42
+ The unique identifier of the workflow for which executions are being retrieved.
43
+
44
+ workflow_execution_id (str, optional):
45
+ The specific workflow execution ID to retrieve. If provided, the method
46
+ returns information for this execution only.
47
+
48
+ page_size (int, optional):
49
+ The number of items to return in a single page (applicable when retrieving a list
50
+ of workflow executions).
51
+
52
+ page_token (str, optional):
53
+ The token for the next page of results (applicable when retrieving a list of
54
+ workflow executions).
55
+
56
+ Returns:
57
+ WorkflowExecution or list: If a `workflow_execution_id` is provided, returns a `WorkflowExecution` object for that ID.
58
+ Otherwise, returns a list of `WorkflowExecution` objects for the specified workflow ID,
59
+ potentially paginated.
60
+ """
61
+ api_req = utils.create_api_requestor(kwargs)
62
+ url = f'/workflows/{workflow_id}{cls.class_url()}'
63
+ response = api_req.get(url, kwargs)
64
+ return utils.to_object(WorkflowExecution, kwargs, response)
65
+
66
+ @classmethod
67
+ def syncronous_retrieve(cls, workflow_id, **kwargs):
68
+ """
69
+ Retrieves a workflow execution synchronously.
70
+ This class method retrieves a workflow execution synchronously, continuously polling the API until the execution is completed.
71
+
72
+ Args:
73
+ workflow_id (str):
74
+ The unique identifier of the workflow for which the execution is being retrieved.
75
+
76
+ **kwargs:
77
+ Additional keyword arguments passed to the `retrieve` method. These can include parameters like
78
+ `workflow_execution_id` to specify the exact execution to poll, or pagination parameters (`page_size`,
79
+ `page_token`) when expecting a list of executions.
80
+
81
+ Returns:
82
+ An instance of `WorkerExecution` containing the details of the ender worker execution of the completed workflow, including execution results.
83
+ """
84
+ workflow_execution = None
85
+ status = None
86
+
87
+ while status != 'COMPLETED':
88
+ workflow_execution = cls.retrieve(workflow_id, **kwargs)
89
+ status = workflow_execution['status']
90
+ utils.sleep(1)
91
+
92
+ worker_execution_id = workflow_execution['ender_worker_execution_id']
93
+ return WorkerExecution.retrieve(worker_execution_id=worker_execution_id, with_result=True)
@@ -0,0 +1,42 @@
1
+ ###############################################################################
2
+ #
3
+ # (C) Copyright 2025 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
+
11
+ ###############################################################################
12
+ # Imports
13
+ ###############################################################################
14
+ from everysk.api.api_resources.api_resource import (
15
+ RetrievableAPIResource,
16
+ ListableAPIResource,
17
+ DeletableAPIResource,
18
+ CreateableAPIResource,
19
+ UpdateableAPIResource
20
+ )
21
+
22
+ ###############################################################################
23
+ # Workspace Implementation
24
+ ###############################################################################
25
+ class Workspace(
26
+ RetrievableAPIResource,
27
+ ListableAPIResource,
28
+ DeletableAPIResource,
29
+ CreateableAPIResource,
30
+ UpdateableAPIResource
31
+ ):
32
+ """
33
+ Represents a workspace object
34
+
35
+ Args:
36
+ RetrievableAPIResource (_type_): _description_
37
+ ListableAPIResource (_type_): _description_
38
+ DeletableAPIResource (_type_): _description_
39
+ CreateableAPIResource (_type_): _description_
40
+ UpdateableAPIResource (_type_): _description_
41
+ """
42
+ pass
@@ -0,0 +1,63 @@
1
+ ###############################################################################
2
+ #
3
+ # (C) Copyright 2025 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
+ import requests
11
+ from requests.packages.urllib3.exceptions import InsecureRequestWarning # pylint: disable=import-error
12
+
13
+ from everysk.core.datetime.date_settings import DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT
14
+ from everysk.core.serialize import dumps
15
+
16
+ requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # pylint: disable=no-member
17
+
18
+
19
+ ###############################################################################
20
+ # HTTPClient Implementation
21
+ ###############################################################################
22
+ class HTTPClient:
23
+ def __init__(self, timeout=3600, verify_ssl_certs=True, allow_redirects=False) -> None:
24
+ self.timeout = timeout
25
+ self.allow_redirects = allow_redirects
26
+ self.verify_ssl_certs = verify_ssl_certs
27
+
28
+ def request(self, method, url, headers, params=None, payload=None):
29
+ raise NotImplementedError('HTTPClient subclasses must implement `request`.')
30
+
31
+
32
+ ###############################################################################
33
+ # Requests Client Implementation
34
+ ###############################################################################
35
+ class RequestsClient(HTTPClient):
36
+ def request(self, method, url, headers, params=None, payload=None):
37
+ _args = {
38
+ 'method': method,
39
+ 'url': url,
40
+ 'headers': headers,
41
+ 'params': params,
42
+ 'timeout': self.timeout,
43
+ 'verify': self.verify_ssl_certs,
44
+ 'allow_redirects': self.allow_redirects,
45
+ }
46
+
47
+ if payload:
48
+ _args['data'] = dumps(
49
+ payload,
50
+ date_format=DEFAULT_DATE_FORMAT,
51
+ datetime_format=DEFAULT_DATE_TIME_FORMAT,
52
+ use_undefined=False,
53
+ add_class_path=False,
54
+ decode_bytes=True,
55
+ )
56
+
57
+ response = requests.request(**_args)
58
+
59
+ return (response.status_code, response.content)
60
+
61
+
62
+ def new_default_http_client(*args, **kwargs):
63
+ return RequestsClient(*args, **kwargs)
everysk/api/tests.py ADDED
@@ -0,0 +1,32 @@
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
+ # pylint: disable=unused-import, wildcard-import, unused-wildcard-import
11
+
12
+ ###############################################################################
13
+ # Imports
14
+ ###############################################################################
15
+ from everysk.api.api_resources.tests import *
16
+
17
+ from everysk.api._tests.api_requestor import APIRequestorTestCase as EveryskLibAPIRequestorTestCase
18
+
19
+ from everysk.api._tests.http_client import (
20
+ HTTPClientTestCase as EveryskLibHTTPClientTestCase,
21
+ RequestsClientTestCase as EveryskLibRequestsClientTestCase,
22
+ StandardHTTPClientTestCase as EveryskLibStandardHTTPClientTestCase
23
+ )
24
+
25
+ from everysk.api._tests.init import TestGetAPIConfig as EveryskLibTestGetAPIConfig
26
+
27
+ from everysk.api._tests.utils import (
28
+ EveryskObjectTestCase as EveryskLibEveryskObjectTestCase,
29
+ EveryskListTestCase as EveryskLibEveryskListTestCase,
30
+ UtilsTestCase as EveryskLibUtilsTestCase
31
+
32
+ )