Class: Api::V2::ForemanDatacenter::PowerOutletsController

Inherits:
BaseController
  • Object
show all
Includes:
ForemanDatacenter::Controller::Parameters::PowerOutlet
Defined in:
app/controllers/api/v2/foreman_datacenter/power_outlets_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

#connectObject



59
60
61
62
63
64
65
# File 'app/controllers/api/v2/foreman_datacenter/power_outlets_controller.rb', line 59

def connect
  power_port = ::ForemanDatacenter::PowerPort.find(params[:power_port_id])
  power_port.connect(
    @power_outlet,
    params[:connection_status]
  )
end

#createObject



33
34
35
36
# File 'app/controllers/api/v2/foreman_datacenter/power_outlets_controller.rb', line 33

def create
  @power_outlet = ::ForemanDatacenter::PowerOutlet.new(power_outlet_params)
  process_response @power_outlet.save
end

#destroyObject



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

def destroy
  process_response @power_outlet.destroy
end

#disconnectObject



71
72
73
# File 'app/controllers/api/v2/foreman_datacenter/power_outlets_controller.rb', line 71

def disconnect
  process_response @power_outlet.power_port.disconnect
end

#indexObject



13
14
15
# File 'app/controllers/api/v2/foreman_datacenter/power_outlets_controller.rb', line 13

def index
  @power_outlets = resource_scope_for_index
end

#showObject



20
21
# File 'app/controllers/api/v2/foreman_datacenter/power_outlets_controller.rb', line 20

def show
end

#updateObject



42
43
44
# File 'app/controllers/api/v2/foreman_datacenter/power_outlets_controller.rb', line 42

def update
  process_response @power_outlet.update(power_outlet_params)
end