Commit f141711c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

API: new feature - remove group

parent 073c8a29
...@@ -57,6 +57,19 @@ Parameters: ...@@ -57,6 +57,19 @@ Parameters:
+ `project_id` (required) - The ID of a project + `project_id` (required) - The ID of a project
## Remove group
Removes group with all projects inside.
```
DELETE /groups/:id
```
Parameters:
+ `id` (required) - The ID of a user group
## Group members ## Group members
......
...@@ -7,12 +7,14 @@ module API ...@@ -7,12 +7,14 @@ module API
helpers do helpers do
def find_group(id) def find_group(id)
group = Group.find(id) group = Group.find(id)
if current_user.admin or current_user.groups.include? group
if can?(current_user, :read_group, group)
group group
else else
render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403) render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403)
end end
end end
def validate_access_level?(level) def validate_access_level?(level)
Gitlab::Access.options_with_owner.values.include? level.to_i Gitlab::Access.options_with_owner.values.include? level.to_i
end end
...@@ -64,6 +66,19 @@ module API ...@@ -64,6 +66,19 @@ module API
present group, with: Entities::GroupDetail present group, with: Entities::GroupDetail
end end
# Remove group
#
# Parameters:
# id (required) - The ID of a group
# Example Request:
# DELETE /groups/:id
delete ":id" do
group = find_group(params[:id])
authorize! :manage_group, group
group.destroy
end
# Transfer a project to the Group namespace # Transfer a project to the Group namespace
# #
# Parameters: # Parameters:
...@@ -132,7 +147,6 @@ module API ...@@ -132,7 +147,6 @@ module API
member.destroy member.destroy
end end
end end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment