added methods to retrieve teams

This commit is contained in:
Kohsuke Kawaguchi
2011-06-25 10:01:37 -07:00
parent ca071d2732
commit 9a88e52260
2 changed files with 19 additions and 0 deletions

View File

@@ -145,6 +145,14 @@ public class GHRepository {
return Collections.unmodifiableSet(r);
}
/**
* If this repository belongs to an organization, return a set of teams.
*/
public Set<GHTeam> getTeams() throws IOException {
return Collections.unmodifiableSet(root.retrieve("/repos/show/"+owner+"/"+name+"/teams",JsonTeams.class).toSet(
root.getOrganization(owner)));
}
public void addCollaborators(GHUser... users) throws IOException {
addCollaborators(asList(users));
}

View File

@@ -1,7 +1,9 @@
package org.kohsuke.github;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
/**
@@ -18,4 +20,13 @@ class JsonTeams {
}
return r;
}
Set<GHTeam> toSet(GHOrganization org) {
Set<GHTeam> r = new HashSet<GHTeam>();
for (GHTeam t : teams) {
t.org = org;
r.add(t);
}
return r;
}
}