Class: Api::V2::JobInvocationsController
- Inherits:
-
BaseController
- Object
- BaseController
- Api::V2::JobInvocationsController
- Includes:
- Api::Version2, Foreman::Renderer
- Defined in:
- app/controllers/api/v2/job_invocations_controller.rb
Instance Method Summary collapse
- #cancel ⇒ Object
- #create ⇒ Object
- #index ⇒ Object
- #output ⇒ Object
- #raw_output ⇒ Object
- #rerun ⇒ Object
- #show ⇒ Object
Instance Method Details
#cancel ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 108 def cancel if @job_invocation.task.cancellable? result = @job_invocation.cancel(params.fetch('force', false)) render :json => { :cancelled => result, :id => @job_invocation.id } else render :json => { :message => _('The job could not be cancelled.') }, :status => :unprocessable_entity end end |
#create ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 66 def create if job_invocation_params[:feature].present? composer = composer_for_feature else validate_template composer = JobInvocationComposer.from_api_params( job_invocation_params ) end composer.trigger! @job_invocation = composer.job_invocation process_response @job_invocation end |
#index ⇒ Object
15 16 17 |
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 15 def index @job_invocations = resource_scope_for_index end |
#output ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 84 def output if @nested_obj.task.scheduled? render :json => delayed_task_output(@nested_obj.task, :default => []) return end render :json => host_output(@nested_obj, @host, :default => [], :since => params[:since]) end |
#raw_output ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 96 def raw_output if @nested_obj.task.scheduled? render :json => delayed_task_output(@nested_obj.task) return end render :json => host_output(@nested_obj, @host, :raw => true) end |
#rerun ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 121 def rerun composer = JobInvocationComposer.from_job_invocation(@job_invocation, params) if composer.rerun_possible? composer.trigger! @job_invocation = composer.job_invocation process_response @job_invocation else render :json => { :error => _('Could not rerun job %{id} because its template could not be found') % { :id => composer.reruns } }, :status => :not_found end end |
#show ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/api/v2/job_invocations_controller.rb', line 21 def show @hosts = @job_invocation.targeting.hosts.(:view_hosts, Host) @template_invocations = @job_invocation.template_invocations .where(host: @hosts) .includes(:input_values) end |