debian-mirror-gitlab/lib/api/container_repositories.rb

56 lines
1.7 KiB
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
module API
class ContainerRepositories < ::API::Base
include Gitlab::Utils::StrongMemoize
2021-11-18 22:05:49 +05:30
include ::API::Helpers::ContainerRegistryHelpers
2021-01-29 00:20:46 +05:30
helpers ::API::Helpers::PackagesHelpers
before { authenticate! }
feature_category :container_registry
2022-07-16 23:28:13 +05:30
urgency :low
2021-01-29 00:20:46 +05:30
namespace 'registry' do
params do
2023-06-09 08:11:10 +05:30
requires :id, types: [String, Integer], desc: 'The ID of the repository'
2021-01-29 00:20:46 +05:30
end
resource :repositories, requirements: { id: /[0-9]*/ } do
desc 'Get a container repository' do
detail 'This feature was introduced in GitLab 13.6.'
success Entities::ContainerRegistry::Repository
2023-06-09 08:11:10 +05:30
failure [
{ code: 401, message: 'Unauthorized' },
{ code: 404, message: 'Repository Not Found' }
]
tags %w[container_registry]
2021-01-29 00:20:46 +05:30
end
params do
optional :tags, type: Boolean, default: false, desc: 'Determines if tags should be included'
optional :tags_count, type: Boolean, default: false, desc: 'Determines if the tags count should be included'
2022-05-07 20:08:51 +05:30
optional :size, type: Boolean, default: false, desc: 'Determines if the size should be included'
2021-01-29 00:20:46 +05:30
end
get ':id' do
authorize!(:read_container_image, repository)
2022-05-07 20:08:51 +05:30
present repository,
with: Entities::ContainerRegistry::Repository,
tags: params[:tags],
tags_count: params[:tags_count],
size: params[:size],
user: current_user
2021-01-29 00:20:46 +05:30
end
end
end
helpers do
def repository
strong_memoize(:repository) do
ContainerRepository.find(params[:id])
end
end
end
end
end