mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-05 08:21:21 +00:00
Make getTeambySlug fast enought
This commit is contained in:
@@ -128,6 +128,24 @@ public class GHOrganization extends GHPerson {
|
||||
.toIterable(GHTeam[].class, item -> item.wrapUp(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single team by ID.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @see <a href=
|
||||
* "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeam(int id) throws IOException {
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/teams/%d", login, id))
|
||||
.fetch(GHTeam.class).wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a team that has the given name in its {@link GHTeam#getName()}
|
||||
*
|
||||
@@ -147,19 +165,19 @@ public class GHOrganization extends GHPerson {
|
||||
|
||||
/**
|
||||
* Finds a team that has the given slug in its {@link GHTeam#getSlug()}
|
||||
*
|
||||
*
|
||||
* @param slug
|
||||
* the slug
|
||||
* @return the team by slug
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see <a href=
|
||||
* "https://developer.github.com/v3/teams/#get-team-by-name">documentation</a>
|
||||
*/
|
||||
public GHTeam getTeamBySlug(String slug) throws IOException {
|
||||
for (GHTeam t : listTeams()) {
|
||||
if (t.getSlug().equals(slug))
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
return root.createRequest()
|
||||
.withUrlPath(String.format("/orgs/%s/teams/%s", login, slug))
|
||||
.fetch(GHTeam.class).wrapUp(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -724,7 +724,10 @@ public class GitHub {
|
||||
* @return the team
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*
|
||||
* @deprecated Use {@link GHOrganization#getTeam(int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public GHTeam getTeam(int id) throws IOException {
|
||||
return createRequest().withUrlPath("/teams/" + id).fetch(GHTeam.class).wrapUp(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user