class Nexpose::Schedule
Configuration structure for schedules.
Attributes
Starting time of the scheduled scan (in ISO 8601 format). Relative to the console timezone
The timezone of the console.
Whether or not this schedule is enabled.
The repeat interval based upon type.
Extended attributes added with the new scheduler implementation
The amount of time, in minutes, to allow execution before stopping.
The date after which the schedule is disabled, in ISO 8601 format.
scan-schedule attributes
Scan
template to use when starting a scan job.
Starting time of the scheduled scan (in ISO 8601 format).
Timezone in which start time run. If not set will default to console timezone. If console timezone is not supported it defaults to utc.
Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.
Public Class Methods
# File lib/nexpose/common.rb, line 179 def self.from_hash(hash) start = nil start = Nexpose::ISO8601.to_time(hash[:start_date]) if hash[:start_date] repeat_scan_hash = hash[:repeat_scan] if repeat_scan_hash.nil? schedule = new('daily', 0, start) else schedule = new(repeat_scan_hash[:type], repeat_scan_hash[:interval], start) end schedule.enabled = hash[:enabled].nil? ? true : hash[:enabled] schedule.scan_template_id = hash[:scan_template_id] schedule.start = Nexpose::ISO8601.to_time(hash[:start_date]) if hash[:start_date] schedule.max_duration = hash[:maximum_scan_duration] if hash[:maximum_scan_duration] schedule.not_valid_after = Nexpose::ISO8601.to_time(hash[:not_valid_after_date]) if hash[:not_valid_after_date] schedule.timezone = hash[:time_zone] if hash[:time_zone] schedule.next_run_time = hash[:next_run_time] if hash[:next_run_time] schedule.console_start = Nexpose::ISO8601.to_time(hash[:console_start_date]) if hash[:console_start_date] schedule.console_timezone = hash[:console_time_zone] if hash[:console_time_zone] unless repeat_scan_hash.nil? schedule.type = repeat_scan_hash[:type] schedule.interval = repeat_scan_hash[:interval] schedule.repeater_type = 'restart' if repeat_scan_hash[:on_repeat] == 'restart-scan' schedule.repeater_type = 'continue' if repeat_scan_hash[:on_repeat] == 'resume-scan' schedule.is_extended = repeat_scan_hash[:is_extended] if repeat_scan_hash[:is_extended] schedule.hour = repeat_scan_hash[:hour] if repeat_scan_hash[:hour] schedule.minute = repeat_scan_hash[:minute] if repeat_scan_hash[:minute] schedule.date = repeat_scan_hash[:date] if repeat_scan_hash[:date] schedule.day = repeat_scan_hash[:day] if repeat_scan_hash[:day] schedule.occurrence = repeat_scan_hash[:occurrence] if repeat_scan_hash[:occurrence] schedule.start_month = repeat_scan_hash[:start_month] if repeat_scan_hash[:start_month] end schedule end
@param [Time] start
# File lib/nexpose/common.rb, line 171 def initialize(type, interval, start, enabled = true, scan_template_id = nil) @type = type @interval = interval @start = start @enabled = enabled @scan_template_id = scan_template_id end
# File lib/nexpose/common.rb, line 272 def self.parse(xml) schedule = Schedule.new(xml.attributes['type'], xml.attributes['interval'].to_i, xml.attributes['start'], xml.attributes['enabled'] != '0') # Optional parameters. schedule.max_duration = xml.attributes['maxDuration'].to_i if xml.attributes['maxDuration'] schedule.not_valid_after = xml.attributes['notValidAfter'] if xml.attributes['notValidAfter'] schedule.repeater_type = xml.attributes['repeaterType'] if xml.attributes['repeaterType'] schedule.is_extended = xml.attributes['is_extended'] if xml.attributes['is_extended'] schedule.hour = xml.attributes['hour'] if xml.attributes['hour'] schedule.minute = xml.attributes['minute'] if xml.attributes['minute'] schedule.date = xml.attributes['date'] if xml.attributes['date'] schedule.day = xml.attributes['day'] if xml.attributes['day'] schedule.occurrence = xml.attributes['occurrence'] if xml.attributes['occurrence'] schedule.start_month = xml.attributes['start_month'] if xml.attributes['start_month'] schedule.timezone = xml.attributes['timezone'] if xml.attributes['timezone'] schedule.next_run_time = xml.attributes['next_run_time'] if xml.attributes['next_run_time'] schedule.scan_template_id = xml.attributes['template'] if xml.attributes['template'] schedule end
Public Instance Methods
# File lib/nexpose/common.rb, line 247 def as_xml xml = REXML::Element.new('Schedule') xml.attributes['enabled'] = @enabled ? 1 : 0 xml.attributes['type'] = @type xml.attributes['interval'] = @interval xml.attributes['start'] = @start if @start xml.attributes['maxDuration'] = @max_duration if @max_duration xml.attributes['notValidAfter'] = @not_valid_after if @not_valid_after xml.attributes['repeaterType'] = @repeater_type if @repeater_type xml.attributes['is_extended'] = @is_extended if @is_extended xml.attributes['hour'] = @hour if @hour xml.attributes['minute'] = @minute if @minute xml.attributes['date'] = @date if @date xml.attributes['day'] = @day if @day xml.attributes['occurrence'] = @occurrence if @occurrence xml.attributes['start_month'] = @start_month if @start_month xml.attributes['timezone'] = @timezone if @timezone xml.attributes['template'] = @scan_template_id if @scan_template_id xml end
# File lib/nexpose/common.rb, line 215 def to_h schedule_hash = { enabled: @enabled, scan_template_id: @scan_template_id, maximum_scan_duration: @max_duration } schedule_hash[:start_date] = Nexpose::ISO8601.to_string(@start) if @start schedule_hash[:not_valid_after_date] = Nexpose::ISO8601.to_string(@not_valid_after) if @not_valid_after schedule_hash[:time_zone] = @timezone if @timezone unless (@type.nil? || @interval.to_i.zero?) && !@is_extended repeat_scan_hash = { type: @type, interval: @interval } repeat_scan_hash[:on_repeat] = 'restart-scan' if @repeater_type == 'restart' repeat_scan_hash[:on_repeat] = 'resume-scan' if @repeater_type == 'continue' if @is_extended repeat_scan_hash[:is_extended] = @is_extended repeat_scan_hash[:hour] = @hour if @hour repeat_scan_hash[:minute] = @minute if @minute repeat_scan_hash[:date] = @date if @date repeat_scan_hash[:day] = @day if @day repeat_scan_hash[:occurrence] = @occurrence if @occurrence repeat_scan_hash[:start_month] = @start_month if @start_month end schedule_hash[:repeat_scan] = repeat_scan_hash end schedule_hash end
# File lib/nexpose/common.rb, line 268 def to_xml as_xml.to_s end