Class: Nagios::API::Services
- Inherits:
-
Object
- Object
- Nagios::API::Services
- Defined in:
- lib/nagios/api/service.rb
Defined Under Namespace
Classes: NoHost
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
-
#host ⇒ Object
Returns the value of attribute host.
Instance Method Summary collapse
- #all ⇒ Object
- #find(name) ⇒ Object
-
#initialize(args = {}) ⇒ Services
constructor
A new instance of Services.
- #reload ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Services
Returns a new instance of Services.
8 9 10 11 |
# File 'lib/nagios/api/service.rb', line 8 def initialize(args = {}) @api_client = args[:api_client] @host = args[:host] end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
5 6 7 |
# File 'lib/nagios/api/service.rb', line 5 def api_client @api_client end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/nagios/api/service.rb', line 6 def host @host end |
Instance Method Details
#all ⇒ Object
13 14 15 16 17 18 19 |
# 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) ⇒ Object
21 22 23 24 25 |
# 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 ⇒ Object
27 28 29 |
# File 'lib/nagios/api/service.rb', line 27 def reload @services = nil end |