Project

General

Profile

Rest Memberships » History » Version 2

Jean-Philippe Lang, 2012-02-06 11:46
More examples

1 1 Jean-Philippe Lang
h1. Project Memberships
2
3
{{>toc}}
4
5
h2. /projects/:project_id/memberships.:format
6
7
h3. GET
8
9
Returns a paginated list of the project memberships. @:project_id@ can be either the project numerical id or the project identifier.
10
11
+Examples+:
12
13
<pre>
14
GET /projects/1/memberships.xml
15
GET /projects/redmine/memberships.xml
16
</pre>
17
18
+Response+:
19
20
<pre>
21
<?xml version="1.0" encoding="UTF-8"?>
22
<memberships type="array" limit="25" offset="0" total_count="2">
23
  <membership>
24
    <id>1</id>
25
    <project name="Redmine" id="1"/>
26
    <user name="David Robert" id="17"/>
27
    <roles type="array">
28
      <role name="Manager" id="1"/>
29
    </roles>
30
  </membership>
31
  <membership>
32
    <id>3</id>
33
    <project name="Redmine" id="1"/>
34
    <group name="Contributors" id="24"/>
35
    <roles type="array">
36
      <role name="Contributor" id="3"/>
37
    </roles>
38
  </membership>
39
  <membership>
40
    <id>4</id>
41
    <project name="Redmine" id="1"/>
42
    <user name="John Smith" id="27"/>
43
    <roles type="array">
44
      <role name="Developer" id="2" />
45
      <role name="Contributor" id="3" inherited="true" />
46
    </roles>
47
  </membership>
48
</memberships>
49
</pre>
50
51
In the above example, the @inherited="true"@ attribute on the last role means that this role was inherited from a group (eg. Jonh Smith belongs to the Contributors group and this group was added as a project member). John Smith's membership can not be deleted without deleting the group membership first.
52
53
h3. POST
54
55
Adds a project member.
56
57
+Parameters+:
58
59
* @membership@ (required): a hash of the membership attributes, including:
60
61
  * @user_id@ (required): the numerical id of the user
62
  * @role_ids@ (required): an array of roles numerical ids
63
64 2 Jean-Philippe Lang
+Example+:
65
66
<pre>
67
POST /projects/redmine/memberships.xml
68
69
<membership>
70
  <user_id>27</user_id>
71
  <role_ids type="array">
72
    <role_id>2</role_id>
73
  </role_ids>
74
</membership>
75
</pre>
76
77 1 Jean-Philippe Lang
+Response+:
78
79
  * @201 Created@: membership was created
80
  * @422 Unprocessable Entity@: membership was not created due to validation failures (response body contains the error messages)
81
82
h2. /memberships/:id.:format
83
84
h3. GET
85
86
Returns the membership of given @:id@.
87
88
+Examples+:
89
90
<pre>
91
GET /memberships/1.xml
92
</pre>
93
94
+Response+:
95
96
<pre>
97
<?xml version="1.0" encoding="UTF-8"?>
98
<membership>
99
  <id>1</id>
100
  <project name="Redmine" id="1"/>
101
  <user name="David Robert" id="17"/>
102
  <roles type="array">
103
    <role name="Developer" id="2"/>
104
    <role name="Manager" id="1"/>
105
  </roles>
106
</membership>
107
</pre>
108
109
h3. PUT
110
111
Updates the membership of given :id. Only the roles can be updated, the project and the user of a membership are read-only.
112
113
+Parameters+:
114
115
* @membership@ (required): a hash of the membership attributes, including:
116
117
  * @role_ids@ (required): an array of roles numerical ids
118
119 2 Jean-Philippe Lang
+Example+:
120
121
<pre>
122
PUT /memberships/2.xml
123
124
<membership>
125
  <role_ids type="array">
126
    <role_id>3</role_id>
127
    <role_id>4</role_id>
128
  </role_ids>
129
</membership>
130
</pre>
131
132 1 Jean-Philippe Lang
+Response+:
133
134
  * @200 OK@: membership was updated
135
  * @422 Unprocessable Entity@: membership was not updated due to validation failures (response body contains the error messages)
136
137
h3. DELETE
138
139
Deletes a memberships.
140
141
Memberships inherited from a group membership can not be deleted. You must delete the group membership.
142
143
+Parameters+:
144
145
_none_
146 2 Jean-Philippe Lang
147
+Example+:
148
149
<pre>
150
DELETE /memberships/2.xml
151
</pre>
152 1 Jean-Philippe Lang
153
+Response+:
154
155
  * @200 OK@: membership was deleted
156
  * @422 Unprocessable Entity@: membership was not deleted