Mitch Garnaat

Allow an event source to be enabled/disabled

......@@ -75,6 +75,30 @@ class KinesisEventSource(EventSource):
except Exception:
LOG.exception('Unable to add event source')
def enable(self, function):
self.enabled = True
try:
response = self._lambda.call(
'update_event_source_mapping',
FunctionName=function.name,
Enabled=self.enabled
)
LOG.debug(response)
except Exception:
LOG.exception('Unable to enable event source')
def disable(self, function):
self.enabled = False
try:
response = self._lambda.call(
'update_event_source_mapping',
FunctionName=function.name,
Enabled=self.enabled
)
LOG.debug(response)
except Exception:
LOG.exception('Unable to disable event source')
def update(self, function):
response = None
uuid = self._get_uuid(function)
......
......@@ -207,4 +207,26 @@ def update_event_sources(ctx):
click.echo('done')
@cli.command()
@click.pass_context
def enable_event_sources(ctx):
"""Enable event sources specified in the config file"""
context = Context(ctx.obj['config'], ctx.obj['environment'],
ctx.obj['debug'], ctx.obj['force'])
click.echo('enabling event sources')
context.enable_event_sources()
click.echo('done')
@cli.command()
@click.pass_context
def disable_event_sources(ctx):
"""Disable event sources specified in the config file"""
context = Context(ctx.obj['config'], ctx.obj['environment'],
ctx.obj['debug'], ctx.obj['force'])
click.echo('enabling event sources')
context.disable_event_sources()
click.echo('done')
cli(obj={})
......