Sha256: 3f7f63fa251c14056abd55822bce9078e20c7a03a41621fd3bf58cbe856d1c00

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Api
  module V2
    class TemplateInvocationsController < ::Api::V2::BaseController

      before_action :find_job_invocation, :only => %w{template_invocations}

      api :GET, '/job_invocations/:job_invocation_id/template_invocations',
        N_('List template invocations belonging to job invocation')
      param_group :search_and_pagination, ::Api::V2::BaseController
      param :job_invocation_id, :identifier, :required => true
      def template_invocations
        @template_invocations = resource_scope.paginate(paginate_options)
        render :layout => 'api/v2/layouts/index_layout'
      end

      def resource_scope
        if params[:action] == 'template_invocations'
          resource_scope_for_template_invocations
        else
          super
        end
      end

      private

      def resource_scope_for_template_invocations
        @job_invocation.template_invocations.search_for(*search_options)
      end

      def find_job_invocation
        @job_invocation = JobInvocation.find(params[:id])
      end

      def action_permission
        case params[:action]
        when 'template_invocations'
          :view
        else
          super
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_remote_execution-3.3.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-3.3.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-3.2.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-3.2.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-3.1.0 app/controllers/api/v2/template_invocations_controller.rb