Class: ScoutScout

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/scout_scout.rb,
lib/scout_scout/version.rb

Constant Summary collapse

VERSION =
'0.0.2'

Instance Method Summary collapse

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(, username, password)
  self.class. = 
  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.}/activities.xml")
  elsif client_id_or_hostname.is_a?(Fixnum)
    self.class.get("/#{self.class.}/clients/#{client_id_or_hostname}/activities.xml")
  else
    self.class.get("/#{self.class.}/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.}/clients/#{client_id_or_hostname}.xml")
    Hashie::Mash.new(response['client'])
  else
    response = self.class.get("/#{self.class.}/clients.xml?host=#{client_id_or_hostname}")
    Hashie::Mash.new(response['clients'].first)
  end
end

#clientsObject



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

def clients
  response = self.class.get("/#{self.class.}/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.}/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.}/clients/#{client_id_or_hostname}/plugins.xml")
  else
    self.class.get("/#{self.class.}/plugins.xml?host=#{client_id_or_hostname}")
  end
  response['plugins'].map { |plugin| format_plugin(Hashie::Mash.new(plugin)) }
end