Project

General

Profile

Rest Groups » History » Version 8

Cyril Jouve, 2017-08-30 12:23

1 1 Jean-Philippe Lang
h1. Groups
2
3 2 Jean-Philippe Lang
{{>toc}}
4
5 1 Jean-Philippe Lang
h2. /groups.:format
6
7
h3. GET
8
9
Returns the list of groups.
10
11 8 Cyril Jouve
This endpoint requires admin privileges.
12
13 1 Jean-Philippe Lang
+Example+:
14
15
  GET /groups.xml
16
17
+Response+:
18
19
<pre>
20
<groups type="array">
21
  <group>
22
    <id>53</id>
23
    <name>Managers</name>
24
  </group>
25
  <group>
26
    <id>55</id>
27
    <name>Developers</name>
28
  </group>
29
</groups>
30
</pre>
31
32
h3. POST
33
34
Creates a group.
35
36 8 Cyril Jouve
This endpoint requires admin privileges.
37
38 1 Jean-Philippe Lang
+Parameters+:
39
40
* @group@ (required): a hash of the group attributes, including:
41
42
  * @name@ (required): the group name
43
  * @user_ids@: ids of the group users (an empty group is created if not provided)
44
45
+Example+:
46
47
<pre>
48
POST /groups.xml
49
50
<group>
51
  <name>Developers</name>
52
  <user_ids>
53
    <user_id>3</user_id>
54
    <user_id>5</user_id>
55
  </user_ids>
56
</group>
57
</pre>
58
59 6 Jean-Baptiste Barth
<pre>
60
POST /groups.json
61
62
{
63
  "group": {
64
    "name": "Developers",
65 7 Matt Wiseley
    "user_ids": [ 3, 5 ]
66 6 Jean-Baptiste Barth
  }
67
}
68
</pre>
69
70 1 Jean-Philippe Lang
+Response+:
71
72
  * @201 Created@: group was created
73
  * @422 Unprocessable Entity@: group was not created due to validation failures (response body contains the error messages)
74
75
h2. /groups/:id.:format
76
77 4 Jean-Philippe Lang
h3. GET
78
79 5 Jean-Philippe Lang
Returns details of a group.
80 4 Jean-Philippe Lang
81 8 Cyril Jouve
This endpoint requires admin privileges.
82
83 4 Jean-Philippe Lang
+Parameters+:
84
85
* @include@ (optional): a coma separated list of associations to include in the response:
86 1 Jean-Philippe Lang
87 5 Jean-Philippe Lang
  * @users@
88 4 Jean-Philippe Lang
  * @memberships@
89
90 1 Jean-Philippe Lang
+Example+:
91 4 Jean-Philippe Lang
92 5 Jean-Philippe Lang
  GET /groups/20.xml?include=users
93 4 Jean-Philippe Lang
94
+Response+:
95
96
<pre>
97
<group>
98
  <id>20</id>
99
  <name>Developers</name>
100
  <users type="array">
101
    <user id="5" name="John Smith"/>
102
    <user id="8" name="Dave Loper"/>
103
  </users>
104
</group>
105
</pre>
106
107 2 Jean-Philippe Lang
h3. PUT
108 1 Jean-Philippe Lang
109 3 Jean-Philippe Lang
Updates an existing group.
110
111 8 Cyril Jouve
This endpoint requires admin privileges.
112
113 2 Jean-Philippe Lang
h3. DELETE
114 1 Jean-Philippe Lang
115 3 Jean-Philippe Lang
Deletes an existing group.
116
117 8 Cyril Jouve
This endpoint requires admin privileges.
118
119 1 Jean-Philippe Lang
h2. /groups/:id/users.:format
120
121 2 Jean-Philippe Lang
h3. POST
122 1 Jean-Philippe Lang
123 3 Jean-Philippe Lang
Adds an existing user to a group.
124
125 8 Cyril Jouve
This endpoint requires admin privileges.
126
127 3 Jean-Philippe Lang
+Parameters+:
128
129
* @user_id@ (required): id of the user to add to the group.
130
131
+Example+:
132
133
<pre>
134
POST /groups/10/users.xml
135
136
<user_id>5</user_id>
137
</pre>
138
139
+Response+:
140
141
* @200 OK@: user was added to the group
142
143 1 Jean-Philippe Lang
h2. /groups/:id/users/:user_id.:format
144
145
h3. DELETE
146 3 Jean-Philippe Lang
147
Removes a user from a group.
148 8 Cyril Jouve
149
This endpoint requires admin privileges.
150 3 Jean-Philippe Lang
151
+Example+:
152
153
<pre>
154
DELETE /groups/10/users/5.xml
155
</pre>
156
157
+Response+:
158
159
* @200 OK@: user was removed to the group