Class: Api::V2::HostClassesController

Inherits:
BaseController show all
Includes:
TaxonomyScope, Api::Version2
Defined in:
app/controllers/api/v2/host_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/host_classes_controller.rb', line 20

def create
  @host_class = HostClass.create!(:host_id => host_id, :puppetclass_id => params[:puppetclass_id].to_i)
  render :json => {:host_id => @host_class.host_id, :puppetclass_id => @host_class.puppetclass_id}
end

#destroyObject


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

def destroy
  @host_class = HostClass.where(:host_id => host_id, :puppetclass_id => params[:id])
  process_response @host_class.destroy_all
end

#indexObject


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

def index
  render :json => HostClass.where(:host_id => host_id).pluck('puppetclass_id')
end