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.



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

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.



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

def max_duration
  @max_duration
end

#scan_template_idObject

The template to use to scan the assets



100
101
102
# File 'lib/nexpose/common.rb', line 100

def scan_template_id
  @scan_template_id
end

#startObject

Start time in ISO8601 format



97
98
99
# File 'lib/nexpose/common.rb', line 97

def start
  @start
end

Instance Method Details

#as_xmlObject



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

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



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

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



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

def to_xml
  as_xml.to_s
end