Class: Api::V2::Compliance::OvalPoliciesController

Inherits:
BaseController
  • Object
show all
Includes:
Foreman::Controller::Parameters::OvalPolicy, Foreman::Controller::SmartProxyAuth, ForemanOpenscap::Api::V2::ScapApiControllerExtensions
Defined in:
app/controllers/api/v2/compliance/oval_policies_controller.rb

Instance Method Summary collapse

Instance Method Details

#action_permissionObject



88
89
90
91
92
93
94
95
96
97
# File 'app/controllers/api/v2/compliance/oval_policies_controller.rb', line 88

def action_permission
  case params[:action]
  when 'assign_hostgroups', 'assign_hosts'
    :edit
  when 'oval_content'
    :show
  else
    super
  end
end

#assign_hostgroupsObject



66
67
68
# File 'app/controllers/api/v2/compliance/oval_policies_controller.rb', line 66

def assign_hostgroups
  assign _('hostgroups'), params["hostgroup_ids"], ::Hostgroup
end

#assign_hostsObject



74
75
76
# File 'app/controllers/api/v2/compliance/oval_policies_controller.rb', line 74

def assign_hosts
  assign _('hosts'), params["host_ids"], ::Host::Managed
end

#createObject



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

def create
  @oval_policy = ForemanOpenscap::OvalPolicy.new(oval_policy_params)
  process_response(@oval_policy.save)
end

#destroyObject



58
59
60
# File 'app/controllers/api/v2/compliance/oval_policies_controller.rb', line 58

def destroy
  process_response @oval_policy.destroy
end

#indexObject



16
17
18
# File 'app/controllers/api/v2/compliance/oval_policies_controller.rb', line 16

def index
  @oval_policies = resource_scope_for_index(:permission => :view_oval_policies)
end

#oval_contentObject



81
82
83
84
85
86
# File 'app/controllers/api/v2/compliance/oval_policies_controller.rb', line 81

def oval_content
  @oval_content = @oval_policy.oval_content
  send_data @oval_content.scap_file,
            :type => 'application/x-bzip2',
            :filename => @oval_content.original_filename
end

#showObject



23
24
# File 'app/controllers/api/v2/compliance/oval_policies_controller.rb', line 23

def show
end

#updateObject



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

def update
  process_response(@oval_policy.update(oval_policy_params))
end