Sha256: d2e3e01c10a6b83c773c44e5ee7fe496d0e5486ca2aacb357e5d779deb8a82b7

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

module Katello
  class Api::V2::DockerTagsController < Api::V2::ApiController
    apipie_concern_subst(:a_resource => N_("a docker tag"), :resource => "docker_tags")
    include Katello::Concerns::Api::V2::RepositoryContentController

    before_action :find_repositories, :only => [:auto_complete_name]

    def auto_complete_name
      page_size = Katello::Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
      tags = Katello::DockerMetaTag.in_repositories(@repositories)
      col = "#{Katello::DockerMetaTag.table_name}.name"
      tags = tags.where("#{Katello::DockerTag.table_name}.name ILIKE ?", "#{params[:term]}%").select(col).group(col).order(col).limit(page_size)
      render :json => tags.pluck(col)
    end

    def index
      if params[:grouped]
        # group docker tags by name, repo, and product
        repos = Repository.readable
        repos = repos.in_organization(@organization) if @organization
        collection = Katello::DockerMetaTag.in_repositories(repos, true)
        respond(:collection => scoped_search(collection, "name", "DESC"))
      else
        super
      end
    end

    private

    def find_repositories
      @repositories = Repository.readable.where(:id => params[:repoids])
    end

    def resource_class
      DockerMetaTag
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
katello-3.5.0.1 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.5.0 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.5.0.rc2 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.5.0.rc1 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.5 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.4 app/controllers/katello/api/v2/docker_tags_controller.rb