Class: Pingdom::Cli::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/pingdom/cli/core.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Core

Returns a new instance of Core.



8
9
10
11
12
# File 'lib/pingdom/cli/core.rb', line 8

def initialize(config)
  @config = config
  @url_base = "https://api.pingdom.com/api/2.0/"
  @header = { "App-Key" => @config['app_key'] }
end

Instance Method Details

#actionsObject



25
26
27
28
# File 'lib/pingdom/cli/core.rb', line 25

def actions
  response = get_resource('actions').get
  JSON.parse(response.body, :symbolize_names => true)[__method__]
end

#checksObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/pingdom/cli/core.rb', line 14

def checks
  response = get_resource('checks').get
  results = JSON.parse(response.body, :symbolize_names => true)
  results[__method__].each do |result|
    result[:lasttesttime] = Time.at(result[:lasttesttime]) unless result[:lasttesttime].nil?
    result[:lasterrortime] = Time.at(result[:lasterrortime]) unless result[:lasterrortime].nil?
    result[:created] = Time.at(result[:created]) unless result[:created].nil?
  end
  results[__method__]
end

#contactsObject



30
31
32
33
# File 'lib/pingdom/cli/core.rb', line 30

def contacts
  response = get_resource('contacts').get
  JSON.parse(response.body, :symbolize_names => true)[__method__]
end

#creditsObject



55
56
57
58
# File 'lib/pingdom/cli/core.rb', line 55

def credits
  response = get_resource('credits').get
  JSON.parse(response.body, :symbolize_names => true)[__method__]
end

#probesObject



35
36
37
38
# File 'lib/pingdom/cli/core.rb', line 35

def probes
  response = get_resource('probes').get
  JSON.parse(response.body, :symbolize_names => true)[__method__]
end

#referenceObject



40
41
42
43
# File 'lib/pingdom/cli/core.rb', line 40

def reference
  response = get_resource('reference').get
  JSON.parse(response.body, :symbolize_names => true)[__method__]
end

#reports_publicObject



45
46
47
48
# File 'lib/pingdom/cli/core.rb', line 45

def reports_public
  response = get_resource('reports.public').get
  JSON.parse(response.body, :symbolize_names => true)[__method__]
end

#settingsObject



50
51
52
53
# File 'lib/pingdom/cli/core.rb', line 50

def settings
  response = get_resource('settings').get
  JSON.parse(response.body, :symbolize_names => true)[__method__]
end

#update(params) ⇒ Object



60
61
62
63
# File 'lib/pingdom/cli/core.rb', line 60

def update(params)
  response = get_resource('checks').put(params)
  response.body
end