Class: Api::V2::HostgroupClassesController

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

Instance Method Summary collapse

Methods included from Api::Version2

#api_version

Methods inherited from BaseController

#append_array_of_ids, #check_content_type, #check_media_type, #metadata_by, #metadata_order, #metadata_page, #metadata_per_page, #metadata_search, #metadata_subtotal, #metadata_total, #render_error, #root_node_name, #setup_has_many_params, skip_before_action

Methods inherited from BaseController

#api_request?, #controller_permission, #get_resource, parameter_filter_context, #parent_scope, #resource_class_join, #resource_scope, #resource_scope_for_index

Methods included from Foreman::Controller::BruteforceProtection

#bruteforce_attempt?

Methods included from ApplicationShared

#current_permission, #find_default_taxonomy, #find_session_taxonomy, #set_current_taxonomy, #set_current_user, #set_taxonomy, #store_default_taxonomy, #store_taxonomy

Methods included from FindCommon

#controller_permission, #find_resource, #resource_class, #resource_class_for, #resource_finder, #resource_name, #resource_scope, #scope_for

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread

Methods included from Foreman::Controller::Timezone

#set_timezone

Methods included from Foreman::Controller::TopbarSweeper

#set_topbar_sweeper_controller

Methods included from Foreman::Controller::Session

#backup_session_content, #expire_session, #ignore_api_request?, #session_expiry, #set_activity_time, #update_activity_time

Methods included from Foreman::Controller::Authentication

#authenticate, #authorized, #available_sso, #check_user_enabled, #is_admin?, #path_to_authenticate, #require_login

Methods included from Foreman::Controller::MigrationChecker

needs_migration?

Instance Method Details

#createObject


18
19
20
21
# File 'app/controllers/api/v2/hostgroup_classes_controller.rb', line 18

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


27
28
29
30
# File 'app/controllers/api/v2/hostgroup_classes_controller.rb', line 27

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

#indexObject


10
11
12
# File 'app/controllers/api/v2/hostgroup_classes_controller.rb', line 10

def index
  render :json => { root_node_name => HostgroupClass.where(:hostgroup_id => @hostgroup.id).pluck('puppetclass_id') }
end