step_rest_client 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. step_rest_client/__init__.py +136 -0
  2. step_rest_client/api/__init__.py +26 -0
  3. step_rest_client/api/assets_api.py +7960 -0
  4. step_rest_client/api/attributes_api.py +340 -0
  5. step_rest_client/api/background_process_types_api.py +640 -0
  6. step_rest_client/api/background_processes_api.py +1577 -0
  7. step_rest_client/api/classifications_api.py +7991 -0
  8. step_rest_client/api/data_container_types_api.py +340 -0
  9. step_rest_client/api/data_type_groups_api.py +340 -0
  10. step_rest_client/api/entities_api.py +8680 -0
  11. step_rest_client/api/event_processors_api.py +3337 -0
  12. step_rest_client/api/export_api.py +383 -0
  13. step_rest_client/api/gateway_integration_endpoints_api.py +1232 -0
  14. step_rest_client/api/import_api.py +390 -0
  15. step_rest_client/api/inbound_integration_endpoints_api.py +2815 -0
  16. step_rest_client/api/lists_of_values_api.py +642 -0
  17. step_rest_client/api/object_types_api.py +340 -0
  18. step_rest_client/api/outbound_integration_endpoints_api.py +3655 -0
  19. step_rest_client/api/products_api.py +8007 -0
  20. step_rest_client/api/reference_types_api.py +340 -0
  21. step_rest_client/api/reporting_api.py +707 -0
  22. step_rest_client/api/units_api.py +340 -0
  23. step_rest_client/api/workflow_tasks_api.py +1887 -0
  24. step_rest_client/api/workflows_api.py +1270 -0
  25. step_rest_client/api_client.py +797 -0
  26. step_rest_client/api_response.py +21 -0
  27. step_rest_client/configuration.py +597 -0
  28. step_rest_client/exceptions.py +216 -0
  29. step_rest_client/models/__init__.py +98 -0
  30. step_rest_client/models/amount.py +89 -0
  31. step_rest_client/models/and_condition.py +107 -0
  32. step_rest_client/models/approval_response.py +87 -0
  33. step_rest_client/models/approval_status.py +99 -0
  34. step_rest_client/models/asset.py +129 -0
  35. step_rest_client/models/attribute.py +120 -0
  36. step_rest_client/models/attribute_link.py +102 -0
  37. step_rest_client/models/background_process.py +139 -0
  38. step_rest_client/models/background_process_attachment_metadata.py +105 -0
  39. step_rest_client/models/background_process_identification.py +89 -0
  40. step_rest_client/models/background_process_type.py +89 -0
  41. step_rest_client/models/classification.py +135 -0
  42. step_rest_client/models/condition.py +265 -0
  43. step_rest_client/models/data_container.py +139 -0
  44. step_rest_client/models/data_container_entry.py +117 -0
  45. step_rest_client/models/data_container_object_condition.py +181 -0
  46. step_rest_client/models/data_container_type.py +106 -0
  47. step_rest_client/models/data_type_group.py +108 -0
  48. step_rest_client/models/endpoint_statistics.py +109 -0
  49. step_rest_client/models/endpoint_status.py +99 -0
  50. step_rest_client/models/entity.py +142 -0
  51. step_rest_client/models/error.py +91 -0
  52. step_rest_client/models/event_processor.py +93 -0
  53. step_rest_client/models/event_processor_statistics.py +97 -0
  54. step_rest_client/models/event_processor_status.py +99 -0
  55. step_rest_client/models/event_queue_status.py +89 -0
  56. step_rest_client/models/execution_report_entry.py +103 -0
  57. step_rest_client/models/export_specification.py +89 -0
  58. step_rest_client/models/find_similar_business_rule_result.py +91 -0
  59. step_rest_client/models/find_similar_entities_request.py +95 -0
  60. step_rest_client/models/find_similar_entities_response.py +103 -0
  61. step_rest_client/models/find_similar_entities_response_record.py +95 -0
  62. step_rest_client/models/find_similar_execution_report.py +103 -0
  63. step_rest_client/models/gateway_integration_endpoint.py +93 -0
  64. step_rest_client/models/has_data_container_object_condition.py +106 -0
  65. step_rest_client/models/has_reference_to_condition.py +108 -0
  66. step_rest_client/models/id_condition.py +105 -0
  67. step_rest_client/models/inbound_integration_endpoint.py +93 -0
  68. step_rest_client/models/incoming_reference_entry.py +118 -0
  69. step_rest_client/models/list_of_values.py +110 -0
  70. step_rest_client/models/list_of_values_entry.py +91 -0
  71. step_rest_client/models/lov_value_condition.py +100 -0
  72. step_rest_client/models/match_and_merge_execution_report.py +119 -0
  73. step_rest_client/models/match_and_merge_general_execution_report.py +91 -0
  74. step_rest_client/models/match_and_merge_potential_duplicate.py +93 -0
  75. step_rest_client/models/match_and_merge_record_in.py +95 -0
  76. step_rest_client/models/match_and_merge_record_out.py +117 -0
  77. step_rest_client/models/match_and_merge_response.py +103 -0
  78. step_rest_client/models/multi_data_container.py +101 -0
  79. step_rest_client/models/multi_reference.py +97 -0
  80. step_rest_client/models/multi_value.py +103 -0
  81. step_rest_client/models/name_condition.py +107 -0
  82. step_rest_client/models/numeric_value_condition.py +111 -0
  83. step_rest_client/models/object_type.py +104 -0
  84. step_rest_client/models/object_type_condition.py +96 -0
  85. step_rest_client/models/or_condition.py +107 -0
  86. step_rest_client/models/outbound_integration_endpoint.py +93 -0
  87. step_rest_client/models/product.py +150 -0
  88. step_rest_client/models/query.py +91 -0
  89. step_rest_client/models/query_result.py +99 -0
  90. step_rest_client/models/reference.py +139 -0
  91. step_rest_client/models/reference_entry.py +141 -0
  92. step_rest_client/models/reference_metadata_condition.py +181 -0
  93. step_rest_client/models/reference_type.py +114 -0
  94. step_rest_client/models/rejected_by_business_condition.py +93 -0
  95. step_rest_client/models/simple_below_condition.py +105 -0
  96. step_rest_client/models/single_data_container.py +97 -0
  97. step_rest_client/models/single_reference.py +93 -0
  98. step_rest_client/models/single_value.py +103 -0
  99. step_rest_client/models/status_flag.py +89 -0
  100. step_rest_client/models/text_value_condition.py +111 -0
  101. step_rest_client/models/trigger_workflow_event.py +93 -0
  102. step_rest_client/models/unit.py +104 -0
  103. step_rest_client/models/value.py +137 -0
  104. step_rest_client/models/value_entry.py +91 -0
  105. step_rest_client/models/workflow.py +91 -0
  106. step_rest_client/models/workflow_event.py +89 -0
  107. step_rest_client/models/workflow_instance.py +87 -0
  108. step_rest_client/models/workflow_instance_creation.py +93 -0
  109. step_rest_client/models/workflow_node.py +99 -0
  110. step_rest_client/models/workflow_task.py +113 -0
  111. step_rest_client/models/workflow_task_query.py +101 -0
  112. step_rest_client/py.typed +0 -0
  113. step_rest_client/rest.py +258 -0
  114. step_rest_client-1.0.0.dist-info/METADATA +23 -0
  115. step_rest_client-1.0.0.dist-info/RECORD +117 -0
  116. step_rest_client-1.0.0.dist-info/WHEEL +5 -0
  117. step_rest_client-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,597 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STEP REST API V2
5
+
6
+ <h1>About</h1><p>The STEP REST API V2 provides read and write access to a set of core STEP objects using the HTTP operations GET, PUT, POST, PATCH and DELETE.</p><h1>Resource Representation</h1><p>With the exception of a few resource operations for retrieving and uploading binary data, all request and response bodies are JSON, compliant with the schema documented here.</p><h1>Context and Workspace</h1><p>All requests are handled in a specific STEP context and workspace and both can be specified via query parameters available for all resource operations. A context must always be specified while requests per default will be handled in the &quot;Main&quot; workspace.</p><h1>Polymorphism</h1><p>In STEP, attributes, reference types and data container types can all be either single- or multivalued. The STEP REST API V2 uses polymorphism to address this complexity with resources that include values, references and data containers specified to produce and consume a common &quot;abstract&quot; supertype that always will be one of either the single- or multivalued subtype.<br/>As an example, the GET /entities/{id}/values/{attributeId} resource operation is specified to return a &quot;Value&quot; but as evident from the model, the &quot;Value&quot; will always be &quot;oneOf&quot; either &quot;SingleValue&quot;, that has a &quot;value&quot; property for which the value is an object, or &quot;MultiValue&quot;, that has a &quot;values&quot; property for which the value is an array.<br/>Clients are advised to use the presence or absence of the plural array property (&quot;values&quot;, &quot;references&quot; and &quot;dataContainers&quot;) to determine the concrete type.</p><h1>Authentication</h1><p>The REST API is protected by HTTP Basic Authentication or if OAuth2-based authentication is enabled (SaaS customers only), by Bearer Authentication. With Basic Authentication, user name and password are supplied with each request and it is therefore highly recommended to only use the API in conjunction with HTTPS. For more information about OAuth2-based authentication for SaaS customers, please see the STEP Authentication Guide.</p><h1>Versioning</h1><p>The STEP REST API V2 is versioned using semantic versioning. Stibo Systems reserve the right to make non-breaking, minor / patch changes in any release without warning and clients must be coded / configured to be 'tolerant' and capable of handling such changes.</p><p>Examples of breaking, major changes:</p><ul><li>Renaming of a property</li><li>Removal of a property</li><li>Property type change</li><li>Addition of new property required for write operations</li><li>Marking existing property as required for write operations</li><li>Removal of resource or resource operation</li><li>Materially different behavior for existing resource operation</li></ul><p>Examples of non-breaking, minor / patch changes:</p><ul><li>Addition of new properties in request responses</li><li>Addition of new query parameter not required for write operations</li><li>Addition of new resource or resource operation</li><li>Bug fixes that do not change the schema or resource operations as described here</li><li>Inclusion of a response body for resource operations specified to return a 200 response with no body</li><li>Change of response &quot;Model&quot; / &quot;schema&quot; to type extending the previously specified type</li><li>Renaming a &quot;Model&quot; / &quot;schema&quot; type</li></ul><p>In addition, error message texts may change without warning within the same version. Client program logic should not depend upon the message content.</p><h1>Error Handling</h1><p>The STEP REST API V2 responds with standard HTTP status codes, with 2** responses indicating a success, 4** responses indicating a client error and 5** indicating a server error. Notice that this specification does not specify common error responses like 500 (internal server error) or 401 (unauthorized) for the individual resource operations. Clients should however be capable of handling such responses.</p><p>Error responses have a JSON response body (see Error schema below) containing HTTP status code information in addition to a message providing details about the error. As mentioned above, client program logic should not depend upon the message content.</p><p>The specific status codes used in the API are:</p><ul><li>200 (OK): Success, response may or may not have a body</li><li>201 (Created): Entity successfully created, response may or may not have a body</li><li>400 (Bad request): The server cannot or will not process the request due to an apparent client error</li><li>401 (Unauthorized): Returned only in relation to failed authentication</li><li>404 (Not Found): Returned only in relation to objects specified via path parameters (variable parts of the URL). If STEP objects referenced in request bodies or via query parameters cannot be found, the response will be 400.</li><li>429 (Too Many Requests): Clients are per default limited to 100 requests per second. Returned if the rate limit is exceeded.</li><li>500 (Internal Server Error): Unexpected error (could potentially cover an issue that rightfully should be a 400)</li></ul>
7
+
8
+ The version of the OpenAPI document: 1.3.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ import copy
16
+ import http.client as httplib
17
+ import logging
18
+ from logging import FileHandler
19
+ import multiprocessing
20
+ import sys
21
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
22
+ from typing_extensions import NotRequired, Self
23
+
24
+ import urllib3
25
+
26
+
27
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
28
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
29
+ 'minimum', 'exclusiveMinimum', 'maxLength',
30
+ 'minLength', 'pattern', 'maxItems', 'minItems'
31
+ }
32
+
33
+ ServerVariablesT = Dict[str, str]
34
+
35
+ GenericAuthSetting = TypedDict(
36
+ "GenericAuthSetting",
37
+ {
38
+ "type": str,
39
+ "in": str,
40
+ "key": str,
41
+ "value": str,
42
+ },
43
+ )
44
+
45
+
46
+ OAuth2AuthSetting = TypedDict(
47
+ "OAuth2AuthSetting",
48
+ {
49
+ "type": Literal["oauth2"],
50
+ "in": Literal["header"],
51
+ "key": Literal["Authorization"],
52
+ "value": str,
53
+ },
54
+ )
55
+
56
+
57
+ APIKeyAuthSetting = TypedDict(
58
+ "APIKeyAuthSetting",
59
+ {
60
+ "type": Literal["api_key"],
61
+ "in": str,
62
+ "key": str,
63
+ "value": Optional[str],
64
+ },
65
+ )
66
+
67
+
68
+ BasicAuthSetting = TypedDict(
69
+ "BasicAuthSetting",
70
+ {
71
+ "type": Literal["basic"],
72
+ "in": Literal["header"],
73
+ "key": Literal["Authorization"],
74
+ "value": Optional[str],
75
+ },
76
+ )
77
+
78
+
79
+ BearerFormatAuthSetting = TypedDict(
80
+ "BearerFormatAuthSetting",
81
+ {
82
+ "type": Literal["bearer"],
83
+ "in": Literal["header"],
84
+ "format": Literal["JWT"],
85
+ "key": Literal["Authorization"],
86
+ "value": str,
87
+ },
88
+ )
89
+
90
+
91
+ BearerAuthSetting = TypedDict(
92
+ "BearerAuthSetting",
93
+ {
94
+ "type": Literal["bearer"],
95
+ "in": Literal["header"],
96
+ "key": Literal["Authorization"],
97
+ "value": str,
98
+ },
99
+ )
100
+
101
+
102
+ HTTPSignatureAuthSetting = TypedDict(
103
+ "HTTPSignatureAuthSetting",
104
+ {
105
+ "type": Literal["http-signature"],
106
+ "in": Literal["header"],
107
+ "key": Literal["Authorization"],
108
+ "value": None,
109
+ },
110
+ )
111
+
112
+
113
+ AuthSettings = TypedDict(
114
+ "AuthSettings",
115
+ {
116
+ "basicAuth": BasicAuthSetting,
117
+ },
118
+ total=False,
119
+ )
120
+
121
+
122
+ class HostSettingVariable(TypedDict):
123
+ description: str
124
+ default_value: str
125
+ enum_values: List[str]
126
+
127
+
128
+ class HostSetting(TypedDict):
129
+ url: str
130
+ description: str
131
+ variables: NotRequired[Dict[str, HostSettingVariable]]
132
+
133
+
134
+ class Configuration:
135
+ """This class contains various settings of the API client.
136
+
137
+ :param host: Base url.
138
+ :param ignore_operation_servers
139
+ Boolean to ignore operation servers for the API client.
140
+ Config will use `host` as the base url regardless of the operation servers.
141
+ :param api_key: Dict to store API key(s).
142
+ Each entry in the dict specifies an API key.
143
+ The dict key is the name of the security scheme in the OAS specification.
144
+ The dict value is the API key secret.
145
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
146
+ The dict key is the name of the security scheme in the OAS specification.
147
+ The dict value is an API key prefix when generating the auth data.
148
+ :param username: Username for HTTP basic authentication.
149
+ :param password: Password for HTTP basic authentication.
150
+ :param access_token: Access token.
151
+ :param server_index: Index to servers configuration.
152
+ :param server_variables: Mapping with string values to replace variables in
153
+ templated server configuration. The validation of enums is performed for
154
+ variables with defined enum values before.
155
+ :param server_operation_index: Mapping from operation ID to an index to server
156
+ configuration.
157
+ :param server_operation_variables: Mapping from operation ID to a mapping with
158
+ string values to replace variables in templated server configuration.
159
+ The validation of enums is performed for variables with defined enum
160
+ values before.
161
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
162
+ in PEM format.
163
+ :param retries: Number of retries for API requests.
164
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
165
+ in PEM (str) or DER (bytes) format.
166
+
167
+ :Example:
168
+
169
+ HTTP Basic Authentication Example.
170
+ Given the following security scheme in the OpenAPI specification:
171
+ components:
172
+ securitySchemes:
173
+ http_basic_auth:
174
+ type: http
175
+ scheme: basic
176
+
177
+ Configure API client with HTTP basic authentication:
178
+
179
+ conf = step_rest_client.Configuration(
180
+ username='the-user',
181
+ password='the-password',
182
+ )
183
+
184
+ """
185
+
186
+ _default: ClassVar[Optional[Self]] = None
187
+
188
+ def __init__(
189
+ self,
190
+ host: Optional[str]=None,
191
+ api_key: Optional[Dict[str, str]]=None,
192
+ api_key_prefix: Optional[Dict[str, str]]=None,
193
+ username: Optional[str]=None,
194
+ password: Optional[str]=None,
195
+ access_token: Optional[str]=None,
196
+ server_index: Optional[int]=None,
197
+ server_variables: Optional[ServerVariablesT]=None,
198
+ server_operation_index: Optional[Dict[int, int]]=None,
199
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
200
+ ignore_operation_servers: bool=False,
201
+ ssl_ca_cert: Optional[str]=None,
202
+ retries: Optional[int] = None,
203
+ ca_cert_data: Optional[Union[str, bytes]] = None,
204
+ *,
205
+ debug: Optional[bool] = None,
206
+ ) -> None:
207
+ """Constructor
208
+ """
209
+ self._base_path = "/restapiv2" if host is None else host
210
+ """Default Base url
211
+ """
212
+ self.server_index = 0 if server_index is None and host is None else server_index
213
+ self.server_operation_index = server_operation_index or {}
214
+ """Default server index
215
+ """
216
+ self.server_variables = server_variables or {}
217
+ self.server_operation_variables = server_operation_variables or {}
218
+ """Default server variables
219
+ """
220
+ self.ignore_operation_servers = ignore_operation_servers
221
+ """Ignore operation servers
222
+ """
223
+ self.temp_folder_path = None
224
+ """Temp file folder for downloading files
225
+ """
226
+ # Authentication Settings
227
+ self.api_key = {}
228
+ if api_key:
229
+ self.api_key = api_key
230
+ """dict to store API key(s)
231
+ """
232
+ self.api_key_prefix = {}
233
+ if api_key_prefix:
234
+ self.api_key_prefix = api_key_prefix
235
+ """dict to store API prefix (e.g. Bearer)
236
+ """
237
+ self.refresh_api_key_hook = None
238
+ """function hook to refresh API key if expired
239
+ """
240
+ self.username = username
241
+ """Username for HTTP basic authentication
242
+ """
243
+ self.password = password
244
+ """Password for HTTP basic authentication
245
+ """
246
+ self.access_token = access_token
247
+ """Access token
248
+ """
249
+ self.logger = {}
250
+ """Logging Settings
251
+ """
252
+ self.logger["package_logger"] = logging.getLogger("step_rest_client")
253
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
254
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
255
+ """Log format
256
+ """
257
+ self.logger_stream_handler = None
258
+ """Log stream handler
259
+ """
260
+ self.logger_file_handler: Optional[FileHandler] = None
261
+ """Log file handler
262
+ """
263
+ self.logger_file = None
264
+ """Debug file location
265
+ """
266
+ if debug is not None:
267
+ self.debug = debug
268
+ else:
269
+ self.__debug = False
270
+ """Debug switch
271
+ """
272
+
273
+ self.verify_ssl = True
274
+ """SSL/TLS verification
275
+ Set this to false to skip verifying SSL certificate when calling API
276
+ from https server.
277
+ """
278
+ self.ssl_ca_cert = ssl_ca_cert
279
+ """Set this to customize the certificate file to verify the peer.
280
+ """
281
+ self.ca_cert_data = ca_cert_data
282
+ """Set this to verify the peer using PEM (str) or DER (bytes)
283
+ certificate data.
284
+ """
285
+ self.cert_file = None
286
+ """client certificate file
287
+ """
288
+ self.key_file = None
289
+ """client key file
290
+ """
291
+ self.assert_hostname = None
292
+ """Set this to True/False to enable/disable SSL hostname verification.
293
+ """
294
+ self.tls_server_name = None
295
+ """SSL/TLS Server Name Indication (SNI)
296
+ Set this to the SNI value expected by the server.
297
+ """
298
+
299
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
300
+ """urllib3 connection pool's maximum number of connections saved
301
+ per pool. urllib3 uses 1 connection as default value, but this is
302
+ not the best value when you are making a lot of possibly parallel
303
+ requests to the same host, which is often the case here.
304
+ cpu_count * 5 is used as default value to increase performance.
305
+ """
306
+
307
+ self.proxy: Optional[str] = None
308
+ """Proxy URL
309
+ """
310
+ self.proxy_headers = None
311
+ """Proxy headers
312
+ """
313
+ self.safe_chars_for_path_param = ''
314
+ """Safe chars for path_param
315
+ """
316
+ self.retries = retries
317
+ """Adding retries to override urllib3 default value 3
318
+ """
319
+ # Enable client side validation
320
+ self.client_side_validation = True
321
+
322
+ self.socket_options = None
323
+ """Options to pass down to the underlying urllib3 socket
324
+ """
325
+
326
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
327
+ """datetime format
328
+ """
329
+
330
+ self.date_format = "%Y-%m-%d"
331
+ """date format
332
+ """
333
+
334
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
335
+ cls = self.__class__
336
+ result = cls.__new__(cls)
337
+ memo[id(self)] = result
338
+ for k, v in self.__dict__.items():
339
+ if k not in ('logger', 'logger_file_handler'):
340
+ setattr(result, k, copy.deepcopy(v, memo))
341
+ # shallow copy of loggers
342
+ result.logger = copy.copy(self.logger)
343
+ # use setters to configure loggers
344
+ result.logger_file = self.logger_file
345
+ result.debug = self.debug
346
+ return result
347
+
348
+ def __setattr__(self, name: str, value: Any) -> None:
349
+ object.__setattr__(self, name, value)
350
+
351
+ @classmethod
352
+ def set_default(cls, default: Optional[Self]) -> None:
353
+ """Set default instance of configuration.
354
+
355
+ It stores default configuration, which can be
356
+ returned by get_default_copy method.
357
+
358
+ :param default: object of Configuration
359
+ """
360
+ cls._default = default
361
+
362
+ @classmethod
363
+ def get_default_copy(cls) -> Self:
364
+ """Deprecated. Please use `get_default` instead.
365
+
366
+ Deprecated. Please use `get_default` instead.
367
+
368
+ :return: The configuration object.
369
+ """
370
+ return cls.get_default()
371
+
372
+ @classmethod
373
+ def get_default(cls) -> Self:
374
+ """Return the default configuration.
375
+
376
+ This method returns newly created, based on default constructor,
377
+ object of Configuration class or returns a copy of default
378
+ configuration.
379
+
380
+ :return: The configuration object.
381
+ """
382
+ if cls._default is None:
383
+ cls._default = cls()
384
+ return cls._default
385
+
386
+ @property
387
+ def logger_file(self) -> Optional[str]:
388
+ """The logger file.
389
+
390
+ If the logger_file is None, then add stream handler and remove file
391
+ handler. Otherwise, add file handler and remove stream handler.
392
+
393
+ :param value: The logger_file path.
394
+ :type: str
395
+ """
396
+ return self.__logger_file
397
+
398
+ @logger_file.setter
399
+ def logger_file(self, value: Optional[str]) -> None:
400
+ """The logger file.
401
+
402
+ If the logger_file is None, then add stream handler and remove file
403
+ handler. Otherwise, add file handler and remove stream handler.
404
+
405
+ :param value: The logger_file path.
406
+ :type: str
407
+ """
408
+ self.__logger_file = value
409
+ if self.__logger_file:
410
+ # If set logging file,
411
+ # then add file handler and remove stream handler.
412
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
413
+ self.logger_file_handler.setFormatter(self.logger_formatter)
414
+ for _, logger in self.logger.items():
415
+ logger.addHandler(self.logger_file_handler)
416
+
417
+ @property
418
+ def debug(self) -> bool:
419
+ """Debug status
420
+
421
+ :param value: The debug status, True or False.
422
+ :type: bool
423
+ """
424
+ return self.__debug
425
+
426
+ @debug.setter
427
+ def debug(self, value: bool) -> None:
428
+ """Debug status
429
+
430
+ :param value: The debug status, True or False.
431
+ :type: bool
432
+ """
433
+ self.__debug = value
434
+ if self.__debug:
435
+ # if debug status is True, turn on debug logging
436
+ for _, logger in self.logger.items():
437
+ logger.setLevel(logging.DEBUG)
438
+ # turn on httplib debug
439
+ httplib.HTTPConnection.debuglevel = 1
440
+ else:
441
+ # if debug status is False, turn off debug logging,
442
+ # setting log level to default `logging.WARNING`
443
+ for _, logger in self.logger.items():
444
+ logger.setLevel(logging.WARNING)
445
+ # turn off httplib debug
446
+ httplib.HTTPConnection.debuglevel = 0
447
+
448
+ @property
449
+ def logger_format(self) -> str:
450
+ """The logger format.
451
+
452
+ The logger_formatter will be updated when sets logger_format.
453
+
454
+ :param value: The format string.
455
+ :type: str
456
+ """
457
+ return self.__logger_format
458
+
459
+ @logger_format.setter
460
+ def logger_format(self, value: str) -> None:
461
+ """The logger format.
462
+
463
+ The logger_formatter will be updated when sets logger_format.
464
+
465
+ :param value: The format string.
466
+ :type: str
467
+ """
468
+ self.__logger_format = value
469
+ self.logger_formatter = logging.Formatter(self.__logger_format)
470
+
471
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
472
+ """Gets API key (with prefix if set).
473
+
474
+ :param identifier: The identifier of apiKey.
475
+ :param alias: The alternative identifier of apiKey.
476
+ :return: The token for api key authentication.
477
+ """
478
+ if self.refresh_api_key_hook is not None:
479
+ self.refresh_api_key_hook(self)
480
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
481
+ if key:
482
+ prefix = self.api_key_prefix.get(identifier)
483
+ if prefix:
484
+ return "%s %s" % (prefix, key)
485
+ else:
486
+ return key
487
+
488
+ return None
489
+
490
+ def get_basic_auth_token(self) -> Optional[str]:
491
+ """Gets HTTP basic authentication header (string).
492
+
493
+ :return: The token for basic HTTP authentication.
494
+ """
495
+ username = ""
496
+ if self.username is not None:
497
+ username = self.username
498
+ password = ""
499
+ if self.password is not None:
500
+ password = self.password
501
+ return urllib3.util.make_headers(
502
+ basic_auth=username + ':' + password
503
+ ).get('authorization')
504
+
505
+ def auth_settings(self)-> AuthSettings:
506
+ """Gets Auth Settings dict for api client.
507
+
508
+ :return: The Auth Settings information dict.
509
+ """
510
+ auth: AuthSettings = {}
511
+ if self.username is not None and self.password is not None:
512
+ auth['basicAuth'] = {
513
+ 'type': 'basic',
514
+ 'in': 'header',
515
+ 'key': 'Authorization',
516
+ 'value': self.get_basic_auth_token()
517
+ }
518
+ return auth
519
+
520
+ def to_debug_report(self) -> str:
521
+ """Gets the essential information for debugging.
522
+
523
+ :return: The report for debugging.
524
+ """
525
+ return "Python SDK Debug Report:\n"\
526
+ "OS: {env}\n"\
527
+ "Python Version: {pyversion}\n"\
528
+ "Version of the API: 1.3.0\n"\
529
+ "SDK Package Version: 1.0.0".\
530
+ format(env=sys.platform, pyversion=sys.version)
531
+
532
+ def get_host_settings(self) -> List[HostSetting]:
533
+ """Gets an array of host settings
534
+
535
+ :return: An array of host settings
536
+ """
537
+ return [
538
+ {
539
+ 'url': "/restapiv2",
540
+ 'description': "No description provided",
541
+ }
542
+ ]
543
+
544
+ def get_host_from_settings(
545
+ self,
546
+ index: Optional[int],
547
+ variables: Optional[ServerVariablesT]=None,
548
+ servers: Optional[List[HostSetting]]=None,
549
+ ) -> str:
550
+ """Gets host URL based on the index and variables
551
+ :param index: array index of the host settings
552
+ :param variables: hash of variable and the corresponding value
553
+ :param servers: an array of host settings or None
554
+ :return: URL based on host settings
555
+ """
556
+ if index is None:
557
+ return self._base_path
558
+
559
+ variables = {} if variables is None else variables
560
+ servers = self.get_host_settings() if servers is None else servers
561
+
562
+ try:
563
+ server = servers[index]
564
+ except IndexError:
565
+ raise ValueError(
566
+ "Invalid index {0} when selecting the host settings. "
567
+ "Must be less than {1}".format(index, len(servers)))
568
+
569
+ url = server['url']
570
+
571
+ # go through variables and replace placeholders
572
+ for variable_name, variable in server.get('variables', {}).items():
573
+ used_value = variables.get(
574
+ variable_name, variable['default_value'])
575
+
576
+ if 'enum_values' in variable \
577
+ and used_value not in variable['enum_values']:
578
+ raise ValueError(
579
+ "The variable `{0}` in the host URL has invalid value "
580
+ "{1}. Must be {2}.".format(
581
+ variable_name, variables[variable_name],
582
+ variable['enum_values']))
583
+
584
+ url = url.replace("{" + variable_name + "}", used_value)
585
+
586
+ return url
587
+
588
+ @property
589
+ def host(self) -> str:
590
+ """Return generated host."""
591
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
592
+
593
+ @host.setter
594
+ def host(self, value: str) -> None:
595
+ """Fix base path."""
596
+ self._base_path = value
597
+ self.server_index = None