Class: PingdomCap::Client
- Inherits:
-
Object
- Object
- PingdomCap::Client
- Defined in:
- lib/pingdom_cap/client.rb
Constant Summary collapse
- BASE_SERVER_ADDRESS =
"https://api.pingdom.com/api/2.0"
- OPTIONS =
{ url: BASE_SERVER_ADDRESS }
- REQUIRED_OPTIONS =
[ :key, :url, :username, :password ]
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #pause(name) ⇒ Object
- #status(name) ⇒ Object
- #unpause(name) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pingdom_cap/client.rb', line 15 def initialize( = {}) = OPTIONS.merge() raise "Options #{REQUIRED_OPTIONS.join(', ')} are required" if REQUIRED_OPTIONS.any? { |op| [op].nil? } headers = { 'App-Key' => [:key] } @connection = Faraday::Connection.new(url: [:url], headers: headers) do |builder| builder.response :logger if [:logger] builder.adapter Faraday.default_adapter builder.request :url_encoded builder.use Faraday::Response::Mashify builder.use Faraday::Response::ParseJson end @connection.basic_auth([:username], [:password]) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
13 14 15 |
# File 'lib/pingdom_cap/client.rb', line 13 def connection @connection end |
Instance Method Details
#pause(name) ⇒ Object
34 35 36 37 |
# File 'lib/pingdom_cap/client.rb', line 34 def pause(name) puts "Pausing Pingdom '#{name}'" check_pause(name_to_checkid(name)) end |
#status(name) ⇒ Object
29 30 31 32 |
# File 'lib/pingdom_cap/client.rb', line 29 def status(name) puts "Status for Pingdom '#{name}'" ap get_detailed_check_information(name_to_checkid(name)).to_hash, plain: true end |
#unpause(name) ⇒ Object
39 40 41 42 |
# File 'lib/pingdom_cap/client.rb', line 39 def unpause(name) puts "Unpausing Pingdom '#{name}'" check_unpause(name_to_checkid(name)) end |