Class: Api::V2::AnsibleOverrideValuesController

Inherits:
BaseController
  • Object
show all
Includes:
Api::Version2, Foreman::Controller::Parameters::AnsibleOverrideValue
Defined in:
app/controllers/api/v2/ansible_override_values_controller.rb

Overview

API controller for Ansible Roles

Instance Method Summary collapse

Methods included from Foreman::Controller::Parameters::AnsibleOverrideValue

#lookup_value_params

Instance Method Details

#createObject



26
27
28
29
30
31
32
# File 'app/controllers/api/v2/ansible_override_values_controller.rb', line 26

def create
  @ansible_variable = AnsibleVariable.authorized(:edit_ansible_variables).
                      find_by(:id => params[:ansible_variable_id].to_i)
  @override_value = @ansible_variable.lookup_values.create!(lookup_value_params['override_value'])
  @ansible_variable.update_attribute(:override, true)
  render 'api/v2/ansible_override_values/show'
end

#destroyObject



37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/api/v2/ansible_override_values_controller.rb', line 37

def destroy
  @override_value = LookupValue.find_by(:id => params[:id])
  if @override_value
    @ansible_variable = AnsibleVariable.where(:id => @override_value.lookup_key_id)
    @override_value.destroy
    render 'api/v2/ansible_override_values/show'
  else
    not_found
  end
end

#resource_nameObject



48
49
50
# File 'app/controllers/api/v2/ansible_override_values_controller.rb', line 48

def resource_name
  'ansible_variable'
end