Class: WatchList::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/watch_list/client.rb

Constant Summary collapse

MONITOR_ATTRS =
[
  :URL,
  :Type,
  :SubType,
  :Port,
  :KeywordType,
  :KeywordValue,
  :HTTPUsername,
  :HTTPPassword,
  :AlertContacts,
  :Interval,
]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
# File 'lib/watch_list/client.rb', line 15

def initialize(options = {})
  @options = options
  @uptimerobot = UptimeRobot::Client.new(:apiKey => options[:apiKey])
  @driver = WatchList::Driver.new(@uptimerobot, options)
end

Instance Method Details

#apply(file) ⇒ Object



38
39
40
# File 'lib/watch_list/client.rb', line 38

def apply(file)
  walk(file)
end

#exportObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/watch_list/client.rb', line 21

def export
  exported = WatchList::Exporter.export(@uptimerobot, @options)

  if block_given?
    exported.each do |name, attrs|
      dsl = WatchList::DSL.convert({name => attrs}, @options).strip
      yield(name, dsl) unless dsl.empty?
    end
  else
    WatchList::DSL.convert(exported, @options)
  end
end

#statusObject



34
35
36
# File 'lib/watch_list/client.rb', line 34

def status
  WatchList::Exporter.export_status(@uptimerobot, @options)
end