Class: Api::V2::ForemanDatacenter::DevicesController

Inherits:
BaseController
  • Object
show all
Includes:
ForemanDatacenter::Controller::Parameters::Device
Defined in:
app/controllers/api/v2/foreman_datacenter/devices_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

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

Instance Method Details

#createObject



49
50
51
52
# File 'app/controllers/api/v2/foreman_datacenter/devices_controller.rb', line 49

def create
  @device = ::ForemanDatacenter::Device.new(device_params.merge(host_id: params[:host_id]))
  process_response @device.save
end

#destroyObject



65
66
67
# File 'app/controllers/api/v2/foreman_datacenter/devices_controller.rb', line 65

def destroy
  process_response @device.destroy
end

#destroy_interfacesObject



72
73
74
75
76
# File 'app/controllers/api/v2/foreman_datacenter/devices_controller.rb', line 72

def destroy_interfaces
  @device.non_management_interfaces.
    where(id: params[:interfaces]).
    destroy_all
end

#indexObject



15
16
17
# File 'app/controllers/api/v2/foreman_datacenter/devices_controller.rb', line 15

def index
  @devices = resource_scope_for_index
end

#showObject



22
23
# File 'app/controllers/api/v2/foreman_datacenter/devices_controller.rb', line 22

def show
end

#sync_interfaces_with_hostObject



81
82
83
# File 'app/controllers/api/v2/foreman_datacenter/devices_controller.rb', line 81

def sync_interfaces_with_host
  @device.sync_interfaces_with_host
end

#updateObject



58
59
60
# File 'app/controllers/api/v2/foreman_datacenter/devices_controller.rb', line 58

def update
  process_response @device.update(device_params)
end