2019-08-05 16:00:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class GroupContainerRepositories < ::API::Base
|
2019-08-05 16:00:50 -04:00
|
|
|
include PaginationParams
|
2021-10-11 14:09:46 -04:00
|
|
|
include ::API::Helpers::ContainerRegistryHelpers
|
2019-08-05 16:00:50 -04:00
|
|
|
|
2020-09-30 08:09:53 -04:00
|
|
|
helpers ::API::Helpers::PackagesHelpers
|
|
|
|
|
2019-08-05 16:00:50 -04:00
|
|
|
before { authorize_read_group_container_images! }
|
|
|
|
|
2020-10-29 08:08:50 -04:00
|
|
|
feature_category :package_registry
|
|
|
|
|
2019-08-05 16:00:50 -04:00
|
|
|
REPOSITORY_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(
|
|
|
|
tag_name: API::NO_SLASH_URL_PART_REGEX)
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: "Group's ID or path"
|
|
|
|
end
|
|
|
|
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
|
|
|
desc 'Get a list of all repositories within a group' do
|
|
|
|
detail 'This feature was introduced in GitLab 12.2.'
|
|
|
|
success Entities::ContainerRegistry::Repository
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
optional :tags, type: Boolean, default: false, desc: 'Determines if tags should be included'
|
2020-05-25 17:08:00 -04:00
|
|
|
optional :tags_count, type: Boolean, default: false, desc: 'Determines if the tags count should be included'
|
2019-08-05 16:00:50 -04:00
|
|
|
end
|
|
|
|
get ':id/registry/repositories' do
|
|
|
|
repositories = ContainerRepositoriesFinder.new(
|
2019-11-04 10:07:36 -05:00
|
|
|
user: current_user, subject: user_group
|
2019-08-05 16:00:50 -04:00
|
|
|
).execute
|
|
|
|
|
2021-06-07 08:10:00 -04:00
|
|
|
track_package_event('list_repositories', :container, user: current_user, namespace: user_group)
|
2019-11-12 04:06:14 -05:00
|
|
|
|
2020-05-25 17:08:00 -04:00
|
|
|
present paginate(repositories), with: Entities::ContainerRegistry::Repository, tags: params[:tags], tags_count: params[:tags_count]
|
2019-08-05 16:00:50 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
helpers do
|
|
|
|
def authorize_read_group_container_images!
|
|
|
|
authorize! :read_container_image, user_group
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|