Class: ScoutScout
- Inherits:
-
Object
- Object
- ScoutScout
- Includes:
- HTTParty
- Defined in:
- lib/scout_scout.rb,
lib/scout_scout/version.rb
Constant Summary collapse
- VERSION =
'0.0.2'
Instance Method Summary collapse
- #alerts(client_id_or_hostname = nil) ⇒ Object
- #client(client_id_or_hostname) ⇒ Object
- #clients ⇒ Object
-
#initialize(scout_account_name, username, password) ⇒ ScoutScout
constructor
A new instance of ScoutScout.
- #plugin_data(hostname, plugin_name) ⇒ Object
- #plugins(client_id_or_hostname) ⇒ Object
Constructor Details
#initialize(scout_account_name, username, password) ⇒ ScoutScout
Returns a new instance of ScoutScout.
12 13 14 15 |
# File 'lib/scout_scout.rb', line 12 def initialize(scout_account_name, username, password) self.class.account = scout_account_name self.class.basic_auth username, password end |
Instance Method Details
#alerts(client_id_or_hostname = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/scout_scout.rb', line 17 def alerts(client_id_or_hostname = nil) response = if client_id_or_hostname.nil? self.class.get("/#{self.class.account}/activities.xml") elsif client_id_or_hostname.is_a?(Fixnum) self.class.get("/#{self.class.account}/clients/#{client_id_or_hostname}/activities.xml") else self.class.get("/#{self.class.account}/activities.xml?host=#{client_id_or_hostname}") end response['alerts'].map { |alert| Hashie::Mash.new(alert) } end |
#client(client_id_or_hostname) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/scout_scout.rb', line 33 def client(client_id_or_hostname) if client_id_or_hostname.is_a?(Fixnum) response = self.class.get("/#{self.class.account}/clients/#{client_id_or_hostname}.xml") Hashie::Mash.new(response['client']) else response = self.class.get("/#{self.class.account}/clients.xml?host=#{client_id_or_hostname}") Hashie::Mash.new(response['clients'].first) end end |
#clients ⇒ Object
28 29 30 31 |
# File 'lib/scout_scout.rb', line 28 def clients response = self.class.get("/#{self.class.account}/clients.xml") response['clients'].map { |client| Hashie::Mash.new(client) } end |
#plugin_data(hostname, plugin_name) ⇒ Object
52 53 54 55 |
# File 'lib/scout_scout.rb', line 52 def plugin_data(hostname, plugin_name) response = self.class.get("/#{self.class.account}/plugins/show.xml?host=#{hostname}&name=#{CGI.escape(plugin_name)}") format_plugin(Hashie::Mash.new(response['plugin'])) end |
#plugins(client_id_or_hostname) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/scout_scout.rb', line 43 def plugins(client_id_or_hostname) response = if client_id_or_hostname.is_a?(Fixnum) self.class.get("/#{self.class.account}/clients/#{client_id_or_hostname}/plugins.xml") else self.class.get("/#{self.class.account}/plugins.xml?host=#{client_id_or_hostname}") end response['plugins'].map { |plugin| format_plugin(Hashie::Mash.new(plugin)) } end |