Sha256: acc5c16e79f9d1d268c3e7aa209112f19b18f64091fef2ba14f64e2bcea932ee

Contents?: true

Size: 1.02 KB

Versions: 76

Compression:

Stored size: 1.02 KB

Contents

module Katello
  module Concerns
    module Api::V2::BulkExtensions
      extend ActiveSupport::Concern

      def find_bulk_items(bulk_params:, model_scope:, key: :id)
        if bulk_params.is_a?(String)
          bulk_params = ActiveSupport::JSON.decode(bulk_params).
                        deep_symbolize_keys
        end
        bulk_params[:included] ||= {}
        bulk_params[:excluded] ||= {}

        if (!bulk_params[:all]) &&
            bulk_params[:included][:ids].blank? &&
            bulk_params[:included][:search].blank?
          fail HttpErrors::BadRequest, _("No items have been specified.")
        end

        if bulk_params[:all] && !bulk_params[:included][:ids].blank?
          fail HttpErrors::BadRequest, _("Sending a list of included IDs is not allowed when all items are being selected.")
        end

        ::Katello::BulkItemsHelper.new(bulk_params: bulk_params,
                                       model_scope: model_scope,
                                       key: key).fetch
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
katello-4.16.0 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.15.1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.16.0.rc2 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.16.0.rc1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.3 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.2 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.15.0 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.15.0.rc2 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.15.0.rc1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.0 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.0.rc3 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.0.rc2 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.0.rc1.1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.14.0.rc1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.13.1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.13.0 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.12.1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.13.0.rc1 app/controllers/katello/concerns/api/v2/bulk_extensions.rb
katello-4.12.0 app/controllers/katello/concerns/api/v2/bulk_extensions.rb