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

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

60 lines
1.8 KiB
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
module API
class DebianGroupPackages < ::API::Base
2021-10-27 15:23:28 +05:30
PACKAGE_FILE_REQUIREMENTS = ::API::DebianProjectPackages::PACKAGE_FILE_REQUIREMENTS.merge(
project_id: %r{[0-9]+}.freeze
).freeze
2021-01-03 14:25:43 +05:30
2022-08-13 15:12:31 +05:30
before do
not_found! if Gitlab::FIPS.enabled?
end
2021-01-03 14:25:43 +05:30
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
2021-10-27 15:23:28 +05:30
helpers do
def project_or_group
user_group
end
2021-09-04 01:27:46 +05:30
end
2021-10-27 15:23:28 +05:30
after_validation do
2021-03-11 19:13:27 +05:30
require_packages_enabled!
2021-10-27 15:23:28 +05:30
not_found! unless ::Feature.enabled?(:debian_group_packages, user_group)
2021-01-03 14:25:43 +05:30
authorize_read_package!(user_group)
end
2021-10-27 15:23:28 +05:30
params do
2023-03-04 22:38:38 +05:30
requires :id, types: [String, Integer], desc: 'The group ID or full group path.'
2021-10-27 15:23:28 +05:30
end
2021-09-30 23:02:18 +05:30
2021-10-27 15:23:28 +05:30
namespace ':id/-/packages/debian' do
2021-09-04 01:27:46 +05:30
include ::API::Concerns::Packages::DebianPackageEndpoints
2021-10-27 15:23:28 +05:30
2021-12-11 22:18:48 +05:30
# GET groups/:id/-/packages/debian/pool/:distribution/:project_id/:letter/:package_name/:package_version/:file_name
2021-10-27 15:23:28 +05:30
params do
requires :project_id, type: Integer, desc: 'The Project Id'
use :shared_package_file_params
end
2023-03-04 22:38:38 +05:30
desc 'Download Debian package' do
2021-10-27 15:23:28 +05:30
detail 'This feature was introduced in GitLab 14.2'
2023-03-04 22:38:38 +05:30
success code: 200
failure [
{ code: 401, message: 'Unauthorized' },
{ code: 403, message: 'Forbidden' },
{ code: 404, message: 'Not Found' }
]
tags %w[debian_packages]
2021-10-27 15:23:28 +05:30
end
route_setting :authentication, authenticate_non_public: true
get 'pool/:distribution/:project_id/:letter/:package_name/:package_version/:file_name', requirements: PACKAGE_FILE_REQUIREMENTS do
2023-03-17 16:20:25 +05:30
present_distribution_package_file!(find_project!(params[:project_id]))
2021-10-27 15:23:28 +05:30
end
2021-01-03 14:25:43 +05:30
end
end
end
end