2021-03-08 18:12:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# NuGet Package Manager Client API
|
|
|
|
#
|
|
|
|
# These API endpoints are not meant to be consumed directly by users. They are
|
|
|
|
# called by the NuGet package manager client when users run commands
|
|
|
|
# like `nuget install` or `nuget push`.
|
|
|
|
#
|
|
|
|
# This is the group level API.
|
|
|
|
module API
|
|
|
|
class NugetGroupPackages < ::API::Base
|
|
|
|
helpers ::API::Helpers::PackagesHelpers
|
|
|
|
helpers ::API::Helpers::Packages::BasicAuthHelpers
|
|
|
|
include ::API::Helpers::Authentication
|
|
|
|
|
|
|
|
feature_category :package_registry
|
|
|
|
|
|
|
|
default_format :json
|
|
|
|
|
|
|
|
authenticate_with do |accept|
|
2021-03-11 19:13:27 +05:30
|
|
|
accept.token_types(:personal_access_token_with_username, :deploy_token_with_username, :job_token_with_username)
|
2021-03-08 18:12:59 +05:30
|
|
|
.sent_through(:http_basic_auth)
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue_from ArgumentError do |e|
|
|
|
|
render_api_error!(e.message, 400)
|
|
|
|
end
|
|
|
|
|
|
|
|
after_validation do
|
|
|
|
require_packages_enabled!
|
|
|
|
end
|
|
|
|
|
|
|
|
helpers do
|
|
|
|
def project_or_group
|
|
|
|
find_authorized_group!
|
|
|
|
end
|
|
|
|
|
|
|
|
def require_authenticated!
|
|
|
|
unauthorized! unless current_user
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
def snowplow_gitlab_standard_context
|
|
|
|
{ namespace: find_authorized_group! }
|
|
|
|
end
|
2023-03-17 16:20:25 +05:30
|
|
|
|
|
|
|
def required_permission
|
|
|
|
:read_group
|
|
|
|
end
|
2021-03-08 18:12:59 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
2023-03-04 22:38:38 +05:30
|
|
|
requires :id, types: [Integer, String], desc: 'The group ID or full group path.', regexp: ::API::Concerns::Packages::NugetEndpoints::POSITIVE_INTEGER_REGEX
|
2021-03-08 18:12:59 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
|
|
|
namespace ':id/-/packages/nuget' do
|
|
|
|
after_validation do
|
|
|
|
# This API can't be accessed anonymously
|
|
|
|
require_authenticated!
|
|
|
|
end
|
|
|
|
|
|
|
|
include ::API::Concerns::Packages::NugetEndpoints
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|