diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-02 21:11:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-02 21:11:52 +0300 |
commit | d1ade10ba69cb7c232daa36625656456c32462e4 (patch) | |
tree | 70597a997a68fc63b009001480247794a60e2dd6 /lib/api/groups.rb | |
parent | 3a52eefc27143af8a2b3838a159c52484ca4bc8b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/groups.rb')
-rw-r--r-- | lib/api/groups.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 8bc19160540..d3d1f03585b 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -382,6 +382,28 @@ module API end end + desc 'Transfer a group to a new parent group or promote a subgroup to a root group' + params do + optional :group_id, type: Integer, + desc: 'The ID of the target group to which the group needs to be transferred to.'\ + 'If not provided, the source group will be promoted to a root group.' + end + post ':id/transfer' do + group = find_group!(params[:id]) + authorize! :admin_group, group + + new_parent_group = find_group!(params[:group_id]) if params[:group_id].present? + + service = ::Groups::TransferService.new(group, current_user) + + if service.execute(new_parent_group) + group.preload_shared_group_links + present group, with: Entities::GroupDetail, current_user: current_user + else + render_api_error!(service.error, 400) + end + end + desc 'Share a group with a group' do success Entities::GroupDetail end |