class Nagios::API::Services

Attributes

api_client[R]
host[RW]

Public Class Methods

new(args = {}) click to toggle source
# File lib/nagios/api/service.rb, line 8
def initialize(args = {})
  @api_client = args[:api_client]
  @host = args[:host]
end

Public Instance Methods

all() click to toggle source
# File lib/nagios/api/service.rb, line 13
def all
  raise NoHost unless host
  
  @services ||= api_client.api.query("/service/#{host.name}").values.collect do |service_attributes|
    Service.new(service_attributes.merge(api_client: api_client, host: host))
  end
end
find(name) click to toggle source
# File lib/nagios/api/service.rb, line 21
def find(name)
  raise NoHost unless host
  
  all.find { |service| service.name.downcase == name.downcase }
end
reload() click to toggle source
# File lib/nagios/api/service.rb, line 27
def reload
  @services = nil
end