diff --git a/src/main/java/org/kohsuke/github/GHOrganization.java b/src/main/java/org/kohsuke/github/GHOrganization.java index c4ae92e6db..0c62fd8a2a 100644 --- a/src/main/java/org/kohsuke/github/GHOrganization.java +++ b/src/main/java/org/kohsuke/github/GHOrganization.java @@ -93,6 +93,17 @@ public GHTeam getTeamByName(String name) throws IOException { return null; } + /** + * Finds a team that has the given slug in its {@link GHTeam#getSlug()} + */ + public GHTeam getTeamBySlug(String slug) throws IOException { + for (GHTeam t : listTeams()) { + if(t.getSlug().equals(slug)) + return t; + } + return null; + } + /** * Checks if this organization has the specified user as a member. */ diff --git a/src/main/java/org/kohsuke/github/GHTeam.java b/src/main/java/org/kohsuke/github/GHTeam.java index cf7dd1fc91..e0cd33b8bd 100644 --- a/src/main/java/org/kohsuke/github/GHTeam.java +++ b/src/main/java/org/kohsuke/github/GHTeam.java @@ -12,7 +12,7 @@ * @author Kohsuke Kawaguchi */ public class GHTeam { - private String name,permission; + private String name,permission,slug; private int id; private GHOrganization organization; // populated by GET /user/teams where Teams+Orgs are returned together @@ -43,6 +43,10 @@ public String getPermission() { return permission; } + public String getSlug() { + return slug; + } + public int getId() { return id; } diff --git a/src/test/java/org/kohsuke/github/AppTest.java b/src/test/java/org/kohsuke/github/AppTest.java index c8d523cd81..905818981b 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -335,6 +335,13 @@ public void testOrgTeamByName() throws Exception { assertNotNull(e); } + @Test + public void testOrgTeamBySlug() throws Exception { + kohsuke(); + GHTeam e = gitHub.getOrganization("github-api-test-org").getTeamBySlug("core-developers"); + assertNotNull(e); + } + @Test public void testCommit() throws Exception { GHCommit commit = gitHub.getUser("jenkinsci").getRepository("jenkins").getCommit("08c1c9970af4d609ae754fbe803e06186e3206f7");