2023-03-11 16:00:52 -01:00
from typing import Optional
2018-07-11 11:39:40 -04:00
from moto . core . exceptions import JsonRESTError
2018-07-10 13:50:47 -04:00
2018-07-11 11:39:40 -04:00
class GlueClientError ( JsonRESTError ) :
code = 400
2018-07-10 13:50:47 -04:00
2018-07-11 11:39:40 -04:00
2018-10-02 17:25:14 +01:00
class AlreadyExistsException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , typ : str ) :
2022-11-17 22:03:53 -01:00
super ( ) . __init__ ( " AlreadyExistsException " , f " { typ } already exists. " )
2018-07-26 17:05:09 -04:00
2018-10-02 17:25:14 +01:00
class DatabaseAlreadyExistsException ( AlreadyExistsException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " Database " )
2018-10-02 17:25:14 +01:00
class TableAlreadyExistsException ( AlreadyExistsException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " Table " )
2018-10-02 17:25:14 +01:00
class PartitionAlreadyExistsException ( AlreadyExistsException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " Partition " )
2018-10-02 17:25:14 +01:00
2021-08-26 10:49:41 +01:00
class CrawlerAlreadyExistsException ( AlreadyExistsException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " Crawler " )
2021-08-26 10:49:41 +01:00
2023-05-12 18:41:48 +03:00
class SessionAlreadyExistsException ( AlreadyExistsException ) :
def __init__ ( self ) - > None :
super ( ) . __init__ ( " Session " )
2018-10-02 17:25:14 +01:00
class EntityNotFoundException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , msg : str ) :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " EntityNotFoundException " , msg )
2018-10-02 17:25:14 +01:00
class DatabaseNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , db : str ) :
2022-11-17 22:03:53 -01:00
super ( ) . __init__ ( f " Database { db } not found. " )
2018-10-02 17:25:14 +01:00
class TableNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , tbl : str ) :
2022-11-17 22:03:53 -01:00
super ( ) . __init__ ( f " Table { tbl } not found. " )
2018-10-02 17:25:14 +01:00
class PartitionNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " Cannot find partition. " )
2018-10-02 17:25:14 +01:00
2021-08-26 10:49:41 +01:00
class CrawlerNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , crawler : str ) :
2022-11-17 22:03:53 -01:00
super ( ) . __init__ ( f " Crawler { crawler } not found. " )
2021-08-26 10:49:41 +01:00
2022-03-19 12:30:46 -04:00
class JobNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , job : str ) :
2022-11-17 22:03:53 -01:00
super ( ) . __init__ ( f " Job { job } not found. " )
2022-03-19 12:30:46 -04:00
2022-09-17 11:46:42 +00:00
class JobRunNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , job_run : str ) :
2022-11-17 22:03:53 -01:00
super ( ) . __init__ ( f " Job run { job_run } not found. " )
2022-09-17 11:46:42 +00:00
2018-10-02 17:25:14 +01:00
class VersionNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " Version not found. " )
2021-10-29 02:50:08 +05:30
2022-08-04 08:48:08 -07:00
class SchemaNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ (
self ,
schema_name : str ,
registry_name : str ,
schema_arn : Optional [ str ] ,
null : str = " null " ,
) :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ (
f " Schema is not found. RegistryName: { registry_name if registry_name else null } , SchemaName: { schema_name if schema_name else null } , SchemaArn: { schema_arn if schema_arn else null } " ,
)
class SchemaVersionNotFoundFromSchemaIdException ( EntityNotFoundException ) :
def __init__ (
self ,
2023-03-11 16:00:52 -01:00
registry_name : Optional [ str ] ,
schema_name : Optional [ str ] ,
schema_arn : Optional [ str ] ,
version_number : Optional [ str ] ,
latest_version : Optional [ str ] ,
null : str = " null " ,
false : str = " false " ,
2022-08-05 13:59:01 -07:00
) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
2022-08-05 13:59:01 -07:00
f " Schema version is not found. RegistryName: { registry_name if registry_name else null } , SchemaName: { schema_name if schema_name else null } , SchemaArn: { schema_arn if schema_arn else null } , VersionNumber: { version_number if version_number else null } , isLatestVersion: { latest_version if latest_version else false } " ,
2022-08-04 08:48:08 -07:00
)
2022-08-05 13:59:01 -07:00
class SchemaVersionNotFoundFromSchemaVersionIdException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , schema_version_id : str ) :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ (
f " Schema version is not found. SchemaVersionId: { schema_version_id } " ,
)
2023-05-12 18:41:48 +03:00
class SessionNotFoundException ( EntityNotFoundException ) :
def __init__ ( self , session : str ) :
super ( ) . __init__ ( f " Session { session } not found. " )
class IllegalSessionStateException ( GlueClientError ) :
def __init__ ( self , msg : str ) :
super ( ) . __init__ ( " IllegalSessionStateException " , msg )
2022-08-05 13:59:01 -07:00
class RegistryNotFoundException ( EntityNotFoundException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , resource : str , param_name : str , param_value : Optional [ str ] ) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
2023-03-11 16:00:52 -01:00
resource + " is not found. " + param_name + " : " + param_value , # type: ignore
2022-08-04 08:48:08 -07:00
)
2023-04-25 18:02:57 +02:00
class TriggerNotFoundException ( EntityNotFoundException ) :
def __init__ ( self , trigger : str ) :
super ( ) . __init__ ( f " Trigger { trigger } not found. " )
2021-10-29 02:50:08 +05:30
class CrawlerRunningException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , msg : str ) :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " CrawlerRunningException " , msg )
2021-10-29 02:50:08 +05:30
class CrawlerNotRunningException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , msg : str ) :
2022-01-14 18:51:49 -01:00
super ( ) . __init__ ( " CrawlerNotRunningException " , msg )
2022-03-22 06:19:56 -04:00
class ConcurrentRunsExceededException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , msg : str ) :
2022-03-22 06:19:56 -04:00
super ( ) . __init__ ( " ConcurrentRunsExceededException " , msg )
2022-04-14 21:37:10 +02:00
2022-08-04 08:48:08 -07:00
class ResourceNumberLimitExceededException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , msg : str ) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
" ResourceNumberLimitExceededException " ,
2022-08-05 13:59:01 -07:00
msg ,
)
class GeneralResourceNumberLimitExceededException ( ResourceNumberLimitExceededException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , resource : str ) :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ (
2022-08-04 08:48:08 -07:00
" More "
+ resource
+ " cannot be created. The maximum limit has been reached. " ,
)
2022-08-05 13:59:01 -07:00
class SchemaVersionMetadataLimitExceededException ( ResourceNumberLimitExceededException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ (
" Your resource limits for Schema Version Metadata have been exceeded. " ,
)
2022-08-04 08:48:08 -07:00
class GSRAlreadyExistsException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , msg : str ) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
" AlreadyExistsException " ,
2022-08-05 13:59:01 -07:00
msg ,
)
class SchemaVersionMetadataAlreadyExistsException ( GSRAlreadyExistsException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , schema_version_id : str , metadata_key : str , metadata_value : str ) :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ (
f " Resource already exist for schema version id: { schema_version_id } , metadata key: { metadata_key } , metadata value: { metadata_value } " ,
)
class GeneralGSRAlreadyExistsException ( GSRAlreadyExistsException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , resource : str , param_name : str , param_value : str ) :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ (
2022-08-04 08:48:08 -07:00
resource + " already exists. " + param_name + " : " + param_value ,
)
2022-04-14 21:37:10 +02:00
class _InvalidOperationException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , error_type : str , op : str , msg : str ) :
2022-04-14 21:37:10 +02:00
super ( ) . __init__ (
error_type ,
" An error occurred ( %s ) when calling the %s operation: %s "
% ( error_type , op , msg ) ,
)
2022-08-04 08:48:08 -07:00
class InvalidStateException ( _InvalidOperationException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , op : str , msg : str ) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ ( " InvalidStateException " , op , msg )
2022-04-14 21:37:10 +02:00
class InvalidInputException ( _InvalidOperationException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , op : str , msg : str ) :
2022-04-14 21:37:10 +02:00
super ( ) . __init__ ( " InvalidInputException " , op , msg )
2022-08-04 08:48:08 -07:00
class GSRInvalidInputException ( GlueClientError ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , msg : str ) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ ( " InvalidInputException " , msg )
2022-06-21 13:31:28 -07:00
2022-08-04 08:48:08 -07:00
class ResourceNameTooLongException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , param_name : str ) :
2022-06-21 13:31:28 -07:00
super ( ) . __init__ (
2022-08-04 08:48:08 -07:00
" The resource name contains too many or too few characters. Parameter Name: "
+ param_name ,
2022-06-21 13:31:28 -07:00
)
2022-08-04 08:48:08 -07:00
class ParamValueContainsInvalidCharactersException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , param_name : str ) :
2022-06-21 13:31:28 -07:00
super ( ) . __init__ (
2022-08-04 08:48:08 -07:00
" The parameter value contains one or more characters that are not valid. Parameter Name: "
+ param_name ,
2022-06-21 13:31:28 -07:00
)
2022-08-04 08:48:08 -07:00
class InvalidNumberOfTagsException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-06-21 13:31:28 -07:00
super ( ) . __init__ (
2022-08-04 08:48:08 -07:00
" New Tags cannot be empty or more than 50 " ,
2022-06-21 13:31:28 -07:00
)
2022-08-04 08:48:08 -07:00
class InvalidDataFormatException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-06-21 13:31:28 -07:00
super ( ) . __init__ (
2022-08-04 08:48:08 -07:00
" Data format is not valid. " ,
2022-06-21 13:31:28 -07:00
)
2022-08-04 08:48:08 -07:00
class InvalidCompatibilityException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-06-21 13:31:28 -07:00
super ( ) . __init__ (
2022-08-04 08:48:08 -07:00
" Compatibility is not valid. " ,
)
class InvalidSchemaDefinitionException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self , data_format_name : str , err : ValueError ) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
" Schema definition of "
+ data_format_name
+ " data format is invalid: "
+ str ( err ) ,
)
class InvalidRegistryIdBothParamsProvidedException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
" One of registryName or registryArn has to be provided, both cannot be provided. " ,
)
class InvalidSchemaIdBothParamsProvidedException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
" One of (registryName and schemaName) or schemaArn has to be provided, both cannot be provided. " ,
)
2022-08-05 13:59:01 -07:00
class InvalidSchemaIdNotProvidedException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
" At least one of (registryName and schemaName) or schemaArn has to be provided. " ,
)
2022-08-05 13:59:01 -07:00
class InvalidSchemaVersionNumberBothParamsProvidedException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ ( " Only one of VersionNumber or LatestVersion is required. " )
class InvalidSchemaVersionNumberNotProvidedException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ ( " One of version number (or) latest version is required. " )
class InvalidSchemaVersionIdProvidedWithOtherParamsException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ ( self ) - > None :
2022-08-05 13:59:01 -07:00
super ( ) . __init__ (
" No other input parameters can be specified when fetching by SchemaVersionId. "
)
2022-08-04 08:48:08 -07:00
class DisabledCompatibilityVersioningException ( GSRInvalidInputException ) :
2023-03-11 16:00:52 -01:00
def __init__ (
self ,
schema_name : str ,
registry_name : str ,
schema_arn : Optional [ str ] ,
null : str = " null " ,
) :
2022-08-04 08:48:08 -07:00
super ( ) . __init__ (
2022-08-05 13:59:01 -07:00
f " Compatibility DISABLED does not allow versioning. SchemaId: SchemaId(schemaArn= { schema_arn if schema_arn else null } , schemaName= { schema_name if schema_name else null } , registryName= { registry_name if registry_name else null } ) "
2022-06-21 13:31:28 -07:00
)