Project

General

Profile

Rest Groups » History » Version 4

Jean-Philippe Lang, 2012-06-03 15:24

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