Class: Awful::Events
  
  
  
  
  
    - Inherits:
 
    - 
      Cli
      
        
        show all
      
    
 
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/awful/lambda_events.rb
 
  
  
 
  
    
      Constant Summary
      collapse
    
    
      
        - COLORS =
          
        
 
        {
  OK:       :green,
  PROBLEM:  :red,
  Enabled:  :green,
  Disabled: :red
} 
      
    
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Cli
  #initialize, #ll, #version
  
  Constructor Details
  
    This class inherits a constructor from Awful::Cli
  
 
  
    Instance Method Details
    
      
  
  
    #create(name, src)  ⇒ Object 
  
  
  
  
    
      
47
48
49
50
51
52
53
54
55 
     | 
    
      # File 'lib/awful/lambda_events.rb', line 47
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)  ⇒ Object 
  
  
  
  
    
      
58
59
60
61
62 
     | 
    
      # File 'lib/awful/lambda_events.rb', line 58
def delete(uuid)
  if yes?("Really delete event source mapping #{uuid}?")
    lambda.delete_event_source_mapping(uuid: uuid)
  end
end
     | 
  
 
    
      
  
  
    #dump(uuid)  ⇒ Object 
  
  
  
  
    
      
37
38
39
40
41 
     | 
    
      # File 'lib/awful/lambda_events.rb', line 37
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)  ⇒ Object 
  
  
  
  
    
      
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 
     | 
    
      # File 'lib/awful/lambda_events.rb', line 18
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
     |