Class: ForemanPatch::Api::V2::InvocationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/foreman_patch/api/v2/invocations_controller.rb

Instance Method Summary collapse

Instance Method Details

#cancelObject



55
56
57
58
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 55

def cancel
  @invocations = ForemanPatch::Invocation.where(id: params[:ids])
  @invocations.update_all(status: 'cancelled')          
end

#destroyObject



62
63
64
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 62

def destroy
  process_response @invocation.destroy
end

#indexObject



19
20
21
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 19

def index
  @invocations = resource_scope_for_index
end

#moveObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 40

def move
  @invocations = ForemanPatch::Invocation.where(id: params[:ids])

  @errors = []
  @invocations.each do |invocation|
    round = invocation.round.cycle.rounds.find(params[:round_id])
    invocation.update(round: round)
  rescue
  end

  @invocations = ForemanPatch::Invocation.where(id: params[:ids], round_id: params[:round_id])
end

#resource_classObject



66
67
68
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 66

def resource_class
  ForemanPatch::Invocation
end

#resource_scope(options = {}) ⇒ Object



70
71
72
73
74
75
76
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 70

def resource_scope(options = {})
  if action_name == 'index'
    @round.invocations.includes(:host).where(host: ::Host.authorized(:view_hosts, ::Host))
  else
    super(options)
  end
end

#showObject



25
26
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 25

def show
end

#updateObject



33
34
35
# File 'app/controllers/foreman_patch/api/v2/invocations_controller.rb', line 33

def update
  process_response @invocation.update(invocation_params)
end