Class: WatchList::Exporter

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uptimerobot, options = {}) ⇒ Exporter

of class methods



12
13
14
15
# File 'lib/watch_list/exporter.rb', line 12

def initialize(uptimerobot, options = {})
  @uptimerobot = uptimerobot
  @options = options
end

Class Method Details

.export(uptimerobot, opts = {}) ⇒ Object



3
4
5
# File 'lib/watch_list/exporter.rb', line 3

def export(uptimerobot, opts = {})
  self.new(uptimerobot, opts).export
end

.export_status(uptimerobot, opts = {}) ⇒ Object



7
8
9
# File 'lib/watch_list/exporter.rb', line 7

def export_status(uptimerobot, opts = {})
  self.new(uptimerobot, opts).export_status
end

Instance Method Details

#exportObject



17
18
19
20
21
22
23
24
25
# File 'lib/watch_list/exporter.rb', line 17

def export
  monitors = @uptimerobot.getMonitors(showMonitorAlertContacts: 1)
  alert_contacts = @uptimerobot.getAlertContacts

  {
    :monitors       => normalize_monitors(monitors),
    :alert_contacts => normalize_alert_contacts(alert_contacts),
  }
end

#export_statusObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/watch_list/exporter.rb', line 27

def export_status
  monitors = @uptimerobot.getMonitors(
    :logs                 => 1,
    :responseTimes        => 1,
    :showTimezone         => 1,
  )

  {
    :timezone => monitors['timezone'],
    :monitors => normalize_monitors_status(monitors),
  }
end