Raise exception on invalid event source type and use full spec
This commit is contained in:
parent
819dcfee24
commit
1efd9ee58d
@ -435,7 +435,6 @@ class EventSourceMapping(BaseModel):
|
|||||||
self.event_source_arn = spec['EventSourceArn']
|
self.event_source_arn = spec['EventSourceArn']
|
||||||
self.uuid = str(uuid.uuid4())
|
self.uuid = str(uuid.uuid4())
|
||||||
self.last_modified = time.mktime(datetime.datetime.utcnow().timetuple())
|
self.last_modified = time.mktime(datetime.datetime.utcnow().timetuple())
|
||||||
self.batch_size = '' # Default to blank
|
|
||||||
|
|
||||||
# BatchSize service default/max mapping
|
# BatchSize service default/max mapping
|
||||||
batch_size_map = {
|
batch_size_map = {
|
||||||
@ -453,6 +452,9 @@ class EventSourceMapping(BaseModel):
|
|||||||
"BatchSize {} exceeds the max of {}".format(batch_size, batch_size_entry[1]))
|
"BatchSize {} exceeds the max of {}".format(batch_size, batch_size_entry[1]))
|
||||||
else:
|
else:
|
||||||
self.batch_size = batch_size
|
self.batch_size = batch_size
|
||||||
|
else:
|
||||||
|
raise ValueError("InvalidParameterValueException",
|
||||||
|
"Unsupported event source type")
|
||||||
|
|
||||||
# optional
|
# optional
|
||||||
self.starting_position = spec.get('StartingPosition', 'TRIM_HORIZON')
|
self.starting_position = spec.get('StartingPosition', 'TRIM_HORIZON')
|
||||||
@ -668,7 +670,7 @@ class LambdaBackend(BaseBackend):
|
|||||||
raise RESTError('InvalidParameterValueException', 'Missing {}'.format(param))
|
raise RESTError('InvalidParameterValueException', 'Missing {}'.format(param))
|
||||||
|
|
||||||
# Validate function name
|
# Validate function name
|
||||||
func = self._lambdas.get_function_by_name_or_arn(spec.get('FunctionName', ''))
|
func = self._lambdas.get_function_by_name_or_arn(spec.pop('FunctionName', ''))
|
||||||
if not func:
|
if not func:
|
||||||
raise RESTError('ResourceNotFoundException', 'Invalid FunctionName')
|
raise RESTError('ResourceNotFoundException', 'Invalid FunctionName')
|
||||||
|
|
||||||
@ -682,11 +684,8 @@ class LambdaBackend(BaseBackend):
|
|||||||
raise RESTError('InvalidParameterValueException',
|
raise RESTError('InvalidParameterValueException',
|
||||||
'{} is FIFO'.format(queue.queue_arn))
|
'{} is FIFO'.format(queue.queue_arn))
|
||||||
else:
|
else:
|
||||||
esm_spec = {
|
spec.update({'FunctionArn': func.function_arn})
|
||||||
'EventSourceArn': spec['EventSourceArn'],
|
esm = EventSourceMapping(spec)
|
||||||
'FunctionArn': func.function_arn,
|
|
||||||
}
|
|
||||||
esm = EventSourceMapping(esm_spec)
|
|
||||||
self._event_source_mappings[esm.uuid] = esm
|
self._event_source_mappings[esm.uuid] = esm
|
||||||
|
|
||||||
# Set backend function on queue
|
# Set backend function on queue
|
||||||
|
Loading…
Reference in New Issue
Block a user