Class: Nexpose::AdHocSchedule

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

Overview

Configuration structure for ad-hoc schedules

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#object_from_hash

Constructor Details

#initialize(start, scan_template_id, max_duration = nil) ⇒ AdHocSchedule

Returns a new instance of AdHocSchedule.



111
112
113
114
115
# File 'lib/nexpose/common.rb', line 111

def initialize(start, scan_template_id, max_duration = nil)
  @start = start
  @scan_template_id = scan_template_id
  @max_duration = max_duration if max_duration
end

Instance Attribute Details

#max_durationObject

The amount of time, in minutes, to allow execution before stopping.



109
110
111
# File 'lib/nexpose/common.rb', line 109

def max_duration
  @max_duration
end

#scan_template_idObject

The template to use to scan the assets



106
107
108
# File 'lib/nexpose/common.rb', line 106

def scan_template_id
  @scan_template_id
end

#startObject

Start time in ISO8601 format



103
104
105
# File 'lib/nexpose/common.rb', line 103

def start
  @start
end

Instance Method Details

#as_xmlObject



117
118
119
120
121
122
123
# File 'lib/nexpose/common.rb', line 117

def as_xml
  xml = REXML::Element.new('AdHocSchedule')
  xml.attributes['start'] = @start
  xml.attributes['maxDuration'] = @max_duration if @max_duration
  xml.attributes['template'] = @scan_template_id
  xml
end

#from_hash(hash) ⇒ Object



125
126
127
128
129
# File 'lib/nexpose/common.rb', line 125

def from_hash(hash)
  schedule = AdHocSchedule.new(hash[:start], hash[:scan_template_id])
  schedule.max_duration = hash[:max_duration] if hash[:max_duration]
  schedule
end

#to_xmlObject



131
132
133
# File 'lib/nexpose/common.rb', line 131

def to_xml
  as_xml.to_s
end