diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs
index 745aa620e3..1a9f40619b 100644
--- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs
@@ -362,5 +362,19 @@ public interface IObservableTeamsClient
/// Thrown when a general API error occurs.
///
IObservable RemoveRepositoryFromATeam(string org, string teamSlug, string owner, string repo);
+
+ ///
+ /// Get a team by slug name
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// The organization name. The name is not case sensitive.
+ /// The slug of the team name.
+ /// Thrown when a general API error occurs.
+ /// Thrown when the team wasn't found
+ /// A instance if found, otherwise a
+ IObservable GetByName(string org, string teamSlug);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs
index f068d468bb..00c2b07616 100644
--- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs
@@ -523,5 +523,23 @@ public IObservable RemoveRepositoryFromATeam(string org, string teamSlug,
{
return _client.RemoveRepositoryFromATeam(org, teamSlug, owner, repo).ToObservable();
}
+
+ ///
+ /// Get a team by slug name
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// The organization name. The name is not case sensitive.
+ /// The slug of the team name.
+ /// Thrown when a general API error occurs.
+ /// Thrown when the team wasn't found
+ /// A instance if found, otherwise a
+ [ManualRoute("GET", "/orgs/{org}/teams/{teamSlug}")]
+ public IObservable GetByName(string org, string teamSlug)
+ {
+ return _client.GetByName(org, teamSlug).ToObservable();
+ }
}
}
diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
index 5cbd7ba8a0..da59b46841 100644
--- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs
@@ -682,4 +682,20 @@ await github.Organization.Team.RemoveRepositoryFromATeam(
}
}
}
+
+ public class TheGetByNameMethod
+ {
+ [OrganizationTest]
+ public async Task GetsTeamByNameWhenAuthenticated()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
+ {
+ var foundTeam = await github.Organization.Team.GetByName(Helper.Organization, teamContext.TeamName);
+
+ Assert.Equal(foundTeam.Name, teamContext.TeamName);
+ }
+ }
+ }
}
diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs
index 7f11425840..3a2d032281 100644
--- a/Octokit.Tests/Clients/TeamsClientTests.cs
+++ b/Octokit.Tests/Clients/TeamsClientTests.cs
@@ -618,5 +618,29 @@ public async Task RequestsTheCorrectUrl()
connection.Received().Delete(Arg.Is(u => u.ToString() == expected));
}
}
+
+ public class TheGetByNameMethod
+ {
+ [Fact]
+ public void RequestsTheCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new TeamsClient(connection);
+
+ client.GetByName("orgName", "teamSlug");
+
+ connection.Received().Get(
+ Arg.Is(u => u.ToString() == "orgs/orgName/teams/teamSlug"));
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var teams = new TeamsClient(Substitute.For());
+
+ await Assert.ThrowsAsync(() => teams.GetByName(null, "teamSlug"));
+ await Assert.ThrowsAsync(() => teams.GetByName("orgName", null));
+ }
+ }
}
}
diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs
index 9507c125e4..790d53cb04 100644
--- a/Octokit/Clients/ITeamsClient.cs
+++ b/Octokit/Clients/ITeamsClient.cs
@@ -354,5 +354,19 @@ public interface ITeamsClient
/// Thrown when a general API error occurs.
///
Task RemoveRepositoryFromATeam(string org, string teamSlug, string owner, string repo);
+
+ ///
+ /// Get a team by slug name
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// The organization name. The name is not case sensitive.
+ /// The slug of the team name.
+ /// Thrown when a general API error occurs.
+ /// Thrown when the team wasn't found
+ /// A instance if found, otherwise a
+ Task GetByName(string org, string teamSlug);
}
}
diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs
index af41cc3119..1c36920d59 100644
--- a/Octokit/Clients/TeamsClient.cs
+++ b/Octokit/Clients/TeamsClient.cs
@@ -686,5 +686,27 @@ public Task RemoveRepositoryFromATeam(string org, string teamSlug, string owner,
return ApiConnection.Delete(endpoint);
}
+
+ ///
+ /// Get a team by slug name
+ ///
+ ///
+ /// See the API Documentation
+ /// for more information.
+ ///
+ /// The organization name. The name is not case sensitive.
+ /// The slug of the team name.
+ /// Thrown when a general API error occurs.
+ /// Thrown when the team wasn't found
+ /// A instance if found, otherwise a
+ [ManualRoute("GET", "/orgs/{org}/teams/{teamSlug}")]
+ public Task GetByName(string org, string teamSlug)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
+ Ensure.ArgumentNotNullOrEmptyString(teamSlug, nameof(teamSlug));
+
+ var endpoint = ApiUrls.TeamsByOrganizationAndSlug(org, teamSlug);
+ return ApiConnection.Get(endpoint);
+ }
}
}