Class: ForemanVirtWhoConfigure::Api::V2::ConfigsController

Inherits:
Api::V2::BaseController
  • Object
show all
Includes:
Api::Version2, Concerns::ConfigParameters
Defined in:
app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb

Instance Method Summary collapse

Instance Method Details

#apply_organization_filter(scope) ⇒ Object



87
88
89
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 87

def apply_organization_filter(scope)
  scope.for_organization(Organization.current)
end

#createObject



67
68
69
70
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 67

def create
  @config = Config.new(config_params)
  process_response @config.save
end

#deploy_scriptObject



31
32
33
34
35
36
37
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 31

def deploy_script
  respond_to do |format|
    format.text { send_data @config.virt_who_bash_script, :filename => "deploy_virt_who_config_#{@config.id}.sh", :type => 'text/x-shellscript', :disposition => :attachment }
    format.sh { send_data @config.virt_who_bash_script, :filename => "deploy_virt_who_config_#{@config.id}.sh", :type => 'text/x-shellscript', :disposition => :attachment }
    format.json
  end
end

#destroyObject



83
84
85
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 83

def destroy
  process_response @config.destroy
end

#indexObject



19
20
21
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 19

def index
  @configs = resource_scope_for_index
end

#resource_classObject



95
96
97
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 95

def resource_class
  ForemanVirtWhoConfigure::Config
end

#resource_scope(*args) ⇒ Object



91
92
93
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 91

def resource_scope(*args)
  apply_organization_filter(super)
end

#showObject



26
27
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 26

def show
end

#updateObject



76
77
78
# File 'app/controllers/foreman_virt_who_configure/api/v2/configs_controller.rb', line 76

def update
  process_response @config.update(config_params)
end