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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
2.5 KiB
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module API
2021-01-03 14:25:43 +05:30
class GroupPackages < ::API::Base
2020-07-28 23:09:34 +05:30
include PaginationParams
before do
authorize_packages_access!(user_group)
end
2021-01-29 00:20:46 +05:30
feature_category :package_registry
2022-07-16 23:28:13 +05:30
urgency :low
2021-01-29 00:20:46 +05:30
2020-07-28 23:09:34 +05:30
helpers ::API::Helpers::PackagesHelpers
params do
2023-01-13 00:05:48 +05:30
requires :id, types: [String, Integer], desc: 'ID or URL-encoded path of the group'
2020-07-28 23:09:34 +05:30
optional :exclude_subgroups, type: Boolean, default: false, desc: 'Determines if subgroups should be excluded'
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
2023-01-13 00:05:48 +05:30
desc 'List packages within a group' do
detail 'Get a list of project packages at the group level. This feature was introduced in GitLab 12.5'
2020-07-28 23:09:34 +05:30
success ::API::Entities::Package
2023-01-13 00:05:48 +05:30
failure [
{ code: 401, message: 'Unauthorized' },
{ code: 404, message: 'Group Not Found' }
]
is_array true
tags %w[group_packages]
2020-07-28 23:09:34 +05:30
end
params do
use :pagination
2022-08-27 11:52:29 +05:30
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'
optional :include_versionless,
type: Boolean,
desc: 'Returns packages without a version'
optional :status,
type: String,
values: Packages::Package.statuses.keys,
2021-03-11 19:13:27 +05:30
desc: 'Return packages with specified status'
2020-07-28 23:09:34 +05:30
end
get ':id/packages' do
packages = Packages::GroupPackagesFinder.new(
current_user,
user_group,
2023-01-13 00:05:48 +05:30
declared(params).slice(
:exclude_subgroups, :order_by, :sort, :package_type, :package_name, :include_versionless, :status
)
2020-07-28 23:09:34 +05:30
).execute
2023-01-13 00:05:48 +05:30
present paginate(packages), with: ::API::Entities::Package, user: current_user, group: true,
namespace: user_group
2020-07-28 23:09:34 +05:30
end
end
end
end