Sha256: 021f8e2b8410b4eea381ed7309022c311a8cce639b7df2bd318081070097aa8e

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 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::DockerTag.in_repositories(@repositories)
      col = "#{Katello::DockerTag.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::DockerTag.in_repositories(repos).grouped

        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
      DockerTag
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
katello-3.4.2 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.1 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.0.2 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.0.1 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.0 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.0.rc2 app/controllers/katello/api/v2/docker_tags_controller.rb
katello-3.4.0.rc1 app/controllers/katello/api/v2/docker_tags_controller.rb