Class: Nexpose::ReportConfig
- Inherits:
-
AdhocReportConfig
- Object
- AdhocReportConfig
- Nexpose::ReportConfig
- Defined in:
- lib/nexpose/report.rb
Overview
Definition object for a report configuration.
Instance Attribute Summary collapse
-
#db_export ⇒ Object
Database export configuration.
-
#delivery ⇒ Object
Report delivery configuration.
-
#description ⇒ Object
Description associated with this report.
-
#generate(connection, wait = false) ⇒ Object
Generate a new report using this report definition.
-
#id ⇒ Object
The ID of the report definition (config).
-
#name ⇒ Object
The unique name assigned to the report definition.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#time_zone ⇒ Object
Returns the value of attribute time_zone.
-
#users ⇒ Object
Array of user IDs which have access to resulting reports.
Attributes inherited from AdhocReportConfig
#baseline, #filters, #format, #template_id
Class Method Summary collapse
-
.build(connection, site_id, site_name, type, format, generate_now = false) ⇒ Object
Build and save a report configuration against the specified site using the supplied type and format.
-
.get(connection, report_config_id) ⇒ Object
Retrieve the configuration for an existing report definition.
- .parse(xml) ⇒ Object
Instance Method Summary collapse
-
#delete(connection) ⇒ Object
Delete this report definition from the Security Console.
-
#initialize(name, template_id, format, id = -1,, owner = nil, time_zone = nil) ⇒ ReportConfig
constructor
Construct a basic ReportConfig object.
-
#save(connection, generate_now = false) ⇒ Object
Save the configuration of this report definition.
- #to_xml ⇒ Object
Methods inherited from AdhocReportConfig
Methods included from XMLUtils
Constructor Details
#initialize(name, template_id, format, id = -1,, owner = nil, time_zone = nil) ⇒ ReportConfig
Construct a basic ReportConfig object.
275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/nexpose/report.rb', line 275 def initialize(name, template_id, format, id = -1, owner = nil, time_zone = nil) @name = name @template_id = template_id @format = format @id = id @owner = owner @time_zone = time_zone @filters = [] @users = [] end |
Instance Attribute Details
#db_export ⇒ Object
Database export configuration.
272 273 274 |
# File 'lib/nexpose/report.rb', line 272 def db_export @db_export end |
#delivery ⇒ Object
Report delivery configuration.
270 271 272 |
# File 'lib/nexpose/report.rb', line 270 def delivery @delivery end |
#description ⇒ Object
Description associated with this report.
264 265 266 |
# File 'lib/nexpose/report.rb', line 264 def description @description end |
#generate(connection, wait = false) ⇒ Object
Generate a new report using this report definition.
268 269 270 |
# File 'lib/nexpose/report.rb', line 268 def generate @generate end |
#id ⇒ Object
The ID of the report definition (config). Use -1 to create a new definition.
257 258 259 |
# File 'lib/nexpose/report.rb', line 257 def id @id end |
#name ⇒ Object
The unique name assigned to the report definition.
259 260 261 |
# File 'lib/nexpose/report.rb', line 259 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
260 261 262 |
# File 'lib/nexpose/report.rb', line 260 def owner @owner end |
#time_zone ⇒ Object
Returns the value of attribute time_zone.
261 262 263 |
# File 'lib/nexpose/report.rb', line 261 def time_zone @time_zone end |
#users ⇒ Object
Array of user IDs which have access to resulting reports.
266 267 268 |
# File 'lib/nexpose/report.rb', line 266 def users @users end |
Class Method Details
.build(connection, site_id, site_name, type, format, generate_now = false) ⇒ Object
Build and save a report configuration against the specified site using the supplied type and format.
Returns the new configuration.
296 297 298 299 300 301 302 303 |
# File 'lib/nexpose/report.rb', line 296 def self.build(connection, site_id, site_name, type, format, generate_now = false) name = %Q{#{site_name} #{type} report in #{format}} config = ReportConfig.new(name, type, format) config.generate = Generate.new(true, false) config.filters << Filter.new('site', site_id) config.save(connection, generate_now) config end |
.get(connection, report_config_id) ⇒ Object
Retrieve the configuration for an existing report definition.
288 289 290 |
# File 'lib/nexpose/report.rb', line 288 def self.get(connection, report_config_id) connection.get_report_config(report_config_id) end |
.parse(xml) ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/nexpose/report.rb', line 348 def self.parse(xml) xml.res.elements.each('//ReportConfig') do |cfg| config = ReportConfig.new(cfg.attributes['name'], cfg.attributes['template-id'], cfg.attributes['format'], cfg.attributes['id'], cfg.attributes['owner'], cfg.attributes['timezone']) cfg.elements.each('//description') do |desc| config.description = desc.text end config.filters = Filter.parse(xml) cfg.elements.each('//user') do |user| config.users << user.attributes['id'].to_i end cfg.elements.each('//Baseline') do |baseline| config.baseline = baseline.attributes['compareTo'] end config.generate = Generate.parse(cfg) config.delivery = Delivery.parse(cfg) config.db_export = DBExport.parse(cfg) return config end nil end |
Instance Method Details
#delete(connection) ⇒ Object
Delete this report definition from the Security Console. Deletion will also remove all reports previously generated from the configuration.
324 325 326 |
# File 'lib/nexpose/report.rb', line 324 def delete(connection) connection.delete_report_config(@id) end |
#save(connection, generate_now = false) ⇒ Object
Save the configuration of this report definition.
306 307 308 309 310 311 312 313 314 |
# File 'lib/nexpose/report.rb', line 306 def save(connection, generate_now = false) xml = %Q{<ReportSaveRequest session-id='#{connection.session_id}' generate-now='#{generate_now ? 1 : 0}'>} xml << to_xml xml << '</ReportSaveRequest>' response = connection.execute(xml) if response.success @id = response.attributes['reportcfg-id'] end end |
#to_xml ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/nexpose/report.rb', line 328 def to_xml xml = %Q{<ReportConfig format='#{@format}' id='#{@id}' name='#{@name}' owner='#{@owner}' template-id='#{@template_id}' timezone='#{@time_zone}'>} xml << %Q{<description>#{@description}</description>} if @description xml << '<Filters>' @filters.each { |filter| xml << filter.to_xml } xml << '</Filters>' xml << '<Users>' @users.each { |user| xml << %Q{<user id='#{user}' />} } xml << '</Users>' xml << %Q{<Baseline compareTo='#{@baseline}' />} if @baseline xml << @generate.to_xml if @generate xml << @delivery.to_xml if @delivery xml << @db_export.to_xml if @db_export xml << '</ReportConfig>' end |