Class: ScoutScout

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(, username, password)
  self.class. = 
  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.

Returns:

  • HTTParty::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.message) : response
end

.http_getObject



43
# File 'lib/scout_scout.rb', line 43

alias_method :http_get, :get

Instance Method Details

#alertsArray

Recent alerts across all servers on this account

Returns:

  • (Array)

    An array of ScoutScout::Alert objects



29
30
31
32
# File 'lib/scout_scout.rb', line 29

def alerts
  response = self.class.get("/#{self.class.}/activities.xml")
  response['alerts'].map { |alert| ScoutScout::Alert.new(alert) }
end

#serversArray

All servers on this account

Returns:

  • (Array)

    An array of ScoutScout::Server objects



37
38
39
40
# File 'lib/scout_scout.rb', line 37

def servers
  response = self.class.get("/#{self.class.}/clients.xml")
  response['clients'].map { |client| ScoutScout::Server.new(client) }
end