2020-12-29 07:10:19 -05:00
|
|
|
# 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
|
2021-01-01 10:10:11 -05:00
|
|
|
helpers ::API::Helpers::PackagesHelpers
|
2020-12-29 07:10:19 -05:00
|
|
|
helpers ::API::Helpers::Packages::BasicAuthHelpers
|
2021-01-01 10:10:11 -05:00
|
|
|
include ::API::Helpers::Authentication
|
2020-12-29 07:10:19 -05:00
|
|
|
|
|
|
|
feature_category :package_registry
|
|
|
|
|
|
|
|
default_format :json
|
|
|
|
|
2021-01-01 10:10:11 -05:00
|
|
|
authenticate_with do |accept|
|
|
|
|
accept.token_types(:personal_access_token, :deploy_token, :job_token)
|
|
|
|
.sent_through(:http_basic_auth)
|
|
|
|
end
|
|
|
|
|
2020-12-29 07:10:19 -05:00
|
|
|
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
|
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a group', regexp: ::API::Concerns::Packages::NugetEndpoints::POSITIVE_INTEGER_REGEX
|
|
|
|
end
|
|
|
|
|
|
|
|
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
2021-01-14 13:10:59 -05:00
|
|
|
namespace ':id/-/packages/nuget' do
|
2020-12-29 07:10:19 -05:00
|
|
|
after_validation do
|
|
|
|
# This API can't be accessed anonymously
|
|
|
|
require_authenticated!
|
|
|
|
end
|
|
|
|
|
|
|
|
include ::API::Concerns::Packages::NugetEndpoints
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|