Class: Nexpose::Blackout
Overview
Constants useful across the Nexpose module. Configuration structure for blackouts.
Instance Attribute Summary collapse
-
#blackout_duration ⇒ Object
The amount of time, in minutes, a blackout period should last.
-
#blackout_interval ⇒ Object
The repeat interval based upon type.
-
#blackout_start ⇒ Object
Starting time of the blackout (in unix epoch with milliseconds. Example: 1464956590000) The timezone is the timezone of the console.
-
#blackout_type ⇒ Object
Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.
-
#enabled ⇒ Object
Whether or not this blackout is enabled.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(start, enabled = true, duration, type, interval) ⇒ Blackout
constructor
A new instance of Blackout.
- #to_h ⇒ Object
Methods inherited from APIObject
Constructor Details
#initialize(start, enabled = true, duration, type, interval) ⇒ Blackout
Returns a new instance of Blackout.
17 18 19 20 21 22 23 |
# File 'lib/nexpose/blackout.rb', line 17 def initialize(start, enabled = true, duration, type, interval) @blackout_start = start @enabled = enabled @blackout_duration = duration.to_i @blackout_type = type @blackout_interval = interval.to_i end |
Instance Attribute Details
#blackout_duration ⇒ Object
The amount of time, in minutes, a blackout period should last.
15 16 17 |
# File 'lib/nexpose/blackout.rb', line 15 def blackout_duration @blackout_duration end |
#blackout_interval ⇒ Object
The repeat interval based upon type.
10 11 12 |
# File 'lib/nexpose/blackout.rb', line 10 def blackout_interval @blackout_interval end |
#blackout_start ⇒ Object
Starting time of the blackout (in unix epoch with milliseconds. Example: 1464956590000) The timezone is the timezone of the console. If the console timezone is not supported it defaults to utc.
13 14 15 |
# File 'lib/nexpose/blackout.rb', line 13 def blackout_start @blackout_start end |
#blackout_type ⇒ Object
Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.
8 9 10 |
# File 'lib/nexpose/blackout.rb', line 8 def blackout_type @blackout_type end |
#enabled ⇒ Object
Whether or not this blackout is enabled.
6 7 8 |
# File 'lib/nexpose/blackout.rb', line 6 def enabled @enabled end |
Class Method Details
.from_hash(hash) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nexpose/blackout.rb', line 25 def self.from_hash(hash) repeat_blackout_hash = hash[:repeat_blackout] if repeat_blackout_hash.nil? type = 'daily' interval = 0 else type = repeat_blackout_hash[:type] interval = repeat_blackout_hash[:interval] end new(hash[:start_date], hash[:enabled], hash[:blackout_duration], type, interval) end |
Instance Method Details
#to_h ⇒ Object
37 38 39 40 41 42 |
# File 'lib/nexpose/blackout.rb', line 37 def to_h blackout_hash = { start_date: @blackout_start, enabled: @enabled, blackout_duration: @blackout_duration } repeat_hash = { type: @blackout_type, interval: @blackout_interval } blackout_hash[:repeat_blackout] = repeat_hash blackout_hash end |