class Awful::Events

Constants

COLORS

Public Instance Methods

color(string) click to toggle source
# File lib/awful/lambda_events.rb, line 17
def color(string)
  set_color(string, COLORS.fetch(string.to_sym, :yellow))
end
create(name, src) click to toggle source
# File lib/awful/lambda_events.rb, line 53
def create(name, src)
  lambda.create_event_source_mapping(
    function_name: name,
    event_source_arn: src,
    enabled: options[:enabled],
    batch_size: options[:batch_size],
    starting_position: options[:starting_position]
  )
end
delete(uuid) click to toggle source
# File lib/awful/lambda_events.rb, line 64
def delete(uuid)
  if yes?("Really delete event source mapping #{uuid}?")
    lambda.delete_event_source_mapping(uuid: uuid)
  end
end
dump(uuid) click to toggle source
# File lib/awful/lambda_events.rb, line 43
def dump(uuid)
  lambda.get_event_source_mapping(uuid: uuid).tap do |details|
    puts YAML.dump(stringify_keys(details.to_hash))
  end
end
ls(name = nil) click to toggle source
# File lib/awful/lambda_events.rb, line 24
def ls(name = nil)
  lambda.list_event_source_mappings(function_name: name).event_source_mappings.tap do |sources|
    if options[:long]
      print_table sources.map { |s|
        [
          s.uuid,
          color(s.state),
          "Batch size: #{s.batch_size}",
          "Last result: #{color(s.last_processing_result.scan(/\w+/).first)}",
          s.last_modified
        ]
      }
    else
      puts sources.map(&:uuid)
    end
  end
end