Skip to content

Commit

Permalink
Add org public-members call, to complement the full members list
Browse files Browse the repository at this point in the history
  • Loading branch information
rtyley committed Mar 13, 2014
1 parent 628034a commit 9930e7b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/main/java/org/kohsuke/github/GHOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,37 @@ public void publicize(GHUser u) throws IOException {
* All the members of this organization.
*/
public PagedIterable<GHUser> getMembers() throws IOException {
return getMembersWithFilter(null);
return getMembers("members");
}

public PagedIterable<GHUser> getMembersWithFilter(final String filter) throws IOException {
/**
* All the public members of this organization.
*/
public PagedIterable<GHUser> getPublicMembers() throws IOException {
return getMembers("public_members");
}

private PagedIterable<GHUser> getMembers(String suffix) throws IOException {
return getMembers(suffix, null);
}

public PagedIterable<GHUser> getMembersWithFilter(String filter) throws IOException {
return getMembers("members", filter);
}

private PagedIterable<GHUser> getMembers(final String suffix, final String filter) throws IOException {
return new PagedIterable<GHUser>() {
public PagedIterator<GHUser> iterator() {
String filterParams = (filter == null) ? "" : ("?filter=" + filter);
return new PagedIterator<GHUser>(root.retrieve().asIterator(String.format("/orgs/%s/members%s", login, filterParams), GHUser[].class)) {
return new PagedIterator<GHUser>(root.retrieve().asIterator(String.format("/orgs/%s/%s%s", login, suffix, filterParams), GHUser[].class)) {
@Override
protected void wrapUp(GHUser[] page) {
}
};
}
};
}

/**
* Conceals the membership.
*/
Expand Down

0 comments on commit 9930e7b

Please sign in to comment.