Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, msg, c, details):
super().__init__(msg)
self.code = c
self.details = details
def getAtlasResponse(self):
"""Get details about the Atlas response
Returns:
int, str: HTTP code, Response payload
"""
return self.code, self.details
class ErrAtlasBadRequest(ErrAtlasGeneric):
"""Atlas : Bad Request
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
if details['errorCode'] == 'DUPLICATE_CLUSTER_NAME':
raise (ErrAtlasDuplicateClusterName(c, details))
if details['errorCode'] == 'RESOURCE_NOT_FOUND_FOR_JOB':
raise (ErrAtlasJobError(c, details))
super().__init__("Something was wrong with the client request.", c, details)
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__(
"This is typically the response to a request to create or modify a property of an entity that is unique "
"when an existing entity already exists with the same value for that property.",
c, details)
class ErrAtlasServerErrors(ErrAtlasGeneric):
"""Atlas : Server Errors
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("Something unexpected went wrong.", c, details)
class ErrConfirmationRequested(Exception):
"""No Confirmation provided
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
if details['errorCode'] == 'DUPLICATE_CLUSTER_NAME':
raise (ErrAtlasDuplicateClusterName(c, details))
if details['errorCode'] == 'RESOURCE_NOT_FOUND_FOR_JOB':
raise (ErrAtlasJobError(c, details))
super().__init__("Something was wrong with the client request.", c, details)
class ErrAtlasJobError(ErrAtlasGeneric):
"""Atlas : Job error Clustername
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__(details.get('detail', 'Duplicate Error'), c, details)
class ErrAtlasDuplicateClusterName(ErrAtlasGeneric):
"""Atlas : Duplicate Clustername
class ErrAtlasNotFound(ErrAtlasGeneric):
"""Atlas : Not Found
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("The requested resource does not exist.", c, details)
class ErrAtlasMethodNotAllowed(ErrAtlasGeneric):
"""Atlas : Method Not Allowed
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("The HTTP method is not supported for the specified resource.", c, details)
class ErrAtlasConflict(ErrAtlasGeneric):
"""Atlas : Conflict
class ErrAtlasForbiddenWL(ErrAtlasGeneric):
"""Atlas : Forbidden by WhiteList
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("This organization requires access through a whitelist of ip ranges.", c, details)
class ErrAtlasNotFound(ErrAtlasGeneric):
"""Atlas : Not Found
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("The requested resource does not exist.", c, details)
class ErrAtlasMethodNotAllowed(ErrAtlasGeneric):
"""Atlas : Method Not Allowed
class ErrAtlasJobError(ErrAtlasGeneric):
"""Atlas : Job error Clustername
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__(details.get('detail', 'Duplicate Error'), c, details)
class ErrAtlasDuplicateClusterName(ErrAtlasGeneric):
"""Atlas : Duplicate Clustername
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__(details.get('detail', 'Duplicate Error'), c, details)
class ErrAtlasUnauthorized(ErrAtlasGeneric):
"""Atlas : Unauthorized
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
if details['errorCode'] == 'ORG_REQUIRES_WHITELIST':
raise ErrAtlasForbiddenWL(c, details)
else:
super().__init__("Access to the specified resource is not permitted.", c, details)
class ErrAtlasForbiddenWL(ErrAtlasGeneric):
"""Atlas : Forbidden by WhiteList
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("This organization requires access through a whitelist of ip ranges.", c, details)
class ErrAtlasNotFound(ErrAtlasGeneric):
"""Atlas : Not Found
class ErrAtlasMethodNotAllowed(ErrAtlasGeneric):
"""Atlas : Method Not Allowed
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("The HTTP method is not supported for the specified resource.", c, details)
class ErrAtlasConflict(ErrAtlasGeneric):
"""Atlas : Conflict
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__(
"This is typically the response to a request to create or modify a property of an entity that is unique "
"when an existing entity already exists with the same value for that property.",
c, details)
class ErrAtlasDuplicateClusterName(ErrAtlasGeneric):
"""Atlas : Duplicate Clustername
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__(details.get('detail', 'Duplicate Error'), c, details)
class ErrAtlasUnauthorized(ErrAtlasGeneric):
"""Atlas : Unauthorized
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("Authentication is required", c, details)
class ErrAtlasForbidden(ErrAtlasGeneric):
"""Atlas : Forbidden
class ErrAtlasUnauthorized(ErrAtlasGeneric):
"""Atlas : Unauthorized
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
super().__init__("Authentication is required", c, details)
class ErrAtlasForbidden(ErrAtlasGeneric):
"""Atlas : Forbidden
Constructor
Args:
c (int): HTTP code
details (dict): Response payload
"""
def __init__(self, c, details):
if details['errorCode'] == 'ORG_REQUIRES_WHITELIST':
raise ErrAtlasForbiddenWL(c, details)
else:
super().__init__("Access to the specified resource is not permitted.", c, details)