the jobq cluster workflow management tool backend
Backend service for the appliedAI infrastructure product
The version of the OpenAPI document: 0.1.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
OpenApiException
Bases: Exception
The base exception class for all OpenAPIExceptions
Source code in client/src/openapi_client/exceptions.py
| class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions"""
|
ApiTypeError
Bases: OpenApiException
, TypeError
Source code in client/src/openapi_client/exceptions.py
| class ApiTypeError(OpenApiException, TypeError):
def __init__(
self, msg, path_to_item=None, valid_classes=None, key_type=None
) -> None:
"""Raises an exception for TypeErrors
Args:
msg (str): the exception message
Keyword Args:
path_to_item (list): a list of keys an indices to get to the
current_item
None if unset
valid_classes (tuple): the primitive classes that current item
should be an instance of
None if unset
key_type (bool): False if our value is a value in a dict
True if it is a key in a dict
False if our item is an item in a list
None if unset
"""
self.path_to_item = path_to_item
self.valid_classes = valid_classes
self.key_type = key_type
full_msg = msg
if path_to_item:
full_msg = f"{msg} at {render_path(path_to_item)}"
super().__init__(full_msg)
|
ApiValueError
Bases: OpenApiException
, ValueError
Source code in client/src/openapi_client/exceptions.py
| class ApiValueError(OpenApiException, ValueError):
def __init__(self, msg, path_to_item=None) -> None:
"""
Args:
msg (str): the exception message
Keyword Args:
path_to_item (list) the path to the exception in the
received_data dict. None if unset
"""
self.path_to_item = path_to_item
full_msg = msg
if path_to_item:
full_msg = f"{msg} at {render_path(path_to_item)}"
super().__init__(full_msg)
|
ApiAttributeError
Bases: OpenApiException
, AttributeError
Source code in client/src/openapi_client/exceptions.py
| class ApiAttributeError(OpenApiException, AttributeError):
def __init__(self, msg, path_to_item=None) -> None:
"""
Raised when an attribute reference or assignment fails.
Args:
msg (str): the exception message
Keyword Args:
path_to_item (None/list) the path to the exception in the
received_data dict
"""
self.path_to_item = path_to_item
full_msg = msg
if path_to_item:
full_msg = f"{msg} at {render_path(path_to_item)}"
super().__init__(full_msg)
|
ApiKeyError
Bases: OpenApiException
, KeyError
Source code in client/src/openapi_client/exceptions.py
| class ApiKeyError(OpenApiException, KeyError):
def __init__(self, msg, path_to_item=None) -> None:
"""
Args:
msg (str): the exception message
Keyword Args:
path_to_item (None/list) the path to the exception in the
received_data dict
"""
self.path_to_item = path_to_item
full_msg = msg
if path_to_item:
full_msg = f"{msg} at {render_path(path_to_item)}"
super().__init__(full_msg)
|
ApiException
Bases: OpenApiException
Source code in client/src/openapi_client/exceptions.py
| class ApiException(OpenApiException):
def __init__(
self,
status=None,
reason=None,
http_resp=None,
*,
body: str | None = None,
data: Any | None = None,
) -> None:
self.status = status
self.reason = reason
self.body = body
self.data = data
self.headers = None
if http_resp:
if self.status is None:
self.status = http_resp.status
if self.reason is None:
self.reason = http_resp.reason
if self.body is None:
try:
self.body = http_resp.data.decode("utf-8")
except Exception:
pass
self.headers = http_resp.getheaders()
@classmethod
def from_response(
cls,
*,
http_resp,
body: str | None,
data: Any | None,
) -> Self:
if http_resp.status == 400:
raise BadRequestException(http_resp=http_resp, body=body, data=data)
if http_resp.status == 401:
raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
if http_resp.status == 403:
raise ForbiddenException(http_resp=http_resp, body=body, data=data)
if http_resp.status == 404:
raise NotFoundException(http_resp=http_resp, body=body, data=data)
if 500 <= http_resp.status <= 599:
raise ServiceException(http_resp=http_resp, body=body, data=data)
raise ApiException(http_resp=http_resp, body=body, data=data)
def __str__(self):
"""Custom error messages for exception"""
error_message = f"({self.status})\n" f"Reason: {self.reason}\n"
if self.headers:
error_message += f"HTTP response headers: {self.headers}\n"
if self.data or self.body:
error_message += f"HTTP response body: {self.data or self.body}\n"
return error_message
|
render_path
render_path(path_to_item)
Returns a string representation of a path
Source code in client/src/openapi_client/exceptions.py
| def render_path(path_to_item):
"""Returns a string representation of a path"""
result = ""
for pth in path_to_item:
if isinstance(pth, int):
result += f"[{pth}]"
else:
result += f"['{pth}']"
return result
|