@@ -18,6 +18,18 @@ public class GHTeam {
18
18
19
19
protected /*final*/ GHOrganization org ;
20
20
21
+ /** Member's role in a team */
22
+ public enum Role {
23
+ /**
24
+ * A normal member of the team
25
+ */
26
+ MEMBER ,
27
+ /**
28
+ * Able to add/remove other team members, promote other team members to team maintainer, and edit the team's name and description.
29
+ */
30
+ MAINTAINER
31
+ }
32
+
21
33
/*package*/ GHTeam wrapUp (GHOrganization owner ) {
22
34
this .org = owner ;
23
35
return this ;
@@ -116,6 +128,22 @@ public void add(GHUser u) throws IOException {
116
128
org .root .retrieve ().method ("PUT" ).to (api ("/memberships/" + u .getLogin ()), null );
117
129
}
118
130
131
+ /**
132
+ * Adds a member to the team
133
+ *
134
+ * The user will be invited to the organization if required.
135
+ *
136
+ * @param user github user
137
+ * @param role role for the new member
138
+ *
139
+ * @throws IOException
140
+ */
141
+ public void add (GHUser user , Role role ) throws IOException {
142
+ org .root .retrieve ().method ("PUT" )
143
+ .with ("role" , role .name ())
144
+ .to (api ("/memberships/" + user .getLogin ()), null );
145
+ }
146
+
119
147
/**
120
148
* Removes a member to the team.
121
149
*/
@@ -129,7 +157,7 @@ public void add(GHRepository r) throws IOException {
129
157
130
158
public void add (GHRepository r , GHOrganization .Permission permission ) throws IOException {
131
159
org .root .retrieve ().method ("PUT" )
132
- .with ("permission" ,permission )
160
+ .with ("permission" , permission )
133
161
.to (api ("/repos/" + r .getOwnerName () + '/' + r .getName ()), null );
134
162
}
135
163
@@ -145,7 +173,7 @@ public void delete() throws IOException {
145
173
}
146
174
147
175
private String api (String tail ) {
148
- return "/teams/" + id + tail ;
176
+ return "/teams/" + id + tail ;
149
177
}
150
178
151
179
public GHOrganization getOrganization () {
0 commit comments