Sha256: bf536ebae6698e42cae3dab825671670794efaa731379cb7ccc8829645db5223

Contents?: true

Size: 1.36 KB

Versions: 96

Compression:

Stored size: 1.36 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
                       .includes(:host)
                       .where(host: Host.authorized(:view_hosts, Host))
                       .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

96 entries across 96 versions & 1 rubygems

Version Path
foreman_remote_execution-10.0.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-8.3.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-9.1.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-8.2.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-8.2.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-9.0.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-9.0.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-8.1.2 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-8.1.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-8.1.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-7.2.2 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-7.2.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-7.2.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.8 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-8.0.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-7.1.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-7.1.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-7.0.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.7 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.6 app/controllers/api/v2/template_invocations_controller.rb