2020-01-23 12:46:24 -06:00
from moto . core . exceptions import JsonRESTError
2023-06-15 11:05:06 +00:00
from typing import Any
2019-11-17 10:59:20 +00:00
2022-02-09 18:31:53 -01:00
class LambdaClientError ( JsonRESTError ) :
2022-10-22 11:40:20 +00:00
def __init__ ( self , error : str , message : str ) :
2022-02-09 18:31:53 -01:00
super ( ) . __init__ ( error , message )
2019-11-17 10:59:20 +00:00
class CrossAccountNotAllowed ( LambdaClientError ) :
2022-10-22 11:40:20 +00:00
def __init__ ( self ) - > None :
2021-12-01 22:06:58 -01:00
super ( ) . __init__ (
2019-11-17 10:59:20 +00:00
" AccessDeniedException " , " Cross-account pass role is not allowed. "
)
2023-08-15 17:24:01 -04:00
class FunctionAlreadyExists ( LambdaClientError ) :
code = 409
def __init__ ( self , function_name : str ) - > None :
message = f " Function already exist: { function_name } "
super ( ) . __init__ ( " ResourceConflictException " , message )
2019-11-17 10:59:20 +00:00
class InvalidParameterValueException ( LambdaClientError ) :
2022-10-22 11:40:20 +00:00
def __init__ ( self , message : str ) :
2021-12-01 22:06:58 -01:00
super ( ) . __init__ ( " InvalidParameterValueException " , message )
2019-11-17 10:59:20 +00:00
class InvalidRoleFormat ( LambdaClientError ) :
pattern = r " arn:(aws[a-zA-Z-]*)?:iam::( \ d {12} ):role/?[a-zA-Z_0-9+=,.@ \ -_/]+ "
2022-10-22 11:40:20 +00:00
def __init__ ( self , role : str ) :
2022-11-12 12:32:07 -01:00
message = f " 1 validation error detected: Value ' { role } ' at ' role ' failed to satisfy constraint: Member must satisfy regular expression pattern: { InvalidRoleFormat . pattern } "
2021-12-01 22:06:58 -01:00
super ( ) . __init__ ( " ValidationException " , message )
2020-01-23 12:46:24 -06:00
class PreconditionFailedException ( JsonRESTError ) :
code = 412
2022-10-22 11:40:20 +00:00
def __init__ ( self , message : str ) :
2021-12-01 22:06:58 -01:00
super ( ) . __init__ ( " PreconditionFailedException " , message )
2022-02-09 18:31:53 -01:00
2023-07-01 11:32:33 +01:00
class ConflictException ( LambdaClientError ) :
code = 409
def __init__ ( self , message : str ) :
super ( ) . __init__ ( " ConflictException " , message )
2022-03-17 11:32:31 -01:00
class UnknownAliasException ( LambdaClientError ) :
2022-02-09 18:31:53 -01:00
code = 404
2022-10-22 11:40:20 +00:00
def __init__ ( self , arn : str ) :
2022-03-17 11:32:31 -01:00
super ( ) . __init__ ( " ResourceNotFoundException " , f " Cannot find alias arn: { arn } " )
2022-03-15 14:07:01 -01:00
class UnknownFunctionException ( LambdaClientError ) :
code = 404
2022-10-22 11:40:20 +00:00
def __init__ ( self , arn : str ) :
2022-03-15 14:07:01 -01:00
super ( ) . __init__ ( " ResourceNotFoundException " , f " Function not found: { arn } " )
2022-03-17 11:32:31 -01:00
2022-08-24 21:19:17 +00:00
class FunctionUrlConfigNotFound ( LambdaClientError ) :
code = 404
2022-10-22 11:40:20 +00:00
def __init__ ( self ) - > None :
2022-08-24 21:19:17 +00:00
super ( ) . __init__ (
" ResourceNotFoundException " , " The resource you requested does not exist. "
)
2022-03-17 11:32:31 -01:00
class UnknownLayerException ( LambdaClientError ) :
code = 404
2022-10-22 11:40:20 +00:00
def __init__ ( self ) - > None :
2022-03-17 11:32:31 -01:00
super ( ) . __init__ ( " ResourceNotFoundException " , " Cannot find layer " )
2023-06-15 11:05:06 +00:00
class UnknownLayerVersionException ( LambdaClientError ) :
code = 404
def __init__ ( self , arns : Any ) - > None :
super ( ) . __init__ (
" ResourceNotFoundException " ,
f " One or more LayerVersion does not exist { arns } " ,
)
2022-03-17 11:32:31 -01:00
class UnknownPolicyException ( LambdaClientError ) :
code = 404
2022-10-22 11:40:20 +00:00
def __init__ ( self ) - > None :
2022-03-17 11:32:31 -01:00
super ( ) . __init__ (
" ResourceNotFoundException " ,
" No policy is associated with the given resource. " ,
)
2023-07-06 17:45:29 +01:00
class ValidationException ( LambdaClientError ) :
def __init__ ( self , value : str , property_name : str , specific_message : str ) :
message = f " 1 validation error detected: Value ' { value } ' at ' { property_name } ' failed to satisfy constraint: { specific_message } "
super ( ) . __init__ ( " ValidationException " , message )