diff options
author | Aram Visser <hello@aramvisser.com> | 2018-06-24 13:10:15 +0700 |
---|---|---|
committer | Aram Visser <hello@aramvisser.com> | 2018-06-27 18:21:18 +0700 |
commit | c3de6a86734f8756de214cc87ac230820fa33acc (patch) | |
tree | e3db898a5a56d6afaf552d82c12e2b3e1d42fafa /lib/api/projects.rb | |
parent | 2452f1a73e8dcf646311c6069a077ab66be5ce51 (diff) | |
download | gitlab-ce-c3de6a86734f8756de214cc87ac230820fa33acc.tar.gz |
Add transfer project endpoint to the Projects API
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 3ef3680c5d9..b83da00502d 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -459,6 +459,23 @@ module API conflict!(error.message) end end + + desc 'Transfer a project to a new namespace' + params do + requires :namespace, type: String, desc: 'The ID or path of the new namespace' + end + put ":id/transfer" do + authorize! :change_namespace, user_project + + namespace = find_namespace!(params[:namespace]) + result = ::Projects::TransferService.new(user_project, current_user).execute(namespace) + + if result + present user_project, with: Entities::Project + else + render_api_error!("Failed to transfer project #{user_project.errors.messages}", 400) + end + end end end end |