diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index b5142b4feb..5a1616214c 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace Octokit @@ -102,7 +103,7 @@ public Task> GetAllForCheckSuite(long repositoryId, long return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); } - public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + public async Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -110,34 +111,38 @@ public Task> GetAllForReference(string owner, string nam Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - throw new NotImplementedException(); + var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckRuns(owner, name, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + return results.SelectMany(x => x.CheckRuns).ToList(); } - public Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + public async Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - throw new NotImplementedException(); + var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckRuns(repositoryId, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + return results.SelectMany(x => x.CheckRuns).ToList(); } - public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + public async Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - throw new NotImplementedException(); + var results = await ApiConnection.GetAll(ApiUrls.CheckSuiteRuns(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + return results.SelectMany(x => x.CheckRuns).ToList(); } - public Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + public async Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - throw new NotImplementedException(); + var results = await ApiConnection.GetAll(ApiUrls.CheckSuiteRuns(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + return results.SelectMany(x => x.CheckRuns).ToList(); } public Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 7c53ab38bf..28398af878 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace Octokit @@ -44,14 +45,14 @@ public Task> GetAllForReference(string owner, string n Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - return GetAllForReference(owner, name, reference, ApiOptions.None); + return GetAllForReference(owner, name, reference, new CheckSuiteRequest(), ApiOptions.None); } public Task> GetAllForReference(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - return GetAllForReference(repositoryId, reference, ApiOptions.None); + return GetAllForReference(repositoryId, reference, new CheckSuiteRequest(), ApiOptions.None); } public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) @@ -71,25 +72,7 @@ public Task> GetAllForReference(long repositoryId, str return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } - public Task> GetAllForReference(string owner, string name, string reference, ApiOptions request) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(request, nameof(request)); - - throw new System.NotImplementedException(); - } - - public Task> GetAllForReference(long repositoryId, string reference, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new System.NotImplementedException(); - } - - public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) + public async Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -97,16 +80,18 @@ public Task> GetAllForReference(string owner, string n Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - throw new System.NotImplementedException(); + var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + return results.SelectMany(x => x.CheckSuites).ToList(); } - public Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) + public async Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - throw new System.NotImplementedException(); + var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + return results.SelectMany(x => x.CheckSuites).ToList(); } public Task Request(string owner, string name, CheckSuiteTriggerRequest request) diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index b425218ef1..18f96dab11 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -11,8 +11,6 @@ public interface ICheckSuitesClient Task> GetAllForReference(long repositoryId, string reference); Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); - Task> GetAllForReference(string owner, string name, string reference, ApiOptions options); - Task> GetAllForReference(long repositoryId, string reference, ApiOptions options); Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); diff --git a/Octokit/Models/Response/CheckRunList.cs b/Octokit/Models/Response/CheckRunList.cs new file mode 100644 index 0000000000..8db48ca360 --- /dev/null +++ b/Octokit/Models/Response/CheckRunList.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public class CheckRunList + { + public CheckRunList() + { + } + + public CheckRunList(int totalCount, IReadOnlyList checkRuns) + { + TotalCount = totalCount; + CheckRuns = checkRuns; + } + + public int TotalCount { get; protected set; } + + public IReadOnlyList CheckRuns { get; protected set; } + } +} diff --git a/Octokit/Models/Response/CheckSuiteList.cs b/Octokit/Models/Response/CheckSuiteList.cs new file mode 100644 index 0000000000..687906c5e5 --- /dev/null +++ b/Octokit/Models/Response/CheckSuiteList.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public class CheckSuiteList + { + public CheckSuiteList() + { + } + + public CheckSuiteList(int totalCount, IReadOnlyList checkSuites) + { + TotalCount = totalCount; + CheckSuites = checkSuites; + } + + public int TotalCount { get; protected set; } + + public IReadOnlyList CheckSuites { get; protected set; } + } +}