diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-07 13:10:01 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-07 13:10:01 +0300 |
commit | f141711cfd47808d5f954e1ccf057a858b36d63a (patch) | |
tree | efafdecf81dde096a40820722564619f2da08c51 | |
parent | 073c8a296668ab1e06b01ebf0a9e94786227eef4 (diff) | |
download | gitlab-ce-f141711cfd47808d5f954e1ccf057a858b36d63a.tar.gz |
API: new feature - remove group
-rw-r--r-- | doc/api/groups.md | 13 | ||||
-rw-r--r-- | lib/api/groups.rb | 18 |
2 files changed, 29 insertions, 2 deletions
diff --git a/doc/api/groups.md b/doc/api/groups.md index f56c534667a..f5f5d769050 100644 --- a/doc/api/groups.md +++ b/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 diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 396554404af..265417fd6bc 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -7,12 +7,14 @@ module 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 @@ module API 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 @@ module API member.destroy end end - end end end |