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.



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

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.



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

def max_duration
  @max_duration
end

#scan_template_idObject

The template to use to scan the assets



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

def scan_template_id
  @scan_template_id
end

#startObject

Start time in ISO8601 format



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

def start
  @start
end

Instance Method Details

#as_xmlObject



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

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



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

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



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

def to_xml
  as_xml.to_s
end