Fix API::Namespaces to accept namepaces with dots
It also renames the API::PROJECT_ENDPOINT_REQUIREMENTS constant to API::NAMESPACE_OR_PROJECT_REQUIREMENTS
This commit is contained in:
parent
1cd570cf77
commit
b1e070bf49
52 changed files with 68 additions and 63 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix API::Namespaces routing to accept namepaces with dots
|
||||
merge_request: 22912
|
||||
author:
|
||||
type: fixed
|
|
@ -511,7 +511,7 @@ module EE
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
# ...
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "The #{source_type} ID"
|
||||
end
|
||||
resource source_type.pluralize, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Gets a list of access requests for a #{source_type}." do
|
||||
detail 'This feature was introduced in GitLab 8.11.'
|
||||
success Entities::AccessRequester
|
||||
|
|
|
@ -7,8 +7,8 @@ module API
|
|||
LOG_FILENAME = Rails.root.join("log", "api_json.log")
|
||||
|
||||
NO_SLASH_URL_PART_REGEX = %r{[^/]+}
|
||||
PROJECT_ENDPOINT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
|
||||
COMMIT_ENDPOINT_REQUIREMENTS = PROJECT_ENDPOINT_REQUIREMENTS.merge(sha: NO_SLASH_URL_PART_REGEX).freeze
|
||||
NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
|
||||
COMMIT_ENDPOINT_REQUIREMENTS = NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(sha: NO_SLASH_URL_PART_REGEX).freeze
|
||||
|
||||
insert_before Grape::Middleware::Error,
|
||||
GrapeLogging::Middleware::RequestLogger,
|
||||
|
|
|
@ -14,7 +14,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
AWARDABLES.each do |awardable_params|
|
||||
awardable_string = awardable_params[:type].pluralize
|
||||
awardable_id_string = "#{awardable_params[:type]}_#{awardable_params[:find_by]}"
|
||||
|
|
|
@ -22,7 +22,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "The ID of a #{source_type}"
|
||||
end
|
||||
resource source_type.pluralize, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Gets a list of #{source_type} badges viewable by the authenticated user." do
|
||||
detail 'This feature was introduced in GitLab 10.6.'
|
||||
success Entities::Badge
|
||||
|
|
|
@ -16,7 +16,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
segment ':id/boards' do
|
||||
desc 'Get all project boards' do
|
||||
detail 'This feature was introduced in 8.13'
|
||||
|
|
|
@ -6,7 +6,7 @@ module API
|
|||
class Branches < Grape::API
|
||||
include PaginationParams
|
||||
|
||||
BRANCH_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(branch: API::NO_SLASH_URL_PART_REGEX)
|
||||
BRANCH_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(branch: API::NO_SLASH_URL_PART_REGEX)
|
||||
|
||||
before { authorize! :download_code, user_project }
|
||||
|
||||
|
@ -20,7 +20,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a project repository branches' do
|
||||
success Entities::Branch
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
include PaginationParams
|
||||
|
||||
before { authenticate! }
|
||||
|
|
|
@ -23,7 +23,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a project repository commits' do
|
||||
success Entities::Commit
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of the project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
before { authorize_admin_project }
|
||||
|
||||
desc "Get a specific project's deploy keys" do
|
||||
|
|
|
@ -10,7 +10,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The project ID'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get all deployments of the project' do
|
||||
detail 'This feature was introduced in GitLab 8.11.'
|
||||
success Entities::Deployment
|
||||
|
|
|
@ -17,7 +17,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "The ID of a #{parent_type}"
|
||||
end
|
||||
resource parent_type.pluralize.to_sym, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource parent_type.pluralize.to_sym, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Get a list of #{noteable_type.to_s.downcase} discussions" do
|
||||
success Entities::Discussion
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The project ID'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get all environments of the project' do
|
||||
detail 'This feature was introduced in GitLab 8.11.'
|
||||
success Entities::Environment
|
||||
|
|
|
@ -97,7 +97,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "List a Project's visible events" do
|
||||
success Entities::Event
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module API
|
||||
class Files < Grape::API
|
||||
FILE_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(file_path: API::NO_SLASH_URL_PART_REGEX)
|
||||
FILE_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(file_path: API::NO_SLASH_URL_PART_REGEX)
|
||||
|
||||
# Prevents returning plain/text responses for files with .txt extension
|
||||
after_validation { content_type "application/json" }
|
||||
|
|
|
@ -19,7 +19,7 @@ module API
|
|||
requires :id, type: String, desc: 'The ID of a group'
|
||||
end
|
||||
|
||||
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
segment ':id/boards' do
|
||||
desc 'Find a group board' do
|
||||
detail 'This feature was introduced in 10.6'
|
||||
|
|
|
@ -12,7 +12,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a group'
|
||||
end
|
||||
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a list of group milestones' do
|
||||
success Entities::Milestone
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ module API
|
|||
requires :id, type: String, desc: 'The ID of a group'
|
||||
end
|
||||
|
||||
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get group-level variables' do
|
||||
success Entities::Variable
|
||||
end
|
||||
|
|
|
@ -140,7 +140,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a group'
|
||||
end
|
||||
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Update a group. Available only for users who can administrate groups.' do
|
||||
success Entities::Group
|
||||
end
|
||||
|
|
|
@ -101,7 +101,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a group'
|
||||
end
|
||||
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a list of group issues' do
|
||||
success Entities::IssueBasic
|
||||
end
|
||||
|
@ -128,7 +128,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
include TimeTrackingEndpoints
|
||||
|
||||
desc 'Get a list of project issues' do
|
||||
|
|
|
@ -14,7 +14,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Download the artifacts archive from a job' do
|
||||
detail 'This feature was introduced in GitLab 8.10'
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
helpers do
|
||||
params :optional_scope do
|
||||
optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show',
|
||||
|
|
|
@ -9,7 +9,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get all labels of the project' do
|
||||
success Entities::Label
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "The #{source_type} ID"
|
||||
end
|
||||
resource source_type.pluralize, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Gets a list of group or project members viewable by the authenticated user.' do
|
||||
success Entities::Member
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a list of merge request diff versions' do
|
||||
detail 'This feature was introduced in GitLab 8.12.'
|
||||
success Entities::MergeRequestDiff
|
||||
|
|
|
@ -122,7 +122,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a group'
|
||||
end
|
||||
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a list of group merge requests' do
|
||||
success Entities::MergeRequestBasic
|
||||
end
|
||||
|
@ -141,7 +141,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
include TimeTrackingEndpoints
|
||||
|
||||
helpers do
|
||||
|
|
|
@ -28,7 +28,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "Namespace's ID or path"
|
||||
end
|
||||
get ':id' do
|
||||
get ':id', requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
present user_namespace, with: Entities::Namespace, current_user: current_user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "The ID of a #{parent_type}"
|
||||
end
|
||||
resource parent_type.pluralize.to_sym, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource parent_type.pluralize.to_sym, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
noteables_str = noteable_type.to_s.underscore.pluralize
|
||||
|
||||
desc "Get a list of #{noteable_type.to_s.downcase} notes" do
|
||||
|
|
|
@ -58,7 +58,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "The #{source_type} ID"
|
||||
end
|
||||
resource source_type.pluralize, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Get #{source_type} level notification level settings, defaults to Global" do
|
||||
detail 'This feature was introduced in GitLab 8.12'
|
||||
success Entities::NotificationSetting
|
||||
|
|
|
@ -4,7 +4,7 @@ module API
|
|||
class PagesDomains < Grape::API
|
||||
include PaginationParams
|
||||
|
||||
PAGES_DOMAINS_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(domain: API::NO_SLASH_URL_PART_REGEX)
|
||||
PAGES_DOMAINS_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(domain: API::NO_SLASH_URL_PART_REGEX)
|
||||
|
||||
before do
|
||||
authenticate!
|
||||
|
@ -54,7 +54,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
before do
|
||||
require_pages_enabled!
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get all pipeline schedules' do
|
||||
success Entities::PipelineSchedule
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The project ID'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get all Pipelines of the project' do
|
||||
detail 'This feature was introduced in GitLab 8.11.'
|
||||
success Entities::PipelineBasic
|
||||
|
|
|
@ -29,7 +29,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get project hooks' do
|
||||
success Entities::ProjectHook
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ module API
|
|||
forbidden! unless Gitlab::CurrentSettings.import_sources.include?('gitlab_project')
|
||||
end
|
||||
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
params do
|
||||
requires :path, type: String, desc: 'The new project path and name'
|
||||
requires :file, type: File, desc: 'The project export file to be imported'
|
||||
|
|
|
@ -12,7 +12,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a list of project milestones' do
|
||||
success Entities::Milestone
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
helpers do
|
||||
def handle_project_member_errors(errors)
|
||||
if errors[:project_access].any?
|
||||
|
|
|
@ -128,7 +128,7 @@ module API
|
|||
end
|
||||
end
|
||||
|
||||
resource :users, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :users, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a user projects' do
|
||||
success Entities::BasicProjectDetails
|
||||
end
|
||||
|
@ -224,7 +224,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a single project' do
|
||||
success Entities::ProjectWithAccess
|
||||
end
|
||||
|
|
|
@ -4,14 +4,14 @@ module API
|
|||
class ProtectedBranches < Grape::API
|
||||
include PaginationParams
|
||||
|
||||
BRANCH_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(name: API::NO_SLASH_URL_PART_REGEX)
|
||||
BRANCH_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(name: API::NO_SLASH_URL_PART_REGEX)
|
||||
|
||||
before { authorize_admin_project }
|
||||
|
||||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Get a project's protected branches" do
|
||||
success Entities::ProtectedBranch
|
||||
end
|
||||
|
|
|
@ -4,14 +4,14 @@ module API
|
|||
class ProtectedTags < Grape::API
|
||||
include PaginationParams
|
||||
|
||||
TAG_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(name: API::NO_SLASH_URL_PART_REGEX)
|
||||
TAG_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(name: API::NO_SLASH_URL_PART_REGEX)
|
||||
|
||||
before { authorize_admin_project }
|
||||
|
||||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Get a project's protected tags" do
|
||||
detail 'This feature was introduced in GitLab 11.3.'
|
||||
success Entities::ProtectedTag
|
||||
|
|
|
@ -11,7 +11,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
helpers do
|
||||
def handle_project_member_errors(errors)
|
||||
if errors[:project_access].any?
|
||||
|
|
|
@ -16,7 +16,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: "The ID of a #{parent_type}"
|
||||
end
|
||||
resource parent_type.pluralize.to_sym, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource parent_type.pluralize.to_sym, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Get a list of #{eventable_type.to_s.downcase} resource label events" do
|
||||
success Entities::ResourceLabelEvent
|
||||
detail 'This feature was introduced in 11.3'
|
||||
|
|
|
@ -126,7 +126,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
before { authorize_admin_project }
|
||||
|
||||
desc 'Get runners available for project' do
|
||||
|
|
|
@ -70,7 +70,7 @@ module API
|
|||
end
|
||||
end
|
||||
|
||||
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Search on GitLab' do
|
||||
detail 'This feature was introduced in GitLab 10.5.'
|
||||
end
|
||||
|
@ -89,7 +89,7 @@ module API
|
|||
end
|
||||
end
|
||||
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Search on GitLab' do
|
||||
detail 'This feature was introduced in GitLab 10.5.'
|
||||
end
|
||||
|
|
|
@ -763,7 +763,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
before { authenticate! }
|
||||
before { authorize_admin_project }
|
||||
|
||||
|
@ -842,7 +842,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc "Trigger a slash command for #{service_slug}" do
|
||||
detail 'Added in GitLab 8.13'
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module API
|
|||
requires :id, type: String, desc: 'The ID of a project'
|
||||
requires :subscribable_id, type: String, desc: 'The ID of a resource'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
subscribable_types.each do |type, finder|
|
||||
type_singularized = type.singularize
|
||||
entity_class = Entities.const_get(type_singularized.camelcase)
|
||||
|
|
|
@ -4,14 +4,14 @@ module API
|
|||
class Tags < Grape::API
|
||||
include PaginationParams
|
||||
|
||||
TAG_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(tag_name: API::NO_SLASH_URL_PART_REGEX)
|
||||
TAG_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(tag_name: API::NO_SLASH_URL_PART_REGEX)
|
||||
|
||||
before { authorize! :download_code, user_project }
|
||||
|
||||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a project repository tags' do
|
||||
success Entities::Tag
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
ISSUABLE_TYPES.each do |type, finder|
|
||||
type_id_str = "#{type.singularize}_iid".to_sym
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ module API
|
|||
params do
|
||||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Trigger a GitLab project pipeline' do
|
||||
success Entities::Pipeline
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ module API
|
|||
requires :id, type: String, desc: 'The ID of a project'
|
||||
end
|
||||
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get project variables' do
|
||||
success Entities::Variable
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ module API
|
|||
end
|
||||
end
|
||||
|
||||
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
desc 'Get a list of wiki pages' do
|
||||
success Entities::WikiPageBasic
|
||||
end
|
||||
|
@ -103,7 +103,7 @@ module API
|
|||
requires :file, type: ::API::Validations::Types::SafeFile, desc: 'The attachment file to be uploaded'
|
||||
optional :branch, type: String, desc: 'The name of the branch'
|
||||
end
|
||||
post ":id/wikis/attachments", requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
|
||||
post ":id/wikis/attachments", requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
|
||||
authorize! :create_wiki, user_project
|
||||
|
||||
result = ::Wikis::CreateAttachmentService.new(user_project,
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe API::Namespaces do
|
||||
let(:admin) { create(:admin) }
|
||||
let(:user) { create(:user) }
|
||||
let!(:group1) { create(:group) }
|
||||
let!(:group1) { create(:group, name: 'group.one') }
|
||||
let!(:group2) { create(:group, :nested) }
|
||||
|
||||
describe "GET /namespaces" do
|
||||
|
|
Loading…
Reference in a new issue