harborapi.exceptions
EXCEPTIONS_MAP = {400: BadRequest, 401: Unauthorized, 403: Forbidden, 404: NotFound, 405: MethodNotAllowed, 409: Conflict, 412: PreconditionFailed, 415: UnsupportedMediaType, 422: UnprocessableEntity, 500: InternalServerError}
module-attribute
HarborAPIException
Bases: Exception
StatusError(*args, errors=None, **kwargs)
Bases: HarborAPIException
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
__cause__: Optional[HTTPStatusError] = None
instance-attribute
The underlying HTTPX exception that caused this exception. Automatically assigned when raised from a HTTPX exception.
errors: List[Error] = []
instance-attribute
A list of errors returned by the Harbor API.
response: Optional[Response]
property
status_code: int
property
__str__()
Return a string representation of this exception.
Source code in harborapi/exceptions.py
BadRequest(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
Unauthorized(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
Forbidden(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
NotFound(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
MethodNotAllowed(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
Conflict(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
PreconditionFailed(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
UnsupportedMediaType(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
UnprocessableEntity(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
InternalServerError(*args, errors=None, **kwargs)
Bases: StatusError
Initialize a StatusError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments to pass to the base Exception class. |
()
|
errors |
Optional[Errors]
|
A list of errors returned by the Harbor API. |
None
|
**kwargs |
Any
|
Keyword arguments to pass to the base Exception class. |
{}
|
Source code in harborapi/exceptions.py
check_response_status(response, missing_ok=None)
Raises an exception if the response status is not 2xx.
Exceptions are wrapped in a StatusError
if the response contains errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response |
Response
|
The response to check. |
required |
missing_ok |
Optional[bool]
|
DEPRECATED: If |
None
|
Source code in harborapi/exceptions.py
try_parse_errors(response)
Attempts to return the errors from a response.
See: models.Errors
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response |
Response
|
|
required |
Returns:
Type | Description |
---|---|
Optional[Errors]
|
The errors from the response. |