Class: Nexpose::Blackout

Inherits:
APIObject show all
Defined in:
lib/nexpose/blackout.rb

Overview

Configuration structure for blackouts.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#object_from_hash

Constructor Details

#initialize(start, enabled = true, duration, type, interval) ⇒ Blackout

Returns a new instance of Blackout.



16
17
18
19
20
21
22
# File 'lib/nexpose/blackout.rb', line 16

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_durationObject

The amount of time, in minutes, a blackout period should last.



14
15
16
# File 'lib/nexpose/blackout.rb', line 14

def blackout_duration
  @blackout_duration
end

#blackout_intervalObject

The repeat interval based upon type.



10
11
12
# File 'lib/nexpose/blackout.rb', line 10

def blackout_interval
  @blackout_interval
end

#blackout_startObject

The earliest date to generate the report on (in ISO 8601 format).



12
13
14
# File 'lib/nexpose/blackout.rb', line 12

def blackout_start
  @blackout_start
end

#blackout_typeObject

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

#enabledObject

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



24
25
26
27
28
# File 'lib/nexpose/blackout.rb', line 24

def self.from_hash(hash)
  repeat_blackout_hash = hash[:repeat_blackout]
  blackout = new(hash[:start_date], hash[:blackout_duration], repeat_blackout_hash[:type], repeat_blackout_hash[:interval])
  blackout
end

Instance Method Details

#to_hObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nexpose/blackout.rb', line 30

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