2020-07-17 02:09:11 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class GroupPackages < ::API::Base
|
2020-07-17 02:09:11 -04:00
|
|
|
include PaginationParams
|
|
|
|
|
|
|
|
before do
|
|
|
|
authorize_packages_access!(user_group)
|
|
|
|
end
|
|
|
|
|
2020-10-30 11:08:59 -04:00
|
|
|
feature_category :package_registry
|
2022-05-06 17:08:35 -04:00
|
|
|
urgency :low
|
2020-10-30 11:08:59 -04:00
|
|
|
|
2020-07-17 02:09:11 -04:00
|
|
|
helpers ::API::Helpers::PackagesHelpers
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: "Group's ID or path"
|
|
|
|
optional :exclude_subgroups, type: Boolean, default: false, desc: 'Determines if subgroups should be excluded'
|
|
|
|
end
|
|
|
|
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
|
|
|
desc 'Get all project packages within a group' do
|
|
|
|
detail 'This feature was introduced in GitLab 12.5'
|
|
|
|
success ::API::Entities::Package
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
optional :order_by, type: String, values: %w[created_at name version type project_path], default: 'created_at',
|
|
|
|
desc: 'Return packages ordered by `created_at`, `name`, `version` or `type` fields.'
|
|
|
|
optional :sort, type: String, values: %w[asc desc], default: 'asc',
|
|
|
|
desc: 'Return packages sorted in `asc` or `desc` order.'
|
|
|
|
optional :package_type, type: String, values: Packages::Package.package_types.keys,
|
|
|
|
desc: 'Return packages of a certain type'
|
|
|
|
optional :package_name, type: String,
|
|
|
|
desc: 'Return packages with this name'
|
2021-01-06 16:10:18 -05:00
|
|
|
optional :include_versionless, type: Boolean,
|
|
|
|
desc: 'Returns packages without a version'
|
2021-02-17 07:09:26 -05:00
|
|
|
optional :status, type: String, values: Packages::Package.statuses.keys,
|
|
|
|
desc: 'Return packages with specified status'
|
2020-07-17 02:09:11 -04:00
|
|
|
end
|
|
|
|
get ':id/packages' do
|
|
|
|
packages = Packages::GroupPackagesFinder.new(
|
|
|
|
current_user,
|
|
|
|
user_group,
|
2021-02-17 07:09:26 -05:00
|
|
|
declared(params).slice(:exclude_subgroups, :order_by, :sort, :package_type, :package_name, :include_versionless, :status)
|
2020-07-17 02:09:11 -04:00
|
|
|
).execute
|
|
|
|
|
2021-06-25 08:07:44 -04:00
|
|
|
present paginate(packages), with: ::API::Entities::Package, user: current_user, group: true, namespace: user_group
|
2020-07-17 02:09:11 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|