diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs new file mode 100644 index 0000000000..62dccdb073 --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs @@ -0,0 +1,124 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Octokit.Reactive +{ + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + public interface IObservableEnterpriseAdminStatsClient + { + /// + /// Gets GitHub Enterprise Issue statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsIssues(); + + /// + /// Gets GitHub Enterprise Hook statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsHooks(); + + /// + /// Gets GitHub Enterprise Milestone statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsMilestones(); + + /// + /// Gets GitHub Enterprise Organization statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsOrgs(); + + /// + /// Gets GitHub Enterprise Comment statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsComments(); + + /// + /// Gets GitHub Enterprise Pages statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsPages(); + + /// + /// Gets GitHub Enterprise User statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsUsers(); + + /// + /// Gets GitHub Enterprise Gist statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsGists(); + + /// + /// Gets GitHub Enterprise PullRequest statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsPulls(); + + /// + /// Gets GitHub Enterprise Repository statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsRepos(); + + /// + /// Gets GitHub Enterprise statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection of statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsAll(); + } +} diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs new file mode 100644 index 0000000000..4a494899ca --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs @@ -0,0 +1,19 @@ +namespace Octokit.Reactive +{ + /// + /// A client for GitHub's Enterprise API. + /// + /// + /// See the Enterprise API documentation for more information. + /// + public interface IObservableEnterpriseClient + { + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + IObservableEnterpriseAdminStatsClient AdminStats { get; } + } +} diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs new file mode 100644 index 0000000000..1ae1f61682 --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs @@ -0,0 +1,155 @@ +using System; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + public class ObservableEnterpriseAdminStatsClient : IObservableEnterpriseAdminStatsClient + { + readonly IEnterpriseAdminStatsClient _client; + + public ObservableEnterpriseAdminStatsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Enterprise.AdminStats; + } + + /// + /// Gets GitHub Enterprise Issue statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsIssues() + { + return _client.GetStatisticsIssues().ToObservable(); + } + + /// + /// Gets GitHub Enterprise Hook statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsHooks() + { + return _client.GetStatisticsHooks().ToObservable(); + } + + /// + /// Gets GitHub Enterprise Milestone statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsMilestones() + { + return _client.GetStatisticsMilestones().ToObservable(); + } + + /// + /// Gets GitHub Enterprise Organization statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsOrgs() + { + return _client.GetStatisticsOrgs().ToObservable(); + } + + /// + /// Gets GitHub Enterprise Comment statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsComments() + { + return _client.GetStatisticsComments().ToObservable(); + } + + /// + /// Gets GitHub Enterprise Pages statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsPages() + { + return _client.GetStatisticsPages().ToObservable(); + } + + /// + /// Gets GitHub Enterprise User statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsUsers() + { + return _client.GetStatisticsUsers().ToObservable(); + } + + /// + /// Gets GitHub Enterprise Gist statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsGists() + { + return _client.GetStatisticsGists().ToObservable(); + } + + /// + /// Gets GitHub Enterprise PullRequest statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsPulls() + { + return _client.GetStatisticsPulls().ToObservable(); + } + + /// + /// Gets GitHub Enterprise Repository statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public IObservable GetStatisticsRepos() + { + return _client.GetStatisticsRepos().ToObservable(); + } + + /// + /// Gets GitHub Enterprise statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection of statistics. + public IObservable GetStatisticsAll() + { + return _client.GetStatisticsAll().ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs new file mode 100644 index 0000000000..8466e9b85a --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs @@ -0,0 +1,26 @@ +namespace Octokit.Reactive +{ + /// + /// A client for GitHub's Enterprise API. + /// + /// + /// See the Enterprise API documentation for more information. + /// + public class ObservableEnterpriseClient : IObservableEnterpriseClient + { + public ObservableEnterpriseClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + AdminStats = new ObservableEnterpriseAdminStatsClient(client); + } + + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + public IObservableEnterpriseAdminStatsClient AdminStats { get; private set; } + } +} diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 717ae82a32..ddc42663dd 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -25,5 +25,6 @@ public interface IObservableGitHubClient : IApiInfoProvider [Obsolete("Use Git instead")] IObservableGitDatabaseClient GitDatabase { get; } IObservableSearchClient Search { get; } + IObservableEnterpriseClient Enterprise { get; } } } \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 9cbaccb497..d938bf1b3a 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -45,6 +45,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Git = new ObservableGitDatabaseClient(gitHubClient); Gist = new ObservableGistsClient(gitHubClient); Search = new ObservableSearchClient(gitHubClient); + Enterprise = new ObservableEnterpriseClient(gitHubClient); } public IConnection Connection @@ -70,6 +71,7 @@ public IConnection Connection public IObservableGitDatabaseClient GitDatabase { get { return Git; } } public IObservableGitDatabaseClient Git { get; private set; } public IObservableSearchClient Search { get; private set; } + public IObservableEnterpriseClient Enterprise { get; private set; } /// /// Gets the latest API Info - this will be null if no API calls have been made diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 194345c7f3..0d93d33ae5 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -159,6 +159,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index 1f676b026f..de9321e9e9 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -167,6 +167,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 9fb92e213c..018f37d0c6 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -163,6 +163,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index ad06ce2c5f..aee83c4189 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -75,6 +75,10 @@ Properties\SolutionInfo.cs + + + + diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs new file mode 100644 index 0000000000..12dc638ae9 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs @@ -0,0 +1,123 @@ +using System.Threading.Tasks; +using Octokit; +using Octokit.Tests.Integration; +using Xunit; + +public class EnterpriseAdminStatsClientTests +{ + readonly IGitHubClient _github; + + public EnterpriseAdminStatsClientTests() + { + _github = Helper.GetAuthenticatedClient(); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsIssues() + { + var issueStats = await + _github.Enterprise.AdminStats.GetStatisticsIssues(); + + Assert.NotNull(issueStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsHooks() + { + var hookStats = await + _github.Enterprise.AdminStats.GetStatisticsHooks(); + + Assert.NotNull(hookStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsMilestones() + { + var milestoneStats = await + _github.Enterprise.AdminStats.GetStatisticsMilestones(); + + Assert.NotNull(milestoneStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsOrgs() + { + var orgStats = await + _github.Enterprise.AdminStats.GetStatisticsOrgs(); + + Assert.NotNull(orgStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsComments() + { + var commentStats = await + _github.Enterprise.AdminStats.GetStatisticsComments(); + + Assert.NotNull(commentStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsPages() + { + var pageStats = await + _github.Enterprise.AdminStats.GetStatisticsPages(); + + Assert.NotNull(pageStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsUsers() + { + var userStats = await + _github.Enterprise.AdminStats.GetStatisticsUsers(); + + Assert.NotNull(userStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsGists() + { + var gistStats = await + _github.Enterprise.AdminStats.GetStatisticsGists(); + + Assert.NotNull(gistStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsPulls() + { + var pullStats = await + _github.Enterprise.AdminStats.GetStatisticsPulls(); + + Assert.NotNull(pullStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsRepos() + { + var repoStats = await + _github.Enterprise.AdminStats.GetStatisticsRepos(); + + Assert.NotNull(repoStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsAll() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatisticsAll(); + + Assert.NotNull(adminStats); + Assert.NotNull(adminStats.Repos); + Assert.NotNull(adminStats.Hooks); + Assert.NotNull(adminStats.Pages); + Assert.NotNull(adminStats.Orgs); + Assert.NotNull(adminStats.Users); + Assert.NotNull(adminStats.Pulls); + Assert.NotNull(adminStats.Issues); + Assert.NotNull(adminStats.Milestones); + Assert.NotNull(adminStats.Gists); + Assert.NotNull(adminStats.Comments); + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index f25b3d6a20..bd11852187 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -98,6 +98,14 @@ public static bool IsPaidAccount } } + public static bool IsGitHubEnterprise + { + get + { + return GitHubEnterpriseUrl != null; + } + } + public static string ClientId { get { return Environment.GetEnvironmentVariable("OCTOKIT_CLIENTID"); } diff --git a/Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs b/Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs new file mode 100644 index 0000000000..80c1df66c2 --- /dev/null +++ b/Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.Linq; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace Octokit.Tests.Integration +{ + public class GitHubEnterpriseTestDiscoverer : IXunitTestCaseDiscoverer + { + readonly IMessageSink diagnosticMessageSink; + + public GitHubEnterpriseTestDiscoverer(IMessageSink diagnosticMessageSink) + { + this.diagnosticMessageSink = diagnosticMessageSink; + } + + public IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + { + if (Helper.Credentials == null) + return Enumerable.Empty(); + + if (!Helper.IsGitHubEnterprise) + return Enumerable.Empty(); + + return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) }; + } + } + + [XunitTestCaseDiscoverer("Octokit.Tests.Integration.GitHubEnterpriseTestDiscoverer", "Octokit.Tests.Integration")] + public class GitHubEnterpriseTestAttribute : FactAttribute + { + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index b2cd9b6c12..145c04c937 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -77,6 +77,7 @@ + @@ -107,6 +108,7 @@ + @@ -118,6 +120,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs new file mode 100644 index 0000000000..2cb61234c0 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs @@ -0,0 +1,126 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration +{ + public class ObservableEnterpriseAdminStatsClientTests + { + readonly IObservableGitHubClient _github; + + public ObservableEnterpriseAdminStatsClientTests() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsIssues() + { + var issueStats = await + _github.Enterprise.AdminStats.GetStatisticsIssues(); + + Assert.NotNull(issueStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsHooks() + { + var hookStats = await + _github.Enterprise.AdminStats.GetStatisticsHooks(); + + Assert.NotNull(hookStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsMilestones() + { + var milestoneStats = await + _github.Enterprise.AdminStats.GetStatisticsMilestones(); + + Assert.NotNull(milestoneStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsOrgs() + { + var orgStats = await + _github.Enterprise.AdminStats.GetStatisticsOrgs(); + + Assert.NotNull(orgStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsComments() + { + var commentStats = await + _github.Enterprise.AdminStats.GetStatisticsComments(); + + Assert.NotNull(commentStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsPages() + { + var pageStats = await + _github.Enterprise.AdminStats.GetStatisticsPages(); + + Assert.NotNull(pageStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsUsers() + { + var userStats = await + _github.Enterprise.AdminStats.GetStatisticsUsers(); + + Assert.NotNull(userStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsGists() + { + var gistStats = await + _github.Enterprise.AdminStats.GetStatisticsGists(); + + Assert.NotNull(gistStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsPulls() + { + var pullStats = await + _github.Enterprise.AdminStats.GetStatisticsPulls(); + + Assert.NotNull(pullStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsRepos() + { + var repoStats = await + _github.Enterprise.AdminStats.GetStatisticsRepos(); + + Assert.NotNull(repoStats); + } + + [GitHubEnterpriseTest] + public async Task CanGetStatisticsAll() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatisticsAll(); + + Assert.NotNull(adminStats); + Assert.NotNull(adminStats.Repos); + Assert.NotNull(adminStats.Hooks); + Assert.NotNull(adminStats.Pages); + Assert.NotNull(adminStats.Orgs); + Assert.NotNull(adminStats.Users); + Assert.NotNull(adminStats.Pulls); + Assert.NotNull(adminStats.Issues); + Assert.NotNull(adminStats.Milestones); + Assert.NotNull(adminStats.Gists); + Assert.NotNull(adminStats.Comments); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/AssigneesClientTests.cs b/Octokit.Tests/Clients/AssigneesClientTests.cs index bd1ae266ce..12615271a2 100644 --- a/Octokit.Tests/Clients/AssigneesClientTests.cs +++ b/Octokit.Tests/Clients/AssigneesClientTests.cs @@ -9,7 +9,7 @@ namespace Octokit.Tests.Clients { - public class AssignessClientTests + public class AssigneesClientTests { public class TheGetForRepositoryMethod { diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs new file mode 100644 index 0000000000..1fe3bfa9e7 --- /dev/null +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs @@ -0,0 +1,163 @@ +using System; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class EnterpriseAdminStatsClientTests + { + public class TheGetStatisticsIssuesMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/issues"; + client.GetStatisticsIssues(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsHooksMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/hooks"; + client.GetStatisticsHooks(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsMilestonesMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/milestones"; + client.GetStatisticsMilestones(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsOrgsMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/orgs"; + client.GetStatisticsOrgs(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsCommentsMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/comments"; + client.GetStatisticsComments(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsPagesMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/pages"; + client.GetStatisticsPages(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsUsersMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/users"; + client.GetStatisticsUsers(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsGistsMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/gists"; + client.GetStatisticsGists(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsPullsMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/pulls"; + client.GetStatisticsPulls(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsReposMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/repos"; + client.GetStatisticsRepos(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + + public class TheGetStatisticsAllMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + string expectedUri = "enterprise/stats/all"; + client.GetStatisticsAll(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index c5ccda1c8c..58da5c6c1b 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -70,6 +70,7 @@ + diff --git a/Octokit.Tests/Octokit.Tests-Portable.csproj b/Octokit.Tests/Octokit.Tests-Portable.csproj index 8babf25a20..a8bde696d5 100644 --- a/Octokit.Tests/Octokit.Tests-Portable.csproj +++ b/Octokit.Tests/Octokit.Tests-Portable.csproj @@ -81,6 +81,7 @@ + diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 57055097f4..5af192547d 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -85,6 +85,7 @@ + @@ -206,6 +207,7 @@ + diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs new file mode 100644 index 0000000000..7c4957733c --- /dev/null +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs @@ -0,0 +1,166 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests +{ + public class ObservableEnterpriseAdminStatsClientTests + { + public class TheGetStatisticsIssuesMethod + { + [Fact] + public void CallsIntoClient() + { + + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsIssues(); + github.Enterprise.AdminStats.Received(1).GetStatisticsIssues(); + } + } + + public class TheGetStatisticsHooksMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsHooks(); + github.Enterprise.AdminStats.Received(1).GetStatisticsHooks(); + } + } + + public class TheGetStatisticsMilestonesMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsMilestones(); + github.Enterprise.AdminStats.Received(1).GetStatisticsMilestones(); + } + } + + public class TheGetStatisticsOrgsMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsOrgs(); + github.Enterprise.AdminStats.Received(1).GetStatisticsOrgs(); + } + } + + public class TheGetStatisticsCommentsMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsComments(); + github.Enterprise.AdminStats.Received(1).GetStatisticsComments(); + } + } + + public class TheGetStatisticsPagesMethod + { + [Fact] + public void CallsIntoClient() + { + + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsPages(); + github.Enterprise.AdminStats.Received(1).GetStatisticsPages(); + } + } + + public class TheGetStatisticsUsersMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsUsers(); + github.Enterprise.AdminStats.Received(1).GetStatisticsUsers(); + } + } + + public class TheGetStatisticsGistsMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsGists(); + github.Enterprise.AdminStats.Received(1).GetStatisticsGists(); + } + } + + public class TheGetStatisticsPullsMethod + { + [Fact] + public void CallsIntoClient() + { + + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsPulls(); + github.Enterprise.AdminStats.Received(1).GetStatisticsPulls(); + } + } + + public class TheGetStatisticsReposMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsRepos(); + github.Enterprise.AdminStats.Received(1).GetStatisticsRepos(); + } + } + + public class TheGetStatisticsAllMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + client.GetStatisticsAll(); + github.Enterprise.AdminStats.Received(1).GetStatisticsAll(); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseAdminStatsClient(null)); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs new file mode 100644 index 0000000000..69bf34f1ee --- /dev/null +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -0,0 +1,182 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + public class EnterpriseAdminStatsClient : ApiClient, IEnterpriseAdminStatsClient + { + public EnterpriseAdminStatsClient(IApiConnection apiConnection) + : base(apiConnection) + { } + + /// + /// Gets GitHub Enterprise Issue statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsIssues() + { + var endpoint = ApiUrls.EnterpriseAdminStatsIssues(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise Hook statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsHooks() + { + var endpoint = ApiUrls.EnterpriseAdminStatsHooks(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise Milestone statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsMilestones() + { + var endpoint = ApiUrls.EnterpriseAdminStatsMilestones(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise Organization statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsOrgs() + { + var endpoint = ApiUrls.EnterpriseAdminStatsOrgs(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise Comment statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsComments() + { + var endpoint = ApiUrls.EnterpriseAdminStatsComments(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise Pages statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsPages() + { + var endpoint = ApiUrls.EnterpriseAdminStatsPages(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise User statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsUsers() + { + var endpoint = ApiUrls.EnterpriseAdminStatsUsers(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise Gist statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsGists() + { + var endpoint = ApiUrls.EnterpriseAdminStatsGists(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise PullRequest statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsPulls() + { + var endpoint = ApiUrls.EnterpriseAdminStatsPulls(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise Repository statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + public async Task GetStatisticsRepos() + { + var endpoint = ApiUrls.EnterpriseAdminStatsRepos(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + + /// + /// Gets GitHub Enterprise statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection of statistics. + public async Task GetStatisticsAll() + { + var endpoint = ApiUrls.EnterpriseAdminStatsAll(); + + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); + } + } +} diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs new file mode 100644 index 0000000000..42e1763a64 --- /dev/null +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -0,0 +1,28 @@ +namespace Octokit +{ + /// + /// A client for GitHub's Enterprise API. + /// + /// + /// See the Enterprise API documentation for more information. + /// + public class EnterpriseClient : ApiClient, IEnterpriseClient + { + /// + /// Instantiates a new GitHub Enterprise API client. + /// + /// An API connection + public EnterpriseClient(IApiConnection apiConnection) : base(apiConnection) + { + AdminStats = new EnterpriseAdminStatsClient(apiConnection); + } + + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + public IEnterpriseAdminStatsClient AdminStats { get; private set; } + } +} diff --git a/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs new file mode 100644 index 0000000000..52c9e4e634 --- /dev/null +++ b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs @@ -0,0 +1,125 @@ +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + public interface IEnterpriseAdminStatsClient + { + /// + /// Gets GitHub Enterprise Issue statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsIssues(); + + /// + /// Gets GitHub Enterprise Hook statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsHooks(); + + /// + /// Gets GitHub Enterprise Milestone statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsMilestones(); + + /// + /// Gets GitHub Enterprise Organization statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsOrgs(); + + /// + /// Gets GitHub Enterprise Comment statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsComments(); + + /// + /// Gets GitHub Enterprise Pages statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsPages(); + + /// + /// Gets GitHub Enterprise User statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsUsers(); + + /// + /// Gets GitHub Enterprise Gist statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsGists(); + + /// + /// Gets GitHub Enterprise PullRequest statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsPulls(); + + /// + /// Gets GitHub Enterprise Repository statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsRepos(); + + /// + /// Gets GitHub Enterprise statistics (must be Site Admin user). + /// + /// + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection of statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsAll(); + } +} diff --git a/Octokit/Clients/Enterprise/IEnterpriseClient.cs b/Octokit/Clients/Enterprise/IEnterpriseClient.cs new file mode 100644 index 0000000000..e5eff83a41 --- /dev/null +++ b/Octokit/Clients/Enterprise/IEnterpriseClient.cs @@ -0,0 +1,19 @@ +namespace Octokit +{ + /// + /// A client for GitHub's Enterprise API. + /// + /// + /// See the Enterprise API documentation for more information. + /// + public interface IEnterpriseClient + { + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Enterprise Admin Stats API documentation for more information. + /// + IEnterpriseAdminStatsClient AdminStats { get; } + } +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index b59830a64b..105a7da1e5 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -97,6 +97,7 @@ public GitHubClient(IConnection connection) Git = new GitDatabaseClient(apiConnection); Search = new SearchClient(apiConnection); Deployment = new DeploymentsClient(apiConnection); + Enterprise = new EnterpriseClient(apiConnection); } /// @@ -287,6 +288,14 @@ public IReleasesClient Release /// public IDeploymentsClient Deployment { get; private set; } + /// + /// Access GitHub's Enterprise API. + /// + /// + /// Refer to the API docmentation for more information: https://developer.github.com/v3/enterprise/ + /// + public IEnterpriseClient Enterprise { get; private set; } + static Uri FixUpBaseUri(Uri uri) { Ensure.ArgumentNotNull(uri, "uri"); diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index a1bc2dcab7..dd2e907c17 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1569,5 +1569,65 @@ public static Uri RepositoryPageBuildsLatest(string owner, string name) { return "repos/{0}/{1}/pages/builds/latest".FormatUri(owner, name); } + + private static Uri EnterpriseAdminStats(string type) + { + return "enterprise/stats/{0}".FormatUri(type); + } + + public static Uri EnterpriseAdminStatsIssues() + { + return EnterpriseAdminStats("issues"); + } + + public static Uri EnterpriseAdminStatsHooks() + { + return EnterpriseAdminStats("hooks"); + } + + public static Uri EnterpriseAdminStatsMilestones() + { + return EnterpriseAdminStats("milestones"); + } + + public static Uri EnterpriseAdminStatsOrgs() + { + return EnterpriseAdminStats("orgs"); + } + + public static Uri EnterpriseAdminStatsComments() + { + return EnterpriseAdminStats("comments"); + } + + public static Uri EnterpriseAdminStatsPages() + { + return EnterpriseAdminStats("pages"); + } + + public static Uri EnterpriseAdminStatsUsers() + { + return EnterpriseAdminStats("users"); + } + + public static Uri EnterpriseAdminStatsGists() + { + return EnterpriseAdminStats("gists"); + } + + public static Uri EnterpriseAdminStatsPulls() + { + return EnterpriseAdminStats("pulls"); + } + + public static Uri EnterpriseAdminStatsRepos() + { + return EnterpriseAdminStats("repos"); + } + + public static Uri EnterpriseAdminStatsAll() + { + return EnterpriseAdminStats("all"); + } } } diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index d5b97ad4d1..26712b07ac 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -146,5 +146,13 @@ public interface IGitHubClient : IApiInfoProvider /// Refer to the API docmentation for more information: https://developer.github.com/v3/search/ /// ISearchClient Search { get; } + + /// + /// Access GitHub's Enterprise API + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/enterprise/ + /// + IEnterpriseClient Enterprise { get; } } } diff --git a/Octokit/Models/Response/Enterprise/AdminStats.cs b/Octokit/Models/Response/Enterprise/AdminStats.cs new file mode 100644 index 0000000000..67e3dc7128 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStats.cs @@ -0,0 +1,107 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStats + { + public AdminStats() { } + + public AdminStats(AdminStatsRepos repos, AdminStatsHooks hooks, AdminStatsPages pages, AdminStatsOrgs orgs, AdminStatsUsers users, AdminStatsPulls pulls, AdminStatsIssues issues, AdminStatsMilestones milestones, AdminStatsGists gists, AdminStatsComments comments) + { + Repos = repos; + Hooks = hooks; + Pages = pages; + Orgs = orgs; + Users = users; + Pulls = pulls; + Issues = issues; + Milestones = milestones; + Gists = gists; + Comments = comments; + } + + public AdminStatsRepos Repos + { + get; + private set; + } + + public AdminStatsHooks Hooks + { + get; + private set; + } + + public AdminStatsPages Pages + { + get; + private set; + } + + public AdminStatsOrgs Orgs + { + get; + private set; + } + + public AdminStatsUsers Users + { + get; + private set; + } + + public AdminStatsPulls Pulls + { + get; + private set; + } + + public AdminStatsIssues Issues + { + get; + private set; + } + + public AdminStatsMilestones Milestones + { + get; + private set; + } + + public AdminStatsGists Gists + { + get; + private set; + } + + public AdminStatsComments Comments + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + string fieldsPresent = String.Concat( + Repos != null ? "Repos," : "", + Hooks != null ? "Hooks," : "", + Pages != null ? "Pages," : "", + Orgs != null ? "Orgs," : "", + Users != null ? "Users," : "", + Pulls != null ? "Pulls," : "", + Issues != null ? "Issues," : "", + Milestones != null ? "Milestones," : "", + Gists != null ? "Gists," : "", + Comments != null ? "Comments," : "" + ).Trim(','); + + return String.Format(CultureInfo.InvariantCulture, "Statistics: {0}", fieldsPresent); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsComments.cs b/Octokit/Models/Response/Enterprise/AdminStatsComments.cs new file mode 100644 index 0000000000..2502b9a92f --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsComments.cs @@ -0,0 +1,52 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsComments + { + public AdminStatsComments() { } + + public AdminStatsComments(int totalCommitComments, int totalGistComments, int totalIssueComments, int totalPullRequestComments) + { + TotalCommitComments = totalCommitComments; + TotalGistComments = totalGistComments; + TotalIssueComments = totalIssueComments; + TotalPullRequestComments = totalPullRequestComments; + } + + public int TotalCommitComments + { + get; + private set; + } + + public int TotalGistComments + { + get; + private set; + } + + public int TotalIssueComments + { + get; + private set; + } + + public int TotalPullRequestComments + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalCommitComments: {0} TotalGistComments: {1} TotalIssueComments: {2} TotalPullRequestComments: {3}", TotalCommitComments, TotalGistComments, TotalIssueComments, TotalPullRequestComments); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsGists.cs b/Octokit/Models/Response/Enterprise/AdminStatsGists.cs new file mode 100644 index 0000000000..2b6488c205 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsGists.cs @@ -0,0 +1,45 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsGists + { + public AdminStatsGists() { } + + public AdminStatsGists(int totalGists, int privateGists, int publicGists) + { + TotalGists = totalGists; + PrivateGists = privateGists; + PublicGists = publicGists; + } + + public int TotalGists + { + get; + private set; + } + + public int PrivateGists + { + get; + private set; + } + + public int PublicGists + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalGists: {0} PrivateGists: {1} PublicGists: {2}", TotalGists, PrivateGists, PublicGists); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs b/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs new file mode 100644 index 0000000000..b960d6d44f --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs @@ -0,0 +1,45 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsHooks + { + public AdminStatsHooks() { } + + public AdminStatsHooks(int totalHooks, int activeHooks, int inactiveHooks) + { + TotalHooks = totalHooks; + ActiveHooks = activeHooks; + InactiveHooks = inactiveHooks; + } + + public int TotalHooks + { + get; + private set; + } + + public int ActiveHooks + { + get; + private set; + } + + public int InactiveHooks + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalHooks: {0} ActiveHooks: {1} InactiveHooks: {2}", TotalHooks, ActiveHooks, InactiveHooks); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs b/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs new file mode 100644 index 0000000000..1b02ae759b --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs @@ -0,0 +1,45 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsIssues + { + public AdminStatsIssues() { } + + public AdminStatsIssues(int totalIssues, int openIssues, int closedIssues) + { + TotalIssues = totalIssues; + OpenIssues = openIssues; + ClosedIssues = closedIssues; + } + + public int TotalIssues + { + get; + private set; + } + + public int OpenIssues + { + get; + private set; + } + + public int ClosedIssues + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalIssues: {0} OpenIssues: {1} ClosedIssues: {2}", TotalIssues, OpenIssues, ClosedIssues); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs b/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs new file mode 100644 index 0000000000..2fd1e8e865 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs @@ -0,0 +1,45 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsMilestones + { + public AdminStatsMilestones() { } + + public AdminStatsMilestones(int totalMilestones, int openMilestones, int closedMilestones) + { + TotalMilestones = totalMilestones; + OpenMilestones = openMilestones; + ClosedMilestones = closedMilestones; + } + + public int TotalMilestones + { + get; + private set; + } + + public int OpenMilestones + { + get; + private set; + } + + public int ClosedMilestones + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalMilestones: {0} OpenMilestones: {1} ClosedMilestones: {2}", TotalMilestones, OpenMilestones, ClosedMilestones); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs b/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs new file mode 100644 index 0000000000..2149227a9b --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs @@ -0,0 +1,52 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsOrgs + { + public AdminStatsOrgs() { } + + public AdminStatsOrgs(int totalOrgs, int disabledOrgs, int totalTeams, int totalTeamMembers) + { + TotalOrgs = totalOrgs; + DisabledOrgs = disabledOrgs; + TotalTeams = totalTeams; + TotalTeamMembers = totalTeamMembers; + } + + public int TotalOrgs + { + get; + private set; + } + + public int DisabledOrgs + { + get; + private set; + } + + public int TotalTeams + { + get; + private set; + } + + public int TotalTeamMembers + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalOrgs: {0} DisabledOrgs: {1} TotalTeams: {2} TotalTeamMembers: {3}", TotalOrgs, DisabledOrgs, TotalTeams, TotalTeamMembers); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsPages.cs b/Octokit/Models/Response/Enterprise/AdminStatsPages.cs new file mode 100644 index 0000000000..4f0965ec3b --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsPages.cs @@ -0,0 +1,31 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsPages + { + public AdminStatsPages() { } + + public AdminStatsPages(int totalPages) + { + TotalPages = totalPages; + } + + public int TotalPages + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalPages: {0}", TotalPages); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs new file mode 100644 index 0000000000..44e6cf34e9 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs @@ -0,0 +1,55 @@ +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsPulls + { + public AdminStatsPulls() { } + + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "unmergeable")] + public AdminStatsPulls(int totalPulls, int mergedPulls, int mergeablePulls, int unmergeablePulls) + { + TotalPulls = totalPulls; + MergedPulls = mergedPulls; + MergeablePulls = mergeablePulls; + UnmergeablePulls = unmergeablePulls; + } + + public int TotalPulls + { + get; + private set; + } + + public int MergedPulls + { + get; + private set; + } + + public int MergeablePulls + { + get; + private set; + } + + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unmergeable")] + public int UnmergeablePulls + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalPulls: {0} MergedPulls: {1} MergeablePulls: {2} UnmergeablePulls: {3}", TotalPulls, MergedPulls, MergeablePulls, UnmergeablePulls); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs b/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs new file mode 100644 index 0000000000..3895389b60 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs @@ -0,0 +1,66 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsRepos + { + public AdminStatsRepos() { } + + public AdminStatsRepos(int totalRepos, int rootRepos, int forkRepos, int orgRepos, int totalPushes, int totalWikis) + { + TotalRepos = totalRepos; + RootRepos = rootRepos; + ForkRepos = forkRepos; + OrgRepos = orgRepos; + TotalPushes = totalPushes; + TotalWikis = totalWikis; + } + + public int TotalRepos + { + get; + private set; + } + + public int RootRepos + { + get; + private set; + } + + public int ForkRepos + { + get; + private set; + } + + public int OrgRepos + { + get; + private set; + } + + public int TotalPushes + { + get; + private set; + } + + public int TotalWikis + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalRepos: {0} RootRepos: {1} ForkRepos: {2} OrgRepos: {3} TotalPushes: {4} TotalWikis: {5}", TotalRepos, RootRepos, ForkRepos, OrgRepos, TotalPushes, TotalWikis); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs b/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs new file mode 100644 index 0000000000..4dcc8242d7 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs @@ -0,0 +1,45 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AdminStatsUsers + { + public AdminStatsUsers() { } + + public AdminStatsUsers(int totalUsers, int adminUsers, int suspendedUsers) + { + TotalUsers = totalUsers; + AdminUsers = adminUsers; + SuspendedUsers = suspendedUsers; + } + + public int TotalUsers + { + get; + private set; + } + + public int AdminUsers + { + get; + private set; + } + + public int SuspendedUsers + { + get; + private set; + } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "TotalUsers: {0} AdminUsers: {1} SuspendedUsers: {2}", TotalUsers, AdminUsers, SuspendedUsers); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index b76e632319..d46271b2a0 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -420,6 +420,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 45e80dc009..3897d4ae61 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -427,6 +427,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index e66291bf67..cd30e2a088 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -423,6 +423,21 @@ + + + + + + + + + + + + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 6860a747e9..dd5907bd89 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -417,6 +417,21 @@ + + + + + + + + + + + + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index e922b06a0a..9d5fd54614 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -424,6 +424,21 @@ + + + + + + + + + + + + + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 38e4487511..549f391f49 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,6 +58,10 @@ Properties\SolutionInfo.cs + + + + @@ -126,6 +130,17 @@ + + + + + + + + + + +