class Nexpose::ScheduledMaintenance

Configuration structure for scheduled maintenance.

Attributes

cancellation_window[RW]

Number of minutes to wait for running scans to pause/complete before aborting the maintenance task. Defaults to 0 if not set

cleanup[RW]

Whether the cleanup task should run. Defaults to true if not set

compress[RW]

Whether the compression task should run. Defaults to true if not set

enabled[RW]

Whether or not this maintenance schedule is enabled. Defaults to true if not set

pause_local_scans[RW]

Whether the maintenance should pause all local scans or wait for local scans to complete. Defaults to true if not set

reindex[RW]

Whether the reindex task should run. Defaults to true if not set

schedule_interval[RW]

The repeat interval based upon type.

schedule_start[RW]

Starting time of the maintenance task (in unix epoch with milliseconds. Example: 1464956590000)

schedule_type[RW]

Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly.

Public Class Methods

delete(nsc) click to toggle source
# File lib/nexpose/scheduled_maintenance.rb, line 86
def self.delete(nsc)
  AJAX.delete(nsc, '/api/2.1/schedule_maintenance/', AJAX::CONTENT_TYPE::JSON)
end
from_hash(hash) click to toggle source
# File lib/nexpose/scheduled_maintenance.rb, line 47
def self.from_hash(hash)
  repeat_backup_hash = hash[:repeat_type]
  backup = new(start: hash[:start_date],
               enabled: hash[:enabled],
               type: repeat_backup_hash[:type],
               interval: repeat_backup_hash[:interval],
               reindex: hash[:reindex],
               compress: hash[:compression],
               cleanup: hash[:cleanup],
               pause_local_scans: hash[:pause_local_scans],
               cancellation_window: hash[:cancellation_window])
  backup
end
load(nsc) click to toggle source
# File lib/nexpose/scheduled_maintenance.rb, line 79
def self.load(nsc)
  uri  = '/api/2.1/schedule_maintenance/'
  resp = AJAX.get(nsc, uri, AJAX::CONTENT_TYPE::JSON)
  hash = JSON.parse(resp, symbolize_names: true).first
  Nexpose::ScheduledMaintenance.from_hash(hash || [])
end
new(start:, enabled: true, type:, interval:, reindex: false, compress: true, cleanup: true, pause_local_scans: true, cancellation_window: 0) click to toggle source
# File lib/nexpose/scheduled_maintenance.rb, line 26
def initialize(start:, enabled: true, type:, interval:, reindex: false, compress: true, cleanup: true, pause_local_scans: true, cancellation_window: 0)
  @schedule_start      = start
  @enabled             = enabled
  @schedule_type       = type
  @schedule_interval   = interval.to_i
  @reindex             = reindex
  @compress            = compress
  @cleanup             = cleanup
  @pause_local_scans   = pause_local_scans
  @cancellation_window = cancellation_window.to_i
end

Public Instance Methods

save(nsc) click to toggle source
# File lib/nexpose/scheduled_maintenance.rb, line 42
def save(nsc)
  params = to_json
  AJAX.post(nsc, '/api/2.1/schedule_maintenance/', params, AJAX::CONTENT_TYPE::JSON)
end
to_h() click to toggle source
# File lib/nexpose/scheduled_maintenance.rb, line 61
def to_h
  maintenance_hash = {
    start_date: @schedule_start,
    enabled: @enabled,
    cleanup: @cleanup,
    reindex: @reindex,
    compression: @compress,
    pause_local_scans: @pause_local_scans,
    cancellation_window: @cancellation_window
  }
  repeat_hash = {
    type: @schedule_type,
    interval: @schedule_interval
  }
  maintenance_hash[:repeat_type] = repeat_hash
  maintenance_hash
end
to_json() click to toggle source
# File lib/nexpose/scheduled_maintenance.rb, line 38
def to_json
  JSON.generate(to_h)
end