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
-
#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://#{CGI::escape @config['user']}:#{CGI::escape @config['password']}@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 = RestClient.get(get_url('actions'), @header) JSON.parse(response.body, :symbolize_names => true) end |
#checks ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pingdom/cli/core.rb', line 14 def checks response = RestClient.get(get_url('checks'), @header) results = JSON.parse(response.body, :symbolize_names => true) results[:checks].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 end |
#contacts ⇒ Object
30 31 32 33 |
# File 'lib/pingdom/cli/core.rb', line 30 def contacts response = RestClient.get(get_url('contacts'), @header) JSON.parse(response.body, :symbolize_names => true) end |
#probes ⇒ Object
35 36 37 38 |
# File 'lib/pingdom/cli/core.rb', line 35 def probes response = RestClient.get(get_url('probes'), @header) JSON.parse(response.body, :symbolize_names => true) end |
#reference ⇒ Object
40 41 42 43 |
# File 'lib/pingdom/cli/core.rb', line 40 def reference response = RestClient.get(get_url('reference'), @header) JSON.parse(response.body, :symbolize_names => true) end |
#reports_public ⇒ Object
45 46 47 48 |
# File 'lib/pingdom/cli/core.rb', line 45 def reports_public response = RestClient.get(get_url('reports.public'), @header) JSON.parse(response.body, :symbolize_names => true) end |
#settings ⇒ Object
50 51 52 53 |
# File 'lib/pingdom/cli/core.rb', line 50 def settings response = RestClient.get(get_url('settings'), @header) JSON.parse(response.body, :symbolize_names => true) end |
#update(params) ⇒ Object
55 56 57 58 |
# File 'lib/pingdom/cli/core.rb', line 55 def update(params) response = RestClient.put(get_url('checks'), params, @header) response.body end |