Class: Api::V2::Compliance::ArfReportsController

Inherits:
V2::BaseController
  • Object
show all
Includes:
Api::Version2, Foreman::Controller::SmartProxyAuth, ForemanOpenscap::ArfReportsControllerCommonExtensions
Defined in:
app/controllers/api/v2/compliance/arf_reports_controller.rb

Instance Method Summary collapse

Methods included from ForemanOpenscap::ArfReportsControllerCommonExtensions

#format_filename

Instance Method Details

#createObject



51
52
53
54
55
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 51

def create
  arf_report = ForemanOpenscap::ArfReport.create_arf(@asset, @smart_proxy, params.to_unsafe_h)
  @asset.host.refresh_statuses([HostStatus.find_status_by_humanized_name("compliance")])
  respond_for_report arf_report
end

#destroyObject



42
43
44
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 42

def destroy
  process_response @arf_report.destroy
end

#downloadObject



60
61
62
63
64
65
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 60

def download
  response = @arf_report.to_bzip
  send_data response, :filename => "#{format_filename}.xml.bz2"
rescue => e
  handle_download_error e
end

#download_htmlObject



70
71
72
73
74
75
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 70

def download_html
  response = @arf_report.to_html
  send_data response, :filename => "#{format_filename}.html"
rescue => e
  handle_download_error e
end

#get_resource(message = 'no resource loaded') ⇒ Object



21
22
23
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 21

def get_resource(message = 'no resource loaded')
  instance_variable_get(:"@arf_report") || raise(message)
end

#indexObject



29
30
31
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 29

def index
  @arf_reports = resource_scope_for_index(:permission => :view_arf_reports).includes(:openscap_proxy, :policy, :host)
end

#resource_name(resource = '::ForemanOpenscap::ArfReport') ⇒ Object



17
18
19
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 17

def resource_name(resource = '::ForemanOpenscap::ArfReport')
  super resource
end

#showObject



36
37
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 36

def show
end