Class: Xronor::AWS::CloudWatchEvents
- Inherits:
-
Object
- Object
- Xronor::AWS::CloudWatchEvents
- Defined in:
- lib/xronor/aws/cloud_watch_events.rb
Instance Method Summary collapse
- #deregister_job(job_name) ⇒ Object
-
#initialize(client: Aws::CloudWatchEvents::Client.new) ⇒ CloudWatchEvents
constructor
A new instance of CloudWatchEvents.
- #list_jobs(prefix = "") ⇒ Object
- #register_job(job, prefix, cluster, task_definition, container, target_function_arn) ⇒ Object
Constructor Details
#initialize(client: Aws::CloudWatchEvents::Client.new) ⇒ CloudWatchEvents
Returns a new instance of CloudWatchEvents.
4 5 6 |
# File 'lib/xronor/aws/cloud_watch_events.rb', line 4 def initialize(client: Aws::CloudWatchEvents::Client.new) @client = client end |
Instance Method Details
#deregister_job(job_name) ⇒ Object
8 9 10 11 12 |
# File 'lib/xronor/aws/cloud_watch_events.rb', line 8 def deregister_job(job_name) targets = @client.list_targets_by_rule(rule: job_name).targets @client.remove_targets(rule: job_name, ids: targets.map(&:id)) @client.delete_rule(name: job_name) end |
#list_jobs(prefix = "") ⇒ Object
14 15 16 |
# File 'lib/xronor/aws/cloud_watch_events.rb', line 14 def list_jobs(prefix = "") @client.list_rules.rules.select { |rule| rule.name.start_with?(prefix) }.map(&:name) end |
#register_job(job, prefix, cluster, task_definition, container, target_function_arn) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/xronor/aws/cloud_watch_events.rb', line 18 def register_job(job, prefix, cluster, task_definition, container, target_function_arn) rule_name = job.cloud_watch_rule_name(prefix) rule_arn = put_rule(rule_name, job.description, job.cloud_watch_schedule) put_target(rule_name, cluster, task_definition, container, job.command, target_function_arn) rule_arn end |