2013-05-14 12:33:31 +00:00
|
|
|
module API
|
2012-06-29 10:46:01 +00:00
|
|
|
# Projects API
|
|
|
|
class Projects < Grape::API
|
2016-11-09 14:51:27 +00:00
|
|
|
include PaginationParams
|
|
|
|
|
2016-11-30 14:48:19 +00:00
|
|
|
before { authenticate_non_get! }
|
2012-06-29 10:46:01 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
helpers do
|
2017-04-05 16:31:15 +00:00
|
|
|
params :optional_params_ce do
|
2016-11-09 14:51:27 +00:00
|
|
|
optional :description, type: String, desc: 'The description of the project'
|
|
|
|
optional :issues_enabled, type: Boolean, desc: 'Flag indication if the issue tracker is enabled'
|
|
|
|
optional :merge_requests_enabled, type: Boolean, desc: 'Flag indication if merge requests are enabled'
|
|
|
|
optional :wiki_enabled, type: Boolean, desc: 'Flag indication if the wiki is enabled'
|
2017-04-19 22:29:09 +00:00
|
|
|
optional :jobs_enabled, type: Boolean, desc: 'Flag indication if jobs are enabled'
|
2016-11-09 14:51:27 +00:00
|
|
|
optional :snippets_enabled, type: Boolean, desc: 'Flag indication if snippets are enabled'
|
|
|
|
optional :shared_runners_enabled, type: Boolean, desc: 'Flag indication if shared runners are enabled for that project'
|
|
|
|
optional :container_registry_enabled, type: Boolean, desc: 'Flag indication if the container registry is enabled for that project'
|
|
|
|
optional :lfs_enabled, type: Boolean, desc: 'Flag indication if Git LFS is enabled for that project'
|
2017-03-01 15:16:29 +00:00
|
|
|
optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'The visibility of the project.'
|
2016-11-09 14:51:27 +00:00
|
|
|
optional :public_builds, type: Boolean, desc: 'Perform public builds'
|
|
|
|
optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
|
2017-02-17 13:56:13 +00:00
|
|
|
optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
|
2016-11-09 14:51:27 +00:00
|
|
|
optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved'
|
|
|
|
end
|
2017-04-05 16:31:15 +00:00
|
|
|
|
|
|
|
params :optional_params do
|
|
|
|
use :optional_params_ce
|
|
|
|
end
|
2017-05-01 09:42:42 +00:00
|
|
|
|
|
|
|
params :statistics_params do
|
|
|
|
optional :statistics, type: Boolean, default: false, desc: 'Include project statistics'
|
|
|
|
end
|
2016-11-09 14:51:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
resource :projects do
|
2013-02-08 15:33:15 +00:00
|
|
|
helpers do
|
2016-11-22 16:58:10 +00:00
|
|
|
params :collection_params do
|
|
|
|
use :sort_params
|
|
|
|
use :filter_params
|
|
|
|
use :pagination
|
|
|
|
|
|
|
|
optional :simple, type: Boolean, default: false,
|
|
|
|
desc: 'Return only the ID, URL, name, and path of each project'
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
params :sort_params do
|
|
|
|
optional :order_by, type: String, values: %w[id name path created_at updated_at last_activity_at],
|
|
|
|
default: 'created_at', desc: 'Return projects ordered by field'
|
|
|
|
optional :sort, type: String, values: %w[asc desc], default: 'desc',
|
|
|
|
desc: 'Return projects sorted in ascending and descending order'
|
|
|
|
end
|
|
|
|
|
|
|
|
params :filter_params do
|
|
|
|
optional :archived, type: Boolean, default: false, desc: 'Limit by archived status'
|
2017-03-01 15:16:29 +00:00
|
|
|
optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values,
|
2016-11-09 14:51:27 +00:00
|
|
|
desc: 'Limit by visibility'
|
2017-03-03 11:00:34 +00:00
|
|
|
optional :search, type: String, desc: 'Return list of projects matching the search criteria'
|
2017-02-01 10:23:57 +00:00
|
|
|
optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user'
|
|
|
|
optional :starred, type: Boolean, default: false, desc: 'Limit by starred status'
|
2017-03-03 11:00:34 +00:00
|
|
|
optional :membership, type: Boolean, default: false, desc: 'Limit by projects that the current user is a member of'
|
2016-11-22 16:58:10 +00:00
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
params :create_params do
|
|
|
|
optional :namespace_id, type: Integer, desc: 'Namespace ID for the new project. Default to the user namespace.'
|
|
|
|
optional :import_url, type: String, desc: 'URL from which the project is imported'
|
2013-11-06 15:13:21 +00:00
|
|
|
end
|
2016-11-22 16:58:10 +00:00
|
|
|
|
|
|
|
def present_projects(projects, options = {})
|
|
|
|
options = options.reverse_merge(
|
|
|
|
with: Entities::Project,
|
|
|
|
current_user: current_user,
|
2017-05-03 11:27:17 +00:00
|
|
|
simple: params[:simple]
|
2016-11-22 16:58:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
projects = filter_projects(projects)
|
|
|
|
projects = projects.with_statistics if options[:statistics]
|
|
|
|
options[:with] = Entities::BasicProjectDetails if options[:simple]
|
|
|
|
|
|
|
|
present paginate(projects), options
|
|
|
|
end
|
2013-02-08 15:33:15 +00:00
|
|
|
end
|
|
|
|
|
2016-11-30 14:48:19 +00:00
|
|
|
desc 'Get a list of visible projects for authenticated user' do
|
2016-11-09 14:51:27 +00:00
|
|
|
success Entities::BasicProjectDetails
|
|
|
|
end
|
|
|
|
params do
|
2016-11-22 16:58:10 +00:00
|
|
|
use :collection_params
|
2017-05-01 09:42:42 +00:00
|
|
|
use :statistics_params
|
2016-11-09 14:51:27 +00:00
|
|
|
end
|
2016-11-30 14:48:19 +00:00
|
|
|
get do
|
2017-02-01 10:23:57 +00:00
|
|
|
entity = current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails
|
2017-03-03 10:35:04 +00:00
|
|
|
present_projects ProjectsFinder.new(current_user: current_user).execute, with: entity, statistics: params[:statistics]
|
2013-11-18 12:15:59 +00:00
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Create new project' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
|
|
|
params do
|
2017-02-21 14:12:32 +00:00
|
|
|
optional :name, type: String, desc: 'The name of the project'
|
2016-11-09 14:51:27 +00:00
|
|
|
optional :path, type: String, desc: 'The path of the repository'
|
2017-02-21 14:12:32 +00:00
|
|
|
at_least_one_of :name, :path
|
2016-11-09 14:51:27 +00:00
|
|
|
use :optional_params
|
|
|
|
use :create_params
|
|
|
|
end
|
2012-08-31 07:15:37 +00:00
|
|
|
post do
|
2017-03-01 20:23:00 +00:00
|
|
|
attrs = declared_params(include_missing: false)
|
2017-04-19 22:29:09 +00:00
|
|
|
attrs[:builds_enabled] = attrs.delete(:jobs_enabled) if attrs.has_key?(:jobs_enabled)
|
2016-11-09 14:51:27 +00:00
|
|
|
project = ::Projects::CreateService.new(current_user, attrs).execute
|
|
|
|
|
|
|
|
if project.saved?
|
|
|
|
present project, with: Entities::Project,
|
|
|
|
user_can_admin_project: can?(current_user, :admin_project, project)
|
2012-08-31 07:15:37 +00:00
|
|
|
else
|
2016-11-09 14:51:27 +00:00
|
|
|
if project.errors[:limit_reached].present?
|
|
|
|
error!(project.errors[:limit_reached], 403)
|
2013-02-14 14:51:56 +00:00
|
|
|
end
|
2016-11-09 14:51:27 +00:00
|
|
|
render_validation_error!(project)
|
2012-08-31 07:15:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Create new project for a specified user. Only available to admin users.' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :name, type: String, desc: 'The name of the project'
|
|
|
|
requires :user_id, type: Integer, desc: 'The ID of a user'
|
|
|
|
optional :default_branch, type: String, desc: 'The default branch of the project'
|
|
|
|
use :optional_params
|
|
|
|
use :create_params
|
|
|
|
end
|
2012-11-14 20:37:52 +00:00
|
|
|
post "user/:user_id" do
|
|
|
|
authenticated_as_admin!
|
2016-11-09 14:51:27 +00:00
|
|
|
user = User.find_by(id: params.delete(:user_id))
|
|
|
|
not_found!('User') unless user
|
|
|
|
|
2017-03-01 20:23:00 +00:00
|
|
|
attrs = declared_params(include_missing: false)
|
2016-11-09 14:51:27 +00:00
|
|
|
project = ::Projects::CreateService.new(user, attrs).execute
|
|
|
|
|
|
|
|
if project.saved?
|
|
|
|
present project, with: Entities::Project,
|
|
|
|
user_can_admin_project: can?(current_user, :admin_project, project)
|
2012-11-14 20:37:52 +00:00
|
|
|
else
|
2016-11-09 14:51:27 +00:00
|
|
|
render_validation_error!(project)
|
2012-11-14 20:37:52 +00:00
|
|
|
end
|
|
|
|
end
|
2016-11-09 14:51:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
params do
|
|
|
|
requires :id, type: String, desc: 'The ID of a project'
|
|
|
|
end
|
2017-03-15 18:09:24 +00:00
|
|
|
resource :projects, requirements: { id: %r{[^/]+} } do
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Get a single project' do
|
|
|
|
success Entities::ProjectWithAccess
|
|
|
|
end
|
2017-05-01 09:42:42 +00:00
|
|
|
params do
|
|
|
|
use :statistics_params
|
|
|
|
end
|
2016-11-09 14:51:27 +00:00
|
|
|
get ":id" do
|
2016-11-30 14:48:19 +00:00
|
|
|
entity = current_user ? Entities::ProjectWithAccess : Entities::BasicProjectDetails
|
2016-11-29 19:21:39 +00:00
|
|
|
present user_project, with: entity, current_user: current_user,
|
2017-05-01 09:42:42 +00:00
|
|
|
user_can_admin_project: can?(current_user, :admin_project, user_project), statistics: params[:statistics]
|
2016-11-09 14:51:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get events for a single project' do
|
|
|
|
success Entities::Event
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get ":id/events" do
|
|
|
|
present paginate(user_project.events.recent), with: Entities::Event
|
|
|
|
end
|
2012-11-14 20:37:52 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Fork new project for the current user or provided namespace.' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be forked into'
|
|
|
|
end
|
2017-02-02 17:57:34 +00:00
|
|
|
post ':id/fork' do
|
2016-11-09 14:51:27 +00:00
|
|
|
fork_params = declared_params(include_missing: false)
|
|
|
|
namespace_id = fork_params[:namespace]
|
2016-09-06 08:52:42 +00:00
|
|
|
|
2016-09-06 00:31:06 +00:00
|
|
|
if namespace_id.present?
|
2016-11-09 14:51:27 +00:00
|
|
|
fork_params[:namespace] = if namespace_id =~ /^\d+$/
|
|
|
|
Namespace.find_by(id: namespace_id)
|
|
|
|
else
|
|
|
|
Namespace.find_by_path_or_name(namespace_id)
|
|
|
|
end
|
2016-09-06 08:52:42 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
unless fork_params[:namespace] && can?(current_user, :create_projects, fork_params[:namespace])
|
2016-09-21 14:40:46 +00:00
|
|
|
not_found!('Target Namespace')
|
|
|
|
end
|
2016-09-06 00:31:06 +00:00
|
|
|
end
|
2016-09-06 08:52:42 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
forked_project = ::Projects::ForkService.new(user_project, current_user, fork_params).execute
|
2016-09-06 08:52:42 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
if forked_project.errors.any?
|
|
|
|
conflict!(forked_project.errors.messages)
|
2014-10-01 08:20:40 +00:00
|
|
|
else
|
2016-11-09 14:51:27 +00:00
|
|
|
present forked_project, with: Entities::Project,
|
|
|
|
user_can_admin_project: can?(current_user, :admin_project, forked_project)
|
2016-01-22 19:13:37 +00:00
|
|
|
end
|
2014-10-01 08:20:40 +00:00
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Update an existing project' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
|
|
|
params do
|
2017-04-05 16:31:15 +00:00
|
|
|
# CE
|
|
|
|
at_least_one_of_ce =
|
|
|
|
[
|
2017-04-19 22:29:09 +00:00
|
|
|
:jobs_enabled,
|
2017-04-05 16:31:15 +00:00
|
|
|
:container_registry_enabled,
|
|
|
|
:default_branch,
|
|
|
|
:description,
|
|
|
|
:issues_enabled,
|
|
|
|
:lfs_enabled,
|
|
|
|
:merge_requests_enabled,
|
|
|
|
:name,
|
|
|
|
:only_allow_merge_if_all_discussions_are_resolved,
|
|
|
|
:only_allow_merge_if_pipeline_succeeds,
|
|
|
|
:path,
|
|
|
|
:public_builds,
|
|
|
|
:request_access_enabled,
|
|
|
|
:shared_runners_enabled,
|
|
|
|
:snippets_enabled,
|
|
|
|
:visibility,
|
2017-05-03 11:22:03 +00:00
|
|
|
:wiki_enabled
|
2017-04-05 16:31:15 +00:00
|
|
|
]
|
2016-11-09 14:51:27 +00:00
|
|
|
optional :name, type: String, desc: 'The name of the project'
|
|
|
|
optional :default_branch, type: String, desc: 'The default branch of the project'
|
|
|
|
optional :path, type: String, desc: 'The path of the repository'
|
2017-04-05 16:31:15 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
use :optional_params
|
2017-04-05 16:31:15 +00:00
|
|
|
at_least_one_of(*at_least_one_of_ce)
|
2016-11-09 14:51:27 +00:00
|
|
|
end
|
2014-10-15 06:57:35 +00:00
|
|
|
put ':id' do
|
|
|
|
authorize_admin_project
|
2017-03-01 20:23:00 +00:00
|
|
|
attrs = declared_params(include_missing: false)
|
2014-10-15 06:57:35 +00:00
|
|
|
authorize! :rename_project, user_project if attrs[:name].present?
|
2017-03-01 20:23:00 +00:00
|
|
|
authorize! :change_visibility_level, user_project if attrs[:visibility].present?
|
2014-10-15 06:57:35 +00:00
|
|
|
|
2017-04-19 22:29:09 +00:00
|
|
|
attrs[:builds_enabled] = attrs.delete(:jobs_enabled) if attrs.has_key?(:jobs_enabled)
|
|
|
|
|
2017-01-15 06:58:05 +00:00
|
|
|
result = ::Projects::UpdateService.new(user_project, current_user, attrs).execute
|
2014-10-15 06:57:35 +00:00
|
|
|
|
2017-01-15 06:58:05 +00:00
|
|
|
if result[:status] == :success
|
2016-01-11 14:27:20 +00:00
|
|
|
present user_project, with: Entities::Project,
|
|
|
|
user_can_admin_project: can?(current_user, :admin_project, user_project)
|
2017-01-15 06:58:05 +00:00
|
|
|
else
|
|
|
|
render_validation_error!(user_project)
|
2014-10-15 06:57:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Archive a project' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
2016-03-24 12:36:45 +00:00
|
|
|
post ':id/archive' do
|
2016-03-23 21:36:35 +00:00
|
|
|
authorize!(:archive_project, user_project)
|
|
|
|
|
|
|
|
user_project.archive!
|
|
|
|
|
2016-03-24 12:36:45 +00:00
|
|
|
present user_project, with: Entities::Project
|
2016-03-23 21:36:35 +00:00
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Unarchive a project' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
2016-03-24 12:36:45 +00:00
|
|
|
post ':id/unarchive' do
|
2016-03-23 21:36:35 +00:00
|
|
|
authorize!(:archive_project, user_project)
|
|
|
|
|
|
|
|
user_project.unarchive!
|
|
|
|
|
2016-03-24 12:36:45 +00:00
|
|
|
present user_project, with: Entities::Project
|
2016-03-23 21:36:35 +00:00
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Star a project' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
2016-04-06 13:52:16 +00:00
|
|
|
post ':id/star' do
|
2016-04-12 16:52:43 +00:00
|
|
|
if current_user.starred?(user_project)
|
|
|
|
not_modified!
|
|
|
|
else
|
2016-04-06 13:52:16 +00:00
|
|
|
current_user.toggle_star(user_project)
|
|
|
|
user_project.reload
|
2016-04-13 10:50:00 +00:00
|
|
|
|
2016-04-06 13:52:16 +00:00
|
|
|
present user_project, with: Entities::Project
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Unstar a project' do
|
|
|
|
success Entities::Project
|
|
|
|
end
|
2017-02-20 14:14:48 +00:00
|
|
|
post ':id/unstar' do
|
2016-04-06 13:52:16 +00:00
|
|
|
if current_user.starred?(user_project)
|
|
|
|
current_user.toggle_star(user_project)
|
|
|
|
user_project.reload
|
2016-04-13 10:50:00 +00:00
|
|
|
|
2016-04-06 13:52:16 +00:00
|
|
|
present user_project, with: Entities::Project
|
|
|
|
else
|
|
|
|
not_modified!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Remove a project'
|
2013-10-09 11:41:41 +00:00
|
|
|
delete ":id" do
|
|
|
|
authorize! :remove_project, user_project
|
2016-08-06 14:25:51 +00:00
|
|
|
::Projects::DestroyService.new(user_project, current_user, {}).async_execute
|
2017-02-22 17:37:13 +00:00
|
|
|
|
|
|
|
accepted!
|
2013-10-09 11:41:41 +00:00
|
|
|
end
|
2012-11-14 20:37:52 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Mark this project as forked from another'
|
|
|
|
params do
|
|
|
|
requires :forked_from_id, type: String, desc: 'The ID of the project it was forked from'
|
|
|
|
end
|
2013-06-27 21:49:26 +00:00
|
|
|
post ":id/fork/:forked_from_id" do
|
|
|
|
authenticated_as_admin!
|
2016-11-09 14:51:27 +00:00
|
|
|
|
2016-11-24 13:40:35 +00:00
|
|
|
forked_from_project = find_project!(params[:forked_from_id])
|
2016-11-09 14:51:27 +00:00
|
|
|
not_found!("Source Project") unless forked_from_project
|
|
|
|
|
|
|
|
if user_project.forked_from_project.nil?
|
|
|
|
user_project.create_forked_project_link(forked_to_project_id: user_project.id, forked_from_project_id: forked_from_project.id)
|
2013-06-27 21:49:26 +00:00
|
|
|
else
|
2016-11-09 14:51:27 +00:00
|
|
|
render_api_error!("Project already forked", 409)
|
2013-06-27 21:49:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Remove a forked_from relationship'
|
2013-06-27 21:49:26 +00:00
|
|
|
delete ":id/fork" do
|
2015-10-13 22:04:22 +00:00
|
|
|
authorize! :remove_fork_project, user_project
|
2016-11-09 14:51:27 +00:00
|
|
|
|
2015-10-13 10:24:44 +00:00
|
|
|
if user_project.forked?
|
2013-06-27 21:49:26 +00:00
|
|
|
user_project.forked_project_link.destroy
|
2016-11-09 14:51:27 +00:00
|
|
|
else
|
|
|
|
not_modified!
|
2013-06-27 21:49:26 +00:00
|
|
|
end
|
|
|
|
end
|
2016-01-07 12:37:14 +00:00
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Share the project with a group' do
|
|
|
|
success Entities::ProjectGroupLink
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :group_id, type: Integer, desc: 'The ID of a group'
|
|
|
|
requires :group_access, type: Integer, values: Gitlab::Access.values, desc: 'The group access level'
|
|
|
|
optional :expires_at, type: Date, desc: 'Share expiration date'
|
|
|
|
end
|
2016-03-13 10:46:16 +00:00
|
|
|
post ":id/share" do
|
|
|
|
authorize! :admin_project, user_project
|
2016-11-09 14:51:27 +00:00
|
|
|
group = Group.find_by_id(params[:group_id])
|
2016-10-11 10:20:35 +00:00
|
|
|
|
|
|
|
unless group && can?(current_user, :read_group, group)
|
|
|
|
not_found!('Group')
|
|
|
|
end
|
|
|
|
|
2016-03-13 10:46:16 +00:00
|
|
|
unless user_project.allowed_to_share_with_group?
|
|
|
|
return render_api_error!("The project sharing with group is disabled", 400)
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
link = user_project.project_group_links.new(declared_params(include_missing: false))
|
2016-09-22 20:31:18 +00:00
|
|
|
|
2016-03-13 10:46:16 +00:00
|
|
|
if link.save
|
|
|
|
present link, with: Entities::ProjectGroupLink
|
|
|
|
else
|
|
|
|
render_api_error!(link.errors.full_messages.first, 409)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-22 10:23:41 +00:00
|
|
|
params do
|
|
|
|
requires :group_id, type: Integer, desc: 'The ID of the group'
|
|
|
|
end
|
|
|
|
delete ":id/share/:group_id" do
|
|
|
|
authorize! :admin_project, user_project
|
|
|
|
|
|
|
|
link = user_project.project_group_links.find_by(group_id: params[:group_id])
|
|
|
|
not_found!('Group Link') unless link
|
|
|
|
|
|
|
|
link.destroy
|
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Upload a file'
|
|
|
|
params do
|
|
|
|
requires :file, type: File, desc: 'The file to be uploaded'
|
|
|
|
end
|
2016-01-07 12:37:14 +00:00
|
|
|
post ":id/uploads" do
|
2017-05-01 13:14:35 +00:00
|
|
|
UploadService.new(user_project, params[:file]).execute
|
2016-01-07 12:37:14 +00:00
|
|
|
end
|
|
|
|
|
2016-11-09 14:51:27 +00:00
|
|
|
desc 'Get the users list of a project' do
|
|
|
|
success Entities::UserBasic
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
optional :search, type: String, desc: 'Return list of users matching the search criteria'
|
|
|
|
use :pagination
|
2013-09-22 04:50:18 +00:00
|
|
|
end
|
2014-02-13 14:08:26 +00:00
|
|
|
get ':id/users' do
|
2016-11-30 14:48:19 +00:00
|
|
|
users = user_project.team.users
|
2016-11-09 14:51:27 +00:00
|
|
|
users = users.search(params[:search]) if params[:search].present?
|
|
|
|
|
|
|
|
present paginate(users), with: Entities::UserBasic
|
2014-02-13 14:08:26 +00:00
|
|
|
end
|
2017-02-21 14:51:31 +00:00
|
|
|
|
|
|
|
desc 'Start the housekeeping task for a project' do
|
|
|
|
detail 'This feature was introduced in GitLab 9.0.'
|
|
|
|
end
|
|
|
|
post ':id/housekeeping' do
|
|
|
|
authorize_admin_project
|
|
|
|
|
|
|
|
begin
|
|
|
|
::Projects::HousekeepingService.new(user_project).execute
|
|
|
|
rescue ::Projects::HousekeepingService::LeaseTaken => error
|
|
|
|
conflict!(error.message)
|
|
|
|
end
|
|
|
|
end
|
2012-06-29 10:46:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|