Sha256: bf536ebae6698e42cae3dab825671670794efaa731379cb7ccc8829645db5223

Contents?: true

Size: 1.36 KB

Versions: 95

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

95 entries across 95 versions & 1 rubygems

Version Path
foreman_remote_execution-5.0.5 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-6.1.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.4 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.3 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-6.0.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.2 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.1.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-5.0.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.8.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.5.6 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.5.5 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.5.4 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.7.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.5.3 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.5.2 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.5.1 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.6.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.5.0 app/controllers/api/v2/template_invocations_controller.rb
foreman_remote_execution-4.4.0 app/controllers/api/v2/template_invocations_controller.rb