Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

API: new feature - remove group

  • Loading branch information...
commit f141711cfd47808d5f954e1ccf057a858b36d63a 1 parent 073c8a2
@randx randx authored
Showing with 29 additions and 2 deletions.
  1. +13 −0 doc/api/groups.md
  2. +16 −2 lib/api/groups.rb
View
13 doc/api/groups.md
@@ -57,6 +57,19 @@ Parameters:
+ `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
View
18 lib/api/groups.rb
@@ -7,12 +7,14 @@ class Groups < Grape::API
helpers do
def find_group(id)
group = Group.find(id)
- if current_user.admin or current_user.groups.include? group
+
+ if can?(current_user, :read_group, group)
group
else
render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403)
end
end
+
def validate_access_level?(level)
Gitlab::Access.options_with_owner.values.include? level.to_i
end
@@ -64,6 +66,19 @@ def validate_access_level?(level)
present group, with: Entities::GroupDetail
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
#
# Parameters:
@@ -132,7 +147,6 @@ def validate_access_level?(level)
member.destroy
end
end
-
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.