Sha256: 80d7156367a94184e06d265990bacc25bdeb4817c832275018e3078b8b76809c

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module Katello
  class Api::V2::GenericContentUnitsController < Api::V2::ApiController
    resource_description do
      name 'Content Units'
      param :content_type, lambda { |val| Katello::RepositoryTypeManager.generic_content_types.include?(val) },
            desc: N_("Possible values: %s") % Katello::RepositoryTypeManager.generic_content_types.join(", "), required: true
    end
    apipie_concern_subst(:a_resource => N_("a content unit"), :resource_id => "content_units")

    Katello::RepositoryTypeManager.generic_content_types(false).each do |type|
      api :GET, "/#{type.pluralize}", N_("List %s" % type.pluralize)
      api :GET, "/#{type.pluralize}/:id", N_("Show %s" % type.gsub(/_/, ' '))
      api :GET, "/repositories/:repository_id/#{type.pluralize}/:id", N_("Show %s" % type.gsub(/_/, ' '))
    end

    include Katello::Concerns::Api::V2::RepositoryContentController

    def default_sort
      %w(name asc)
    end

    def resource_class
      fail "Required param content_type is missing" unless params[:content_type]
      ::Katello::GenericContentUnit.where(content_type: params[:content_type].singularize)
    end

    private

    def repo_association
      :repository_id
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
katello-4.15.0 app/controllers/katello/api/v2/generic_content_units_controller.rb
katello-4.15.0.rc2 app/controllers/katello/api/v2/generic_content_units_controller.rb