Class: Api::V2::HostClassesController

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

Instance Method Summary collapse

Methods included from Api::Version2

#api_version

Methods inherited from BaseController

#append_array_of_ids, #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

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, #scope_by_resource_id, #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


19
20
21
22
# File 'app/controllers/api/v2/host_classes_controller.rb', line 19

def create
  @host_class = HostClass.create!(:host_id => @host.id, :puppetclass_id => @puppetclass.id)
  render :json => {:host_id => @host_class.host_id, :puppetclass_id => @host_class.puppetclass_id}
end

#destroyObject


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

def destroy
  @host_class = HostClass.authorized(:edit_classes).where(:host_id => @host.id, :puppetclass_id => @puppetclass.id)
  process_response @host_class.destroy_all
end

#indexObject


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

def index
  render :json => { root_node_name => HostClass.authorized(:edit_classes).where(:host_id => @host.id).pluck('puppetclass_id') }
end