Class: Api::V2::AnsibleVariablesController

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

Overview

API controller for Ansible Variables

Instance Method Summary collapse

Methods included from Foreman::Controller::Parameters::AnsibleVariable

#ansible_variable_params

Instance Method Details

#createObject



57
58
59
60
# File 'app/controllers/api/v2/ansible_variables_controller.rb', line 57

def create
  @ansible_variable = AnsibleVariable.new(ansible_variable_params.merge(:imported => false))
  process_response @ansible_variable.save
end

#destroyObject



32
33
34
35
# File 'app/controllers/api/v2/ansible_variables_controller.rb', line 32

def destroy
  @ansible_variable.destroy
  render 'api/v2/ansible_variables/destroy'
end

#importObject



75
76
77
78
79
80
# File 'app/controllers/api/v2/ansible_variables_controller.rb', line 75

def import
  Foreman::Deprecation.api_deprecation_warning(_('Use sync instead, to sync roles from Smart Proxy with Ansible feature enabled'))
  new_variables = @importer.import_variable_names([])[:new]
  new_variables.map(&:save)
  @imported = new_variables
end

#indexObject



26
27
28
# File 'app/controllers/api/v2/ansible_variables_controller.rb', line 26

def index
  @ansible_variables = resource_scope_for_index
end

#obsoleteObject



86
87
88
89
90
91
# File 'app/controllers/api/v2/ansible_variables_controller.rb', line 86

def obsolete
  Foreman::Deprecation.api_deprecation_warning(_('Use sync instead, to sync roles from Smart Proxy with Ansible feature enabled'))
  old_variables = @importer.import_variable_names([])[:obsolete]
  old_variables.map(&:destroy)
  @obsoleted = old_variables
end

#showObject



21
# File 'app/controllers/api/v2/ansible_variables_controller.rb', line 21

def show; end

#updateObject



66
67
68
69
# File 'app/controllers/api/v2/ansible_variables_controller.rb', line 66

def update
  @ansible_variable.update!(ansible_variable_params)
  render 'api/v2/ansible_variables/show'
end