summaryrefslogtreecommitdiff
path: root/lib/api/groups.rb
blob: bc856eccdaba6609cfc05c784568991d10f55595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Gitlab
  # groups API
  class Groups < Grape::API
    before { authenticate! }
   
       resource :groups do
         # Get a groups list
         #
         # Example Request:
         #  GET /groups
         get do
           @groups = paginate Group
           present @groups, with: Entities::Group

         end
         
         # Create group. Available only for admin
         #
         # Parameters:
         #   name (required)                   - Name
         #   path (required)                   - Path
         # Example Request:
         #   POST /groups
         post do
           authenticated_as_admin!
           attrs = attributes_for_keys [:name, :path]
           @group = Group.new(attrs)
           @group.owner = current_user
           
           if @group.save
             present @group, with: Entities::Group
           else
             not_found!
           end
         end
         
         # Get a single group, with containing projects
         #
         # Parameters:
         #   id (required) - The ID of a group
         # Example Request:
         #   GET /groups/:id
         get ":id" do
           @group = Group.find(params[:id])
           present @group, with: Entities::GroupDetail
         end
         
       end
  end
end