Class: Api::V1::HostsController

Inherits:
BaseController show all
Defined in:
app/controllers/api/v1/hosts_controller.rb

Direct Known Subclasses

Api::V2::HostsController

Instance Method Summary collapse

Methods included from Api::Version1

#api_version

Methods inherited from BaseController

#get_resource, #resource_class, #resource_name

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#createObject


44
45
46
47
48
49
# File 'app/controllers/api/v1/hosts_controller.rb', line 44

def create
  @host = Host.new(params[:host])
  @host.managed = true if (params[:host] && params[:host][:managed].nil?)
  forward_request_url
  process_response @host.save
end

#destroyObject


81
82
83
# File 'app/controllers/api/v1/hosts_controller.rb', line 81

def destroy
  process_response @host.destroy
end

#indexObject


12
13
14
# File 'app/controllers/api/v1/hosts_controller.rb', line 12

def index
  @hosts = Host.my_hosts.search_for(*search_options).paginate(paginate_options)
end

#resource_scopeObject

we need to limit resources for a current user


105
106
107
# File 'app/controllers/api/v1/hosts_controller.rb', line 105

def resource_scope
  resource_class.my_hosts
end

#showObject


19
20
# File 'app/controllers/api/v1/hosts_controller.rb', line 19

def show
end

#statusObject


100
101
102
# File 'app/controllers/api/v1/hosts_controller.rb', line 100

def status
  render :json => { :status => @host.host_status }.to_json if @host
end

#updateObject


74
75
76
# File 'app/controllers/api/v1/hosts_controller.rb', line 74

def update
  process_response @host.update_attributes(params[:host])
end