Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b1d37e4

Browse filesBrowse files
committed
Support the check-user-team-membership API call
http://developer.github.com/v3/orgs/teams/#get-team-member
1 parent ce5ae13 commit b1d37e4
Copy full SHA for b1d37e4

File tree

Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-0
lines changed

‎src/main/java/org/kohsuke/github/GHTeam.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHTeam.java
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ public Set<GHUser> getMembers() throws IOException {
4949
return new HashSet<GHUser>(Arrays.asList(GHUser.wrap(org.root.retrieve().to(api("/members"), GHUser[].class), org.root)));
5050
}
5151

52+
/**
53+
* Checks if this team has the specified user as a member.
54+
*/
55+
public boolean hasMember(GHUser user) {
56+
try {
57+
org.root.retrieve().to("/teams/" + id + "/members/" + user.getLogin());
58+
return true;
59+
} catch (IOException ignore) {
60+
return false;
61+
}
62+
}
63+
5264
public Map<String,GHRepository> getRepositories() throws IOException {
5365
GHRepository[] repos = org.root.retrieve().to(api("/repos"), GHRepository[].class);
5466
Map<String,GHRepository> m = new TreeMap<String, GHRepository>();

‎src/main/java/org/kohsuke/github/GHUser.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHUser.java
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public boolean isMemberOf(GHOrganization org) {
7676
return org.hasMember(this);
7777
}
7878

79+
/**
80+
* Returns true if this user belongs to the specified team.
81+
*/
82+
public boolean isMemberOf(GHTeam team) {
83+
return team.hasMember(this);
84+
}
85+
7986
/**
8087
* Returns true if this user belongs to the specified organization as a public member.
8188
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.