Class: Api::V2::HostgroupClassesController

Inherits:
BaseController show all
Includes:
TaxonomyScope, Api::Version2
Defined in:
app/controllers/api/v2/hostgroup_classes_controller.rb

Instance Method Summary collapse

Methods included from TaxonomyScope

#set_taxonomy_scope

Methods included from Api::Version2

#api_version

Methods inherited from BaseController

#get_resource, #resource_class, #resource_name, #resource_scope

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#createObject


20
21
22
23
# File 'app/controllers/api/v2/hostgroup_classes_controller.rb', line 20

def create
  @hostgroup_class = HostgroupClass.create!(:hostgroup_id => hostgroup_id, :puppetclass_id => params[:puppetclass_id].to_i)
  render :json => {:hostgroup_id => @hostgroup_class.hostgroup_id, :puppetclass_id => @hostgroup_class.puppetclass_id}
end

#destroyObject


29
30
31
32
# File 'app/controllers/api/v2/hostgroup_classes_controller.rb', line 29

def destroy
  @hostgroup_class = HostgroupClass.where(:hostgroup_id => @hostgroup_id, :puppetclass_id => params[:id])
  process_response @hostgroup_class.destroy_all
end

#indexObject


12
13
14
# File 'app/controllers/api/v2/hostgroup_classes_controller.rb', line 12

def index
  render :json => HostgroupClass.where(:hostgroup_id => hostgroup_id).pluck('puppetclass_id')
end