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.

Files changed (244) hide show
  1. cosmotech_api/__init__.py +134 -9
  2. cosmotech_api/api/__init__.py +14 -3
  3. cosmotech_api/api/connector_api.py +1313 -641
  4. cosmotech_api/api/dataset_api.py +8974 -4465
  5. cosmotech_api/api/organization_api.py +4633 -2269
  6. cosmotech_api/api/run_api.py +2174 -778
  7. cosmotech_api/api/runner_api.py +4483 -2280
  8. cosmotech_api/api/scenario_api.py +6544 -3265
  9. cosmotech_api/api/scenariorun_api.py +4007 -1960
  10. cosmotech_api/api/scenariorunresult_api.py +659 -341
  11. cosmotech_api/api/solution_api.py +6341 -3140
  12. cosmotech_api/api/twingraph_api.py +4134 -2077
  13. cosmotech_api/api/validator_api.py +2501 -1249
  14. cosmotech_api/api/workspace_api.py +5999 -2977
  15. cosmotech_api/api_client.py +529 -637
  16. cosmotech_api/configuration.py +63 -73
  17. cosmotech_api/exceptions.py +71 -31
  18. cosmotech_api/model/component_role_permissions.py +1 -1
  19. cosmotech_api/model/connector.py +1 -1
  20. cosmotech_api/model/connector_parameter.py +1 -1
  21. cosmotech_api/model/connector_parameter_group.py +1 -1
  22. cosmotech_api/model/container_resource_size_info.py +1 -1
  23. cosmotech_api/model/container_resource_sizing.py +1 -1
  24. cosmotech_api/model/dataset.py +1 -1
  25. cosmotech_api/model/dataset_access_control.py +1 -1
  26. cosmotech_api/model/dataset_compatibility.py +1 -1
  27. cosmotech_api/model/dataset_connector.py +1 -1
  28. cosmotech_api/model/dataset_copy_parameters.py +1 -1
  29. cosmotech_api/model/dataset_role.py +1 -1
  30. cosmotech_api/model/dataset_search.py +1 -1
  31. cosmotech_api/model/dataset_security.py +1 -1
  32. cosmotech_api/model/dataset_source_type.py +1 -1
  33. cosmotech_api/model/dataset_twin_graph_hash.py +1 -1
  34. cosmotech_api/model/dataset_twin_graph_info.py +1 -1
  35. cosmotech_api/model/dataset_twin_graph_query.py +1 -1
  36. cosmotech_api/model/delete_historical_data.py +1 -1
  37. cosmotech_api/model/file_upload_metadata.py +1 -1
  38. cosmotech_api/model/file_upload_validation.py +1 -1
  39. cosmotech_api/model/graph_properties.py +1 -1
  40. cosmotech_api/model/organization.py +1 -1
  41. cosmotech_api/model/organization_access_control.py +1 -1
  42. cosmotech_api/model/organization_role.py +1 -1
  43. cosmotech_api/model/organization_security.py +1 -1
  44. cosmotech_api/model/organization_service.py +1 -1
  45. cosmotech_api/model/organization_services.py +1 -1
  46. cosmotech_api/model/resource_size_info.py +1 -1
  47. cosmotech_api/model/run.py +1 -1
  48. cosmotech_api/model/run_container.py +1 -1
  49. cosmotech_api/model/run_container_artifact.py +1 -1
  50. cosmotech_api/model/run_container_logs.py +1 -1
  51. cosmotech_api/model/run_logs.py +1 -1
  52. cosmotech_api/model/run_resource_requested.py +1 -1
  53. cosmotech_api/model/run_search.py +1 -1
  54. cosmotech_api/model/run_start_containers.py +1 -1
  55. cosmotech_api/model/run_state.py +1 -1
  56. cosmotech_api/model/run_status.py +1 -1
  57. cosmotech_api/model/run_status_node.py +1 -1
  58. cosmotech_api/model/run_template.py +1 -1
  59. cosmotech_api/model/run_template_handler_id.py +1 -1
  60. cosmotech_api/model/run_template_orchestrator.py +1 -1
  61. cosmotech_api/model/run_template_parameter.py +1 -1
  62. cosmotech_api/model/run_template_parameter_group.py +1 -1
  63. cosmotech_api/model/run_template_parameter_value.py +1 -1
  64. cosmotech_api/model/run_template_resource_sizing.py +1 -1
  65. cosmotech_api/model/run_template_step_source.py +1 -1
  66. cosmotech_api/model/runner.py +1 -1
  67. cosmotech_api/model/runner_access_control.py +1 -1
  68. cosmotech_api/model/runner_changed_parameter_value.py +1 -1
  69. cosmotech_api/model/runner_comparison_result.py +1 -1
  70. cosmotech_api/model/runner_data_download_info.py +1 -1
  71. cosmotech_api/model/runner_data_download_job.py +1 -1
  72. cosmotech_api/model/runner_job_state.py +1 -1
  73. cosmotech_api/model/runner_last_run.py +1 -1
  74. cosmotech_api/model/runner_resource_sizing.py +1 -1
  75. cosmotech_api/model/runner_role.py +1 -1
  76. cosmotech_api/model/runner_run_template_parameter_value.py +1 -1
  77. cosmotech_api/model/runner_security.py +1 -1
  78. cosmotech_api/model/runner_validation_status.py +1 -1
  79. cosmotech_api/model/scenario.py +1 -1
  80. cosmotech_api/model/scenario_access_control.py +1 -1
  81. cosmotech_api/model/scenario_changed_parameter_value.py +1 -1
  82. cosmotech_api/model/scenario_comparison_result.py +1 -1
  83. cosmotech_api/model/scenario_data_download_info.py +1 -1
  84. cosmotech_api/model/scenario_data_download_job.py +1 -1
  85. cosmotech_api/model/scenario_job_state.py +1 -1
  86. cosmotech_api/model/scenario_last_run.py +1 -1
  87. cosmotech_api/model/scenario_resource_sizing.py +1 -1
  88. cosmotech_api/model/scenario_role.py +1 -1
  89. cosmotech_api/model/scenario_run.py +1 -1
  90. cosmotech_api/model/scenario_run_container.py +1 -1
  91. cosmotech_api/model/scenario_run_container_artifact.py +1 -1
  92. cosmotech_api/model/scenario_run_container_logs.py +1 -1
  93. cosmotech_api/model/scenario_run_logs.py +1 -1
  94. cosmotech_api/model/scenario_run_resource_requested.py +1 -1
  95. cosmotech_api/model/scenario_run_result.py +1 -1
  96. cosmotech_api/model/scenario_run_search.py +1 -1
  97. cosmotech_api/model/scenario_run_start_containers.py +1 -1
  98. cosmotech_api/model/scenario_run_state.py +1 -1
  99. cosmotech_api/model/scenario_run_status.py +1 -1
  100. cosmotech_api/model/scenario_run_status_node.py +1 -1
  101. cosmotech_api/model/scenario_run_template_parameter_value.py +1 -1
  102. cosmotech_api/model/scenario_security.py +1 -1
  103. cosmotech_api/model/scenario_validation_status.py +1 -1
  104. cosmotech_api/model/solution.py +1 -1
  105. cosmotech_api/model/solution_access_control.py +1 -1
  106. cosmotech_api/model/solution_role.py +1 -1
  107. cosmotech_api/model/solution_security.py +1 -1
  108. cosmotech_api/model/source_info.py +1 -1
  109. cosmotech_api/model/sub_dataset_graph_query.py +1 -1
  110. cosmotech_api/model/translated_labels.py +1 -1
  111. cosmotech_api/model/twin_graph_batch_result.py +1 -1
  112. cosmotech_api/model/twin_graph_hash.py +1 -1
  113. cosmotech_api/model/twin_graph_import.py +1 -1
  114. cosmotech_api/model/twin_graph_import_info.py +1 -1
  115. cosmotech_api/model/twin_graph_query.py +1 -1
  116. cosmotech_api/model/validator.py +1 -1
  117. cosmotech_api/model/validator_run.py +1 -1
  118. cosmotech_api/model/workspace.py +1 -1
  119. cosmotech_api/model/workspace_access_control.py +1 -1
  120. cosmotech_api/model/workspace_file.py +1 -1
  121. cosmotech_api/model/workspace_role.py +1 -1
  122. cosmotech_api/model/workspace_secret.py +1 -1
  123. cosmotech_api/model/workspace_security.py +1 -1
  124. cosmotech_api/model/workspace_solution.py +1 -1
  125. cosmotech_api/model/workspace_web_app.py +1 -1
  126. cosmotech_api/model_utils.py +1 -1
  127. cosmotech_api/models/__init__.py +124 -114
  128. cosmotech_api/models/component_role_permissions.py +1 -1
  129. cosmotech_api/models/connector.py +1 -1
  130. cosmotech_api/models/connector_parameter.py +1 -1
  131. cosmotech_api/models/connector_parameter_group.py +1 -1
  132. cosmotech_api/models/container_resource_size_info.py +1 -1
  133. cosmotech_api/models/container_resource_sizing.py +1 -1
  134. cosmotech_api/models/dataset.py +1 -1
  135. cosmotech_api/models/dataset_access_control.py +1 -1
  136. cosmotech_api/models/dataset_compatibility.py +1 -1
  137. cosmotech_api/models/dataset_connector.py +1 -1
  138. cosmotech_api/models/dataset_copy_parameters.py +1 -1
  139. cosmotech_api/models/dataset_role.py +1 -1
  140. cosmotech_api/models/dataset_search.py +1 -1
  141. cosmotech_api/models/dataset_security.py +1 -1
  142. cosmotech_api/models/dataset_source_type.py +1 -1
  143. cosmotech_api/models/dataset_twin_graph_hash.py +1 -1
  144. cosmotech_api/models/dataset_twin_graph_info.py +1 -1
  145. cosmotech_api/models/dataset_twin_graph_query.py +1 -1
  146. cosmotech_api/models/delete_historical_data.py +1 -1
  147. cosmotech_api/models/file_upload_metadata.py +1 -1
  148. cosmotech_api/models/file_upload_validation.py +1 -1
  149. cosmotech_api/models/graph_properties.py +1 -1
  150. cosmotech_api/models/organization.py +1 -1
  151. cosmotech_api/models/organization_access_control.py +1 -1
  152. cosmotech_api/models/organization_role.py +1 -1
  153. cosmotech_api/models/organization_security.py +1 -1
  154. cosmotech_api/models/organization_service.py +1 -1
  155. cosmotech_api/models/organization_services.py +1 -1
  156. cosmotech_api/models/query_result.py +88 -0
  157. cosmotech_api/models/resource_size_info.py +1 -1
  158. cosmotech_api/models/run.py +1 -1
  159. cosmotech_api/models/run_container.py +1 -1
  160. cosmotech_api/models/run_container_artifact.py +1 -1
  161. cosmotech_api/models/run_container_logs.py +1 -1
  162. cosmotech_api/models/run_data.py +92 -0
  163. cosmotech_api/models/run_data_query.py +88 -0
  164. cosmotech_api/models/run_logs.py +1 -1
  165. cosmotech_api/models/run_resource_requested.py +1 -1
  166. cosmotech_api/models/run_search.py +1 -1
  167. cosmotech_api/models/run_start_containers.py +1 -1
  168. cosmotech_api/models/run_state.py +1 -1
  169. cosmotech_api/models/run_status.py +1 -1
  170. cosmotech_api/models/run_status_node.py +1 -1
  171. cosmotech_api/models/run_template.py +1 -1
  172. cosmotech_api/models/run_template_handler_id.py +1 -1
  173. cosmotech_api/models/run_template_orchestrator.py +1 -1
  174. cosmotech_api/models/run_template_parameter.py +1 -1
  175. cosmotech_api/models/run_template_parameter_group.py +1 -1
  176. cosmotech_api/models/run_template_parameter_value.py +1 -1
  177. cosmotech_api/models/run_template_resource_sizing.py +1 -1
  178. cosmotech_api/models/run_template_step_source.py +1 -1
  179. cosmotech_api/models/runner.py +1 -1
  180. cosmotech_api/models/runner_access_control.py +1 -1
  181. cosmotech_api/models/runner_changed_parameter_value.py +1 -1
  182. cosmotech_api/models/runner_comparison_result.py +1 -1
  183. cosmotech_api/models/runner_data_download_info.py +1 -1
  184. cosmotech_api/models/runner_data_download_job.py +1 -1
  185. cosmotech_api/models/runner_job_state.py +1 -1
  186. cosmotech_api/models/runner_last_run.py +1 -1
  187. cosmotech_api/models/runner_parent_last_run.py +1 -1
  188. cosmotech_api/models/runner_resource_sizing.py +1 -1
  189. cosmotech_api/models/runner_role.py +1 -1
  190. cosmotech_api/models/runner_root_last_run.py +1 -1
  191. cosmotech_api/models/runner_run_template_parameter_value.py +1 -1
  192. cosmotech_api/models/runner_security.py +1 -1
  193. cosmotech_api/models/runner_validation_status.py +1 -1
  194. cosmotech_api/models/scenario.py +1 -1
  195. cosmotech_api/models/scenario_access_control.py +1 -1
  196. cosmotech_api/models/scenario_changed_parameter_value.py +1 -1
  197. cosmotech_api/models/scenario_comparison_result.py +1 -1
  198. cosmotech_api/models/scenario_data_download_info.py +1 -1
  199. cosmotech_api/models/scenario_data_download_job.py +1 -1
  200. cosmotech_api/models/scenario_job_state.py +1 -1
  201. cosmotech_api/models/scenario_last_run.py +1 -1
  202. cosmotech_api/models/scenario_resource_sizing.py +1 -1
  203. cosmotech_api/models/scenario_role.py +1 -1
  204. cosmotech_api/models/scenario_run.py +1 -1
  205. cosmotech_api/models/scenario_run_container.py +1 -1
  206. cosmotech_api/models/scenario_run_container_artifact.py +1 -1
  207. cosmotech_api/models/scenario_run_container_logs.py +1 -1
  208. cosmotech_api/models/scenario_run_logs.py +1 -1
  209. cosmotech_api/models/scenario_run_resource_requested.py +1 -1
  210. cosmotech_api/models/scenario_run_search.py +1 -1
  211. cosmotech_api/models/scenario_run_start_containers.py +1 -1
  212. cosmotech_api/models/scenario_run_state.py +1 -1
  213. cosmotech_api/models/scenario_run_status.py +1 -1
  214. cosmotech_api/models/scenario_run_status_node.py +1 -1
  215. cosmotech_api/models/scenario_run_template_parameter_value.py +1 -1
  216. cosmotech_api/models/scenario_security.py +1 -1
  217. cosmotech_api/models/scenario_validation_status.py +1 -1
  218. cosmotech_api/models/send_run_data_request.py +90 -0
  219. cosmotech_api/models/solution.py +1 -1
  220. cosmotech_api/models/solution_access_control.py +1 -1
  221. cosmotech_api/models/solution_role.py +1 -1
  222. cosmotech_api/models/solution_security.py +1 -1
  223. cosmotech_api/models/source_info.py +1 -1
  224. cosmotech_api/models/sub_dataset_graph_query.py +1 -1
  225. cosmotech_api/models/twin_graph_batch_result.py +1 -1
  226. cosmotech_api/models/twin_graph_hash.py +1 -1
  227. cosmotech_api/models/twin_graph_query.py +1 -1
  228. cosmotech_api/models/validator.py +1 -1
  229. cosmotech_api/models/validator_run.py +1 -1
  230. cosmotech_api/models/workspace.py +1 -1
  231. cosmotech_api/models/workspace_access_control.py +1 -1
  232. cosmotech_api/models/workspace_file.py +1 -1
  233. cosmotech_api/models/workspace_role.py +1 -1
  234. cosmotech_api/models/workspace_secret.py +1 -1
  235. cosmotech_api/models/workspace_security.py +1 -1
  236. cosmotech_api/models/workspace_solution.py +1 -1
  237. cosmotech_api/models/workspace_web_app.py +1 -1
  238. cosmotech_api/rest.py +139 -230
  239. {cosmotech_api-3.1.1.dist-info → cosmotech_api-3.2.0.dist-info}/METADATA +6 -4
  240. cosmotech_api-3.2.0.dist-info/RECORD +255 -0
  241. cosmotech_api-3.1.1.dist-info/RECORD +0 -251
  242. {cosmotech_api-3.1.1.dist-info → cosmotech_api-3.2.0.dist-info}/LICENSE +0 -0
  243. {cosmotech_api-3.1.1.dist-info → cosmotech_api-3.2.0.dist-info}/WHEEL +0 -0
  244. {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 # noqa: E501
6
+ Cosmo Tech Platform API
5
7
 
6
- The version of the OpenAPI document: 3.1.1
8
+ The version of the OpenAPI document: 3.2.0
7
9
  Contact: platform@cosmotech.com
8
- Generated by: https://openapi-generator.tech
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
- from urllib.parse import urlencode
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, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError
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
- logger = logging.getLogger(__name__)
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.urllib3_response = resp
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 = resp.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.urllib3_response.getheaders()
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.urllib3_response.getheader(name, default)
58
+ return self.response.headers.get(name, default)
44
59
 
45
60
 
46
- class RESTClientObject(object):
61
+ class RESTClientObject:
47
62
 
48
- def __init__(self, configuration, pools_size=4, maxsize=None):
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
- addition_pool_args = {}
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
- addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501
82
+ pool_args['assert_hostname'] = (
83
+ configuration.assert_hostname
84
+ )
64
85
 
65
86
  if configuration.retries is not None:
66
- addition_pool_args['retries'] = configuration.retries
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
- addition_pool_args['socket_options'] = configuration.socket_options
94
+ pool_args['socket_options'] = configuration.socket_options
70
95
 
71
- if maxsize is None:
72
- if configuration.connection_pool_maxsize is not None:
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
- if configuration.proxy and not should_bypass_proxies(configuration.host, no_proxy=configuration.no_proxy or ''):
79
- self.pool_manager = urllib3.ProxyManager(
80
- num_pools=pools_size,
81
- maxsize=maxsize,
82
- cert_reqs=cert_reqs,
83
- ca_certs=configuration.ssl_ca_cert,
84
- cert_file=configuration.cert_file,
85
- key_file=configuration.key_file,
86
- proxy_url=configuration.proxy,
87
- proxy_headers=configuration.proxy_headers,
88
- **addition_pool_args
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
- num_pools=pools_size,
93
- maxsize=maxsize,
94
- cert_reqs=cert_reqs,
95
- ca_certs=configuration.ssl_ca_cert,
96
- cert_file=configuration.cert_file,
97
- key_file=configuration.key_file,
98
- **addition_pool_args
99
- )
100
-
101
- def request(self, method, url, query_params=None, headers=None,
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 ['GET', 'HEAD', 'DELETE', 'POST', 'PUT',
124
- 'PATCH', 'OPTIONS']
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)): # noqa: E501,F821
159
+ if isinstance(_request_timeout, (int, float)):
137
160
  timeout = urllib3.Timeout(total=_request_timeout)
138
- elif (isinstance(_request_timeout, tuple) and
139
- len(_request_timeout) == 2):
161
+ elif (
162
+ isinstance(_request_timeout, tuple)
163
+ and len(_request_timeout) == 2
164
+ ):
140
165
  timeout = urllib3.Timeout(
141
- connect=_request_timeout[0], read=_request_timeout[1])
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
- # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests
147
- if (method != 'DELETE') and ('Content-Type' not in headers):
148
- headers['Content-Type'] = 'application/json'
149
- if query_params:
150
- url += '?' + urlencode(query_params)
151
- if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)):
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, url,
184
+ method,
185
+ url,
157
186
  body=request_body,
158
- preload_content=_preload_content,
159
187
  timeout=timeout,
160
- headers=headers)
161
- elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
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, url,
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
- elif headers['Content-Type'] == 'multipart/form-data':
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, url,
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 Json when `body` argument is
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, url,
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=_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(method, url,
201
- fields=query_params,
202
- preload_content=_preload_content,
203
- timeout=timeout,
204
- headers=headers)
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 = "{0}\n{1}".format(type(e).__name__, str(e))
253
+ msg = "\n".join([type(e).__name__, str(e)])
207
254
  raise ApiException(status=0, reason=msg)
208
255
 
209
- if _preload_content:
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.1.1
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
- Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
- Requires-Dist: urllib3 >=1.25.3
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 # noqa: E501
17
+ Cosmo Tech Platform API
16
18