- Modernized authentication with the introduction of TenantProject
- Created a base mail template - Adapt and improve document API to usage of catalogs and processors - Adapt eveai_sync to new authentication mechanism and usage of catalogs and processors
This commit is contained in:
@@ -13,6 +13,9 @@ class EveAIException(Exception):
|
||||
rv['error'] = self.__class__.__name__
|
||||
return rv
|
||||
|
||||
def __str__(self):
|
||||
return self.message # Return the message when the exception is converted to a string
|
||||
|
||||
|
||||
class EveAIInvalidLanguageException(EveAIException):
|
||||
"""Raised when an invalid language is provided"""
|
||||
@@ -45,6 +48,73 @@ class EveAINoLicenseForTenant(EveAIException):
|
||||
class EveAITenantNotFound(EveAIException):
|
||||
"""Raised when a tenant is not found"""
|
||||
|
||||
def __init__(self, message="Tenant not found", status_code=400, payload=None):
|
||||
def __init__(self, tenant_id, status_code=400, payload=None):
|
||||
self.tenant_id = tenant_id
|
||||
message = f"Tenant {tenant_id} not found"
|
||||
super().__init__(message, status_code, payload)
|
||||
|
||||
|
||||
class EveAITenantInvalid(EveAIException):
|
||||
"""Raised when a tenant is invalid"""
|
||||
|
||||
def __init__(self, tenant_id, status_code=400, payload=None):
|
||||
self.tenant_id = tenant_id
|
||||
# Construct the message dynamically
|
||||
message = f"Tenant with ID '{tenant_id}' is not valid. Please contact the System Administrator."
|
||||
super().__init__(message, status_code, payload)
|
||||
|
||||
|
||||
class EveAINoActiveLicense(EveAIException):
|
||||
"""Raised when a tenant has no active licenses"""
|
||||
|
||||
def __init__(self, tenant_id, status_code=400, payload=None):
|
||||
self.tenant_id = tenant_id
|
||||
# Construct the message dynamically
|
||||
message = f"Tenant with ID '{tenant_id}' has no active licenses. Please contact the System Administrator."
|
||||
super().__init__(message, status_code, payload)
|
||||
|
||||
|
||||
class EveAIInvalidCatalog(EveAIException):
|
||||
"""Raised when a catalog cannot be found"""
|
||||
|
||||
def __init__(self, tenant_id, catalog_id, status_code=400, payload=None):
|
||||
self.tenant_id = tenant_id
|
||||
self.catalog_id = catalog_id
|
||||
# Construct the message dynamically
|
||||
message = f"Tenant with ID '{tenant_id}' has no valid catalog with ID {catalog_id}. Please contact the System Administrator."
|
||||
super().__init__(message, status_code, payload)
|
||||
|
||||
|
||||
class EveAIInvalidProcessor(EveAIException):
|
||||
"""Raised when no valid processor can be found for a given Catalog ID"""
|
||||
|
||||
def __init__(self, tenant_id, catalog_id, file_type, status_code=400, payload=None):
|
||||
self.tenant_id = tenant_id
|
||||
self.catalog_id = catalog_id
|
||||
self.file_type = file_type
|
||||
# Construct the message dynamically
|
||||
message = (f"Tenant with ID '{tenant_id}' has no valid {file_type} processor for catalog with ID {catalog_id}. "
|
||||
f"Please contact the System Administrator.")
|
||||
super().__init__(message, status_code, payload)
|
||||
|
||||
|
||||
class EveAIInvalidDocument(EveAIException):
|
||||
"""Raised when a tenant has no document with given ID"""
|
||||
|
||||
def __init__(self, tenant_id, document_id, status_code=400, payload=None):
|
||||
self.tenant_id = tenant_id
|
||||
self.document_id = document_id
|
||||
# Construct the message dynamically
|
||||
message = f"Tenant with ID '{tenant_id}' has no document with ID {document_id}."
|
||||
super().__init__(message, status_code, payload)
|
||||
|
||||
|
||||
class EveAIInvalidDocumentVersion(EveAIException):
|
||||
"""Raised when a tenant has no document version with given ID"""
|
||||
|
||||
def __init__(self, tenant_id, document_version_id, status_code=400, payload=None):
|
||||
self.tenant_id = tenant_id
|
||||
self.document_version_id = document_version_id
|
||||
# Construct the message dynamically
|
||||
message = f"Tenant with ID '{tenant_id}' has no document version with ID {document_version_id}."
|
||||
super().__init__(message, status_code, payload)
|
||||
|
||||
Reference in New Issue
Block a user