Class: ScoutScout
- Inherits:
-
Object
- Object
- ScoutScout
- Includes:
- HTTParty
- Defined in:
- lib/scout_scout.rb,
lib/scout_scout/version.rb
Defined Under Namespace
Classes: Alert, Cluster, Descriptor, Error, Metric, Plugin, Server
Constant Summary collapse
- VERSION =
'0.0.4'
Class Method Summary collapse
-
.get(uri) ⇒ Object
Checks for errors via the HTTP status code.
- .http_get ⇒ Object
Instance Method Summary collapse
-
#alerts ⇒ Array
Recent alerts across all servers on this account.
-
#initialize(scout_account_name, username, password) ⇒ ScoutScout
constructor
A new instance of ScoutScout.
-
#servers ⇒ Array
All servers on this account.
Constructor Details
#initialize(scout_account_name, username, password) ⇒ ScoutScout
Returns a new instance of ScoutScout.
21 22 23 24 |
# File 'lib/scout_scout.rb', line 21 def initialize(scout_account_name, username, password) self.class.account = scout_account_name self.class.basic_auth username, password end |
Class Method Details
.get(uri) ⇒ Object
Checks for errors via the HTTP status code. If an error is found, a ScoutScout::Error is raised. Otherwise, the response.
50 51 52 53 |
# File 'lib/scout_scout.rb', line 50 def self.get(uri) response = http_get(uri) response.code.to_s =~ /^(4|5)/ ? raise( ScoutScout::Error,response.) : response end |
.http_get ⇒ Object
43 |
# File 'lib/scout_scout.rb', line 43 alias_method :http_get, :get |
Instance Method Details
#alerts ⇒ Array
Recent alerts across all servers on this account
29 30 31 32 |
# File 'lib/scout_scout.rb', line 29 def alerts response = self.class.get("/#{self.class.account}/activities.xml") response['alerts'].map { |alert| ScoutScout::Alert.new(alert) } end |
#servers ⇒ Array
All servers on this account
37 38 39 40 |
# File 'lib/scout_scout.rb', line 37 def servers response = self.class.get("/#{self.class.account}/clients.xml") response['clients'].map { |client| ScoutScout::Server.new(client) } end |