Mitch Garnaat

Allow an event source to be enabled/disabled

...@@ -75,6 +75,30 @@ class KinesisEventSource(EventSource): ...@@ -75,6 +75,30 @@ class KinesisEventSource(EventSource):
75 except Exception: 75 except Exception:
76 LOG.exception('Unable to add event source') 76 LOG.exception('Unable to add event source')
77 77
78 + def enable(self, function):
79 + self.enabled = True
80 + try:
81 + response = self._lambda.call(
82 + 'update_event_source_mapping',
83 + FunctionName=function.name,
84 + Enabled=self.enabled
85 + )
86 + LOG.debug(response)
87 + except Exception:
88 + LOG.exception('Unable to enable event source')
89 +
90 + def disable(self, function):
91 + self.enabled = False
92 + try:
93 + response = self._lambda.call(
94 + 'update_event_source_mapping',
95 + FunctionName=function.name,
96 + Enabled=self.enabled
97 + )
98 + LOG.debug(response)
99 + except Exception:
100 + LOG.exception('Unable to disable event source')
101 +
78 def update(self, function): 102 def update(self, function):
79 response = None 103 response = None
80 uuid = self._get_uuid(function) 104 uuid = self._get_uuid(function)
......
...@@ -207,4 +207,26 @@ def update_event_sources(ctx): ...@@ -207,4 +207,26 @@ def update_event_sources(ctx):
207 click.echo('done') 207 click.echo('done')
208 208
209 209
210 +@cli.command()
211 +@click.pass_context
212 +def enable_event_sources(ctx):
213 + """Enable event sources specified in the config file"""
214 + context = Context(ctx.obj['config'], ctx.obj['environment'],
215 + ctx.obj['debug'], ctx.obj['force'])
216 + click.echo('enabling event sources')
217 + context.enable_event_sources()
218 + click.echo('done')
219 +
220 +
221 +@cli.command()
222 +@click.pass_context
223 +def disable_event_sources(ctx):
224 + """Disable event sources specified in the config file"""
225 + context = Context(ctx.obj['config'], ctx.obj['environment'],
226 + ctx.obj['debug'], ctx.obj['force'])
227 + click.echo('enabling event sources')
228 + context.disable_event_sources()
229 + click.echo('done')
230 +
231 +
210 cli(obj={}) 232 cli(obj={})
......