From 2f4b855e84b3fdca9b9e563ac2a982fc35a725c0 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 24 Dec 2015 13:54:11 +1000 Subject: [PATCH 01/26] Add Enterprise base API stub --- .../Clients/Enterprise/EnterpriseClient.cs | 24 +++++++++++++++++++ .../Clients/Enterprise/IEnterpriseClient.cs | 16 +++++++++++++ Octokit/Octokit.csproj | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 Octokit/Clients/Enterprise/EnterpriseClient.cs create mode 100644 Octokit/Clients/Enterprise/IEnterpriseClient.cs diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs new file mode 100644 index 0000000000..7991bb363f --- /dev/null +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -0,0 +1,24 @@ +using System; +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's Users API. + /// + /// + /// See the Users API documentation for more information. + /// + public class EnterpriseClient : ApiClient, IEnterpriseClient + { + static readonly Uri _enterpriseEndpoint = new Uri("enterprise", UriKind.Relative); + + /// + /// Instantiates a new GitHub Enterprise API client. + /// + /// An API connection + public EnterpriseClient(IApiConnection apiConnection) : base(apiConnection) + { + } + } +} diff --git a/Octokit/Clients/Enterprise/IEnterpriseClient.cs b/Octokit/Clients/Enterprise/IEnterpriseClient.cs new file mode 100644 index 0000000000..3d991dd322 --- /dev/null +++ b/Octokit/Clients/Enterprise/IEnterpriseClient.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's Enterprise API. + /// + /// + /// See the Enterprise API documentation for more information. + /// + public interface IEnterpriseClient + { + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 3bd8bb7a7c..e06b6b6e53 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,6 +58,8 @@ Properties\SolutionInfo.cs + + From 40120619c61cbb69a62d7b1904a951996a8ecf51 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 24 Dec 2015 14:20:49 +1000 Subject: [PATCH 02/26] compiler whinging about unused field --- Octokit/Clients/Enterprise/EnterpriseClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs index 7991bb363f..ae3bf6b002 100644 --- a/Octokit/Clients/Enterprise/EnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -11,7 +11,7 @@ namespace Octokit /// public class EnterpriseClient : ApiClient, IEnterpriseClient { - static readonly Uri _enterpriseEndpoint = new Uri("enterprise", UriKind.Relative); + //static readonly Uri _enterpriseEndpoint = new Uri("enterprise", UriKind.Relative); /// /// Instantiates a new GitHub Enterprise API client. From c9026e472378b427fd6ac1dfac15028a6d859261 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 24 Dec 2015 15:05:34 +1000 Subject: [PATCH 03/26] add base Enterprise client to GitHubClient --- Octokit/GitHubClient.cs | 9 +++++++++ Octokit/IGitHubClient.cs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index 6115f282a0..6b59e94530 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -98,6 +98,7 @@ public GitHubClient(IConnection connection) GitDatabase = new GitDatabaseClient(apiConnection); Search = new SearchClient(apiConnection); Deployment = new DeploymentsClient(apiConnection); + Enterprise = new EnterpriseClient(apiConnection); } /// @@ -276,6 +277,14 @@ public Uri BaseAddress /// 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/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 07aae0a5bf..281d0de9b4 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -134,5 +134,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; } } } From 3f437eb9f0d40c9cfd765b6e8b54711c9e50136a Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 24 Dec 2015 15:08:43 +1000 Subject: [PATCH 04/26] First cut of AdminStats client and tests --- .../EnterpriseAdminStatsClientTest.cs | 35 ++++++++ Octokit.Tests.Integration/Helper.cs | 8 ++ .../Helpers/GitHubEnterpriseTestAttribute.cs | 34 ++++++++ .../Octokit.Tests.Integration.csproj | 2 + Octokit.Tests/Clients/AssigneesClientTests.cs | 2 +- .../EnterpriseAdminStatsClientTest.cs | 31 ++++++++ Octokit.Tests/Octokit.Tests.csproj | 1 + .../Enterprise/EnterpriseAdminStatsClient.cs | 29 +++++++ .../Clients/Enterprise/EnterpriseClient.cs | 9 +++ .../Enterprise/IEnterpriseAdminStatsClient.cs | 28 +++++++ .../Clients/Enterprise/IEnterpriseClient.cs | 7 ++ Octokit/Helpers/ApiUrls.cs | 5 ++ .../Models/Response/Enterprise/AdminStats.cs | 79 +++++++++++++++++++ .../Response/Enterprise/AdminStatsComments.cs | 37 +++++++++ .../Response/Enterprise/AdminStatsGists.cs | 30 +++++++ .../Response/Enterprise/AdminStatsHooks.cs | 30 +++++++ .../Response/Enterprise/AdminStatsIssues.cs | 30 +++++++ .../Enterprise/AdminStatsMilestones.cs | 30 +++++++ .../Response/Enterprise/AdminStatsOrgs.cs | 37 +++++++++ .../Response/Enterprise/AdminStatsPages.cs | 16 ++++ .../Response/Enterprise/AdminStatsPulls.cs | 40 ++++++++++ .../Response/Enterprise/AdminStatsRepos.cs | 51 ++++++++++++ .../Response/Enterprise/AdminStatsUsers.cs | 30 +++++++ Octokit/Octokit.csproj | 13 +++ 24 files changed, 613 insertions(+), 1 deletion(-) create mode 100644 Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs create mode 100644 Octokit.Tests.Integration/Helpers/GitHubEnterpriseTestAttribute.cs create mode 100644 Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs create mode 100644 Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs create mode 100644 Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStats.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsComments.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsGists.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsHooks.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsIssues.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsPages.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsPulls.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsRepos.cs create mode 100644 Octokit/Models/Response/Enterprise/AdminStatsUsers.cs diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs new file mode 100644 index 0000000000..6e0298ca49 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -0,0 +1,35 @@ +using System.Linq; +using System.Threading.Tasks; +using Octokit; +using Octokit.Tests.Integration; +using Octokit.Tests.Integration.Helpers; +using Xunit; + +public class EnterpriseAdminStatsClientTest +{ + readonly IGitHubClient _github; + + public EnterpriseAdminStatsClientTest() + { + _github = Helper.GetAuthenticatedClient(); + } + + [GitHubEnterpriseTest] + public async Task CanGetAllStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.All); + + 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 73eb4124e8..a85fdf7131 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -77,6 +77,7 @@ + @@ -106,6 +107,7 @@ + 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/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs new file mode 100644 index 0000000000..f1c5107eda --- /dev/null +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Internal; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class EnterpriseAdminStatsClientTest + { + public class TheGetStatisticsMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new EnterpriseAdminStatsClient(connection); + + foreach (AdminStatsType adminType in Enum.GetValues(typeof(AdminStatsType))) + { + client.GetStatistics(adminType); + + connection.Received().Get(Arg.Is(u => u.ToString() == String.Concat("enterprise/stats/", adminType.ToString().ToLowerInvariant()))); + } + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 5dc32016bc..aacc1e364a 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -85,6 +85,7 @@ + diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs new file mode 100644 index 0000000000..85d86cf207 --- /dev/null +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + public class EnterpriseAdminStatsClient : ApiClient, IEnterpriseAdminStatsClient + { + public EnterpriseAdminStatsClient(IApiConnection apiConnection) + : base(apiConnection) + { } + + /// + /// Gets all email addresses for the authenticated user. + /// + /// + ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection for the requested type. + [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] + public Task GetStatistics(AdminStatsType type) + { + return ApiConnection.Get(ApiUrls.EnterpriseAdminStats(type.ToString().ToLowerInvariant())); + } + } +} diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs index ae3bf6b002..99ab9604a9 100644 --- a/Octokit/Clients/Enterprise/EnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -19,6 +19,15 @@ public class EnterpriseClient : ApiClient, IEnterpriseClient /// An API connection public EnterpriseClient(IApiConnection apiConnection) : base(apiConnection) { + AdminStats = new EnterpriseAdminStatsClient(apiConnection); } + + /// + /// A client for GitHub's Enterprise AdminStats 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..36891c46eb --- /dev/null +++ b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IEnterpriseAdminStatsClient + { + Task GetStatistics(AdminStatsType type); + } + + public enum AdminStatsType + { + Issues, + Hooks, + Milestones, + Orgs, + Comments, + Pages, + Users, + Gists, + Pulls, + Repos, + All + } +} diff --git a/Octokit/Clients/Enterprise/IEnterpriseClient.cs b/Octokit/Clients/Enterprise/IEnterpriseClient.cs index 3d991dd322..cfd48dfa0a 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseClient.cs @@ -12,5 +12,12 @@ namespace Octokit /// public interface IEnterpriseClient { + /// + /// A client for GitHub's Enterprise Admin Stats API + /// + /// + /// See the Admin Stats API documentation for more information. + /// + IEnterpriseAdminStatsClient AdminStats { get; } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index f8f79d68cd..9811e44669 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1554,5 +1554,10 @@ public static Uri RepositoryContent(string owner, string name, string path, stri { return "repos/{0}/{1}/contents/{2}?ref={3}".FormatUri(owner, name, path, reference); } + + public static Uri EnterpriseAdminStats(string type) + { + return "enterprise/stats/{0}".FormatUri(type); + } } } diff --git a/Octokit/Models/Response/Enterprise/AdminStats.cs b/Octokit/Models/Response/Enterprise/AdminStats.cs new file mode 100644 index 0000000000..93829a6378 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStats.cs @@ -0,0 +1,79 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..31f82bfa1e --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsComments.cs @@ -0,0 +1,37 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..f116db9d43 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsGists.cs @@ -0,0 +1,30 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..76aa2e085f --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs @@ -0,0 +1,30 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..9016e70463 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs @@ -0,0 +1,30 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..193ebeeb86 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs @@ -0,0 +1,30 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..1696725efb --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs @@ -0,0 +1,37 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..0ea507d3ea --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsPages.cs @@ -0,0 +1,16 @@ +namespace Octokit +{ + public class AdminStatsPages + { + public AdminStatsPages(int totalPages) + { + TotalPages = totalPages; + } + + public int TotalPages + { + get; + private set; + } + } +} \ 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..5071da64d4 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs @@ -0,0 +1,40 @@ +using System.Diagnostics.CodeAnalysis; + +namespace Octokit +{ + public class AdminStatsPulls + { + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "unmergeablePulls")] + 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; + } + + public int UnmergeablePulls + { + get; + private set; + } + } +} \ 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..c9b324b42b --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs @@ -0,0 +1,51 @@ +namespace Octokit +{ + public class 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; + } + } +} \ 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..3af82db98f --- /dev/null +++ b/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs @@ -0,0 +1,30 @@ +namespace Octokit +{ + public class 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; + } + } +} \ No newline at end of file diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index e06b6b6e53..c01e803703 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,7 +58,9 @@ Properties\SolutionInfo.cs + + @@ -126,6 +128,17 @@ + + + + + + + + + + + From 18bb3fa4f33eb8932025ac7a6009dc3b6efcad78 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 26 Dec 2015 19:45:20 +1000 Subject: [PATCH 05/26] add new files to all projects --- Octokit/Octokit-Mono.csproj | 15 +++++++++++++++ Octokit/Octokit-MonoAndroid.csproj | 15 +++++++++++++++ Octokit/Octokit-Monotouch.csproj | 15 +++++++++++++++ Octokit/Octokit-Portable.csproj | 15 +++++++++++++++ Octokit/Octokit-netcore45.csproj | 15 +++++++++++++++ 5 files changed, 75 insertions(+) diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 3b4d98aecf..ea33a7b032 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -414,6 +414,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 83b337ac6a..f91ee71089 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -421,6 +421,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 79d05bde5d..a66e81652e 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -417,6 +417,21 @@ + + + + + + + + + + + + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index b1ac0d7072..722805ca67 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -411,6 +411,21 @@ + + + + + + + + + + + + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 11a51e179e..02373a0e62 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -418,6 +418,21 @@ + + + + + + + + + + + + + + + From 53baabcda59782111c115a560cba9eca030d626f Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 26 Dec 2015 22:44:28 +1000 Subject: [PATCH 06/26] fix code analysis suppression --- Octokit/Models/Response/Enterprise/AdminStatsPulls.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs index 5071da64d4..7c6a6b4daa 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs @@ -4,7 +4,7 @@ namespace Octokit { public class AdminStatsPulls { - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "unmergeablePulls")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "unmergeable")] public AdminStatsPulls(int totalPulls, int mergedPulls, int mergeablePulls, int unmergeablePulls) { TotalPulls = totalPulls; @@ -31,6 +31,7 @@ public int MergeablePulls private set; } + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unmergeable")] public int UnmergeablePulls { get; From e621f1e0513d8c046c3df96c8d7b49be87744f5f Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 26 Dec 2015 22:44:58 +1000 Subject: [PATCH 07/26] fix unit test --- .../Clients/Enterprise/EnterpriseAdminStatsClientTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs index f1c5107eda..3753513372 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -23,7 +23,7 @@ public void RequestsCorrectUrl() { client.GetStatistics(adminType); - connection.Received().Get(Arg.Is(u => u.ToString() == String.Concat("enterprise/stats/", adminType.ToString().ToLowerInvariant()))); + connection.Received().Get(Arg.Is(u => u.ToString() == String.Concat("enterprise/stats/", adminType.ToString().ToLowerInvariant())), null); } } } From 0424205f72081d06baa832310eaeacc5539abef0 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 26 Dec 2015 22:45:49 +1000 Subject: [PATCH 08/26] add default constructors to Response model classes --- Octokit/Models/Response/Enterprise/AdminStats.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsComments.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsGists.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsHooks.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsIssues.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsPages.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsPulls.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsRepos.cs | 2 ++ Octokit/Models/Response/Enterprise/AdminStatsUsers.cs | 2 ++ 11 files changed, 22 insertions(+) diff --git a/Octokit/Models/Response/Enterprise/AdminStats.cs b/Octokit/Models/Response/Enterprise/AdminStats.cs index 93829a6378..2e7b6b8565 100644 --- a/Octokit/Models/Response/Enterprise/AdminStats.cs +++ b/Octokit/Models/Response/Enterprise/AdminStats.cs @@ -2,6 +2,8 @@ { 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; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsComments.cs b/Octokit/Models/Response/Enterprise/AdminStatsComments.cs index 31f82bfa1e..bdca28e40d 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsComments.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsComments.cs @@ -2,6 +2,8 @@ { public class AdminStatsComments { + public AdminStatsComments() { } + public AdminStatsComments(int totalCommitComments, int totalGistComments, int totalIssueComments, int totalPullRequestComments) { TotalCommitComments = totalCommitComments; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsGists.cs b/Octokit/Models/Response/Enterprise/AdminStatsGists.cs index f116db9d43..b9fb451d86 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsGists.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsGists.cs @@ -2,6 +2,8 @@ { public class AdminStatsGists { + public AdminStatsGists() { } + public AdminStatsGists(int totalGists, int privateGists, int publicGists) { TotalGists = totalGists; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs b/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs index 76aa2e085f..5fa06bbe68 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs @@ -2,6 +2,8 @@ { public class AdminStatsHooks { + public AdminStatsHooks() { } + public AdminStatsHooks(int totalHooks, int activeHooks, int inactiveHooks) { TotalHooks = totalHooks; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs b/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs index 9016e70463..c769e2ece3 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs @@ -2,6 +2,8 @@ { public class AdminStatsIssues { + public AdminStatsIssues() { } + public AdminStatsIssues(int totalIssues, int openIssues, int closedIssues) { TotalIssues = totalIssues; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs b/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs index 193ebeeb86..f944f3e3b1 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs @@ -2,6 +2,8 @@ { public class AdminStatsMilestones { + public AdminStatsMilestones() { } + public AdminStatsMilestones(int totalMilestones, int openMilestones, int closedMilestones) { TotalMilestones = totalMilestones; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs b/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs index 1696725efb..d52ac6d409 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs @@ -2,6 +2,8 @@ { public class AdminStatsOrgs { + public AdminStatsOrgs() { } + public AdminStatsOrgs(int totalOrgs, int disabledOrgs, int totalTeams, int totalTeamMembers) { TotalOrgs = totalOrgs; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsPages.cs b/Octokit/Models/Response/Enterprise/AdminStatsPages.cs index 0ea507d3ea..65d351172a 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsPages.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsPages.cs @@ -2,6 +2,8 @@ { public class AdminStatsPages { + public AdminStatsPages() { } + public AdminStatsPages(int totalPages) { TotalPages = totalPages; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs index 7c6a6b4daa..1e6916d717 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs @@ -4,6 +4,8 @@ namespace Octokit { public class AdminStatsPulls { + public AdminStatsPulls() { } + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "unmergeable")] public AdminStatsPulls(int totalPulls, int mergedPulls, int mergeablePulls, int unmergeablePulls) { diff --git a/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs b/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs index c9b324b42b..4430ef77cc 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs @@ -2,6 +2,8 @@ { public class AdminStatsRepos { + public AdminStatsRepos() { } + public AdminStatsRepos(int totalRepos, int rootRepos, int forkRepos, int orgRepos, int totalPushes, int totalWikis) { TotalRepos = totalRepos; diff --git a/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs b/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs index 3af82db98f..af1106de6c 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs @@ -2,6 +2,8 @@ { public class AdminStatsUsers { + public AdminStatsUsers() { } + public AdminStatsUsers(int totalUsers, int adminUsers, int suspendedUsers) { TotalUsers = totalUsers; From 91ca43bf3c19b62d671e03b618b6a43a659dd7d9 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 26 Dec 2015 23:49:01 +1000 Subject: [PATCH 09/26] add comments and tidy up --- .../Enterprise/EnterpriseAdminStatsClientTest.cs | 6 +++--- .../Enterprise/EnterpriseAdminStatsClient.cs | 8 +++++++- Octokit/Clients/Enterprise/EnterpriseClient.cs | 6 +++--- .../Enterprise/IEnterpriseAdminStatsClient.cs | 13 +++++++++++++ Octokit/Clients/Enterprise/IEnterpriseClient.cs | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs index 3753513372..25a0abe7ca 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -19,11 +19,11 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new EnterpriseAdminStatsClient(connection); - foreach (AdminStatsType adminType in Enum.GetValues(typeof(AdminStatsType))) + foreach (AdminStatsType type in Enum.GetValues(typeof(AdminStatsType))) { - client.GetStatistics(adminType); + client.GetStatistics(type); - connection.Received().Get(Arg.Is(u => u.ToString() == String.Concat("enterprise/stats/", adminType.ToString().ToLowerInvariant())), null); + connection.Received().Get(Arg.Is(u => u == "enterprise/stats/{0}".FormatUri(type.ToString().ToLowerInvariant())), null); } } } diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs index 85d86cf207..e9ee1895e6 100644 --- a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -7,6 +7,12 @@ 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) @@ -14,7 +20,7 @@ public EnterpriseAdminStatsClient(IApiConnection apiConnection) { } /// - /// Gets all email addresses for the authenticated user. + /// Gets GitHub Enterprise statistics (must be Site Admin user). /// /// ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs index 99ab9604a9..add12d9341 100644 --- a/Octokit/Clients/Enterprise/EnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -4,10 +4,10 @@ namespace Octokit { /// - /// A client for GitHub's Users API. + /// A client for GitHub's Enterprise API. /// /// - /// See the Users API documentation for more information. + /// See the Enterprise API documentation for more information. /// public class EnterpriseClient : ApiClient, IEnterpriseClient { @@ -23,7 +23,7 @@ public EnterpriseClient(IApiConnection apiConnection) : base(apiConnection) } /// - /// A client for GitHub's Enterprise AdminStats API + /// A client for GitHub's Enterprise Admin Stats API /// /// /// See the Enterprise Admin Stats API documentation for more information. diff --git a/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs index 36891c46eb..465a56aded 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs @@ -6,8 +6,21 @@ 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 statistics (must be Site Admin user). + /// + /// + ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection for the requested type. Task GetStatistics(AdminStatsType type); } diff --git a/Octokit/Clients/Enterprise/IEnterpriseClient.cs b/Octokit/Clients/Enterprise/IEnterpriseClient.cs index cfd48dfa0a..eaf2d3aaa9 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseClient.cs @@ -16,7 +16,7 @@ public interface IEnterpriseClient /// A client for GitHub's Enterprise Admin Stats API /// /// - /// See the Admin Stats API documentation for more information. + /// See the Enterprise Admin Stats API documentation for more information. /// IEnterpriseAdminStatsClient AdminStats { get; } } From f196631b8997d32ccfdc94ff350eee559f2e9445 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 26 Dec 2015 23:49:26 +1000 Subject: [PATCH 10/26] Add Enterprise and EnterpriseAdminStats to Reactive project and tests --- .../IObservableEnterpriseAdminStatsClient.cs | 25 ++++++++++++ .../Enterprise/IObservableEnterpriseClient.cs | 22 +++++++++++ .../ObservableEnterpriseAdminStatsClient.cs | 37 ++++++++++++++++++ .../Enterprise/ObservableEnterpriseClient.cs | 29 ++++++++++++++ Octokit.Reactive/Octokit.Reactive.csproj | 4 ++ Octokit.Tests/Octokit.Tests.csproj | 1 + ...servableEnterpriseAdminStatsClientTests.cs | 39 +++++++++++++++++++ 7 files changed, 157 insertions(+) create mode 100644 Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs create mode 100644 Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs create mode 100644 Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs create mode 100644 Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs create mode 100644 Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs new file mode 100644 index 0000000000..bee756019f --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs @@ -0,0 +1,25 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Reactive; + +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 statistics (must be Site Admin user). + /// + /// + ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection for the requested type. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatistics(AdminStatsType type); + } +} diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs new file mode 100644 index 0000000000..25bf89a81b --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs @@ -0,0 +1,22 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +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..59c13f0342 --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs @@ -0,0 +1,37 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Reactive; +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 statistics (must be Site Admin user). + /// + /// + ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// + /// The collection for the requested type. + public IObservable GetStatistics(AdminStatsType type) + { + return _client.GetStatistics(type).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs new file mode 100644 index 0000000000..5f9067f4b3 --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs @@ -0,0 +1,29 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +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/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index d25d860ae6..cf5dca1e12 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/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index aacc1e364a..1a475c6c09 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -206,6 +206,7 @@ + diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs new file mode 100644 index 0000000000..4786faa010 --- /dev/null +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs @@ -0,0 +1,39 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using System.Collections.Generic; +using Xunit; + +namespace Octokit.Tests +{ + public class ObservableEnterpriseAdminStatsClientTests + { + public class TheGetStatisticsMethod + { + [Fact] + public void CallsIntoClient() + { + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); + + foreach (AdminStatsType type in Enum.GetValues(typeof(AdminStatsType))) + { + var expectedUri = "enterprise/stats/{0}".FormatUri(type.ToString().ToLowerInvariant()); + client.GetStatistics(type); + + github.Enterprise.AdminStats.Received(1).GetStatistics(type); + } + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseAdminStatsClient(null)); + } + } + } +} From feda6bcd117538ec30ede27ec529d4c475afb14b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 00:04:16 +1000 Subject: [PATCH 11/26] tidy up --- .../Enterprise/IObservableEnterpriseAdminStatsClient.cs | 3 --- .../Clients/Enterprise/IObservableEnterpriseClient.cs | 5 +---- .../Enterprise/ObservableEnterpriseAdminStatsClient.cs | 2 -- .../Clients/Enterprise/ObservableEnterpriseClient.cs | 5 +---- .../Clients/Enterprise/EnterpriseAdminStatsClientTest.cs | 5 ----- .../Enterprise/ObservableEnterpriseAdminStatsClientTests.cs | 1 - Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs | 6 +----- Octokit/Clients/Enterprise/EnterpriseClient.cs | 2 -- Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs | 6 +----- Octokit/Clients/Enterprise/IEnterpriseClient.cs | 6 +----- 10 files changed, 5 insertions(+), 36 deletions(-) diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs index bee756019f..af46950fc1 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs @@ -1,6 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive; namespace Octokit.Reactive { @@ -19,7 +17,6 @@ public interface IObservableEnterpriseAdminStatsClient ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The collection for the requested type. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetStatistics(AdminStatsType type); } } diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs index 25bf89a81b..4a494899ca 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Octokit.Reactive +namespace Octokit.Reactive { /// /// A client for GitHub's Enterprise API. diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs index 59c13f0342..1e121a488f 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs @@ -1,6 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; -using System.Reactive; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs index 5f9067f4b3..8466e9b85a 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Octokit.Reactive +namespace Octokit.Reactive { /// /// A client for GitHub's Enterprise API. diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs index 25a0abe7ca..4a7ff51988 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Net; -using System.Threading.Tasks; using NSubstitute; -using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs index 4786faa010..bfbfc9d51a 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs @@ -1,7 +1,6 @@ using NSubstitute; using Octokit.Reactive; using System; -using System.Collections.Generic; using Xunit; namespace Octokit.Tests diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs index e9ee1895e6..2d3f78b3ba 100644 --- a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; namespace Octokit diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs index add12d9341..f78d7aac7b 100644 --- a/Octokit/Clients/Enterprise/EnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -11,8 +11,6 @@ namespace Octokit /// public class EnterpriseClient : ApiClient, IEnterpriseClient { - //static readonly Uri _enterpriseEndpoint = new Uri("enterprise", UriKind.Relative); - /// /// Instantiates a new GitHub Enterprise API client. /// diff --git a/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs index 465a56aded..718b9f2993 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Octokit { diff --git a/Octokit/Clients/Enterprise/IEnterpriseClient.cs b/Octokit/Clients/Enterprise/IEnterpriseClient.cs index eaf2d3aaa9..e5eff83a41 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseClient.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; - -namespace Octokit +namespace Octokit { /// /// A client for GitHub's Enterprise API. From dc1a03bc3a70f16046841bf25c228fb848f890a4 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 01:16:33 +1000 Subject: [PATCH 12/26] Add Enterprise to Reactive GitHubClient --- Octokit.Reactive/IObservableGitHubClient.cs | 1 + Octokit.Reactive/ObservableGitHubClient.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 4bb181cf97..5c235bd0ce 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -20,5 +20,6 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableNotificationsClient Notification { get; } 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 c2230d2fd0..ea2d676897 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -68,6 +68,7 @@ public IConnection Connection public IObservableNotificationsClient Notification { get; private set; } public IObservableGitDatabaseClient GitDatabase { 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 From 28934e1284ebd2f84de56112174789d48121aa79 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 01:17:04 +1000 Subject: [PATCH 13/26] fixup mono projects --- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 6 +++++- Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj | 6 +++++- Octokit.Reactive/Octokit.Reactive-Monotouch.csproj | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index ceafa27403..56fa579383 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -157,6 +157,10 @@ + + + + @@ -165,4 +169,4 @@ Octokit-Mono - + \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index 3faa06a17b..6f95392393 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -165,6 +165,10 @@ + + + + @@ -173,4 +177,4 @@ Octokit-MonoAndroid - + \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 4dbf2a612d..47fc963c2d 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -161,6 +161,10 @@ + + + + @@ -169,4 +173,4 @@ Octokit-Monotouch - + \ No newline at end of file From 5a35b3c0fdd13f3cbaf3d8666f4aba416b60f93a Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 01:31:09 +1000 Subject: [PATCH 14/26] Add DebuggerDisplay --- .../Models/Response/Enterprise/AdminStats.cs | 28 ++++++++++++++++++- .../Response/Enterprise/AdminStatsComments.cs | 15 +++++++++- .../Response/Enterprise/AdminStatsGists.cs | 15 +++++++++- .../Response/Enterprise/AdminStatsHooks.cs | 15 +++++++++- .../Response/Enterprise/AdminStatsIssues.cs | 15 +++++++++- .../Enterprise/AdminStatsMilestones.cs | 15 +++++++++- .../Response/Enterprise/AdminStatsOrgs.cs | 15 +++++++++- .../Response/Enterprise/AdminStatsPages.cs | 15 +++++++++- .../Response/Enterprise/AdminStatsPulls.cs | 14 +++++++++- .../Response/Enterprise/AdminStatsRepos.cs | 15 +++++++++- .../Response/Enterprise/AdminStatsUsers.cs | 15 +++++++++- 11 files changed, 166 insertions(+), 11 deletions(-) diff --git a/Octokit/Models/Response/Enterprise/AdminStats.cs b/Octokit/Models/Response/Enterprise/AdminStats.cs index 2e7b6b8565..67e3dc7128 100644 --- a/Octokit/Models/Response/Enterprise/AdminStats.cs +++ b/Octokit/Models/Response/Enterprise/AdminStats.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStats { public AdminStats() { } @@ -77,5 +82,26 @@ 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 index bdca28e40d..2502b9a92f 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsComments.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsComments.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsComments { public AdminStatsComments() { } @@ -35,5 +40,13 @@ 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 index b9fb451d86..2b6488c205 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsGists.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsGists.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsGists { public AdminStatsGists() { } @@ -28,5 +33,13 @@ 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 index 5fa06bbe68..b960d6d44f 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsHooks.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsHooks { public AdminStatsHooks() { } @@ -28,5 +33,13 @@ 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 index c769e2ece3..1b02ae759b 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsIssues.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsIssues { public AdminStatsIssues() { } @@ -28,5 +33,13 @@ 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 index f944f3e3b1..2fd1e8e865 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsMilestones.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsMilestones { public AdminStatsMilestones() { } @@ -28,5 +33,13 @@ 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 index d52ac6d409..2149227a9b 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsOrgs.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsOrgs { public AdminStatsOrgs() { } @@ -35,5 +40,13 @@ 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 index 65d351172a..4f0965ec3b 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsPages.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsPages.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsPages { public AdminStatsPages() { } @@ -14,5 +19,13 @@ 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 index 1e6916d717..44e6cf34e9 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsPulls.cs @@ -1,7 +1,11 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsPulls { public AdminStatsPulls() { } @@ -39,5 +43,13 @@ 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 index 4430ef77cc..3895389b60 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsRepos.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsRepos { public AdminStatsRepos() { } @@ -49,5 +54,13 @@ 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 index af1106de6c..4dcc8242d7 100644 --- a/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs +++ b/Octokit/Models/Response/Enterprise/AdminStatsUsers.cs @@ -1,5 +1,10 @@ -namespace Octokit +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AdminStatsUsers { public AdminStatsUsers() { } @@ -28,5 +33,13 @@ 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 From 08581e6c6e3a18f28d9b04a349b3a47cd207d7d0 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 01:31:28 +1000 Subject: [PATCH 15/26] complete integration tests --- .../EnterpriseAdminStatsClientTest.cs | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs index 6e0298ca49..3e8dc2f123 100644 --- a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -32,4 +32,194 @@ public async Task CanGetAllStatistics() Assert.NotNull(adminStats.Gists); Assert.NotNull(adminStats.Comments); } + + [GitHubEnterpriseTest] + public async Task CanGetReposStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Repos); + + Assert.NotNull(adminStats); + Assert.NotNull(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetHooksStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Hooks); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.NotNull(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetPagesStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Pages); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.NotNull(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetOrgsStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Orgs); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.NotNull(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetUsersStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Users); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.NotNull(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetPullsStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Pulls); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.NotNull(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetIssuesStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Issues); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.NotNull(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetMilstonesStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Milestones); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.NotNull(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetGistsStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Gists); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.NotNull(adminStats.Gists); + Assert.Null(adminStats.Comments); + } + + [GitHubEnterpriseTest] + public async Task CanGetCommentsStatistics() + { + var adminStats = await + _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Comments); + + Assert.NotNull(adminStats); + Assert.Null(adminStats.Repos); + Assert.Null(adminStats.Hooks); + Assert.Null(adminStats.Pages); + Assert.Null(adminStats.Orgs); + Assert.Null(adminStats.Users); + Assert.Null(adminStats.Pulls); + Assert.Null(adminStats.Issues); + Assert.Null(adminStats.Milestones); + Assert.Null(adminStats.Gists); + Assert.NotNull(adminStats.Comments); + } } \ No newline at end of file From bebf96bbf98b7fbd1663f9b97927b9695e6634bf Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 01:31:40 +1000 Subject: [PATCH 16/26] Damn, it turns out that requests for specific stat types only provide the respective json fragment rather than the overall collection object. This is the best workaround i could come up that still preserves the single GetStatistics call and returning the parent AdminStats object --- .../Enterprise/EnterpriseAdminStatsClient.cs | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs index 2d3f78b3ba..39fe1e1181 100644 --- a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; namespace Octokit @@ -25,7 +26,84 @@ public EnterpriseAdminStatsClient(IApiConnection apiConnection) [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] public Task GetStatistics(AdminStatsType type) { - return ApiConnection.Get(ApiUrls.EnterpriseAdminStats(type.ToString().ToLowerInvariant())); + var endpoint = ApiUrls.EnterpriseAdminStats(type.ToString().ToLowerInvariant()); + + if (type == AdminStatsType.All) + { + return ApiConnection.Get(endpoint); + } + + AdminStatsRepos repos = null; + AdminStatsHooks hooks = null; + AdminStatsPages pages = null; + AdminStatsOrgs orgs = null; + AdminStatsUsers users = null; + AdminStatsPulls pulls = null; + AdminStatsIssues issues = null; + AdminStatsMilestones milestones = null; + AdminStatsGists gists = null; + AdminStatsComments comments = null; + + switch (type) + { + case AdminStatsType.Repos: + { + repos = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Hooks: + { + hooks = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Pages: + { + pages = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Orgs: + { + orgs = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Users: + { + users = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Pulls: + { + pulls = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Issues: + { + issues = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Milestones: + { + milestones = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Gists: + { + gists = ApiConnection.Get(endpoint).Result; + break; + } + case AdminStatsType.Comments: + { + comments = ApiConnection.Get(endpoint).Result; + break; + } + } + + //return new AdminStats(repos, hooks, pages, orgs, users, pulls, issues, milestones, gists, comments); + + return Task.Run(() => + { + return new AdminStats(repos, hooks, pages, orgs, users, pulls, issues, milestones, gists, comments); + }); } } } From a2c8771ff43220a55eaaa3ce1f574dcaaaf437a7 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 01:35:13 +1000 Subject: [PATCH 17/26] Reactive - dont forget to Init the Enterprise client in GitHubClient ctor! --- Octokit.Reactive/ObservableGitHubClient.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index ea2d676897..43b14ec285 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -46,6 +46,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) GitDatabase = new ObservableGitDatabaseClient(gitHubClient); Gist = new ObservableGistsClient(gitHubClient); Search = new ObservableSearchClient(gitHubClient); + Enterprise = new ObservableEnterpriseClient(gitHubClient); } public IConnection Connection From 5691c14c38112e12935d7a245614df82182cbb46 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 27 Dec 2015 01:48:34 +1000 Subject: [PATCH 18/26] fix unit test now that each stats type calls a different Get<> method --- .../EnterpriseAdminStatsClientTest.cs | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs index 4a7ff51988..ee3b9848b2 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -18,7 +18,65 @@ public void RequestsCorrectUrl() { client.GetStatistics(type); - connection.Received().Get(Arg.Is(u => u == "enterprise/stats/{0}".FormatUri(type.ToString().ToLowerInvariant())), null); + string expectedUri = String.Format("enterprise/stats/{0}", type.ToString().ToLowerInvariant()); + switch (type) + { + case AdminStatsType.All: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Repos: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Hooks: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Pages: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Orgs: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Users: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Pulls: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Issues: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Milestones: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Gists: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + case AdminStatsType.Comments: + { + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + break; + } + } } } } From 5739b251ffd475086f87ed87d90498e324074355 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 16 Jan 2016 14:21:20 +1000 Subject: [PATCH 19/26] Fix up async calls --- .../Enterprise/EnterpriseAdminStatsClient.cs | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs index 39fe1e1181..03bc82899e 100644 --- a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -24,13 +24,14 @@ public EnterpriseAdminStatsClient(IApiConnection apiConnection) /// /// The collection for the requested type. [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] - public Task GetStatistics(AdminStatsType type) + public async Task GetStatistics(AdminStatsType type) { var endpoint = ApiUrls.EnterpriseAdminStats(type.ToString().ToLowerInvariant()); if (type == AdminStatsType.All) { - return ApiConnection.Get(endpoint); + return await ApiConnection.Get(endpoint) + .ConfigureAwait(false); } AdminStatsRepos repos = null; @@ -48,62 +49,67 @@ public Task GetStatistics(AdminStatsType type) { case AdminStatsType.Repos: { - repos = ApiConnection.Get(endpoint).Result; + repos = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Hooks: { - hooks = ApiConnection.Get(endpoint).Result; + hooks = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Pages: { - pages = ApiConnection.Get(endpoint).Result; + pages = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Orgs: { - orgs = ApiConnection.Get(endpoint).Result; + orgs = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Users: { - users = ApiConnection.Get(endpoint).Result; + users = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Pulls: { - pulls = ApiConnection.Get(endpoint).Result; + pulls = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Issues: { - issues = ApiConnection.Get(endpoint).Result; + issues = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Milestones: { - milestones = ApiConnection.Get(endpoint).Result; + milestones = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Gists: { - gists = ApiConnection.Get(endpoint).Result; + gists = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } case AdminStatsType.Comments: { - comments = ApiConnection.Get(endpoint).Result; + comments = await ApiConnection.Get(endpoint) + .ConfigureAwait(false); break; } } - //return new AdminStats(repos, hooks, pages, orgs, users, pulls, issues, milestones, gists, comments); - - return Task.Run(() => - { - return new AdminStats(repos, hooks, pages, orgs, users, pulls, issues, milestones, gists, comments); - }); + return new AdminStats(repos, hooks, pages, orgs, users, pulls, issues, milestones, gists, comments); } } } From d2b747641c27d18dcf22ec39995b8f4bd98e9131 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 26 Jan 2016 22:40:35 +1000 Subject: [PATCH 20/26] Implement individual methods for each AdminStats call Remove AdminStatsTypeEnum Add tests for new methods --- .../IObservableEnterpriseAdminStatsClient.cs | 108 +++++++- .../ObservableEnterpriseAdminStatsClient.cs | 128 +++++++++- .../EnterpriseAdminStatsClientTest.cs | 206 ++++----------- .../Octokit.Tests.Integration.csproj | 1 + ...bservableEnterpriseAdminStatsClientTest.cs | 126 ++++++++++ .../EnterpriseAdminStatsClientTest.cs | 209 +++++++++++----- ...servableEnterpriseAdminStatsClientTests.cs | 146 ++++++++++- .../Enterprise/EnterpriseAdminStatsClient.cs | 235 +++++++++++------- .../Clients/Enterprise/EnterpriseClient.cs | 5 +- .../Enterprise/IEnterpriseAdminStatsClient.cs | 126 ++++++++-- Octokit/Helpers/ApiUrls.cs | 57 ++++- 11 files changed, 1005 insertions(+), 342 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTest.cs diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs index af46950fc1..62dccdb073 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Octokit.Reactive { @@ -10,13 +11,114 @@ namespace Octokit.Reactive /// 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 + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// - /// The collection for the requested type. - IObservable GetStatistics(AdminStatsType type); + /// The collection of statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetStatisticsAll(); } } diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs index 1e121a488f..1ae1f61682 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseAdminStatsClient.cs @@ -20,16 +20,136 @@ public ObservableEnterpriseAdminStatsClient(IGitHubClient 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 + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// - /// The collection for the requested type. - public IObservable GetStatistics(AdminStatsType type) + /// The collection of statistics. + public IObservable GetStatisticsAll() { - return _client.GetStatistics(type).ToObservable(); + return _client.GetStatisticsAll().ToObservable(); } } } diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs index 3e8dc2f123..43b9da9b3c 100644 --- a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -1,8 +1,6 @@ -using System.Linq; -using System.Threading.Tasks; +using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; -using Octokit.Tests.Integration.Helpers; using Xunit; public class EnterpriseAdminStatsClientTest @@ -15,211 +13,111 @@ public EnterpriseAdminStatsClientTest() } [GitHubEnterpriseTest] - public async Task CanGetAllStatistics() + public async Task CanGetStatisticsIssues() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.All); + var issueStats = await + _github.Enterprise.AdminStats.GetStatisticsIssues(); - 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); + Assert.NotNull(issueStats); } [GitHubEnterpriseTest] - public async Task CanGetReposStatistics() + public async Task CanGetStatisticsHooks() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Repos); + var hookStats = await + _github.Enterprise.AdminStats.GetStatisticsHooks(); - Assert.NotNull(adminStats); - Assert.NotNull(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(hookStats); } [GitHubEnterpriseTest] - public async Task CanGetHooksStatistics() + public async Task CanGetStatisticsMilestones() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Hooks); + var milestoneStats = await + _github.Enterprise.AdminStats.GetStatisticsMilestones(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.NotNull(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(milestoneStats); } [GitHubEnterpriseTest] - public async Task CanGetPagesStatistics() + public async Task CanGetStatisticsOrgs() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Pages); + var orgStats = await + _github.Enterprise.AdminStats.GetStatisticsOrgs(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.NotNull(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(orgStats); } [GitHubEnterpriseTest] - public async Task CanGetOrgsStatistics() + public async Task CanGetStatisticsComments() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Orgs); + var commentStats = await + _github.Enterprise.AdminStats.GetStatisticsComments(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.NotNull(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(commentStats); } [GitHubEnterpriseTest] - public async Task CanGetUsersStatistics() + public async Task CanGetStatisticsPages() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Users); + var pageStats = await + _github.Enterprise.AdminStats.GetStatisticsPages(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.NotNull(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(pageStats); } [GitHubEnterpriseTest] - public async Task CanGetPullsStatistics() + public async Task CanGetStatisticsUsers() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Pulls); + var userStats = await + _github.Enterprise.AdminStats.GetStatisticsUsers(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.NotNull(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(userStats); } [GitHubEnterpriseTest] - public async Task CanGetIssuesStatistics() + public async Task CanGetStatisticsGists() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Issues); + var gistStats = await + _github.Enterprise.AdminStats.GetStatisticsGists(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.NotNull(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(gistStats); } [GitHubEnterpriseTest] - public async Task CanGetMilstonesStatistics() + public async Task CanGetStatisticsPulls() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Milestones); + var pullStats = await + _github.Enterprise.AdminStats.GetStatisticsPulls(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.NotNull(adminStats.Milestones); - Assert.Null(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(pullStats); } [GitHubEnterpriseTest] - public async Task CanGetGistsStatistics() + public async Task CanGetStatisticsRepos() { - var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Gists); + var repoStats = await + _github.Enterprise.AdminStats.GetStatisticsRepos(); - Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.NotNull(adminStats.Gists); - Assert.Null(adminStats.Comments); + Assert.NotNull(repoStats); } [GitHubEnterpriseTest] - public async Task CanGetCommentsStatistics() + public async Task CanGetStatisticsAll() { var adminStats = await - _github.Enterprise.AdminStats.GetStatistics(AdminStatsType.Comments); + _github.Enterprise.AdminStats.GetStatisticsAll(); Assert.NotNull(adminStats); - Assert.Null(adminStats.Repos); - Assert.Null(adminStats.Hooks); - Assert.Null(adminStats.Pages); - Assert.Null(adminStats.Orgs); - Assert.Null(adminStats.Users); - Assert.Null(adminStats.Pulls); - Assert.Null(adminStats.Issues); - Assert.Null(adminStats.Milestones); - Assert.Null(adminStats.Gists); + 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/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 1ce27e0808..0a54c7a913 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -119,6 +119,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTest.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTest.cs new file mode 100644 index 0000000000..a87c127543 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTest.cs @@ -0,0 +1,126 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration +{ + public class ObservableEnterpriseAdminStatsClientTest + { + readonly IObservableGitHubClient _github; + + public ObservableEnterpriseAdminStatsClientTest() + { + _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/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs index ee3b9848b2..dbb270b336 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs @@ -6,7 +6,7 @@ namespace Octokit.Tests.Clients { public class EnterpriseAdminStatsClientTest { - public class TheGetStatisticsMethod + public class TheGetStatisticsIssuesMethod { [Fact] public void RequestsCorrectUrl() @@ -14,70 +14,149 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new EnterpriseAdminStatsClient(connection); - foreach (AdminStatsType type in Enum.GetValues(typeof(AdminStatsType))) - { - client.GetStatistics(type); - - string expectedUri = String.Format("enterprise/stats/{0}", type.ToString().ToLowerInvariant()); - switch (type) - { - case AdminStatsType.All: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Repos: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Hooks: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Pages: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Orgs: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Users: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Pulls: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Issues: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Milestones: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Gists: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - case AdminStatsType.Comments: - { - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); - break; - } - } - } + string expectedUri = "enterprise/stats/issues"; + client.GetStatisticsIssues(); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); + } + } + + 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), null); } } } diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs index bfbfc9d51a..fb219ba987 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs @@ -1,13 +1,53 @@ -using NSubstitute; +using System; +using NSubstitute; using Octokit.Reactive; -using System; using Xunit; namespace Octokit.Tests { public class ObservableEnterpriseAdminStatsClientTests { - public class TheGetStatisticsMethod + 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() @@ -15,16 +55,106 @@ public void CallsIntoClient() var github = Substitute.For(); var client = new ObservableEnterpriseAdminStatsClient(github); - foreach (AdminStatsType type in Enum.GetValues(typeof(AdminStatsType))) + client.GetStatisticsOrgs(); + github.Enterprise.AdminStats.Received(1).GetStatisticsOrgs(); + } + } + + public class TheGetStatisticsCommentsMethod + { + [Fact] + public void CallsIntoClient() + { { - var expectedUri = "enterprise/stats/{0}".FormatUri(type.ToString().ToLowerInvariant()); - client.GetStatistics(type); + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); - github.Enterprise.AdminStats.Received(1).GetStatistics(type); + 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] @@ -35,4 +165,4 @@ public void EnsuresNonNullArguments() } } } -} +} \ No newline at end of file diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs index 03bc82899e..69bf34f1ee 100644 --- a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Octokit { @@ -17,99 +15,168 @@ public EnterpriseAdminStatsClient(IApiConnection apiConnection) { } /// - /// Gets GitHub Enterprise statistics (must be Site Admin user). + /// Gets GitHub Enterprise Issue statistics (must be Site Admin user). /// /// - ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// - /// The collection for the requested type. - [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] - public async Task GetStatistics(AdminStatsType type) + /// The statistics. + public async Task GetStatisticsIssues() { - var endpoint = ApiUrls.EnterpriseAdminStats(type.ToString().ToLowerInvariant()); + var endpoint = ApiUrls.EnterpriseAdminStatsIssues(); - if (type == AdminStatsType.All) - { - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); - } - - AdminStatsRepos repos = null; - AdminStatsHooks hooks = null; - AdminStatsPages pages = null; - AdminStatsOrgs orgs = null; - AdminStatsUsers users = null; - AdminStatsPulls pulls = null; - AdminStatsIssues issues = null; - AdminStatsMilestones milestones = null; - AdminStatsGists gists = null; - AdminStatsComments comments = null; - - switch (type) - { - case AdminStatsType.Repos: - { - repos = await ApiConnection.Get(endpoint) + 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); - break; - } - case AdminStatsType.Hooks: - { - hooks = await ApiConnection.Get(endpoint) + } + + /// + /// 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); - break; - } - case AdminStatsType.Pages: - { - pages = await ApiConnection.Get(endpoint) + } + + /// + /// 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); - break; - } - case AdminStatsType.Orgs: - { - orgs = await ApiConnection.Get(endpoint) - .ConfigureAwait(false); - break; - } - case AdminStatsType.Users: - { - users = await ApiConnection.Get(endpoint) + } + + /// + /// 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); - break; - } - case AdminStatsType.Pulls: - { - pulls = await ApiConnection.Get(endpoint) + } + + /// + /// 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); - break; - } - case AdminStatsType.Issues: - { - issues = await ApiConnection.Get(endpoint) - .ConfigureAwait(false); - break; - } - case AdminStatsType.Milestones: - { - milestones = await ApiConnection.Get(endpoint) - .ConfigureAwait(false); - break; - } - case AdminStatsType.Gists: - { - gists = await ApiConnection.Get(endpoint) + } + + /// + /// 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); - break; - } - case AdminStatsType.Comments: - { - comments = await ApiConnection.Get(endpoint) - .ConfigureAwait(false); - break; - } - } + } - return new AdminStats(repos, hooks, pages, orgs, users, pulls, issues, milestones, gists, comments); + /// + /// 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 index f78d7aac7b..42e1763a64 100644 --- a/Octokit/Clients/Enterprise/EnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading.Tasks; - -namespace Octokit +namespace Octokit { /// /// A client for GitHub's Enterprise API. diff --git a/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs index 718b9f2993..52c9e4e634 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseAdminStatsClient.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; namespace Octokit { @@ -11,27 +12,114 @@ namespace Octokit public interface IEnterpriseAdminStatsClient { /// - /// Gets GitHub Enterprise statistics (must be Site Admin user). + /// Gets GitHub Enterprise Issue statistics (must be Site Admin user). /// /// - ///https://developer.github.com/v3/enterprise/admin_stats/#get-statistics + /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// - /// The collection for the requested type. - Task GetStatistics(AdminStatsType type); - } + /// The statistics. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task GetStatisticsIssues(); - public enum AdminStatsType - { - Issues, - Hooks, - Milestones, - Orgs, - Comments, - Pages, - Users, - Gists, - Pulls, - Repos, - All + /// + /// 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/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 9811e44669..734382be5d 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1555,9 +1555,64 @@ public static Uri RepositoryContent(string owner, string name, string path, stri return "repos/{0}/{1}/contents/{2}?ref={3}".FormatUri(owner, name, path, reference); } - public static Uri EnterpriseAdminStats(string type) + 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"); + } } } From b1f6c3a1b74e3627fc18570777e3da1eeaaeed2a Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 30 Jan 2016 07:44:33 +1000 Subject: [PATCH 21/26] Rename test class to be consistent with others --- ...minStatsClientTest.cs => EnterpriseAdminStatsClientTests.cs} | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename Octokit.Tests/Clients/Enterprise/{EnterpriseAdminStatsClientTest.cs => EnterpriseAdminStatsClientTests.cs} (99%) diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs similarity index 99% rename from Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs rename to Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs index dbb270b336..5c0ffecfa9 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs @@ -4,7 +4,7 @@ namespace Octokit.Tests.Clients { - public class EnterpriseAdminStatsClientTest + public class EnterpriseAdminStatsClientTests { public class TheGetStatisticsIssuesMethod { diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 02ea7fae8a..5af192547d 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -85,7 +85,7 @@ - + From e87f200b7a17e5483dfa24955196ecbae5750cad Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 30 Jan 2016 16:37:06 +1000 Subject: [PATCH 22/26] Rename test class to be consistent with others --- ...minStatsClientTest.cs => EnterpriseAdminStatsClientTests.cs} | 0 Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 1 + Octokit.Tests/Octokit.Tests-Portable.csproj | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) rename Octokit.Tests.Integration/Clients/Enterprise/{EnterpriseAdminStatsClientTest.cs => EnterpriseAdminStatsClientTests.cs} (100%) diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs similarity index 100% rename from Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTest.cs rename to Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 90484d4c0b..4d0265e9c9 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -77,7 +77,7 @@ - + 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 @@ + From fcfec9466599b46db5cf893f6810dce90cc54aad Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 30 Jan 2016 17:30:11 +1000 Subject: [PATCH 23/26] Fix up tests now the ApiConnection has the proper Get() method --- .../EnterpriseAdminStatsClientTests.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs index 5c0ffecfa9..1fe3bfa9e7 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs @@ -16,7 +16,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/issues"; client.GetStatisticsIssues(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -30,7 +30,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/hooks"; client.GetStatisticsHooks(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -44,7 +44,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/milestones"; client.GetStatisticsMilestones(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -58,7 +58,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/orgs"; client.GetStatisticsOrgs(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -72,7 +72,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/comments"; client.GetStatisticsComments(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -86,7 +86,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/pages"; client.GetStatisticsPages(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -100,7 +100,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/users"; client.GetStatisticsUsers(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -114,7 +114,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/gists"; client.GetStatisticsGists(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -128,7 +128,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/pulls"; client.GetStatisticsPulls(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -142,7 +142,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/repos"; client.GetStatisticsRepos(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } @@ -156,7 +156,7 @@ public void RequestsCorrectUrl() string expectedUri = "enterprise/stats/all"; client.GetStatisticsAll(); - connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri), null); + connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } } From 5f6460642d28846c13f47482f37c921b351f3b7d Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 31 Jan 2016 14:11:51 +1000 Subject: [PATCH 24/26] Fixup class name --- .../Clients/Enterprise/EnterpriseAdminStatsClientTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs index 43b9da9b3c..12dc638ae9 100644 --- a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs @@ -3,11 +3,11 @@ using Octokit.Tests.Integration; using Xunit; -public class EnterpriseAdminStatsClientTest +public class EnterpriseAdminStatsClientTests { readonly IGitHubClient _github; - public EnterpriseAdminStatsClientTest() + public EnterpriseAdminStatsClientTests() { _github = Helper.GetAuthenticatedClient(); } From 7e4848c69edd2cf6e55fc5f05e4445cf31b9f174 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 31 Jan 2016 14:29:45 +1000 Subject: [PATCH 25/26] Another rename --- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- ...ntTest.cs => ObservableEnterpriseAdminStatsClientTests.cs} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename Octokit.Tests.Integration/Reactive/Enterprise/{ObservableEnterpriseAdminStatsClientTest.cs => ObservableEnterpriseAdminStatsClientTests.cs} (96%) diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 4d0265e9c9..145c04c937 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -120,7 +120,7 @@ - + diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTest.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs similarity index 96% rename from Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTest.cs rename to Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs index a87c127543..2cb61234c0 100644 --- a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTest.cs +++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs @@ -5,11 +5,11 @@ namespace Octokit.Tests.Integration { - public class ObservableEnterpriseAdminStatsClientTest + public class ObservableEnterpriseAdminStatsClientTests { readonly IObservableGitHubClient _github; - public ObservableEnterpriseAdminStatsClientTest() + public ObservableEnterpriseAdminStatsClientTests() { _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); } From 539fb8be34582c6cdb31f796d39d69dcc3ddad15 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 1 Feb 2016 20:55:01 +1000 Subject: [PATCH 26/26] Remove redundant duplicate braces --- .../ObservableEnterpriseAdminStatsClientTests.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs index fb219ba987..7c4957733c 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseAdminStatsClientTests.cs @@ -65,13 +65,11 @@ public class TheGetStatisticsCommentsMethod [Fact] public void CallsIntoClient() { - { - var github = Substitute.For(); - var client = new ObservableEnterpriseAdminStatsClient(github); + var github = Substitute.For(); + var client = new ObservableEnterpriseAdminStatsClient(github); - client.GetStatisticsComments(); - github.Enterprise.AdminStats.Received(1).GetStatisticsComments(); - } + client.GetStatisticsComments(); + github.Enterprise.AdminStats.Received(1).GetStatisticsComments(); } }