Class: Api::V2::JobInvocationsController

Inherits:
BaseController
  • Object
show all
Includes:
TaxonomyScope, Api::Version2, Foreman::Renderer
Defined in:
app/controllers/api/v2/job_invocations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



61
62
63
64
65
66
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 61

def create
  composer = JobInvocationComposer.from_api_params(job_invocation_params)
  composer.trigger!
  @job_invocation = composer.job_invocation
  process_response @job_invocation
end

#indexObject



17
18
19
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 17

def index
  @job_invocations = resource_scope_for_index
end

#outputObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 72

def output
  task = @nested_obj.sub_task_for_host(@host)
  refresh = task.pending?
  since = params[:since].to_f if params[:since].present?

  line_sets = task.main_action.live_output
  line_sets = line_sets.drop_while { |o| o['timestamp'].to_f <= since } if since

  if line_sets.blank?
    render :json => {:refresh => refresh, :output => []}
  else
    render :json => {:refresh => refresh, :output => line_sets }
  end
end

#showObject



23
24
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 23

def show
end