Class: ForemanInventoryUpload::TasksController

Inherits:
ApplicationController
  • Object
show all
Includes:
InventoryUpload::TaskActions
Defined in:
app/controllers/foreman_inventory_upload/tasks_controller.rb

Instance Method Summary collapse

Methods included from InventoryUpload::TaskActions

#start_inventory_sync

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/foreman_inventory_upload/tasks_controller.rb', line 5

def create
  selected_org = Organization.current

  task = start_inventory_sync(selected_org)

  render json: {
    task: task,
  }, status: :ok
rescue InventoryUpload::TaskActions::NothingToSyncError => error
  render json: { message: error.message }, status: :internal_server_error
end

#showObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/foreman_inventory_upload/tasks_controller.rb', line 17

def show
  task = ForemanTasks::Task.find_by(id: params[:id])
  return render json: { message: N_('No task was found') }, status: :internal_server_error unless task

  render json: {
    endedAt: task.ended_at,
    output: task.output,
    result: task.result,
  }, status: :ok
end