testit-python-commons 4.2.8__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 (71) hide show
  1. api_client_syncstorage/__init__.py +27 -0
  2. api_client_syncstorage/api/__init__.py +3 -0
  3. api_client_syncstorage/api/completion_api.py +302 -0
  4. api_client_syncstorage/api/health_api.py +158 -0
  5. api_client_syncstorage/api/system_api.py +158 -0
  6. api_client_syncstorage/api/test_results_api.py +182 -0
  7. api_client_syncstorage/api/workers_api.py +308 -0
  8. api_client_syncstorage/api_client.py +898 -0
  9. api_client_syncstorage/apis/__init__.py +21 -0
  10. api_client_syncstorage/configuration.py +450 -0
  11. api_client_syncstorage/exceptions.py +158 -0
  12. api_client_syncstorage/model/__init__.py +5 -0
  13. api_client_syncstorage/model/completion_response.py +267 -0
  14. api_client_syncstorage/model/health_status_response.py +267 -0
  15. api_client_syncstorage/model/register_request.py +275 -0
  16. api_client_syncstorage/model/register_response.py +279 -0
  17. api_client_syncstorage/model/set_worker_status_request.py +271 -0
  18. api_client_syncstorage/model/set_worker_status_response.py +267 -0
  19. api_client_syncstorage/model/shutdown_response.py +267 -0
  20. api_client_syncstorage/model/test_result_cut_api_model.py +279 -0
  21. api_client_syncstorage/model/test_result_save_response.py +267 -0
  22. api_client_syncstorage/model_utils.py +2058 -0
  23. api_client_syncstorage/models/__init__.py +20 -0
  24. api_client_syncstorage/rest.py +356 -0
  25. testit.py +69 -0
  26. testit_python_commons/__init__.py +0 -0
  27. testit_python_commons/app_properties.py +257 -0
  28. testit_python_commons/client/__init__.py +9 -0
  29. testit_python_commons/client/api_client.py +560 -0
  30. testit_python_commons/client/client_configuration.py +74 -0
  31. testit_python_commons/client/converter.py +618 -0
  32. testit_python_commons/client/helpers/__init__.py +0 -0
  33. testit_python_commons/client/helpers/bulk_autotest_helper.py +246 -0
  34. testit_python_commons/client/helpers/threads_manager.py +86 -0
  35. testit_python_commons/client/models/__init__.py +8 -0
  36. testit_python_commons/client/models/threads_for_create_and_result.py +35 -0
  37. testit_python_commons/client/models/threads_for_update_and_result.py +45 -0
  38. testit_python_commons/configurations/__init__.py +0 -0
  39. testit_python_commons/configurations/properties_names.py +51 -0
  40. testit_python_commons/decorators.py +221 -0
  41. testit_python_commons/dynamic_methods.py +237 -0
  42. testit_python_commons/models/__init__.py +5 -0
  43. testit_python_commons/models/adapter_mode.py +4 -0
  44. testit_python_commons/models/fixture.py +24 -0
  45. testit_python_commons/models/link.py +53 -0
  46. testit_python_commons/models/link_type.py +10 -0
  47. testit_python_commons/models/outcome_type.py +5 -0
  48. testit_python_commons/models/status_type.py +6 -0
  49. testit_python_commons/models/step_result.py +90 -0
  50. testit_python_commons/models/test_result.py +297 -0
  51. testit_python_commons/models/test_result_with_all_fixture_step_results_model.py +28 -0
  52. testit_python_commons/services/__init__.py +41 -0
  53. testit_python_commons/services/adapter_manager.py +318 -0
  54. testit_python_commons/services/adapter_manager_configuration.py +42 -0
  55. testit_python_commons/services/fixture_manager.py +60 -0
  56. testit_python_commons/services/fixture_storage.py +40 -0
  57. testit_python_commons/services/logger.py +32 -0
  58. testit_python_commons/services/plugin_manager.py +101 -0
  59. testit_python_commons/services/retry.py +92 -0
  60. testit_python_commons/services/step_manager.py +36 -0
  61. testit_python_commons/services/step_result_storage.py +26 -0
  62. testit_python_commons/services/sync_storage/__init__.py +9 -0
  63. testit_python_commons/services/sync_storage/sync_storage_runner.py +589 -0
  64. testit_python_commons/services/utils.py +132 -0
  65. testit_python_commons/step.py +101 -0
  66. testit_python_commons/utils/__init__.py +3 -0
  67. testit_python_commons/utils/html_escape_utils.py +219 -0
  68. testit_python_commons-4.2.8.dist-info/METADATA +52 -0
  69. testit_python_commons-4.2.8.dist-info/RECORD +71 -0
  70. testit_python_commons-4.2.8.dist-info/WHEEL +5 -0
  71. testit_python_commons-4.2.8.dist-info/top_level.txt +3 -0
@@ -0,0 +1,21 @@
1
+
2
+ # flake8: noqa
3
+
4
+ # Import all APIs into this package.
5
+ # If you have many APIs here with many many models used in each API this may
6
+ # raise a `RecursionError`.
7
+ # In order to avoid this, import only the API that you directly need like:
8
+ #
9
+ # from api_client_syncstorage.api.completion_api import CompletionApi
10
+ #
11
+ # or import this package, but before doing it, use:
12
+ #
13
+ # import sys
14
+ # sys.setrecursionlimit(n)
15
+
16
+ # Import APIs into API package:
17
+ from api_client_syncstorage.api.completion_api import CompletionApi
18
+ from api_client_syncstorage.api.health_api import HealthApi
19
+ from api_client_syncstorage.api.system_api import SystemApi
20
+ from api_client_syncstorage.api.test_results_api import TestResultsApi
21
+ from api_client_syncstorage.api.workers_api import WorkersApi
@@ -0,0 +1,450 @@
1
+ """
2
+ Sync Storage Service API
3
+
4
+ This is a sync storage service for coordinating test workers. # noqa: E501
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Generated by: https://openapi-generator.tech
8
+ """
9
+
10
+
11
+ import copy
12
+ import logging
13
+ import multiprocessing
14
+ import sys
15
+ import urllib3
16
+
17
+ from http import client as http_client
18
+ from api_client_syncstorage.exceptions import ApiValueError
19
+
20
+
21
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
22
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
23
+ 'minimum', 'exclusiveMinimum', 'maxLength',
24
+ 'minLength', 'pattern', 'maxItems', 'minItems'
25
+ }
26
+
27
+ class Configuration(object):
28
+ """NOTE: This class is auto generated by OpenAPI Generator
29
+
30
+ Ref: https://openapi-generator.tech
31
+ Do not edit the class manually.
32
+
33
+ :param host: Base url
34
+ :param api_key: Dict to store API key(s).
35
+ Each entry in the dict specifies an API key.
36
+ The dict key is the name of the security scheme in the OAS specification.
37
+ The dict value is the API key secret.
38
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer)
39
+ The dict key is the name of the security scheme in the OAS specification.
40
+ The dict value is an API key prefix when generating the auth data.
41
+ :param username: Username for HTTP basic authentication
42
+ :param password: Password for HTTP basic authentication
43
+ :param discard_unknown_keys: Boolean value indicating whether to discard
44
+ unknown properties. A server may send a response that includes additional
45
+ properties that are not known by the client in the following scenarios:
46
+ 1. The OpenAPI document is incomplete, i.e. it does not match the server
47
+ implementation.
48
+ 2. The client was generated using an older version of the OpenAPI document
49
+ and the server has been upgraded since then.
50
+ If a schema in the OpenAPI document defines the additionalProperties attribute,
51
+ then all undeclared properties received by the server are injected into the
52
+ additional properties map. In that case, there are undeclared properties, and
53
+ nothing to discard.
54
+ :param disabled_client_side_validations (string): Comma-separated list of
55
+ JSON schema validation keywords to disable JSON schema structural validation
56
+ rules. The following keywords may be specified: multipleOf, maximum,
57
+ exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern,
58
+ maxItems, minItems.
59
+ By default, the validation is performed for data generated locally by the client
60
+ and data received from the server, independent of any validation performed by
61
+ the server side. If the input data does not satisfy the JSON schema validation
62
+ rules specified in the OpenAPI document, an exception is raised.
63
+ If disabled_client_side_validations is set, structural validation is
64
+ disabled. This can be useful to troubleshoot data validation problem, such as
65
+ when the OpenAPI document validation rules do not match the actual API data
66
+ received by the server.
67
+ :param server_index: Index to servers configuration.
68
+ :param server_variables: Mapping with string values to replace variables in
69
+ templated server configuration. The validation of enums is performed for
70
+ variables with defined enum values before.
71
+ :param server_operation_index: Mapping from operation ID to an index to server
72
+ configuration.
73
+ :param server_operation_variables: Mapping from operation ID to a mapping with
74
+ string values to replace variables in templated server configuration.
75
+ The validation of enums is performed for variables with defined enum values before.
76
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
77
+ in PEM format
78
+
79
+ """
80
+
81
+ _default = None
82
+
83
+ def __init__(self, host=None,
84
+ api_key=None, api_key_prefix=None,
85
+ access_token=None,
86
+ username=None, password=None,
87
+ discard_unknown_keys=False,
88
+ disabled_client_side_validations="",
89
+ server_index=None, server_variables=None,
90
+ server_operation_index=None, server_operation_variables=None,
91
+ ssl_ca_cert=None,
92
+ ):
93
+ """Constructor
94
+ """
95
+ self._base_path = "http://localhost" if host is None else host
96
+ """Default Base url
97
+ """
98
+ self.server_index = 0 if server_index is None and host is None else server_index
99
+ self.server_operation_index = server_operation_index or {}
100
+ """Default server index
101
+ """
102
+ self.server_variables = server_variables or {}
103
+ self.server_operation_variables = server_operation_variables or {}
104
+ """Default server variables
105
+ """
106
+ self.temp_folder_path = None
107
+ """Temp file folder for downloading files
108
+ """
109
+ # Authentication Settings
110
+ self.access_token = access_token
111
+ self.api_key = {}
112
+ if api_key:
113
+ self.api_key = api_key
114
+ """dict to store API key(s)
115
+ """
116
+ self.api_key_prefix = {}
117
+ if api_key_prefix:
118
+ self.api_key_prefix = api_key_prefix
119
+ """dict to store API prefix (e.g. Bearer)
120
+ """
121
+ self.refresh_api_key_hook = None
122
+ """function hook to refresh API key if expired
123
+ """
124
+ self.username = username
125
+ """Username for HTTP basic authentication
126
+ """
127
+ self.password = password
128
+ """Password for HTTP basic authentication
129
+ """
130
+ self.discard_unknown_keys = discard_unknown_keys
131
+ self.disabled_client_side_validations = disabled_client_side_validations
132
+ self.logger = {}
133
+ """Logging Settings
134
+ """
135
+ self.logger["package_logger"] = logging.getLogger("api_client_syncstorage")
136
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
137
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
138
+ """Log format
139
+ """
140
+ self.logger_stream_handler = None
141
+ """Log stream handler
142
+ """
143
+ self.logger_file_handler = None
144
+ """Log file handler
145
+ """
146
+ self.logger_file = None
147
+ """Debug file location
148
+ """
149
+ self.debug = False
150
+ """Debug switch
151
+ """
152
+
153
+ self.verify_ssl = True
154
+ """SSL/TLS verification
155
+ Set this to false to skip verifying SSL certificate when calling API
156
+ from https server.
157
+ """
158
+ self.ssl_ca_cert = ssl_ca_cert
159
+ """Set this to customize the certificate file to verify the peer.
160
+ """
161
+ self.cert_file = None
162
+ """client certificate file
163
+ """
164
+ self.key_file = None
165
+ """client key file
166
+ """
167
+ self.assert_hostname = None
168
+ """Set this to True/False to enable/disable SSL hostname verification.
169
+ """
170
+ self.tls_server_name = None
171
+ """SSL/TLS Server Name Indication (SNI)
172
+ Set this to the SNI value expected by the server.
173
+ """
174
+
175
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
176
+ """urllib3 connection pool's maximum number of connections saved
177
+ per pool. urllib3 uses 1 connection as default value, but this is
178
+ not the best value when you are making a lot of possibly parallel
179
+ requests to the same host, which is often the case here.
180
+ cpu_count * 5 is used as default value to increase performance.
181
+ """
182
+
183
+ self.proxy = None
184
+ """Proxy URL
185
+ """
186
+ self.no_proxy = None
187
+ """bypass proxy for host in the no_proxy list.
188
+ """
189
+ self.proxy_headers = None
190
+ """Proxy headers
191
+ """
192
+ self.safe_chars_for_path_param = ''
193
+ """Safe chars for path_param
194
+ """
195
+ self.retries = None
196
+ """Adding retries to override urllib3 default value 3
197
+ """
198
+ # Enable client side validation
199
+ self.client_side_validation = True
200
+
201
+ # Options to pass down to the underlying urllib3 socket
202
+ self.socket_options = None
203
+
204
+ def __deepcopy__(self, memo):
205
+ cls = self.__class__
206
+ result = cls.__new__(cls)
207
+ memo[id(self)] = result
208
+ for k, v in self.__dict__.items():
209
+ if k not in ('logger', 'logger_file_handler'):
210
+ setattr(result, k, copy.deepcopy(v, memo))
211
+ # shallow copy of loggers
212
+ result.logger = copy.copy(self.logger)
213
+ # use setters to configure loggers
214
+ result.logger_file = self.logger_file
215
+ result.debug = self.debug
216
+ return result
217
+
218
+ def __setattr__(self, name, value):
219
+ object.__setattr__(self, name, value)
220
+ if name == 'disabled_client_side_validations':
221
+ s = set(filter(None, value.split(',')))
222
+ for v in s:
223
+ if v not in JSON_SCHEMA_VALIDATION_KEYWORDS:
224
+ raise ApiValueError(
225
+ "Invalid keyword: '{0}''".format(v))
226
+ self._disabled_client_side_validations = s
227
+
228
+ @classmethod
229
+ def set_default(cls, default):
230
+ """Set default instance of configuration.
231
+
232
+ It stores default configuration, which can be
233
+ returned by get_default_copy method.
234
+
235
+ :param default: object of Configuration
236
+ """
237
+ cls._default = copy.deepcopy(default)
238
+
239
+ @classmethod
240
+ def get_default_copy(cls):
241
+ """Return new instance of configuration.
242
+
243
+ This method returns newly created, based on default constructor,
244
+ object of Configuration class or returns a copy of default
245
+ configuration passed by the set_default method.
246
+
247
+ :return: The configuration object.
248
+ """
249
+ if cls._default is not None:
250
+ return copy.deepcopy(cls._default)
251
+ return Configuration()
252
+
253
+ @property
254
+ def logger_file(self):
255
+ """The logger file.
256
+
257
+ If the logger_file is None, then add stream handler and remove file
258
+ handler. Otherwise, add file handler and remove stream handler.
259
+
260
+ :param value: The logger_file path.
261
+ :type: str
262
+ """
263
+ return self.__logger_file
264
+
265
+ @logger_file.setter
266
+ def logger_file(self, value):
267
+ """The logger file.
268
+
269
+ If the logger_file is None, then add stream handler and remove file
270
+ handler. Otherwise, add file handler and remove stream handler.
271
+
272
+ :param value: The logger_file path.
273
+ :type: str
274
+ """
275
+ self.__logger_file = value
276
+ if self.__logger_file:
277
+ # If set logging file,
278
+ # then add file handler and remove stream handler.
279
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
280
+ self.logger_file_handler.setFormatter(self.logger_formatter)
281
+ for _, logger in self.logger.items():
282
+ logger.addHandler(self.logger_file_handler)
283
+
284
+ @property
285
+ def debug(self):
286
+ """Debug status
287
+
288
+ :param value: The debug status, True or False.
289
+ :type: bool
290
+ """
291
+ return self.__debug
292
+
293
+ @debug.setter
294
+ def debug(self, value):
295
+ """Debug status
296
+
297
+ :param value: The debug status, True or False.
298
+ :type: bool
299
+ """
300
+ self.__debug = value
301
+ if self.__debug:
302
+ # if debug status is True, turn on debug logging
303
+ for _, logger in self.logger.items():
304
+ logger.setLevel(logging.DEBUG)
305
+ # turn on http_client debug
306
+ http_client.HTTPConnection.debuglevel = 1
307
+ else:
308
+ # if debug status is False, turn off debug logging,
309
+ # setting log level to default `logging.WARNING`
310
+ for _, logger in self.logger.items():
311
+ logger.setLevel(logging.WARNING)
312
+ # turn off http_client debug
313
+ http_client.HTTPConnection.debuglevel = 0
314
+
315
+ @property
316
+ def logger_format(self):
317
+ """The logger format.
318
+
319
+ The logger_formatter will be updated when sets logger_format.
320
+
321
+ :param value: The format string.
322
+ :type: str
323
+ """
324
+ return self.__logger_format
325
+
326
+ @logger_format.setter
327
+ def logger_format(self, value):
328
+ """The logger format.
329
+
330
+ The logger_formatter will be updated when sets logger_format.
331
+
332
+ :param value: The format string.
333
+ :type: str
334
+ """
335
+ self.__logger_format = value
336
+ self.logger_formatter = logging.Formatter(self.__logger_format)
337
+
338
+ def get_api_key_with_prefix(self, identifier, alias=None):
339
+ """Gets API key (with prefix if set).
340
+
341
+ :param identifier: The identifier of apiKey.
342
+ :param alias: The alternative identifier of apiKey.
343
+ :return: The token for api key authentication.
344
+ """
345
+ if self.refresh_api_key_hook is not None:
346
+ self.refresh_api_key_hook(self)
347
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
348
+ if key:
349
+ prefix = self.api_key_prefix.get(identifier)
350
+ if prefix:
351
+ return "%s %s" % (prefix, key)
352
+ else:
353
+ return key
354
+
355
+ def get_basic_auth_token(self):
356
+ """Gets HTTP basic authentication header (string).
357
+
358
+ :return: The token for basic HTTP authentication.
359
+ """
360
+ username = ""
361
+ if self.username is not None:
362
+ username = self.username
363
+ password = ""
364
+ if self.password is not None:
365
+ password = self.password
366
+ return urllib3.util.make_headers(
367
+ basic_auth=username + ':' + password
368
+ ).get('authorization')
369
+
370
+ def auth_settings(self):
371
+ """Gets Auth Settings dict for api client.
372
+
373
+ :return: The Auth Settings information dict.
374
+ """
375
+ auth = {}
376
+ return auth
377
+
378
+ def to_debug_report(self):
379
+ """Gets the essential information for debugging.
380
+
381
+ :return: The report for debugging.
382
+ """
383
+ return "Python SDK Debug Report:\n"\
384
+ "OS: {env}\n"\
385
+ "Python Version: {pyversion}\n"\
386
+ "Version of the API: 1.0\n"\
387
+ "SDK Package Version: 1.0.0".\
388
+ format(env=sys.platform, pyversion=sys.version)
389
+
390
+ def get_host_settings(self):
391
+ """Gets an array of host settings
392
+
393
+ :return: An array of host settings
394
+ """
395
+ return [
396
+ {
397
+ 'url': "",
398
+ 'description': "Default Server URL",
399
+ }
400
+ ]
401
+
402
+ def get_host_from_settings(self, index, variables=None, servers=None):
403
+ """Gets host URL based on the index and variables
404
+ :param index: array index of the host settings
405
+ :param variables: hash of variable and the corresponding value
406
+ :param servers: an array of host settings or None
407
+ :return: URL based on host settings
408
+ """
409
+ if index is None:
410
+ return self._base_path
411
+
412
+ variables = {} if variables is None else variables
413
+ servers = self.get_host_settings() if servers is None else servers
414
+
415
+ try:
416
+ server = servers[index]
417
+ except IndexError:
418
+ raise ValueError(
419
+ "Invalid index {0} when selecting the host settings. "
420
+ "Must be less than {1}".format(index, len(servers)))
421
+
422
+ url = server['url']
423
+
424
+ # go through variables and replace placeholders
425
+ for variable_name, variable in server.get('variables', {}).items():
426
+ used_value = variables.get(
427
+ variable_name, variable['default_value'])
428
+
429
+ if 'enum_values' in variable \
430
+ and used_value not in variable['enum_values']:
431
+ raise ValueError(
432
+ "The variable `{0}` in the host URL has invalid value "
433
+ "{1}. Must be {2}.".format(
434
+ variable_name, variables[variable_name],
435
+ variable['enum_values']))
436
+
437
+ url = url.replace("{" + variable_name + "}", used_value)
438
+
439
+ return url
440
+
441
+ @property
442
+ def host(self):
443
+ """Return generated host."""
444
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
445
+
446
+ @host.setter
447
+ def host(self, value):
448
+ """Fix base path."""
449
+ self._base_path = value
450
+ self.server_index = None
@@ -0,0 +1,158 @@
1
+ """
2
+ Sync Storage Service API
3
+
4
+ This is a sync storage service for coordinating test workers. # noqa: E501
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Generated by: https://openapi-generator.tech
8
+ """
9
+
10
+
11
+ class OpenApiException(Exception):
12
+ """The base exception class for all OpenAPIExceptions"""
13
+
14
+
15
+ class ApiTypeError(OpenApiException, TypeError):
16
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
17
+ key_type=None):
18
+ """ Raises an exception for TypeErrors
19
+
20
+ Args:
21
+ msg (str): the exception message
22
+
23
+ Keyword Args:
24
+ path_to_item (list): a list of keys an indices to get to the
25
+ current_item
26
+ None if unset
27
+ valid_classes (tuple): the primitive classes that current item
28
+ should be an instance of
29
+ None if unset
30
+ key_type (bool): False if our value is a value in a dict
31
+ True if it is a key in a dict
32
+ False if our item is an item in a list
33
+ None if unset
34
+ """
35
+ self.path_to_item = path_to_item
36
+ self.valid_classes = valid_classes
37
+ self.key_type = key_type
38
+ full_msg = msg
39
+ if path_to_item:
40
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
41
+ super(ApiTypeError, self).__init__(full_msg)
42
+
43
+
44
+ class ApiValueError(OpenApiException, ValueError):
45
+ def __init__(self, msg, path_to_item=None):
46
+ """
47
+ Args:
48
+ msg (str): the exception message
49
+
50
+ Keyword Args:
51
+ path_to_item (list) the path to the exception in the
52
+ received_data dict. None if unset
53
+ """
54
+
55
+ self.path_to_item = path_to_item
56
+ full_msg = msg
57
+ if path_to_item:
58
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
59
+ super(ApiValueError, self).__init__(full_msg)
60
+
61
+
62
+ class ApiAttributeError(OpenApiException, AttributeError):
63
+ def __init__(self, msg, path_to_item=None):
64
+ """
65
+ Raised when an attribute reference or assignment fails.
66
+
67
+ Args:
68
+ msg (str): the exception message
69
+
70
+ Keyword Args:
71
+ path_to_item (None/list) the path to the exception in the
72
+ received_data dict
73
+ """
74
+ self.path_to_item = path_to_item
75
+ full_msg = msg
76
+ if path_to_item:
77
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
78
+ super(ApiAttributeError, self).__init__(full_msg)
79
+
80
+
81
+ class ApiKeyError(OpenApiException, KeyError):
82
+ def __init__(self, msg, path_to_item=None):
83
+ """
84
+ Args:
85
+ msg (str): the exception message
86
+
87
+ Keyword Args:
88
+ path_to_item (None/list) the path to the exception in the
89
+ received_data dict
90
+ """
91
+ self.path_to_item = path_to_item
92
+ full_msg = msg
93
+ if path_to_item:
94
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
95
+ super(ApiKeyError, self).__init__(full_msg)
96
+
97
+
98
+ class ApiException(OpenApiException):
99
+
100
+ def __init__(self, status=None, reason=None, http_resp=None):
101
+ if http_resp:
102
+ self.status = http_resp.status
103
+ self.reason = http_resp.reason
104
+ self.body = http_resp.data
105
+ self.headers = http_resp.getheaders()
106
+ else:
107
+ self.status = status
108
+ self.reason = reason
109
+ self.body = None
110
+ self.headers = None
111
+
112
+ def __str__(self):
113
+ """Custom error messages for exception"""
114
+ error_message = "Status Code: {0}\n"\
115
+ "Reason: {1}\n".format(self.status, self.reason)
116
+ if self.headers:
117
+ error_message += "HTTP response headers: {0}\n".format(
118
+ self.headers)
119
+
120
+ if self.body:
121
+ error_message += "HTTP response body: {0}\n".format(self.body)
122
+
123
+ return error_message
124
+
125
+
126
+ class NotFoundException(ApiException):
127
+
128
+ def __init__(self, status=None, reason=None, http_resp=None):
129
+ super(NotFoundException, self).__init__(status, reason, http_resp)
130
+
131
+
132
+ class UnauthorizedException(ApiException):
133
+
134
+ def __init__(self, status=None, reason=None, http_resp=None):
135
+ super(UnauthorizedException, self).__init__(status, reason, http_resp)
136
+
137
+
138
+ class ForbiddenException(ApiException):
139
+
140
+ def __init__(self, status=None, reason=None, http_resp=None):
141
+ super(ForbiddenException, self).__init__(status, reason, http_resp)
142
+
143
+
144
+ class ServiceException(ApiException):
145
+
146
+ def __init__(self, status=None, reason=None, http_resp=None):
147
+ super(ServiceException, self).__init__(status, reason, http_resp)
148
+
149
+
150
+ def render_path(path_to_item):
151
+ """Returns a string representation of a path"""
152
+ result = ""
153
+ for pth in path_to_item:
154
+ if isinstance(pth, int):
155
+ result += "[{0}]".format(pth)
156
+ else:
157
+ result += "['{0}']".format(pth)
158
+ return result
@@ -0,0 +1,5 @@
1
+ # we can not import model classes here because that would create a circular
2
+ # reference which would not work in python2
3
+ # do not import all models into this module because that uses a lot of memory and stack frames
4
+ # if you need the ability to import all models from one package, import them with
5
+ # from api_client_syncstorage.models import ModelA, ModelB