Class: Nagios::API::Client
- Inherits:
-
Object
- Object
- Nagios::API::Client
- Defined in:
- lib/nagios/api/client.rb
Overview
Create a new client to interact with the nagios-api server.
client = Nagios::API::Client.new("http://nagios-server:8181")
Optionally set authentication credentials
client = Nagios::API::Client.new("http://nagios-server:8181", user: 'user', password: 'password')
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #api ⇒ Object
- #hosts ⇒ Object
-
#initialize(base_url, extra_args = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(base_url, extra_args = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/nagios/api/client.rb', line 13 def initialize(base_url, extra_args = {}) @base_url = base_url = extra_args end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
11 12 13 |
# File 'lib/nagios/api/client.rb', line 11 def base_url @base_url end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/nagios/api/client.rb', line 11 def end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
11 12 13 |
# File 'lib/nagios/api/client.rb', line 11 def state @state end |
Instance Method Details
#api ⇒ Object
18 19 20 |
# File 'lib/nagios/api/client.rb', line 18 def api @api ||= Nagios::API::Interface.new(.merge(base_url: base_url)) end |
#hosts ⇒ Object
22 23 24 |
# File 'lib/nagios/api/client.rb', line 22 def hosts @hosts ||= Nagios::API::Hosts.new(api_client: self) end |