Class: Api::V2::Compliance::PoliciesController
- Inherits:
-
BaseController
- Object
- BaseController
- Api::V2::Compliance::PoliciesController
- Includes:
- Foreman::Controller::Parameters::PolicyApi, Foreman::Controller::SmartProxyAuth, ForemanOpenscap::Api::V2::ScapApiControllerExtensions
- Defined in:
- app/controllers/api/v2/compliance/policies_controller.rb
Instance Method Summary collapse
- #content ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #policy_url(policy = nil) ⇒ Object
- #show ⇒ Object
- #tailoring ⇒ Object
- #update ⇒ Object
Instance Method Details
#content ⇒ Object
78 79 80 81 82 83 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 78 def content @scap_content = @policy.scap_content send_data @scap_content.scap_file, :type => 'application/xml', :filename => @scap_content.original_filename end |
#create ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 54 def create @policy = ForemanOpenscap::Policy.new(policy_params) ForemanOpenscap::LookupKeyOverrider.new(@policy).override process_response(@policy.errors.none? && @policy.save) end |
#destroy ⇒ Object
71 72 73 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 71 def destroy process_response @policy.destroy end |
#index ⇒ Object
22 23 24 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 22 def index @policies = resource_scope_for_index(:permission => :view_policies) end |
#policy_url(policy = nil) ⇒ Object
14 15 16 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 14 def policy_url(policy = nil) api_compliance_policy_url(@policy) end |
#show ⇒ Object
29 30 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 29 def show end |
#tailoring ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 88 def tailoring @tailoring_file = @policy.tailoring_file if @tailoring_file send_data @tailoring_file.scap_file, :type => 'application/xml', :filename => @tailoring_file.original_filename else render(:json => { :error => { :message => _("No Tailoring file assigned for policy with id %s") % @policy.id } }, :status => 404) end end |
#update ⇒ Object
64 65 66 |
# File 'app/controllers/api/v2/compliance/policies_controller.rb', line 64 def update process_response(@policy.change_deploy_type(policy_params)) end |