Class: Nagios::API::Downtime
- Defined in:
- lib/nagios/api/downtime.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Attributes inherited from Resource
Instance Method Summary collapse
- #cancel ⇒ Object
- #id ⇒ Object
-
#initialize(args = {}) ⇒ Downtime
constructor
A new instance of Downtime.
Methods inherited from Resource
Constructor Details
#initialize(args = {}) ⇒ Downtime
Returns a new instance of Downtime.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/nagios/api/downtime.rb', line 5 def initialize(args = {}) @service = args.delete(:service) @host = args.delete(:host) args['end_time'] = Time.at(args['end_time'].to_i) args['start_time'] = Time.at(args['start_time'].to_i) args['created_at'] = Time.at(args['entry_time'].to_i) super(args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Nagios::API::Resource
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
3 4 5 |
# File 'lib/nagios/api/downtime.rb', line 3 def api_client @api_client end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/nagios/api/downtime.rb', line 3 def host @host end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
3 4 5 |
# File 'lib/nagios/api/downtime.rb', line 3 def service @service end |
Instance Method Details
#cancel ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/nagios/api/downtime.rb', line 20 def cancel result = api_client.api.post("/cancel_downtime/#{id}", {}) raise StandardError, "Unknown response canceling downtime: #{result}" unless result == "cancelled" true end |
#id ⇒ Object
16 17 18 |
# File 'lib/nagios/api/downtime.rb', line 16 def id downtime_id end |