Class: Pingdom::Cli::Core
- Inherits:
-
Object
- Object
- Pingdom::Cli::Core
- Defined in:
- lib/pingdom/cli/core.rb
Instance Method Summary collapse
- #actions ⇒ Object
- #checks ⇒ Object
- #contacts ⇒ Object
- #credits ⇒ Object
-
#initialize(config) ⇒ Core
constructor
A new instance of Core.
- #probes ⇒ Object
- #reference ⇒ Object
- #reports_public ⇒ Object
- #settings ⇒ Object
- #update(params) ⇒ Object
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
#actions ⇒ Object
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 |
#checks ⇒ Object
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 |
#contacts ⇒ Object
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 |
#credits ⇒ Object
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 |
#probes ⇒ Object
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 |
#reference ⇒ Object
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_public ⇒ Object
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 |
#settings ⇒ Object
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 |