Sha256: f766445530c4ca5f2e9bd75a4e3b79f2a6647538031c90bbb91f914079d7e71b

Contents?: true

Size: 1.32 KB

Versions: 23

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Api
  module V2
    class PreupgradeReportsController < ::Api::V2::BaseController
      include ApiAuthorizer

      layout 'api/v2/layouts/index_layout', except: %i[show]

      api :GET, '/preupgrade_reports/', N_('List Preupgrade reports')
      param_group :search_and_pagination, ::Api::V2::BaseController
      def index
        @preupgrade_reports = resource_scope_for_index
      end

      api :GET, '/preupgrade_reports/:id', N_('Show Preupgrade report')
      param :id, :identifier, required: true
      def show
        @preupgrade_report = resource_scope.find(params[:id])
      end

      api :GET, '/job_invocations/:id/preupgrade_reports', N_('List Preupgrade reports for Job invocation')
      param :id, :identifier, required: true
      def job_invocation
        @preupgrade_reports = resource_scope_for_index.where(job_invocation_id: params[:id])
      end

      private

      # By overriding path_to_authenticate we can require REX's permission view_job_invocations
      def path_to_authenticate
        params['action'] = 'show' if params['action'] == 'job_invocation'
        Foreman::AccessControl.normalize_path_hash params.slice(:action, :id, :user_id)
                                                         .merge({ controller: 'api/v2/job_invocations' })
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
foreman_leapp-2.0.1 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-2.0.0 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-1.2.1 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-1.2.0 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.15 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-1.1.1 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-1.1.0 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-1.0.0 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.14 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.13 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.12 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.11 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.10 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.9 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.8 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.7 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.6 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.5 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.4 app/controllers/api/v2/preupgrade_reports_controller.rb
foreman_leapp-0.1.3 app/controllers/api/v2/preupgrade_reports_controller.rb