terra-scientific-pipelines-service-api-client 0.1.28__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 terra-scientific-pipelines-service-api-client might be problematic. Click here for more details.

Files changed (44) hide show
  1. teaspoons_client/__init__.py +63 -0
  2. teaspoons_client/api/__init__.py +10 -0
  3. teaspoons_client/api/admin_api.py +1229 -0
  4. teaspoons_client/api/jobs_api.py +592 -0
  5. teaspoons_client/api/pipeline_runs_api.py +1166 -0
  6. teaspoons_client/api/pipelines_api.py +581 -0
  7. teaspoons_client/api/public_api.py +532 -0
  8. teaspoons_client/api/quotas_api.py +303 -0
  9. teaspoons_client/api_client.py +797 -0
  10. teaspoons_client/api_response.py +21 -0
  11. teaspoons_client/configuration.py +465 -0
  12. teaspoons_client/exceptions.py +199 -0
  13. teaspoons_client/models/__init__.py +41 -0
  14. teaspoons_client/models/admin_pipeline.py +103 -0
  15. teaspoons_client/models/admin_quota.py +93 -0
  16. teaspoons_client/models/async_pipeline_run_response.py +103 -0
  17. teaspoons_client/models/error_report.py +91 -0
  18. teaspoons_client/models/get_jobs_response.py +99 -0
  19. teaspoons_client/models/get_pipeline_details_request_body.py +87 -0
  20. teaspoons_client/models/get_pipeline_runs_response.py +97 -0
  21. teaspoons_client/models/get_pipelines_result.py +95 -0
  22. teaspoons_client/models/job_control.py +87 -0
  23. teaspoons_client/models/job_report.py +106 -0
  24. teaspoons_client/models/job_result.py +97 -0
  25. teaspoons_client/models/pipeline.py +93 -0
  26. teaspoons_client/models/pipeline_run.py +97 -0
  27. teaspoons_client/models/pipeline_run_report.py +93 -0
  28. teaspoons_client/models/pipeline_user_provided_input_definition.py +91 -0
  29. teaspoons_client/models/pipeline_with_details.py +105 -0
  30. teaspoons_client/models/prepare_pipeline_run_request_body.py +95 -0
  31. teaspoons_client/models/prepare_pipeline_run_response.py +89 -0
  32. teaspoons_client/models/quota_with_details.py +91 -0
  33. teaspoons_client/models/start_pipeline_run_request_body.py +91 -0
  34. teaspoons_client/models/system_status.py +102 -0
  35. teaspoons_client/models/system_status_systems_value.py +89 -0
  36. teaspoons_client/models/update_pipeline_request_body.py +91 -0
  37. teaspoons_client/models/update_quota_limit_request_body.py +87 -0
  38. teaspoons_client/models/version_properties.py +93 -0
  39. teaspoons_client/py.typed +0 -0
  40. teaspoons_client/rest.py +257 -0
  41. terra_scientific_pipelines_service_api_client-0.1.28.dist-info/METADATA +23 -0
  42. terra_scientific_pipelines_service_api_client-0.1.28.dist-info/RECORD +44 -0
  43. terra_scientific_pipelines_service_api_client-0.1.28.dist-info/WHEEL +5 -0
  44. terra_scientific_pipelines_service_api_client-0.1.28.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,465 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Terra Scientific Pipelines Service
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 1.0.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 logging
17
+ from logging import FileHandler
18
+ import multiprocessing
19
+ import sys
20
+ from typing import Optional
21
+ import urllib3
22
+
23
+ import http.client as httplib
24
+
25
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
26
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
27
+ 'minimum', 'exclusiveMinimum', 'maxLength',
28
+ 'minLength', 'pattern', 'maxItems', 'minItems'
29
+ }
30
+
31
+ class Configuration:
32
+ """This class contains various settings of the API client.
33
+
34
+ :param host: Base url.
35
+ :param ignore_operation_servers
36
+ Boolean to ignore operation servers for the API client.
37
+ Config will use `host` as the base url regardless of the operation servers.
38
+ :param api_key: Dict to store API key(s).
39
+ Each entry in the dict specifies an API key.
40
+ The dict key is the name of the security scheme in the OAS specification.
41
+ The dict value is the API key secret.
42
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
43
+ The dict key is the name of the security scheme in the OAS specification.
44
+ The dict value is an API key prefix when generating the auth data.
45
+ :param username: Username for HTTP basic authentication.
46
+ :param password: Password for HTTP basic authentication.
47
+ :param access_token: Access token.
48
+ :param server_index: Index to servers configuration.
49
+ :param server_variables: Mapping with string values to replace variables in
50
+ templated server configuration. The validation of enums is performed for
51
+ variables with defined enum values before.
52
+ :param server_operation_index: Mapping from operation ID to an index to server
53
+ configuration.
54
+ :param server_operation_variables: Mapping from operation ID to a mapping with
55
+ string values to replace variables in templated server configuration.
56
+ The validation of enums is performed for variables with defined enum
57
+ values before.
58
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
59
+ in PEM format.
60
+ :param retries: Number of retries for API requests.
61
+
62
+ :Example:
63
+ """
64
+
65
+ _default = None
66
+
67
+ def __init__(self, host=None,
68
+ api_key=None, api_key_prefix=None,
69
+ username=None, password=None,
70
+ access_token=None,
71
+ server_index=None, server_variables=None,
72
+ server_operation_index=None, server_operation_variables=None,
73
+ ignore_operation_servers=False,
74
+ ssl_ca_cert=None,
75
+ retries=None,
76
+ *,
77
+ debug: Optional[bool] = None
78
+ ) -> None:
79
+ """Constructor
80
+ """
81
+ self._base_path = "http://localhost" if host is None else host
82
+ """Default Base url
83
+ """
84
+ self.server_index = 0 if server_index is None and host is None else server_index
85
+ self.server_operation_index = server_operation_index or {}
86
+ """Default server index
87
+ """
88
+ self.server_variables = server_variables or {}
89
+ self.server_operation_variables = server_operation_variables or {}
90
+ """Default server variables
91
+ """
92
+ self.ignore_operation_servers = ignore_operation_servers
93
+ """Ignore operation servers
94
+ """
95
+ self.temp_folder_path = None
96
+ """Temp file folder for downloading files
97
+ """
98
+ # Authentication Settings
99
+ self.api_key = {}
100
+ if api_key:
101
+ self.api_key = api_key
102
+ """dict to store API key(s)
103
+ """
104
+ self.api_key_prefix = {}
105
+ if api_key_prefix:
106
+ self.api_key_prefix = api_key_prefix
107
+ """dict to store API prefix (e.g. Bearer)
108
+ """
109
+ self.refresh_api_key_hook = None
110
+ """function hook to refresh API key if expired
111
+ """
112
+ self.username = username
113
+ """Username for HTTP basic authentication
114
+ """
115
+ self.password = password
116
+ """Password for HTTP basic authentication
117
+ """
118
+ self.access_token = access_token
119
+ """Access token
120
+ """
121
+ self.logger = {}
122
+ """Logging Settings
123
+ """
124
+ self.logger["package_logger"] = logging.getLogger("teaspoons_client")
125
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
126
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
127
+ """Log format
128
+ """
129
+ self.logger_stream_handler = None
130
+ """Log stream handler
131
+ """
132
+ self.logger_file_handler: Optional[FileHandler] = None
133
+ """Log file handler
134
+ """
135
+ self.logger_file = None
136
+ """Debug file location
137
+ """
138
+ if debug is not None:
139
+ self.debug = debug
140
+ else:
141
+ self.__debug = False
142
+ """Debug switch
143
+ """
144
+
145
+ self.verify_ssl = True
146
+ """SSL/TLS verification
147
+ Set this to false to skip verifying SSL certificate when calling API
148
+ from https server.
149
+ """
150
+ self.ssl_ca_cert = ssl_ca_cert
151
+ """Set this to customize the certificate file to verify the peer.
152
+ """
153
+ self.cert_file = None
154
+ """client certificate file
155
+ """
156
+ self.key_file = None
157
+ """client key file
158
+ """
159
+ self.assert_hostname = None
160
+ """Set this to True/False to enable/disable SSL hostname verification.
161
+ """
162
+ self.tls_server_name = None
163
+ """SSL/TLS Server Name Indication (SNI)
164
+ Set this to the SNI value expected by the server.
165
+ """
166
+
167
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
168
+ """urllib3 connection pool's maximum number of connections saved
169
+ per pool. urllib3 uses 1 connection as default value, but this is
170
+ not the best value when you are making a lot of possibly parallel
171
+ requests to the same host, which is often the case here.
172
+ cpu_count * 5 is used as default value to increase performance.
173
+ """
174
+
175
+ self.proxy: Optional[str] = None
176
+ """Proxy URL
177
+ """
178
+ self.proxy_headers = None
179
+ """Proxy headers
180
+ """
181
+ self.safe_chars_for_path_param = ''
182
+ """Safe chars for path_param
183
+ """
184
+ self.retries = retries
185
+ """Adding retries to override urllib3 default value 3
186
+ """
187
+ # Enable client side validation
188
+ self.client_side_validation = True
189
+
190
+ self.socket_options = None
191
+ """Options to pass down to the underlying urllib3 socket
192
+ """
193
+
194
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
195
+ """datetime format
196
+ """
197
+
198
+ self.date_format = "%Y-%m-%d"
199
+ """date format
200
+ """
201
+
202
+ def __deepcopy__(self, memo):
203
+ cls = self.__class__
204
+ result = cls.__new__(cls)
205
+ memo[id(self)] = result
206
+ for k, v in self.__dict__.items():
207
+ if k not in ('logger', 'logger_file_handler'):
208
+ setattr(result, k, copy.deepcopy(v, memo))
209
+ # shallow copy of loggers
210
+ result.logger = copy.copy(self.logger)
211
+ # use setters to configure loggers
212
+ result.logger_file = self.logger_file
213
+ result.debug = self.debug
214
+ return result
215
+
216
+ def __setattr__(self, name, value):
217
+ object.__setattr__(self, name, value)
218
+
219
+ @classmethod
220
+ def set_default(cls, default):
221
+ """Set default instance of configuration.
222
+
223
+ It stores default configuration, which can be
224
+ returned by get_default_copy method.
225
+
226
+ :param default: object of Configuration
227
+ """
228
+ cls._default = default
229
+
230
+ @classmethod
231
+ def get_default_copy(cls):
232
+ """Deprecated. Please use `get_default` instead.
233
+
234
+ Deprecated. Please use `get_default` instead.
235
+
236
+ :return: The configuration object.
237
+ """
238
+ return cls.get_default()
239
+
240
+ @classmethod
241
+ def get_default(cls):
242
+ """Return the default configuration.
243
+
244
+ This method returns newly created, based on default constructor,
245
+ object of Configuration class or returns a copy of default
246
+ configuration.
247
+
248
+ :return: The configuration object.
249
+ """
250
+ if cls._default is None:
251
+ cls._default = Configuration()
252
+ return cls._default
253
+
254
+ @property
255
+ def logger_file(self):
256
+ """The logger file.
257
+
258
+ If the logger_file is None, then add stream handler and remove file
259
+ handler. Otherwise, add file handler and remove stream handler.
260
+
261
+ :param value: The logger_file path.
262
+ :type: str
263
+ """
264
+ return self.__logger_file
265
+
266
+ @logger_file.setter
267
+ def logger_file(self, value):
268
+ """The logger file.
269
+
270
+ If the logger_file is None, then add stream handler and remove file
271
+ handler. Otherwise, add file handler and remove stream handler.
272
+
273
+ :param value: The logger_file path.
274
+ :type: str
275
+ """
276
+ self.__logger_file = value
277
+ if self.__logger_file:
278
+ # If set logging file,
279
+ # then add file handler and remove stream handler.
280
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
281
+ self.logger_file_handler.setFormatter(self.logger_formatter)
282
+ for _, logger in self.logger.items():
283
+ logger.addHandler(self.logger_file_handler)
284
+
285
+ @property
286
+ def debug(self):
287
+ """Debug status
288
+
289
+ :param value: The debug status, True or False.
290
+ :type: bool
291
+ """
292
+ return self.__debug
293
+
294
+ @debug.setter
295
+ def debug(self, value):
296
+ """Debug status
297
+
298
+ :param value: The debug status, True or False.
299
+ :type: bool
300
+ """
301
+ self.__debug = value
302
+ if self.__debug:
303
+ # if debug status is True, turn on debug logging
304
+ for _, logger in self.logger.items():
305
+ logger.setLevel(logging.DEBUG)
306
+ # turn on httplib debug
307
+ httplib.HTTPConnection.debuglevel = 1
308
+ else:
309
+ # if debug status is False, turn off debug logging,
310
+ # setting log level to default `logging.WARNING`
311
+ for _, logger in self.logger.items():
312
+ logger.setLevel(logging.WARNING)
313
+ # turn off httplib debug
314
+ httplib.HTTPConnection.debuglevel = 0
315
+
316
+ @property
317
+ def logger_format(self):
318
+ """The logger format.
319
+
320
+ The logger_formatter will be updated when sets logger_format.
321
+
322
+ :param value: The format string.
323
+ :type: str
324
+ """
325
+ return self.__logger_format
326
+
327
+ @logger_format.setter
328
+ def logger_format(self, value):
329
+ """The logger format.
330
+
331
+ The logger_formatter will be updated when sets logger_format.
332
+
333
+ :param value: The format string.
334
+ :type: str
335
+ """
336
+ self.__logger_format = value
337
+ self.logger_formatter = logging.Formatter(self.__logger_format)
338
+
339
+ def get_api_key_with_prefix(self, identifier, alias=None):
340
+ """Gets API key (with prefix if set).
341
+
342
+ :param identifier: The identifier of apiKey.
343
+ :param alias: The alternative identifier of apiKey.
344
+ :return: The token for api key authentication.
345
+ """
346
+ if self.refresh_api_key_hook is not None:
347
+ self.refresh_api_key_hook(self)
348
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
349
+ if key:
350
+ prefix = self.api_key_prefix.get(identifier)
351
+ if prefix:
352
+ return "%s %s" % (prefix, key)
353
+ else:
354
+ return key
355
+
356
+ def get_basic_auth_token(self):
357
+ """Gets HTTP basic authentication header (string).
358
+
359
+ :return: The token for basic HTTP authentication.
360
+ """
361
+ username = ""
362
+ if self.username is not None:
363
+ username = self.username
364
+ password = ""
365
+ if self.password is not None:
366
+ password = self.password
367
+ return urllib3.util.make_headers(
368
+ basic_auth=username + ':' + password
369
+ ).get('authorization')
370
+
371
+ def auth_settings(self):
372
+ """Gets Auth Settings dict for api client.
373
+
374
+ :return: The Auth Settings information dict.
375
+ """
376
+ auth = {}
377
+ if self.access_token is not None:
378
+ auth['oidc'] = {
379
+ 'type': 'oauth2',
380
+ 'in': 'header',
381
+ 'key': 'Authorization',
382
+ 'value': 'Bearer ' + self.access_token
383
+ }
384
+ if self.access_token is not None:
385
+ auth['bearerAuth'] = {
386
+ 'type': 'bearer',
387
+ 'in': 'header',
388
+ 'key': 'Authorization',
389
+ 'value': 'Bearer ' + self.access_token
390
+ }
391
+ return auth
392
+
393
+ def to_debug_report(self):
394
+ """Gets the essential information for debugging.
395
+
396
+ :return: The report for debugging.
397
+ """
398
+ return "Python SDK Debug Report:\n"\
399
+ "OS: {env}\n"\
400
+ "Python Version: {pyversion}\n"\
401
+ "Version of the API: 1.0.0\n"\
402
+ "SDK Package Version: 0.1.28".\
403
+ format(env=sys.platform, pyversion=sys.version)
404
+
405
+ def get_host_settings(self):
406
+ """Gets an array of host settings
407
+
408
+ :return: An array of host settings
409
+ """
410
+ return [
411
+ {
412
+ 'url': "",
413
+ 'description': "No description provided",
414
+ }
415
+ ]
416
+
417
+ def get_host_from_settings(self, index, variables=None, servers=None):
418
+ """Gets host URL based on the index and variables
419
+ :param index: array index of the host settings
420
+ :param variables: hash of variable and the corresponding value
421
+ :param servers: an array of host settings or None
422
+ :return: URL based on host settings
423
+ """
424
+ if index is None:
425
+ return self._base_path
426
+
427
+ variables = {} if variables is None else variables
428
+ servers = self.get_host_settings() if servers is None else servers
429
+
430
+ try:
431
+ server = servers[index]
432
+ except IndexError:
433
+ raise ValueError(
434
+ "Invalid index {0} when selecting the host settings. "
435
+ "Must be less than {1}".format(index, len(servers)))
436
+
437
+ url = server['url']
438
+
439
+ # go through variables and replace placeholders
440
+ for variable_name, variable in server.get('variables', {}).items():
441
+ used_value = variables.get(
442
+ variable_name, variable['default_value'])
443
+
444
+ if 'enum_values' in variable \
445
+ and used_value not in variable['enum_values']:
446
+ raise ValueError(
447
+ "The variable `{0}` in the host URL has invalid value "
448
+ "{1}. Must be {2}.".format(
449
+ variable_name, variables[variable_name],
450
+ variable['enum_values']))
451
+
452
+ url = url.replace("{" + variable_name + "}", used_value)
453
+
454
+ return url
455
+
456
+ @property
457
+ def host(self):
458
+ """Return generated host."""
459
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
460
+
461
+ @host.setter
462
+ def host(self, value):
463
+ """Fix base path."""
464
+ self._base_path = value
465
+ self.server_index = None
@@ -0,0 +1,199 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Terra Scientific Pipelines Service
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ from typing import Any, Optional
15
+ from typing_extensions import Self
16
+
17
+ class OpenApiException(Exception):
18
+ """The base exception class for all OpenAPIExceptions"""
19
+
20
+
21
+ class ApiTypeError(OpenApiException, TypeError):
22
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
23
+ key_type=None) -> None:
24
+ """ Raises an exception for TypeErrors
25
+
26
+ Args:
27
+ msg (str): the exception message
28
+
29
+ Keyword Args:
30
+ path_to_item (list): a list of keys an indices to get to the
31
+ current_item
32
+ None if unset
33
+ valid_classes (tuple): the primitive classes that current item
34
+ should be an instance of
35
+ None if unset
36
+ key_type (bool): False if our value is a value in a dict
37
+ True if it is a key in a dict
38
+ False if our item is an item in a list
39
+ None if unset
40
+ """
41
+ self.path_to_item = path_to_item
42
+ self.valid_classes = valid_classes
43
+ self.key_type = key_type
44
+ full_msg = msg
45
+ if path_to_item:
46
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
47
+ super(ApiTypeError, self).__init__(full_msg)
48
+
49
+
50
+ class ApiValueError(OpenApiException, ValueError):
51
+ def __init__(self, msg, path_to_item=None) -> None:
52
+ """
53
+ Args:
54
+ msg (str): the exception message
55
+
56
+ Keyword Args:
57
+ path_to_item (list) the path to the exception in the
58
+ received_data dict. None if unset
59
+ """
60
+
61
+ self.path_to_item = path_to_item
62
+ full_msg = msg
63
+ if path_to_item:
64
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
65
+ super(ApiValueError, self).__init__(full_msg)
66
+
67
+
68
+ class ApiAttributeError(OpenApiException, AttributeError):
69
+ def __init__(self, msg, path_to_item=None) -> None:
70
+ """
71
+ Raised when an attribute reference or assignment fails.
72
+
73
+ Args:
74
+ msg (str): the exception message
75
+
76
+ Keyword Args:
77
+ path_to_item (None/list) the path to the exception in the
78
+ received_data dict
79
+ """
80
+ self.path_to_item = path_to_item
81
+ full_msg = msg
82
+ if path_to_item:
83
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
84
+ super(ApiAttributeError, self).__init__(full_msg)
85
+
86
+
87
+ class ApiKeyError(OpenApiException, KeyError):
88
+ def __init__(self, msg, path_to_item=None) -> None:
89
+ """
90
+ Args:
91
+ msg (str): the exception message
92
+
93
+ Keyword Args:
94
+ path_to_item (None/list) the path to the exception in the
95
+ received_data dict
96
+ """
97
+ self.path_to_item = path_to_item
98
+ full_msg = msg
99
+ if path_to_item:
100
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
101
+ super(ApiKeyError, self).__init__(full_msg)
102
+
103
+
104
+ class ApiException(OpenApiException):
105
+
106
+ def __init__(
107
+ self,
108
+ status=None,
109
+ reason=None,
110
+ http_resp=None,
111
+ *,
112
+ body: Optional[str] = None,
113
+ data: Optional[Any] = None,
114
+ ) -> None:
115
+ self.status = status
116
+ self.reason = reason
117
+ self.body = body
118
+ self.data = data
119
+ self.headers = None
120
+
121
+ if http_resp:
122
+ if self.status is None:
123
+ self.status = http_resp.status
124
+ if self.reason is None:
125
+ self.reason = http_resp.reason
126
+ if self.body is None:
127
+ try:
128
+ self.body = http_resp.data.decode('utf-8')
129
+ except Exception:
130
+ pass
131
+ self.headers = http_resp.getheaders()
132
+
133
+ @classmethod
134
+ def from_response(
135
+ cls,
136
+ *,
137
+ http_resp,
138
+ body: Optional[str],
139
+ data: Optional[Any],
140
+ ) -> Self:
141
+ if http_resp.status == 400:
142
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
143
+
144
+ if http_resp.status == 401:
145
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
146
+
147
+ if http_resp.status == 403:
148
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
149
+
150
+ if http_resp.status == 404:
151
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
152
+
153
+ if 500 <= http_resp.status <= 599:
154
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
155
+ raise ApiException(http_resp=http_resp, body=body, data=data)
156
+
157
+ def __str__(self):
158
+ """Custom error messages for exception"""
159
+ error_message = "({0})\n"\
160
+ "Reason: {1}\n".format(self.status, self.reason)
161
+ if self.headers:
162
+ error_message += "HTTP response headers: {0}\n".format(
163
+ self.headers)
164
+
165
+ if self.data or self.body:
166
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
167
+
168
+ return error_message
169
+
170
+
171
+ class BadRequestException(ApiException):
172
+ pass
173
+
174
+
175
+ class NotFoundException(ApiException):
176
+ pass
177
+
178
+
179
+ class UnauthorizedException(ApiException):
180
+ pass
181
+
182
+
183
+ class ForbiddenException(ApiException):
184
+ pass
185
+
186
+
187
+ class ServiceException(ApiException):
188
+ pass
189
+
190
+
191
+ def render_path(path_to_item):
192
+ """Returns a string representation of a path"""
193
+ result = ""
194
+ for pth in path_to_item:
195
+ if isinstance(pth, int):
196
+ result += "[{0}]".format(pth)
197
+ else:
198
+ result += "['{0}']".format(pth)
199
+ return result