cosmotech-api 3.1.1__py3-none-any.whl → 3.2.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.
Potentially problematic release.
This version of cosmotech-api might be problematic. Click here for more details.
- cosmotech_api/__init__.py +134 -9
- cosmotech_api/api/__init__.py +14 -3
- cosmotech_api/api/connector_api.py +1313 -641
- cosmotech_api/api/dataset_api.py +8974 -4465
- cosmotech_api/api/organization_api.py +4633 -2269
- cosmotech_api/api/run_api.py +2174 -778
- cosmotech_api/api/runner_api.py +4483 -2280
- cosmotech_api/api/scenario_api.py +6544 -3265
- cosmotech_api/api/scenariorun_api.py +4007 -1960
- cosmotech_api/api/scenariorunresult_api.py +659 -341
- cosmotech_api/api/solution_api.py +6341 -3140
- cosmotech_api/api/twingraph_api.py +4134 -2077
- cosmotech_api/api/validator_api.py +2501 -1249
- cosmotech_api/api/workspace_api.py +5999 -2977
- cosmotech_api/api_client.py +529 -637
- cosmotech_api/configuration.py +63 -73
- cosmotech_api/exceptions.py +71 -31
- cosmotech_api/model/component_role_permissions.py +1 -1
- cosmotech_api/model/connector.py +1 -1
- cosmotech_api/model/connector_parameter.py +1 -1
- cosmotech_api/model/connector_parameter_group.py +1 -1
- cosmotech_api/model/container_resource_size_info.py +1 -1
- cosmotech_api/model/container_resource_sizing.py +1 -1
- cosmotech_api/model/dataset.py +1 -1
- cosmotech_api/model/dataset_access_control.py +1 -1
- cosmotech_api/model/dataset_compatibility.py +1 -1
- cosmotech_api/model/dataset_connector.py +1 -1
- cosmotech_api/model/dataset_copy_parameters.py +1 -1
- cosmotech_api/model/dataset_role.py +1 -1
- cosmotech_api/model/dataset_search.py +1 -1
- cosmotech_api/model/dataset_security.py +1 -1
- cosmotech_api/model/dataset_source_type.py +1 -1
- cosmotech_api/model/dataset_twin_graph_hash.py +1 -1
- cosmotech_api/model/dataset_twin_graph_info.py +1 -1
- cosmotech_api/model/dataset_twin_graph_query.py +1 -1
- cosmotech_api/model/delete_historical_data.py +1 -1
- cosmotech_api/model/file_upload_metadata.py +1 -1
- cosmotech_api/model/file_upload_validation.py +1 -1
- cosmotech_api/model/graph_properties.py +1 -1
- cosmotech_api/model/organization.py +1 -1
- cosmotech_api/model/organization_access_control.py +1 -1
- cosmotech_api/model/organization_role.py +1 -1
- cosmotech_api/model/organization_security.py +1 -1
- cosmotech_api/model/organization_service.py +1 -1
- cosmotech_api/model/organization_services.py +1 -1
- cosmotech_api/model/resource_size_info.py +1 -1
- cosmotech_api/model/run.py +1 -1
- cosmotech_api/model/run_container.py +1 -1
- cosmotech_api/model/run_container_artifact.py +1 -1
- cosmotech_api/model/run_container_logs.py +1 -1
- cosmotech_api/model/run_logs.py +1 -1
- cosmotech_api/model/run_resource_requested.py +1 -1
- cosmotech_api/model/run_search.py +1 -1
- cosmotech_api/model/run_start_containers.py +1 -1
- cosmotech_api/model/run_state.py +1 -1
- cosmotech_api/model/run_status.py +1 -1
- cosmotech_api/model/run_status_node.py +1 -1
- cosmotech_api/model/run_template.py +1 -1
- cosmotech_api/model/run_template_handler_id.py +1 -1
- cosmotech_api/model/run_template_orchestrator.py +1 -1
- cosmotech_api/model/run_template_parameter.py +1 -1
- cosmotech_api/model/run_template_parameter_group.py +1 -1
- cosmotech_api/model/run_template_parameter_value.py +1 -1
- cosmotech_api/model/run_template_resource_sizing.py +1 -1
- cosmotech_api/model/run_template_step_source.py +1 -1
- cosmotech_api/model/runner.py +1 -1
- cosmotech_api/model/runner_access_control.py +1 -1
- cosmotech_api/model/runner_changed_parameter_value.py +1 -1
- cosmotech_api/model/runner_comparison_result.py +1 -1
- cosmotech_api/model/runner_data_download_info.py +1 -1
- cosmotech_api/model/runner_data_download_job.py +1 -1
- cosmotech_api/model/runner_job_state.py +1 -1
- cosmotech_api/model/runner_last_run.py +1 -1
- cosmotech_api/model/runner_resource_sizing.py +1 -1
- cosmotech_api/model/runner_role.py +1 -1
- cosmotech_api/model/runner_run_template_parameter_value.py +1 -1
- cosmotech_api/model/runner_security.py +1 -1
- cosmotech_api/model/runner_validation_status.py +1 -1
- cosmotech_api/model/scenario.py +1 -1
- cosmotech_api/model/scenario_access_control.py +1 -1
- cosmotech_api/model/scenario_changed_parameter_value.py +1 -1
- cosmotech_api/model/scenario_comparison_result.py +1 -1
- cosmotech_api/model/scenario_data_download_info.py +1 -1
- cosmotech_api/model/scenario_data_download_job.py +1 -1
- cosmotech_api/model/scenario_job_state.py +1 -1
- cosmotech_api/model/scenario_last_run.py +1 -1
- cosmotech_api/model/scenario_resource_sizing.py +1 -1
- cosmotech_api/model/scenario_role.py +1 -1
- cosmotech_api/model/scenario_run.py +1 -1
- cosmotech_api/model/scenario_run_container.py +1 -1
- cosmotech_api/model/scenario_run_container_artifact.py +1 -1
- cosmotech_api/model/scenario_run_container_logs.py +1 -1
- cosmotech_api/model/scenario_run_logs.py +1 -1
- cosmotech_api/model/scenario_run_resource_requested.py +1 -1
- cosmotech_api/model/scenario_run_result.py +1 -1
- cosmotech_api/model/scenario_run_search.py +1 -1
- cosmotech_api/model/scenario_run_start_containers.py +1 -1
- cosmotech_api/model/scenario_run_state.py +1 -1
- cosmotech_api/model/scenario_run_status.py +1 -1
- cosmotech_api/model/scenario_run_status_node.py +1 -1
- cosmotech_api/model/scenario_run_template_parameter_value.py +1 -1
- cosmotech_api/model/scenario_security.py +1 -1
- cosmotech_api/model/scenario_validation_status.py +1 -1
- cosmotech_api/model/solution.py +1 -1
- cosmotech_api/model/solution_access_control.py +1 -1
- cosmotech_api/model/solution_role.py +1 -1
- cosmotech_api/model/solution_security.py +1 -1
- cosmotech_api/model/source_info.py +1 -1
- cosmotech_api/model/sub_dataset_graph_query.py +1 -1
- cosmotech_api/model/translated_labels.py +1 -1
- cosmotech_api/model/twin_graph_batch_result.py +1 -1
- cosmotech_api/model/twin_graph_hash.py +1 -1
- cosmotech_api/model/twin_graph_import.py +1 -1
- cosmotech_api/model/twin_graph_import_info.py +1 -1
- cosmotech_api/model/twin_graph_query.py +1 -1
- cosmotech_api/model/validator.py +1 -1
- cosmotech_api/model/validator_run.py +1 -1
- cosmotech_api/model/workspace.py +1 -1
- cosmotech_api/model/workspace_access_control.py +1 -1
- cosmotech_api/model/workspace_file.py +1 -1
- cosmotech_api/model/workspace_role.py +1 -1
- cosmotech_api/model/workspace_secret.py +1 -1
- cosmotech_api/model/workspace_security.py +1 -1
- cosmotech_api/model/workspace_solution.py +1 -1
- cosmotech_api/model/workspace_web_app.py +1 -1
- cosmotech_api/model_utils.py +1 -1
- cosmotech_api/models/__init__.py +124 -114
- cosmotech_api/models/component_role_permissions.py +1 -1
- cosmotech_api/models/connector.py +1 -1
- cosmotech_api/models/connector_parameter.py +1 -1
- cosmotech_api/models/connector_parameter_group.py +1 -1
- cosmotech_api/models/container_resource_size_info.py +1 -1
- cosmotech_api/models/container_resource_sizing.py +1 -1
- cosmotech_api/models/dataset.py +1 -1
- cosmotech_api/models/dataset_access_control.py +1 -1
- cosmotech_api/models/dataset_compatibility.py +1 -1
- cosmotech_api/models/dataset_connector.py +1 -1
- cosmotech_api/models/dataset_copy_parameters.py +1 -1
- cosmotech_api/models/dataset_role.py +1 -1
- cosmotech_api/models/dataset_search.py +1 -1
- cosmotech_api/models/dataset_security.py +1 -1
- cosmotech_api/models/dataset_source_type.py +1 -1
- cosmotech_api/models/dataset_twin_graph_hash.py +1 -1
- cosmotech_api/models/dataset_twin_graph_info.py +1 -1
- cosmotech_api/models/dataset_twin_graph_query.py +1 -1
- cosmotech_api/models/delete_historical_data.py +1 -1
- cosmotech_api/models/file_upload_metadata.py +1 -1
- cosmotech_api/models/file_upload_validation.py +1 -1
- cosmotech_api/models/graph_properties.py +1 -1
- cosmotech_api/models/organization.py +1 -1
- cosmotech_api/models/organization_access_control.py +1 -1
- cosmotech_api/models/organization_role.py +1 -1
- cosmotech_api/models/organization_security.py +1 -1
- cosmotech_api/models/organization_service.py +1 -1
- cosmotech_api/models/organization_services.py +1 -1
- cosmotech_api/models/query_result.py +88 -0
- cosmotech_api/models/resource_size_info.py +1 -1
- cosmotech_api/models/run.py +1 -1
- cosmotech_api/models/run_container.py +1 -1
- cosmotech_api/models/run_container_artifact.py +1 -1
- cosmotech_api/models/run_container_logs.py +1 -1
- cosmotech_api/models/run_data.py +92 -0
- cosmotech_api/models/run_data_query.py +88 -0
- cosmotech_api/models/run_logs.py +1 -1
- cosmotech_api/models/run_resource_requested.py +1 -1
- cosmotech_api/models/run_search.py +1 -1
- cosmotech_api/models/run_start_containers.py +1 -1
- cosmotech_api/models/run_state.py +1 -1
- cosmotech_api/models/run_status.py +1 -1
- cosmotech_api/models/run_status_node.py +1 -1
- cosmotech_api/models/run_template.py +1 -1
- cosmotech_api/models/run_template_handler_id.py +1 -1
- cosmotech_api/models/run_template_orchestrator.py +1 -1
- cosmotech_api/models/run_template_parameter.py +1 -1
- cosmotech_api/models/run_template_parameter_group.py +1 -1
- cosmotech_api/models/run_template_parameter_value.py +1 -1
- cosmotech_api/models/run_template_resource_sizing.py +1 -1
- cosmotech_api/models/run_template_step_source.py +1 -1
- cosmotech_api/models/runner.py +1 -1
- cosmotech_api/models/runner_access_control.py +1 -1
- cosmotech_api/models/runner_changed_parameter_value.py +1 -1
- cosmotech_api/models/runner_comparison_result.py +1 -1
- cosmotech_api/models/runner_data_download_info.py +1 -1
- cosmotech_api/models/runner_data_download_job.py +1 -1
- cosmotech_api/models/runner_job_state.py +1 -1
- cosmotech_api/models/runner_last_run.py +1 -1
- cosmotech_api/models/runner_parent_last_run.py +1 -1
- cosmotech_api/models/runner_resource_sizing.py +1 -1
- cosmotech_api/models/runner_role.py +1 -1
- cosmotech_api/models/runner_root_last_run.py +1 -1
- cosmotech_api/models/runner_run_template_parameter_value.py +1 -1
- cosmotech_api/models/runner_security.py +1 -1
- cosmotech_api/models/runner_validation_status.py +1 -1
- cosmotech_api/models/scenario.py +1 -1
- cosmotech_api/models/scenario_access_control.py +1 -1
- cosmotech_api/models/scenario_changed_parameter_value.py +1 -1
- cosmotech_api/models/scenario_comparison_result.py +1 -1
- cosmotech_api/models/scenario_data_download_info.py +1 -1
- cosmotech_api/models/scenario_data_download_job.py +1 -1
- cosmotech_api/models/scenario_job_state.py +1 -1
- cosmotech_api/models/scenario_last_run.py +1 -1
- cosmotech_api/models/scenario_resource_sizing.py +1 -1
- cosmotech_api/models/scenario_role.py +1 -1
- cosmotech_api/models/scenario_run.py +1 -1
- cosmotech_api/models/scenario_run_container.py +1 -1
- cosmotech_api/models/scenario_run_container_artifact.py +1 -1
- cosmotech_api/models/scenario_run_container_logs.py +1 -1
- cosmotech_api/models/scenario_run_logs.py +1 -1
- cosmotech_api/models/scenario_run_resource_requested.py +1 -1
- cosmotech_api/models/scenario_run_search.py +1 -1
- cosmotech_api/models/scenario_run_start_containers.py +1 -1
- cosmotech_api/models/scenario_run_state.py +1 -1
- cosmotech_api/models/scenario_run_status.py +1 -1
- cosmotech_api/models/scenario_run_status_node.py +1 -1
- cosmotech_api/models/scenario_run_template_parameter_value.py +1 -1
- cosmotech_api/models/scenario_security.py +1 -1
- cosmotech_api/models/scenario_validation_status.py +1 -1
- cosmotech_api/models/send_run_data_request.py +90 -0
- cosmotech_api/models/solution.py +1 -1
- cosmotech_api/models/solution_access_control.py +1 -1
- cosmotech_api/models/solution_role.py +1 -1
- cosmotech_api/models/solution_security.py +1 -1
- cosmotech_api/models/source_info.py +1 -1
- cosmotech_api/models/sub_dataset_graph_query.py +1 -1
- cosmotech_api/models/twin_graph_batch_result.py +1 -1
- cosmotech_api/models/twin_graph_hash.py +1 -1
- cosmotech_api/models/twin_graph_query.py +1 -1
- cosmotech_api/models/validator.py +1 -1
- cosmotech_api/models/validator_run.py +1 -1
- cosmotech_api/models/workspace.py +1 -1
- cosmotech_api/models/workspace_access_control.py +1 -1
- cosmotech_api/models/workspace_file.py +1 -1
- cosmotech_api/models/workspace_role.py +1 -1
- cosmotech_api/models/workspace_secret.py +1 -1
- cosmotech_api/models/workspace_security.py +1 -1
- cosmotech_api/models/workspace_solution.py +1 -1
- cosmotech_api/models/workspace_web_app.py +1 -1
- cosmotech_api/rest.py +139 -230
- {cosmotech_api-3.1.1.dist-info → cosmotech_api-3.2.0.dist-info}/METADATA +6 -4
- cosmotech_api-3.2.0.dist-info/RECORD +255 -0
- cosmotech_api-3.1.1.dist-info/RECORD +0 -251
- {cosmotech_api-3.1.1.dist-info → cosmotech_api-3.2.0.dist-info}/LICENSE +0 -0
- {cosmotech_api-3.1.1.dist-info → cosmotech_api-3.2.0.dist-info}/WHEEL +0 -0
- {cosmotech_api-3.1.1.dist-info → cosmotech_api-3.2.0.dist-info}/top_level.txt +0 -0
cosmotech_api/rest.py
CHANGED
|
@@ -1,55 +1,69 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
1
3
|
"""
|
|
2
4
|
Cosmo Tech Platform API
|
|
3
5
|
|
|
4
|
-
Cosmo Tech Platform API
|
|
6
|
+
Cosmo Tech Platform API
|
|
5
7
|
|
|
6
|
-
The version of the OpenAPI document: 3.
|
|
8
|
+
The version of the OpenAPI document: 3.2.0
|
|
7
9
|
Contact: platform@cosmotech.com
|
|
8
|
-
Generated by
|
|
9
|
-
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
import io
|
|
13
17
|
import json
|
|
14
|
-
import logging
|
|
15
18
|
import re
|
|
16
19
|
import ssl
|
|
17
|
-
|
|
18
|
-
from urllib.parse import urlparse
|
|
19
|
-
from urllib.request import proxy_bypass_environment
|
|
20
|
+
|
|
20
21
|
import urllib3
|
|
21
|
-
import ipaddress
|
|
22
22
|
|
|
23
|
-
from cosmotech_api.exceptions import ApiException,
|
|
23
|
+
from cosmotech_api.exceptions import ApiException, ApiValueError
|
|
24
|
+
|
|
25
|
+
SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"}
|
|
26
|
+
RESTResponseType = urllib3.HTTPResponse
|
|
24
27
|
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
def is_socks_proxy_url(url):
|
|
30
|
+
if url is None:
|
|
31
|
+
return False
|
|
32
|
+
split_section = url.split("://")
|
|
33
|
+
if len(split_section) < 2:
|
|
34
|
+
return False
|
|
35
|
+
else:
|
|
36
|
+
return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES
|
|
27
37
|
|
|
28
38
|
|
|
29
39
|
class RESTResponse(io.IOBase):
|
|
30
40
|
|
|
31
|
-
def __init__(self, resp):
|
|
32
|
-
self.
|
|
41
|
+
def __init__(self, resp) -> None:
|
|
42
|
+
self.response = resp
|
|
33
43
|
self.status = resp.status
|
|
34
44
|
self.reason = resp.reason
|
|
35
|
-
self.data =
|
|
45
|
+
self.data = None
|
|
46
|
+
|
|
47
|
+
def read(self):
|
|
48
|
+
if self.data is None:
|
|
49
|
+
self.data = self.response.data
|
|
50
|
+
return self.data
|
|
36
51
|
|
|
37
52
|
def getheaders(self):
|
|
38
53
|
"""Returns a dictionary of the response headers."""
|
|
39
|
-
return self.
|
|
54
|
+
return self.response.headers
|
|
40
55
|
|
|
41
56
|
def getheader(self, name, default=None):
|
|
42
57
|
"""Returns a given response header."""
|
|
43
|
-
return self.
|
|
58
|
+
return self.response.headers.get(name, default)
|
|
44
59
|
|
|
45
60
|
|
|
46
|
-
class RESTClientObject
|
|
61
|
+
class RESTClientObject:
|
|
47
62
|
|
|
48
|
-
def __init__(self, configuration
|
|
63
|
+
def __init__(self, configuration) -> None:
|
|
49
64
|
# urllib3.PoolManager will pass all kw parameters to connectionpool
|
|
50
65
|
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
|
|
51
66
|
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
|
|
52
|
-
# maxsize is the number of requests to host that are allowed in parallel # noqa: E501
|
|
53
67
|
# Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
|
|
54
68
|
|
|
55
69
|
# cert_reqs
|
|
@@ -58,70 +72,79 @@ class RESTClientObject(object):
|
|
|
58
72
|
else:
|
|
59
73
|
cert_reqs = ssl.CERT_NONE
|
|
60
74
|
|
|
61
|
-
|
|
75
|
+
pool_args = {
|
|
76
|
+
"cert_reqs": cert_reqs,
|
|
77
|
+
"ca_certs": configuration.ssl_ca_cert,
|
|
78
|
+
"cert_file": configuration.cert_file,
|
|
79
|
+
"key_file": configuration.key_file,
|
|
80
|
+
}
|
|
62
81
|
if configuration.assert_hostname is not None:
|
|
63
|
-
|
|
82
|
+
pool_args['assert_hostname'] = (
|
|
83
|
+
configuration.assert_hostname
|
|
84
|
+
)
|
|
64
85
|
|
|
65
86
|
if configuration.retries is not None:
|
|
66
|
-
|
|
87
|
+
pool_args['retries'] = configuration.retries
|
|
88
|
+
|
|
89
|
+
if configuration.tls_server_name:
|
|
90
|
+
pool_args['server_hostname'] = configuration.tls_server_name
|
|
91
|
+
|
|
67
92
|
|
|
68
93
|
if configuration.socket_options is not None:
|
|
69
|
-
|
|
94
|
+
pool_args['socket_options'] = configuration.socket_options
|
|
70
95
|
|
|
71
|
-
if
|
|
72
|
-
|
|
73
|
-
maxsize = configuration.connection_pool_maxsize
|
|
74
|
-
else:
|
|
75
|
-
maxsize = 4
|
|
96
|
+
if configuration.connection_pool_maxsize is not None:
|
|
97
|
+
pool_args['maxsize'] = configuration.connection_pool_maxsize
|
|
76
98
|
|
|
77
99
|
# https pool manager
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
self.pool_manager: urllib3.PoolManager
|
|
101
|
+
|
|
102
|
+
if configuration.proxy:
|
|
103
|
+
if is_socks_proxy_url(configuration.proxy):
|
|
104
|
+
from urllib3.contrib.socks import SOCKSProxyManager
|
|
105
|
+
pool_args["proxy_url"] = configuration.proxy
|
|
106
|
+
pool_args["headers"] = configuration.proxy_headers
|
|
107
|
+
self.pool_manager = SOCKSProxyManager(**pool_args)
|
|
108
|
+
else:
|
|
109
|
+
pool_args["proxy_url"] = configuration.proxy
|
|
110
|
+
pool_args["proxy_headers"] = configuration.proxy_headers
|
|
111
|
+
self.pool_manager = urllib3.ProxyManager(**pool_args)
|
|
90
112
|
else:
|
|
91
|
-
self.pool_manager = urllib3.PoolManager(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
body=None, post_params=None, _preload_content=True,
|
|
103
|
-
_request_timeout=None):
|
|
113
|
+
self.pool_manager = urllib3.PoolManager(**pool_args)
|
|
114
|
+
|
|
115
|
+
def request(
|
|
116
|
+
self,
|
|
117
|
+
method,
|
|
118
|
+
url,
|
|
119
|
+
headers=None,
|
|
120
|
+
body=None,
|
|
121
|
+
post_params=None,
|
|
122
|
+
_request_timeout=None
|
|
123
|
+
):
|
|
104
124
|
"""Perform requests.
|
|
105
125
|
|
|
106
126
|
:param method: http request method
|
|
107
127
|
:param url: http request url
|
|
108
|
-
:param query_params: query parameters in the url
|
|
109
128
|
:param headers: http request headers
|
|
110
129
|
:param body: request json body, for `application/json`
|
|
111
130
|
:param post_params: request post parameters,
|
|
112
131
|
`application/x-www-form-urlencoded`
|
|
113
132
|
and `multipart/form-data`
|
|
114
|
-
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
|
115
|
-
be returned without reading/decoding response
|
|
116
|
-
data. Default is True.
|
|
117
133
|
:param _request_timeout: timeout setting for this request. If one
|
|
118
134
|
number provided, it will be total request
|
|
119
135
|
timeout. It can also be a pair (tuple) of
|
|
120
136
|
(connection, read) timeouts.
|
|
121
137
|
"""
|
|
122
138
|
method = method.upper()
|
|
123
|
-
assert method in [
|
|
124
|
-
|
|
139
|
+
assert method in [
|
|
140
|
+
'GET',
|
|
141
|
+
'HEAD',
|
|
142
|
+
'DELETE',
|
|
143
|
+
'POST',
|
|
144
|
+
'PUT',
|
|
145
|
+
'PATCH',
|
|
146
|
+
'OPTIONS'
|
|
147
|
+
]
|
|
125
148
|
|
|
126
149
|
if post_params and body:
|
|
127
150
|
raise ApiValueError(
|
|
@@ -133,60 +156,81 @@ class RESTClientObject(object):
|
|
|
133
156
|
|
|
134
157
|
timeout = None
|
|
135
158
|
if _request_timeout:
|
|
136
|
-
if isinstance(_request_timeout, (int, float)):
|
|
159
|
+
if isinstance(_request_timeout, (int, float)):
|
|
137
160
|
timeout = urllib3.Timeout(total=_request_timeout)
|
|
138
|
-
elif (
|
|
139
|
-
|
|
161
|
+
elif (
|
|
162
|
+
isinstance(_request_timeout, tuple)
|
|
163
|
+
and len(_request_timeout) == 2
|
|
164
|
+
):
|
|
140
165
|
timeout = urllib3.Timeout(
|
|
141
|
-
connect=_request_timeout[0],
|
|
166
|
+
connect=_request_timeout[0],
|
|
167
|
+
read=_request_timeout[1]
|
|
168
|
+
)
|
|
142
169
|
|
|
143
170
|
try:
|
|
144
171
|
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
|
145
172
|
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if
|
|
150
|
-
|
|
151
|
-
|
|
173
|
+
|
|
174
|
+
# no content type provided or payload is json
|
|
175
|
+
content_type = headers.get('Content-Type')
|
|
176
|
+
if (
|
|
177
|
+
not content_type
|
|
178
|
+
or re.search('json', content_type, re.IGNORECASE)
|
|
179
|
+
):
|
|
152
180
|
request_body = None
|
|
153
181
|
if body is not None:
|
|
154
182
|
request_body = json.dumps(body)
|
|
155
183
|
r = self.pool_manager.request(
|
|
156
|
-
method,
|
|
184
|
+
method,
|
|
185
|
+
url,
|
|
157
186
|
body=request_body,
|
|
158
|
-
preload_content=_preload_content,
|
|
159
187
|
timeout=timeout,
|
|
160
|
-
headers=headers
|
|
161
|
-
|
|
188
|
+
headers=headers,
|
|
189
|
+
preload_content=False
|
|
190
|
+
)
|
|
191
|
+
elif content_type == 'application/x-www-form-urlencoded':
|
|
162
192
|
r = self.pool_manager.request(
|
|
163
|
-
method,
|
|
193
|
+
method,
|
|
194
|
+
url,
|
|
164
195
|
fields=post_params,
|
|
165
196
|
encode_multipart=False,
|
|
166
|
-
preload_content=_preload_content,
|
|
167
197
|
timeout=timeout,
|
|
168
|
-
headers=headers
|
|
169
|
-
|
|
198
|
+
headers=headers,
|
|
199
|
+
preload_content=False
|
|
200
|
+
)
|
|
201
|
+
elif content_type == 'multipart/form-data':
|
|
170
202
|
# must del headers['Content-Type'], or the correct
|
|
171
203
|
# Content-Type which generated by urllib3 will be
|
|
172
204
|
# overwritten.
|
|
173
205
|
del headers['Content-Type']
|
|
174
206
|
r = self.pool_manager.request(
|
|
175
|
-
method,
|
|
207
|
+
method,
|
|
208
|
+
url,
|
|
176
209
|
fields=post_params,
|
|
177
210
|
encode_multipart=True,
|
|
178
|
-
preload_content=_preload_content,
|
|
179
211
|
timeout=timeout,
|
|
180
|
-
headers=headers
|
|
212
|
+
headers=headers,
|
|
213
|
+
preload_content=False
|
|
214
|
+
)
|
|
181
215
|
# Pass a `string` parameter directly in the body to support
|
|
182
|
-
# other content types than
|
|
183
|
-
# provided in serialized form
|
|
216
|
+
# other content types than JSON when `body` argument is
|
|
217
|
+
# provided in serialized form.
|
|
184
218
|
elif isinstance(body, str) or isinstance(body, bytes):
|
|
185
|
-
request_body = body
|
|
186
219
|
r = self.pool_manager.request(
|
|
187
|
-
method,
|
|
220
|
+
method,
|
|
221
|
+
url,
|
|
222
|
+
body=body,
|
|
223
|
+
timeout=timeout,
|
|
224
|
+
headers=headers,
|
|
225
|
+
preload_content=False
|
|
226
|
+
)
|
|
227
|
+
elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool):
|
|
228
|
+
request_body = "true" if body else "false"
|
|
229
|
+
r = self.pool_manager.request(
|
|
230
|
+
method,
|
|
231
|
+
url,
|
|
188
232
|
body=request_body,
|
|
189
|
-
preload_content=
|
|
233
|
+
preload_content=False,
|
|
190
234
|
timeout=timeout,
|
|
191
235
|
headers=headers)
|
|
192
236
|
else:
|
|
@@ -197,151 +241,16 @@ class RESTClientObject(object):
|
|
|
197
241
|
raise ApiException(status=0, reason=msg)
|
|
198
242
|
# For `GET`, `HEAD`
|
|
199
243
|
else:
|
|
200
|
-
r = self.pool_manager.request(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
244
|
+
r = self.pool_manager.request(
|
|
245
|
+
method,
|
|
246
|
+
url,
|
|
247
|
+
fields={},
|
|
248
|
+
timeout=timeout,
|
|
249
|
+
headers=headers,
|
|
250
|
+
preload_content=False
|
|
251
|
+
)
|
|
205
252
|
except urllib3.exceptions.SSLError as e:
|
|
206
|
-
msg = "
|
|
253
|
+
msg = "\n".join([type(e).__name__, str(e)])
|
|
207
254
|
raise ApiException(status=0, reason=msg)
|
|
208
255
|
|
|
209
|
-
|
|
210
|
-
r = RESTResponse(r)
|
|
211
|
-
|
|
212
|
-
# log response body
|
|
213
|
-
logger.debug("response body: %s", r.data)
|
|
214
|
-
|
|
215
|
-
if not 200 <= r.status <= 299:
|
|
216
|
-
if r.status == 401:
|
|
217
|
-
raise UnauthorizedException(http_resp=r)
|
|
218
|
-
|
|
219
|
-
if r.status == 403:
|
|
220
|
-
raise ForbiddenException(http_resp=r)
|
|
221
|
-
|
|
222
|
-
if r.status == 404:
|
|
223
|
-
raise NotFoundException(http_resp=r)
|
|
224
|
-
|
|
225
|
-
if 500 <= r.status <= 599:
|
|
226
|
-
raise ServiceException(http_resp=r)
|
|
227
|
-
|
|
228
|
-
raise ApiException(http_resp=r)
|
|
229
|
-
|
|
230
|
-
return r
|
|
231
|
-
|
|
232
|
-
def GET(self, url, headers=None, query_params=None, _preload_content=True,
|
|
233
|
-
_request_timeout=None):
|
|
234
|
-
return self.request("GET", url,
|
|
235
|
-
headers=headers,
|
|
236
|
-
_preload_content=_preload_content,
|
|
237
|
-
_request_timeout=_request_timeout,
|
|
238
|
-
query_params=query_params)
|
|
239
|
-
|
|
240
|
-
def HEAD(self, url, headers=None, query_params=None, _preload_content=True,
|
|
241
|
-
_request_timeout=None):
|
|
242
|
-
return self.request("HEAD", url,
|
|
243
|
-
headers=headers,
|
|
244
|
-
_preload_content=_preload_content,
|
|
245
|
-
_request_timeout=_request_timeout,
|
|
246
|
-
query_params=query_params)
|
|
247
|
-
|
|
248
|
-
def OPTIONS(self, url, headers=None, query_params=None, post_params=None,
|
|
249
|
-
body=None, _preload_content=True, _request_timeout=None):
|
|
250
|
-
return self.request("OPTIONS", url,
|
|
251
|
-
headers=headers,
|
|
252
|
-
query_params=query_params,
|
|
253
|
-
post_params=post_params,
|
|
254
|
-
_preload_content=_preload_content,
|
|
255
|
-
_request_timeout=_request_timeout,
|
|
256
|
-
body=body)
|
|
257
|
-
|
|
258
|
-
def DELETE(self, url, headers=None, query_params=None, body=None,
|
|
259
|
-
_preload_content=True, _request_timeout=None):
|
|
260
|
-
return self.request("DELETE", url,
|
|
261
|
-
headers=headers,
|
|
262
|
-
query_params=query_params,
|
|
263
|
-
_preload_content=_preload_content,
|
|
264
|
-
_request_timeout=_request_timeout,
|
|
265
|
-
body=body)
|
|
266
|
-
|
|
267
|
-
def POST(self, url, headers=None, query_params=None, post_params=None,
|
|
268
|
-
body=None, _preload_content=True, _request_timeout=None):
|
|
269
|
-
return self.request("POST", url,
|
|
270
|
-
headers=headers,
|
|
271
|
-
query_params=query_params,
|
|
272
|
-
post_params=post_params,
|
|
273
|
-
_preload_content=_preload_content,
|
|
274
|
-
_request_timeout=_request_timeout,
|
|
275
|
-
body=body)
|
|
276
|
-
|
|
277
|
-
def PUT(self, url, headers=None, query_params=None, post_params=None,
|
|
278
|
-
body=None, _preload_content=True, _request_timeout=None):
|
|
279
|
-
return self.request("PUT", url,
|
|
280
|
-
headers=headers,
|
|
281
|
-
query_params=query_params,
|
|
282
|
-
post_params=post_params,
|
|
283
|
-
_preload_content=_preload_content,
|
|
284
|
-
_request_timeout=_request_timeout,
|
|
285
|
-
body=body)
|
|
286
|
-
|
|
287
|
-
def PATCH(self, url, headers=None, query_params=None, post_params=None,
|
|
288
|
-
body=None, _preload_content=True, _request_timeout=None):
|
|
289
|
-
return self.request("PATCH", url,
|
|
290
|
-
headers=headers,
|
|
291
|
-
query_params=query_params,
|
|
292
|
-
post_params=post_params,
|
|
293
|
-
_preload_content=_preload_content,
|
|
294
|
-
_request_timeout=_request_timeout,
|
|
295
|
-
body=body)
|
|
296
|
-
|
|
297
|
-
# end of class RESTClientObject
|
|
298
|
-
def is_ipv4(target):
|
|
299
|
-
""" Test if IPv4 address or not
|
|
300
|
-
"""
|
|
301
|
-
try:
|
|
302
|
-
chk = ipaddress.IPv4Address(target)
|
|
303
|
-
return True
|
|
304
|
-
except ipaddress.AddressValueError:
|
|
305
|
-
return False
|
|
306
|
-
|
|
307
|
-
def in_ipv4net(target, net):
|
|
308
|
-
""" Test if target belongs to given IPv4 network
|
|
309
|
-
"""
|
|
310
|
-
try:
|
|
311
|
-
nw = ipaddress.IPv4Network(net)
|
|
312
|
-
ip = ipaddress.IPv4Address(target)
|
|
313
|
-
if ip in nw:
|
|
314
|
-
return True
|
|
315
|
-
return False
|
|
316
|
-
except ipaddress.AddressValueError:
|
|
317
|
-
return False
|
|
318
|
-
except ipaddress.NetmaskValueError:
|
|
319
|
-
return False
|
|
320
|
-
|
|
321
|
-
def should_bypass_proxies(url, no_proxy=None):
|
|
322
|
-
""" Yet another requests.should_bypass_proxies
|
|
323
|
-
Test if proxies should not be used for a particular url.
|
|
324
|
-
"""
|
|
325
|
-
|
|
326
|
-
parsed = urlparse(url)
|
|
327
|
-
|
|
328
|
-
# special cases
|
|
329
|
-
if parsed.hostname in [None, '']:
|
|
330
|
-
return True
|
|
331
|
-
|
|
332
|
-
# special cases
|
|
333
|
-
if no_proxy in [None , '']:
|
|
334
|
-
return False
|
|
335
|
-
if no_proxy == '*':
|
|
336
|
-
return True
|
|
337
|
-
|
|
338
|
-
no_proxy = no_proxy.lower().replace(' ','');
|
|
339
|
-
entries = (
|
|
340
|
-
host for host in no_proxy.split(',') if host
|
|
341
|
-
)
|
|
342
|
-
|
|
343
|
-
if is_ipv4(parsed.hostname):
|
|
344
|
-
for item in entries:
|
|
345
|
-
if in_ipv4net(parsed.hostname, item):
|
|
346
|
-
return True
|
|
347
|
-
return proxy_bypass_environment(parsed.hostname, {'no': no_proxy} )
|
|
256
|
+
return RESTResponse(r)
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cosmotech-api
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Cosmo Tech Platform API
|
|
5
5
|
Home-page:
|
|
6
6
|
Author: Repository
|
|
7
7
|
Author-email: platform@cosmotech.com
|
|
8
8
|
License: MIT License
|
|
9
9
|
Keywords: OpenAPI,OpenAPI-Generator,Cosmo Tech Platform API
|
|
10
|
-
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
|
-
Requires-Dist: urllib3
|
|
12
|
+
Requires-Dist: urllib3 <2.1.0,>=1.25.3
|
|
13
13
|
Requires-Dist: python-dateutil
|
|
14
|
+
Requires-Dist: pydantic >=2
|
|
15
|
+
Requires-Dist: typing-extensions >=4.7.1
|
|
14
16
|
|
|
15
|
-
Cosmo Tech Platform API
|
|
17
|
+
Cosmo Tech Platform API
|
|
16
18
|
|