Project

General

Profile

Rest Memberships » History » Version 1

Jean-Philippe Lang, 2012-02-06 11:40

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
+Response+:
65
66
  * @201 Created@: membership was created
67
  * @422 Unprocessable Entity@: membership was not created due to validation failures (response body contains the error messages)
68
69
h2. /memberships/:id.:format
70
71
h3. GET
72
73
Returns the membership of given @:id@.
74
75
+Examples+:
76
77
<pre>
78
GET /memberships/1.xml
79
</pre>
80
81
+Response+:
82
83
<pre>
84
<?xml version="1.0" encoding="UTF-8"?>
85
<membership>
86
  <id>1</id>
87
  <project name="Redmine" id="1"/>
88
  <user name="David Robert" id="17"/>
89
  <roles type="array">
90
    <role name="Developer" id="2"/>
91
    <role name="Manager" id="1"/>
92
  </roles>
93
</membership>
94
</pre>
95
96
h3. PUT
97
98
Updates the membership of given :id. Only the roles can be updated, the project and the user of a membership are read-only.
99
100
+Parameters+:
101
102
* @membership@ (required): a hash of the membership attributes, including:
103
104
  * @role_ids@ (required): an array of roles numerical ids
105
106
+Response+:
107
108
  * @200 OK@: membership was updated
109
  * @422 Unprocessable Entity@: membership was not updated due to validation failures (response body contains the error messages)
110
111
h3. DELETE
112
113
Deletes a memberships.
114
115
Memberships inherited from a group membership can not be deleted. You must delete the group membership.
116
117
+Parameters+:
118
119
_none_
120
121
+Response+:
122
123
  * @200 OK@: membership was deleted
124
  * @422 Unprocessable Entity@: membership was not deleted