Project

General

Profile

Rest Groups » History » Version 6

Jean-Baptiste Barth, 2013-05-03 11:58
Add json example to create groups

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 6 Jean-Baptiste Barth
<pre>
56
POST /groups.json
57
58
{
59
  "group": {
60
    "name": "Developers",
61
    "users_ids": [ 3, 5 ]
62
  }
63
}
64
</pre>
65
66 1 Jean-Philippe Lang
+Response+:
67
68
  * @201 Created@: group was created
69
  * @422 Unprocessable Entity@: group was not created due to validation failures (response body contains the error messages)
70
71
h2. /groups/:id.:format
72
73 4 Jean-Philippe Lang
h3. GET
74
75 5 Jean-Philippe Lang
Returns details of a group.
76 4 Jean-Philippe Lang
77
+Parameters+:
78
79
* @include@ (optional): a coma separated list of associations to include in the response:
80 1 Jean-Philippe Lang
81 5 Jean-Philippe Lang
  * @users@
82 4 Jean-Philippe Lang
  * @memberships@
83
84 1 Jean-Philippe Lang
+Example+:
85 4 Jean-Philippe Lang
86 5 Jean-Philippe Lang
  GET /groups/20.xml?include=users
87 4 Jean-Philippe Lang
88
+Response+:
89
90
<pre>
91
<group>
92
  <id>20</id>
93
  <name>Developers</name>
94
  <users type="array">
95
    <user id="5" name="John Smith"/>
96
    <user id="8" name="Dave Loper"/>
97
  </users>
98
</group>
99
</pre>
100
101 2 Jean-Philippe Lang
h3. PUT
102 1 Jean-Philippe Lang
103 3 Jean-Philippe Lang
Updates an existing group.
104
105 2 Jean-Philippe Lang
h3. DELETE
106 1 Jean-Philippe Lang
107 3 Jean-Philippe Lang
Deletes an existing group.
108
109 1 Jean-Philippe Lang
h2. /groups/:id/users.:format
110
111 2 Jean-Philippe Lang
h3. POST
112 1 Jean-Philippe Lang
113 3 Jean-Philippe Lang
Adds an existing user to a group.
114
115
+Parameters+:
116
117
* @user_id@ (required): id of the user to add to the group.
118
119
+Example+:
120
121
<pre>
122
POST /groups/10/users.xml
123
124
<user_id>5</user_id>
125
</pre>
126
127
+Response+:
128
129
* @200 OK@: user was added to the group
130
131 1 Jean-Philippe Lang
h2. /groups/:id/users/:user_id.:format
132
133
h3. DELETE
134 3 Jean-Philippe Lang
135
Removes a user from a group.
136
137
+Example+:
138
139
<pre>
140
DELETE /groups/10/users/5.xml
141
</pre>
142
143
+Response+:
144
145
* @200 OK@: user was removed to the group