From ae43fc7ed4100dc13aa94bf9b80aa3869ccd0975 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 7 May 2018 15:54:57 -0400 Subject: [PATCH 01/82] Check run request models --- Octokit/Models/Request/CheckAnnotation.cs | 28 +++++++++++++ Octokit/Models/Request/CheckImage.cs | 9 ++++ Octokit/Models/Request/CheckOutput.cs | 12 ++++++ Octokit/Models/Request/CheckRunRequest.cs | 20 +++++++++ Octokit/Models/Request/CheckRunUpdate.cs | 50 +++++++++++++++++++++++ Octokit/Models/Request/NewCheckRun.cs | 8 ++++ 6 files changed, 127 insertions(+) create mode 100644 Octokit/Models/Request/CheckAnnotation.cs create mode 100644 Octokit/Models/Request/CheckImage.cs create mode 100644 Octokit/Models/Request/CheckOutput.cs create mode 100644 Octokit/Models/Request/CheckRunRequest.cs create mode 100644 Octokit/Models/Request/CheckRunUpdate.cs create mode 100644 Octokit/Models/Request/NewCheckRun.cs diff --git a/Octokit/Models/Request/CheckAnnotation.cs b/Octokit/Models/Request/CheckAnnotation.cs new file mode 100644 index 0000000000..d5020bddf4 --- /dev/null +++ b/Octokit/Models/Request/CheckAnnotation.cs @@ -0,0 +1,28 @@ +using Octokit.Internal; + +namespace Octokit +{ + public sealed class CheckAnnotation + { + string Filename { get; set; } + string BlobHref { get; set; } + int StartLine { get; set; } + int EndLine { get; set; } + CheckWarningLevel WarningLevel { get; set; } + string Message { get; set; } + string Title { get; set; } + string RawDetails { get; set; } + } + + public enum CheckWarningLevel + { + [Parameter(Value = "notice")] + Notice, + + [Parameter(Value = "warning")] + Warning, + + [Parameter(Value = "failure")] + Failure, + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckImage.cs b/Octokit/Models/Request/CheckImage.cs new file mode 100644 index 0000000000..12737b54ba --- /dev/null +++ b/Octokit/Models/Request/CheckImage.cs @@ -0,0 +1,9 @@ +namespace Octokit +{ + public sealed class CheckImage + { + string Alt { get; set; } + string ImageUrl { get; set; } + string Caption { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckOutput.cs b/Octokit/Models/Request/CheckOutput.cs new file mode 100644 index 0000000000..3a3868c1cd --- /dev/null +++ b/Octokit/Models/Request/CheckOutput.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public sealed class CheckOutput + { + public string Title { get; set; } + public string Summary { get; set; } + public List Annotations { get; set; } + public List Images { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckRunRequest.cs b/Octokit/Models/Request/CheckRunRequest.cs new file mode 100644 index 0000000000..618463b049 --- /dev/null +++ b/Octokit/Models/Request/CheckRunRequest.cs @@ -0,0 +1,20 @@ +using Octokit.Internal; + +namespace Octokit +{ + public sealed class CheckRunRequest + { + public string Ref { get; set; } + public string CheckName { get; set; } + public CheckStatus? Status { get; set; } + public CheckRunRequestFilter? Filter { get; set; } + } + + public enum CheckRunRequestFilter + { + [Parameter(Value = "latest")] + Latest, + [Parameter(Value = "all")] + All + } +} diff --git a/Octokit/Models/Request/CheckRunUpdate.cs b/Octokit/Models/Request/CheckRunUpdate.cs new file mode 100644 index 0000000000..dfb422489c --- /dev/null +++ b/Octokit/Models/Request/CheckRunUpdate.cs @@ -0,0 +1,50 @@ +using Octokit.Internal; +using System; + +namespace Octokit +{ + public class CheckRunUpdate + { + public string Name { get; set; } + public string DetailsUrl { get; set; } + public string ExternalId { get; set; } + public CheckStatus? Status { get; set; } + public DateTimeOffset StartedAt { get; set; } + public CheckConclusion Conclusion { get; set; } + public DateTimeOffset CompletedAt { get; set; } + public CheckOutput Output { get; set; } + } + + public enum CheckStatus + { + [Parameter(Value = "queued")] + Queued, + + [Parameter(Value = "in_progress")] + InProgress, + + [Parameter(Value = "completed")] + Completed, + } + + public enum CheckConclusion + { + [Parameter(Value = "success")] + Success, + + [Parameter(Value = "failure")] + Failure, + + [Parameter(Value = "neutral")] + Neutral, + + [Parameter(Value = "cancelled")] + Cancelled, + + [Parameter(Value = "timed_out")] + TimedOut, + + [Parameter(Value = "action_required")] + ActionRequired, + } +} diff --git a/Octokit/Models/Request/NewCheckRun.cs b/Octokit/Models/Request/NewCheckRun.cs new file mode 100644 index 0000000000..8ae40a52fb --- /dev/null +++ b/Octokit/Models/Request/NewCheckRun.cs @@ -0,0 +1,8 @@ +namespace Octokit.Models.Request +{ + public sealed class NewCheckRun : CheckRunUpdate + { + public string HeadBranch { get; set; } + public string HeadSha { get; set; } + } +} From 8ab8d63b70e0232f9b319d21a9958e1be0a06465 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 7 May 2018 16:04:08 -0400 Subject: [PATCH 02/82] Check Run response models --- Octokit/Models/Request/NewCheckRun.cs | 4 ++-- Octokit/Models/Response/CheckRun.cs | 15 +++++++++++++++ Octokit/Models/Response/CheckRunsList.cs | 10 ++++++++++ Octokit/Models/Response/CheckSuite.cs | 7 +++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 Octokit/Models/Response/CheckRun.cs create mode 100644 Octokit/Models/Response/CheckRunsList.cs create mode 100644 Octokit/Models/Response/CheckSuite.cs diff --git a/Octokit/Models/Request/NewCheckRun.cs b/Octokit/Models/Request/NewCheckRun.cs index 8ae40a52fb..d0ada5772b 100644 --- a/Octokit/Models/Request/NewCheckRun.cs +++ b/Octokit/Models/Request/NewCheckRun.cs @@ -1,6 +1,6 @@ -namespace Octokit.Models.Request +namespace Octokit { - public sealed class NewCheckRun : CheckRunUpdate + public class NewCheckRun : CheckRunUpdate { public string HeadBranch { get; set; } public string HeadSha { get; set; } diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs new file mode 100644 index 0000000000..2fd33df4e1 --- /dev/null +++ b/Octokit/Models/Response/CheckRun.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public class CheckRun : NewCheckRun + { + public long Id { get; protected set; } + + public GitHubApp App { get; protected set; } + + public CheckSuite CheckSuite { get; protected set; } + + public IReadOnlyList PullRequests { get; protected set; } + } +} diff --git a/Octokit/Models/Response/CheckRunsList.cs b/Octokit/Models/Response/CheckRunsList.cs new file mode 100644 index 0000000000..3a29348768 --- /dev/null +++ b/Octokit/Models/Response/CheckRunsList.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public class CheckRunsList + { + public int TotalCount { get; protected set; } + public IReadOnlyList CheckRuns { get; protected set; } + } +} diff --git a/Octokit/Models/Response/CheckSuite.cs b/Octokit/Models/Response/CheckSuite.cs new file mode 100644 index 0000000000..e4a31f950a --- /dev/null +++ b/Octokit/Models/Response/CheckSuite.cs @@ -0,0 +1,7 @@ +namespace Octokit +{ + public class CheckSuite + { + public long Id { get; protected set; } + } +} From a473b2441ff0b3617a676b01608949b1f8a821ff Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 7 May 2018 16:13:28 -0400 Subject: [PATCH 03/82] Check run clients --- Octokit/Clients/ICheckRunAnnotationsClient.cs | 11 ++++++++++ Octokit/Clients/ICheckRunsClient.cs | 21 +++++++++++++++++++ Octokit/Models/Request/CheckRunRequest.cs | 1 - 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Octokit/Clients/ICheckRunAnnotationsClient.cs create mode 100644 Octokit/Clients/ICheckRunsClient.cs diff --git a/Octokit/Clients/ICheckRunAnnotationsClient.cs b/Octokit/Clients/ICheckRunAnnotationsClient.cs new file mode 100644 index 0000000000..e713981199 --- /dev/null +++ b/Octokit/Clients/ICheckRunAnnotationsClient.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface ICheckRunAnnotationsClient + { + Task> List(long repositoryId, long checkRunId); + Task> List(string owner, string name, long checkRunId); + } +} \ No newline at end of file diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs new file mode 100644 index 0000000000..b041051825 --- /dev/null +++ b/Octokit/Clients/ICheckRunsClient.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + interface ICheckRunsClient + { + ICheckRunAnnotationsClient Annotations { get; } + + Task Create(long repositoryId, NewCheckRun newCheckRun); + Task Create(string owner, string name, NewCheckRun newCheckRun); + Task Update(long repositoryId, CheckRunUpdate checkRunUpdate); + Task Update(string owner, string name, CheckRunUpdate checkRunUpdate); + Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest); + Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest); + Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); + Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); + Task Get(long repositoryId, long checkRunId); + Task Get(string owner, string name, long checkRunId); + } +} diff --git a/Octokit/Models/Request/CheckRunRequest.cs b/Octokit/Models/Request/CheckRunRequest.cs index 618463b049..535f6b7b4e 100644 --- a/Octokit/Models/Request/CheckRunRequest.cs +++ b/Octokit/Models/Request/CheckRunRequest.cs @@ -4,7 +4,6 @@ namespace Octokit { public sealed class CheckRunRequest { - public string Ref { get; set; } public string CheckName { get; set; } public CheckStatus? Status { get; set; } public CheckRunRequestFilter? Filter { get; set; } From 561d086be6230039b98d1cb9e32839715aee14a6 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 7 May 2018 16:28:13 -0400 Subject: [PATCH 04/82] Check run ApiUrls and AcceptHeaders --- Octokit/Helpers/AcceptHeaders.cs | 2 + Octokit/Helpers/ApiUrls.cs | 113 +++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index e8389ee76a..c391e1ce00 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -57,6 +57,8 @@ public static class AcceptHeaders public const string GitHubAppsPreview = "application/vnd.github.machine-man-preview+json"; + public const string ChecksApiPreview = "application/vnd.github.antiope-preview+json"; + /// /// Combines multiple preview headers. GitHub API supports Accept header with multiple /// values separated by comma. diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index f2f1d7f70e..c3ab043192 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -3762,5 +3762,118 @@ public static Uri RepositoryLicense(long repositoryId) { return "repositories/{0}/license".FormatUri(repositoryId); } + + /// + /// Returns the that returns the specified check run. + /// + /// The Id of the repository + /// The check run Id + /// The that returns the specified check run. + public static Uri CheckRun(long repositoryId, long id) + { + return "repositories/{0}/check-runs/{1}".FormatUri(repositoryId, id); + } + + /// + /// Returns the that returns the specified check run. + /// + /// The owner of repo + /// The name of repo + /// The check run Id + /// The that returns the specified check run. + public static Uri CheckRun(string owner, string repo, long id) + { + return "repositories/{0}/{1}/check-runs/{2}".FormatUri(owner, repo, id); + } + + /// + /// Returns the that lists the check runs for the repository. + /// + /// The Id of the repository + /// The that returns the check runs for the specified reference. + public static Uri CheckRuns(long repositoryId) + { + return "repositories/{0}/check-runs".FormatUri(repositoryId); + } + + /// + /// Returns the that lists the check runs for the repository. + /// + /// The owner of repo + /// The name of repo + /// The that returns the check runs for the specified reference. + public static Uri CheckRuns(string owner, string repo) + { + return "repositories/{0}/{1}/check-runs".FormatUri(owner, repo); + } + + /// + /// Returns the that returns the specified check run's annotations. + /// + /// The Id of the repository + /// The check run Id + /// The that returns the specified check run's annotations. + public static Uri CheckRunAnnotations(long repositoryId, long id) + { + return "repositories/{0}/check-runs/{1}/annotations".FormatUri(repositoryId, id); + } + + /// + /// Returns the that returns the specified check run's annotations. + /// + /// The owner of repo + /// The name of repo + /// The check run Id + /// The that returns the specified check run's annotations. + public static Uri CheckRunAnnotations(string owner, string repo, long id) + { + return "repositories/{0}/{1}/check-runs/{2}/annotations".FormatUri(owner, repo, id); + } + + /// + /// Returns the that lists the check runs for the specified reference. + /// + /// The Id of the repository + /// The git reference + /// The that returns the check runs for the specified reference. + public static Uri ReferenceCheckRuns(long repositoryId, string reference) + { + return "repositories/{0}/commits/{1}/check-runs".FormatUri(repositoryId, reference); + } + + /// + /// Returns the that lists the check runs for the specified reference. + /// + /// The owner of repo + /// The name of repo + /// The git reference + /// The that returns the check runs for the specified reference. + public static Uri ReferenceCheckRuns(string owner, string repo, string reference) + { + return "repositories/{0}/{1}/commits/{2}/check-runs".FormatUri(owner, repo, reference); + } + + /// + /// Returns the that lists the check runs for the specified check suite. + /// + /// The Id of the repository + /// The Id of the check suite + /// The that returns the check runs for the specified reference. + public static Uri CheckSuiteRuns(long repositoryId, long id) + { + return "repositories/{0}/check-suites/{1}/check-runs".FormatUri(repositoryId, id); + } + + /// + /// Returns the that returns the specified pull request. + /// + /// The owner of repo + /// The name of repo + /// The Id of the check suite + /// The that returns the specified pull request. + public static Uri CheckSuiteRuns(string owner, string repo, long id) + { + return "repositories/{0}/{1}/check-suites/{2}/check-runs".FormatUri(owner, repo, id); + } } } From c7704b0cb79cf0e89876e4f086a6adae5d5e1a10 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 7 May 2018 16:54:58 -0400 Subject: [PATCH 05/82] Pack it all together for now --- Octokit/CheckRunAnnotationsClient.cs | 38 +++++ Octokit/Clients/CheckRunsClient.cs | 133 ++++++++++++++++++ Octokit/Clients/ICheckRunAnnotationsClient.cs | 6 +- Octokit/Clients/ICheckRunsClient.cs | 10 +- Octokit/GitHubClient.cs | 9 ++ Octokit/IGitHubClient.cs | 8 ++ .../CheckRunAnnotation.cs} | 2 +- Octokit/Models/Request/CheckOutput.cs | 12 -- .../{CheckImage.cs => CheckRunImage.cs} | 2 +- Octokit/Models/Request/CheckRunOutput.cs | 12 ++ Octokit/Models/Request/CheckRunRequest.cs | 2 +- Octokit/Models/Request/CheckRunUpdate.cs | 2 +- 12 files changed, 215 insertions(+), 21 deletions(-) create mode 100644 Octokit/CheckRunAnnotationsClient.cs create mode 100644 Octokit/Clients/CheckRunsClient.cs rename Octokit/Models/{Request/CheckAnnotation.cs => Common/CheckRunAnnotation.cs} (93%) delete mode 100644 Octokit/Models/Request/CheckOutput.cs rename Octokit/Models/Request/{CheckImage.cs => CheckRunImage.cs} (79%) create mode 100644 Octokit/Models/Request/CheckRunOutput.cs diff --git a/Octokit/CheckRunAnnotationsClient.cs b/Octokit/CheckRunAnnotationsClient.cs new file mode 100644 index 0000000000..69ef64d46b --- /dev/null +++ b/Octokit/CheckRunAnnotationsClient.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + internal class CheckRunAnnotationsClient : ApiClient, ICheckRunAnnotationsClient + { + public CheckRunAnnotationsClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + public Task> List(long repositoryId, long checkRunId) + { + return List(repositoryId, checkRunId, ApiOptions.None); + } + + public Task> List(string owner, string name, long checkRunId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return List(owner, name, checkRunId, ApiOptions.None); + } + + public Task> List(long repositoryId, long checkRunId, ApiOptions options) + { + return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), options); + } + + public Task> List(string owner, string name, long checkRunId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), options); + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs new file mode 100644 index 0000000000..2cfb86eac9 --- /dev/null +++ b/Octokit/Clients/CheckRunsClient.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public sealed class CheckRunsClient : ApiClient, ICheckRunsClient + { + public ICheckRunAnnotationsClient Annotations { get; } + + public CheckRunsClient(IApiConnection apiConnection) : base(apiConnection) + { + Annotations = new CheckRunAnnotationsClient(apiConnection); + } + + public Task Create(long repositoryId, NewCheckRun newCheckRun) + { + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return ApiConnection.Post(ApiUrls.CheckRuns(repositoryId), newCheckRun); + } + + public Task Create(string owner, string name, NewCheckRun newCheckRun) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return ApiConnection.Post(ApiUrls.CheckRuns(owner, name), newCheckRun); + } + + public Task Get(long repositoryId, long checkRunId) + { + return ApiConnection.Get(ApiUrls.CheckRun(repositoryId, checkRunId)); + } + + public Task Get(string owner, string name, long checkRunId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Get(ApiUrls.CheckRun(owner, name, checkRunId)); + } + + public Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return List(repositoryId, reference, checkRunRequest, ApiOptions.None); + } + + public Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return List(owner, name, reference, checkRunRequest, ApiOptions.None); + } + + public Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return List(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); + } + + public Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return List(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); + } + + public Task> List(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(); + } + + public Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); + } + + public Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + { + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); + } + + public Task> List(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(); + } + + public Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) + { + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + + return ApiConnection.Patch(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate); + } + + public Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + + return ApiConnection.Patch(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate); + } + } +} diff --git a/Octokit/Clients/ICheckRunAnnotationsClient.cs b/Octokit/Clients/ICheckRunAnnotationsClient.cs index e713981199..ba5d189d3c 100644 --- a/Octokit/Clients/ICheckRunAnnotationsClient.cs +++ b/Octokit/Clients/ICheckRunAnnotationsClient.cs @@ -5,7 +5,9 @@ namespace Octokit { public interface ICheckRunAnnotationsClient { - Task> List(long repositoryId, long checkRunId); - Task> List(string owner, string name, long checkRunId); + Task> List(long repositoryId, long checkRunId); + Task> List(string owner, string name, long checkRunId); + Task> List(long repositoryId, long checkRunId, ApiOptions options); + Task> List(string owner, string name, long checkRunId, ApiOptions options); } } \ No newline at end of file diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs index b041051825..6a4ae690d1 100644 --- a/Octokit/Clients/ICheckRunsClient.cs +++ b/Octokit/Clients/ICheckRunsClient.cs @@ -3,18 +3,22 @@ namespace Octokit { - interface ICheckRunsClient + public interface ICheckRunsClient { ICheckRunAnnotationsClient Annotations { get; } Task Create(long repositoryId, NewCheckRun newCheckRun); Task Create(string owner, string name, NewCheckRun newCheckRun); - Task Update(long repositoryId, CheckRunUpdate checkRunUpdate); - Task Update(string owner, string name, CheckRunUpdate checkRunUpdate); + Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); + Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest); Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest); Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); + Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); + Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); Task Get(long repositoryId, long checkRunId); Task Get(string owner, string name, long checkRunId); } diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index bb84c5eec7..19a78ead14 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -110,6 +110,7 @@ public GitHubClient(IConnection connection) Search = new SearchClient(apiConnection); User = new UsersClient(apiConnection); Reaction = new ReactionsClient(apiConnection); + CheckRuns = new CheckRunsClient(apiConnection); } /// @@ -296,6 +297,14 @@ public Uri BaseAddress /// public IReactionsClient Reaction { get; private set; } + /// + /// Access GitHub's Check Runs API + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/runs + /// + public ICheckRunsClient CheckRuns { get; private set; } + static Uri FixUpBaseUri(Uri uri) { Ensure.ArgumentNotNull(uri, nameof(uri)); diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index a9298a3ddc..3f02762342 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -149,5 +149,13 @@ public interface IGitHubClient : IApiInfoProvider /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// IReactionsClient Reaction { get; } + + /// + /// Access GitHub's Check Runs API. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/runs/ + /// + ICheckRunsClient CheckRuns { get; } } } diff --git a/Octokit/Models/Request/CheckAnnotation.cs b/Octokit/Models/Common/CheckRunAnnotation.cs similarity index 93% rename from Octokit/Models/Request/CheckAnnotation.cs rename to Octokit/Models/Common/CheckRunAnnotation.cs index d5020bddf4..b67ef1e4f6 100644 --- a/Octokit/Models/Request/CheckAnnotation.cs +++ b/Octokit/Models/Common/CheckRunAnnotation.cs @@ -2,7 +2,7 @@ namespace Octokit { - public sealed class CheckAnnotation + public sealed class CheckRunAnnotation { string Filename { get; set; } string BlobHref { get; set; } diff --git a/Octokit/Models/Request/CheckOutput.cs b/Octokit/Models/Request/CheckOutput.cs deleted file mode 100644 index 3a3868c1cd..0000000000 --- a/Octokit/Models/Request/CheckOutput.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; - -namespace Octokit -{ - public sealed class CheckOutput - { - public string Title { get; set; } - public string Summary { get; set; } - public List Annotations { get; set; } - public List Images { get; set; } - } -} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckImage.cs b/Octokit/Models/Request/CheckRunImage.cs similarity index 79% rename from Octokit/Models/Request/CheckImage.cs rename to Octokit/Models/Request/CheckRunImage.cs index 12737b54ba..d2b826a4ba 100644 --- a/Octokit/Models/Request/CheckImage.cs +++ b/Octokit/Models/Request/CheckRunImage.cs @@ -1,6 +1,6 @@ namespace Octokit { - public sealed class CheckImage + public sealed class CheckRunImage { string Alt { get; set; } string ImageUrl { get; set; } diff --git a/Octokit/Models/Request/CheckRunOutput.cs b/Octokit/Models/Request/CheckRunOutput.cs new file mode 100644 index 0000000000..c87c966e41 --- /dev/null +++ b/Octokit/Models/Request/CheckRunOutput.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public sealed class CheckRunOutput + { + public string Title { get; set; } + public string Summary { get; set; } + public List Annotations { get; set; } + public List Images { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckRunRequest.cs b/Octokit/Models/Request/CheckRunRequest.cs index 535f6b7b4e..b6834f3c2e 100644 --- a/Octokit/Models/Request/CheckRunRequest.cs +++ b/Octokit/Models/Request/CheckRunRequest.cs @@ -2,7 +2,7 @@ namespace Octokit { - public sealed class CheckRunRequest + public sealed class CheckRunRequest : RequestParameters { public string CheckName { get; set; } public CheckStatus? Status { get; set; } diff --git a/Octokit/Models/Request/CheckRunUpdate.cs b/Octokit/Models/Request/CheckRunUpdate.cs index dfb422489c..4f1d1b371f 100644 --- a/Octokit/Models/Request/CheckRunUpdate.cs +++ b/Octokit/Models/Request/CheckRunUpdate.cs @@ -12,7 +12,7 @@ public class CheckRunUpdate public DateTimeOffset StartedAt { get; set; } public CheckConclusion Conclusion { get; set; } public DateTimeOffset CompletedAt { get; set; } - public CheckOutput Output { get; set; } + public CheckRunOutput Output { get; set; } } public enum CheckStatus From 319444d996750f6a6c8f9b56732016ca418da771 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:19:39 -0400 Subject: [PATCH 06/82] Add missing accept headers to connection calls --- Octokit/{ => Clients}/CheckRunAnnotationsClient.cs | 4 ++-- Octokit/Clients/CheckRunsClient.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) rename Octokit/{ => Clients}/CheckRunAnnotationsClient.cs (87%) diff --git a/Octokit/CheckRunAnnotationsClient.cs b/Octokit/Clients/CheckRunAnnotationsClient.cs similarity index 87% rename from Octokit/CheckRunAnnotationsClient.cs rename to Octokit/Clients/CheckRunAnnotationsClient.cs index 69ef64d46b..666dd1c732 100644 --- a/Octokit/CheckRunAnnotationsClient.cs +++ b/Octokit/Clients/CheckRunAnnotationsClient.cs @@ -24,7 +24,7 @@ public Task> List(string owner, string name, l public Task> List(long repositoryId, long checkRunId, ApiOptions options) { - return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), options); + return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } public Task> List(string owner, string name, long checkRunId, ApiOptions options) @@ -32,7 +32,7 @@ public Task> List(string owner, string name, l Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), options); + return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } } } \ No newline at end of file diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index 2cfb86eac9..556a15e406 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -17,7 +17,7 @@ public Task Create(long repositoryId, NewCheckRun newCheckRun) { Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - return ApiConnection.Post(ApiUrls.CheckRuns(repositoryId), newCheckRun); + return ApiConnection.Post(ApiUrls.CheckRuns(repositoryId), newCheckRun, AcceptHeaders.ChecksApiPreview); } public Task Create(string owner, string name, NewCheckRun newCheckRun) @@ -26,12 +26,12 @@ public Task Create(string owner, string name, NewCheckRun newCheckRun) Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - return ApiConnection.Post(ApiUrls.CheckRuns(owner, name), newCheckRun); + return ApiConnection.Post(ApiUrls.CheckRuns(owner, name), newCheckRun, AcceptHeaders.ChecksApiPreview); } public Task Get(long repositoryId, long checkRunId) { - return ApiConnection.Get(ApiUrls.CheckRun(repositoryId, checkRunId)); + return ApiConnection.Get(ApiUrls.CheckRun(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview); } public Task Get(string owner, string name, long checkRunId) @@ -39,7 +39,7 @@ public Task Get(string owner, string name, long checkRunId) Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get(ApiUrls.CheckRun(owner, name, checkRunId)); + return ApiConnection.Get(ApiUrls.CheckRun(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview); } public Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest) @@ -118,7 +118,7 @@ public Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUp { Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - return ApiConnection.Patch(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate); + return ApiConnection.Patch(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); } public Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) @@ -127,7 +127,7 @@ public Task Update(string owner, string name, long checkRunId, CheckRunUpdate ch Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - return ApiConnection.Patch(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate); + return ApiConnection.Patch(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); } } } From c17c9973572517d2eff70744ca72dc75d1fdc7d3 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:22:56 -0400 Subject: [PATCH 07/82] Standardize class definitions --- Octokit/Clients/CheckRunAnnotationsClient.cs | 2 +- Octokit/Clients/CheckRunsClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/CheckRunAnnotationsClient.cs b/Octokit/Clients/CheckRunAnnotationsClient.cs index 666dd1c732..ba9477f9df 100644 --- a/Octokit/Clients/CheckRunAnnotationsClient.cs +++ b/Octokit/Clients/CheckRunAnnotationsClient.cs @@ -3,7 +3,7 @@ namespace Octokit { - internal class CheckRunAnnotationsClient : ApiClient, ICheckRunAnnotationsClient + class CheckRunAnnotationsClient : ApiClient, ICheckRunAnnotationsClient { public CheckRunAnnotationsClient(IApiConnection apiConnection) : base(apiConnection) { diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index 556a15e406..2511d0d8fa 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -4,7 +4,7 @@ namespace Octokit { - public sealed class CheckRunsClient : ApiClient, ICheckRunsClient + public class CheckRunsClient : ApiClient, ICheckRunsClient { public ICheckRunAnnotationsClient Annotations { get; } From ef25014ece73e9268d218b88406c614e5ce47a6c Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:28:55 -0400 Subject: [PATCH 08/82] Standardize function names --- Octokit/Clients/CheckRunAnnotationsClient.cs | 14 +++++------ Octokit/Clients/CheckRunsClient.cs | 24 +++++++++---------- Octokit/Clients/ICheckRunAnnotationsClient.cs | 8 +++---- Octokit/Clients/ICheckRunsClient.cs | 16 ++++++------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Octokit/Clients/CheckRunAnnotationsClient.cs b/Octokit/Clients/CheckRunAnnotationsClient.cs index ba9477f9df..ea96c3e00c 100644 --- a/Octokit/Clients/CheckRunAnnotationsClient.cs +++ b/Octokit/Clients/CheckRunAnnotationsClient.cs @@ -3,31 +3,31 @@ namespace Octokit { - class CheckRunAnnotationsClient : ApiClient, ICheckRunAnnotationsClient + public class CheckRunAnnotationsClient : ApiClient, ICheckRunAnnotationsClient { public CheckRunAnnotationsClient(IApiConnection apiConnection) : base(apiConnection) { } - public Task> List(long repositoryId, long checkRunId) + public Task> GetAllAnnotations(long repositoryId, long checkRunId) { - return List(repositoryId, checkRunId, ApiOptions.None); + return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); } - public Task> List(string owner, string name, long checkRunId) + public Task> GetAllAnnotations(string owner, string name, long checkRunId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return List(owner, name, checkRunId, ApiOptions.None); + return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); } - public Task> List(long repositoryId, long checkRunId, ApiOptions options) + public Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) { return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } - public Task> List(string owner, string name, long checkRunId, ApiOptions options) + public Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index 2511d0d8fa..6992c1c289 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -42,41 +42,41 @@ public Task Get(string owner, string name, long checkRunId) return ApiConnection.Get(ApiUrls.CheckRun(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview); } - public Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest) + public Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - return List(repositoryId, reference, checkRunRequest, ApiOptions.None); + return GetAllForReference(repositoryId, reference, checkRunRequest, ApiOptions.None); } - public Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest) + public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - return List(owner, name, reference, checkRunRequest, ApiOptions.None); + return GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None); } - public Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) + public Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - return List(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); + return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); } - public Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) + public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - return List(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); + return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); } - public Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + public Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); @@ -85,7 +85,7 @@ public Task> List(long repositoryId, string reference, C throw new NotImplementedException(); } - public Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -96,7 +96,7 @@ public Task> List(string owner, string name, string refe throw new NotImplementedException(); } - public Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + public Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); @@ -104,7 +104,7 @@ public Task> List(long repositoryId, long checkSuiteId, throw new NotImplementedException(); } - public Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); diff --git a/Octokit/Clients/ICheckRunAnnotationsClient.cs b/Octokit/Clients/ICheckRunAnnotationsClient.cs index ba5d189d3c..9dcdc63383 100644 --- a/Octokit/Clients/ICheckRunAnnotationsClient.cs +++ b/Octokit/Clients/ICheckRunAnnotationsClient.cs @@ -5,9 +5,9 @@ namespace Octokit { public interface ICheckRunAnnotationsClient { - Task> List(long repositoryId, long checkRunId); - Task> List(string owner, string name, long checkRunId); - Task> List(long repositoryId, long checkRunId, ApiOptions options); - Task> List(string owner, string name, long checkRunId, ApiOptions options); + Task> GetAllAnnotations(long repositoryId, long checkRunId); + Task> GetAllAnnotations(string owner, string name, long checkRunId); + Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); + Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); } } \ No newline at end of file diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs index 6a4ae690d1..b16b3b20f8 100644 --- a/Octokit/Clients/ICheckRunsClient.cs +++ b/Octokit/Clients/ICheckRunsClient.cs @@ -11,14 +11,14 @@ public interface ICheckRunsClient Task Create(string owner, string name, NewCheckRun newCheckRun); Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); - Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest); - Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest); - Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); - Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); - Task> List(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - Task> List(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - Task> List(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); - Task> List(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); + Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); + Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); + Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); + Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); + Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); + Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); Task Get(long repositoryId, long checkRunId); Task Get(string owner, string name, long checkRunId); } From 5530d72eaed9a56922de910dba291de5741333b6 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:30:33 -0400 Subject: [PATCH 09/82] Merge ICheckRunAnnotationsClient into ICheckRunsClient --- Octokit/Clients/CheckRunAnnotationsClient.cs | 38 ------------------- Octokit/Clients/CheckRunsClient.cs | 28 ++++++++++++-- Octokit/Clients/ICheckRunAnnotationsClient.cs | 13 ------- Octokit/Clients/ICheckRunsClient.cs | 6 ++- 4 files changed, 29 insertions(+), 56 deletions(-) delete mode 100644 Octokit/Clients/CheckRunAnnotationsClient.cs delete mode 100644 Octokit/Clients/ICheckRunAnnotationsClient.cs diff --git a/Octokit/Clients/CheckRunAnnotationsClient.cs b/Octokit/Clients/CheckRunAnnotationsClient.cs deleted file mode 100644 index ea96c3e00c..0000000000 --- a/Octokit/Clients/CheckRunAnnotationsClient.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Octokit -{ - public class CheckRunAnnotationsClient : ApiClient, ICheckRunAnnotationsClient - { - public CheckRunAnnotationsClient(IApiConnection apiConnection) : base(apiConnection) - { - } - - public Task> GetAllAnnotations(long repositoryId, long checkRunId) - { - return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); - } - - public Task> GetAllAnnotations(string owner, string name, long checkRunId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); - } - - public Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) - { - return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - - public Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - } -} \ No newline at end of file diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index 6992c1c289..887148d530 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -6,11 +6,8 @@ namespace Octokit { public class CheckRunsClient : ApiClient, ICheckRunsClient { - public ICheckRunAnnotationsClient Annotations { get; } - public CheckRunsClient(IApiConnection apiConnection) : base(apiConnection) { - Annotations = new CheckRunAnnotationsClient(apiConnection); } public Task Create(long repositoryId, NewCheckRun newCheckRun) @@ -129,5 +126,30 @@ public Task Update(string owner, string name, long checkRunId, CheckRunUpdate ch return ApiConnection.Patch(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); } + public Task> GetAllAnnotations(long repositoryId, long checkRunId) + { + return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); + } + + public Task> GetAllAnnotations(string owner, string name, long checkRunId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); + } + + public Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) + { + return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + } + + public Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + } } } diff --git a/Octokit/Clients/ICheckRunAnnotationsClient.cs b/Octokit/Clients/ICheckRunAnnotationsClient.cs deleted file mode 100644 index 9dcdc63383..0000000000 --- a/Octokit/Clients/ICheckRunAnnotationsClient.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Octokit -{ - public interface ICheckRunAnnotationsClient - { - Task> GetAllAnnotations(long repositoryId, long checkRunId); - Task> GetAllAnnotations(string owner, string name, long checkRunId); - Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); - Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); - } -} \ No newline at end of file diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs index b16b3b20f8..939e5422b9 100644 --- a/Octokit/Clients/ICheckRunsClient.cs +++ b/Octokit/Clients/ICheckRunsClient.cs @@ -5,8 +5,6 @@ namespace Octokit { public interface ICheckRunsClient { - ICheckRunAnnotationsClient Annotations { get; } - Task Create(long repositoryId, NewCheckRun newCheckRun); Task Create(string owner, string name, NewCheckRun newCheckRun); Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); @@ -21,5 +19,9 @@ public interface ICheckRunsClient Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); Task Get(long repositoryId, long checkRunId); Task Get(string owner, string name, long checkRunId); + Task> GetAllAnnotations(long repositoryId, long checkRunId); + Task> GetAllAnnotations(string owner, string name, long checkRunId); + Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); + Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); } } From ea9d6297b1d2d3934639d8e30814a6cf8da4dc05 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:38:06 -0400 Subject: [PATCH 10/82] Properly organize clients --- Octokit/Clients/CheckSuitesClient.cs | 9 +++++++++ Octokit/Clients/ChecksClient.cs | 14 ++++++++++++++ Octokit/Clients/ICheckSuitesClient.cs | 6 ++++++ Octokit/Clients/IChecksClient.cs | 9 +++++++++ Octokit/GitHubClient.cs | 8 ++++---- Octokit/IGitHubClient.cs | 6 +++--- 6 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 Octokit/Clients/CheckSuitesClient.cs create mode 100644 Octokit/Clients/ChecksClient.cs create mode 100644 Octokit/Clients/ICheckSuitesClient.cs create mode 100644 Octokit/Clients/IChecksClient.cs diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs new file mode 100644 index 0000000000..134ce56e33 --- /dev/null +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -0,0 +1,9 @@ +namespace Octokit +{ + public class CheckSuitesClient : ApiClient, ICheckSuitesClient + { + public CheckSuitesClient(ApiConnection apiConnection) : base(apiConnection) + { + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/ChecksClient.cs b/Octokit/Clients/ChecksClient.cs new file mode 100644 index 0000000000..edbbcd1f3f --- /dev/null +++ b/Octokit/Clients/ChecksClient.cs @@ -0,0 +1,14 @@ +namespace Octokit +{ + public class ChecksClient : IChecksClient + { + public ICheckRunsClient Runs { get; private set; } + public ICheckSuitesClient Suites { get; private set; } + + public ChecksClient(ApiConnection apiConnection) + { + Runs = new CheckRunsClient(apiConnection); + Suites = new CheckSuitesClient(apiConnection); + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs new file mode 100644 index 0000000000..39675ec0c6 --- /dev/null +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -0,0 +1,6 @@ +namespace Octokit +{ + public interface ICheckSuitesClient + { + } +} \ No newline at end of file diff --git a/Octokit/Clients/IChecksClient.cs b/Octokit/Clients/IChecksClient.cs new file mode 100644 index 0000000000..83b0f2983f --- /dev/null +++ b/Octokit/Clients/IChecksClient.cs @@ -0,0 +1,9 @@ +namespace Octokit +{ + public interface IChecksClient + { + ICheckRunsClient Runs { get; } + + ICheckSuitesClient Suites { get; } + } +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index 19a78ead14..a329793907 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -110,7 +110,7 @@ public GitHubClient(IConnection connection) Search = new SearchClient(apiConnection); User = new UsersClient(apiConnection); Reaction = new ReactionsClient(apiConnection); - CheckRuns = new CheckRunsClient(apiConnection); + Checks = new ChecksClient(apiConnection); } /// @@ -298,12 +298,12 @@ public Uri BaseAddress public IReactionsClient Reaction { get; private set; } /// - /// Access GitHub's Check Runs API + /// Access GitHub's Checks API /// /// - /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/runs + /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/ /// - public ICheckRunsClient CheckRuns { get; private set; } + public IChecksClient Checks { get; private set; } static Uri FixUpBaseUri(Uri uri) { diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 3f02762342..0eff3d5c1c 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -151,11 +151,11 @@ public interface IGitHubClient : IApiInfoProvider IReactionsClient Reaction { get; } /// - /// Access GitHub's Check Runs API. + /// Access GitHub's Checks API. /// /// - /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/runs/ + /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/ /// - ICheckRunsClient CheckRuns { get; } + IChecksClient Checks { get; } } } From 2960e5ea0d73b062c025d58f7c670fcc6c7b4ab3 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:47:35 -0400 Subject: [PATCH 11/82] Cleanup CheckRun response model --- Octokit/Models/Response/CheckRun.cs | 38 ++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index 2fd33df4e1..2171d6564c 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -1,15 +1,41 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Octokit { - public class CheckRun : NewCheckRun + public class CheckRun { - public long Id { get; protected set; } + public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion conclusion, DateTimeOffset startedAt, DateTimeOffset completedAt, CheckRunOutput output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList pullRequests) + { + Id = id; + HeadSha = headSha; + ExternalId = externalId; + Url = url; + HtmlUrl = htmlUrl; + Status = status; + Conclusion = conclusion; + StartedAt = startedAt; + CompletedAt = completedAt; + Output = output; + Name = name; + CheckSuite = checkSuite; + App = app; + PullRequests = pullRequests; + } - public GitHubApp App { get; protected set; } - + public long Id { get; protected set; } + public string HeadSha { get; protected set; } + public string ExternalId { get; protected set; } + public string Url { get; protected set; } + public string HtmlUrl { get; protected set; } + public CheckStatus Status { get; protected set; } + public CheckConclusion Conclusion { get; protected set; } + public DateTimeOffset StartedAt { get; protected set; } + public DateTimeOffset CompletedAt { get; protected set; } + public CheckRunOutput Output { get; protected set; } + public string Name { get; protected set; } public CheckSuite CheckSuite { get; protected set; } - + public GitHubApp App { get; protected set; } public IReadOnlyList PullRequests { get; protected set; } } } From 92333d30d4ce89897cc22ed6ea8cd53bef43afed Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:48:56 -0400 Subject: [PATCH 12/82] Fix slug check run urls --- Octokit/Helpers/ApiUrls.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index d36f20329e..8697633655 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -3819,7 +3819,7 @@ public static Uri CheckRun(long repositoryId, long id) /// The that returns the specified check run. public static Uri CheckRun(string owner, string repo, long id) { - return "repositories/{0}/{1}/check-runs/{2}".FormatUri(owner, repo, id); + return "repos/{0}/{1}/check-runs/{2}".FormatUri(owner, repo, id); } /// @@ -3840,7 +3840,7 @@ public static Uri CheckRuns(long repositoryId) /// The that returns the check runs for the specified reference. public static Uri CheckRuns(string owner, string repo) { - return "repositories/{0}/{1}/check-runs".FormatUri(owner, repo); + return "repos/{0}/{1}/check-runs".FormatUri(owner, repo); } /// @@ -3863,7 +3863,7 @@ public static Uri CheckRunAnnotations(long repositoryId, long id) /// The that returns the specified check run's annotations. public static Uri CheckRunAnnotations(string owner, string repo, long id) { - return "repositories/{0}/{1}/check-runs/{2}/annotations".FormatUri(owner, repo, id); + return "repos/{0}/{1}/check-runs/{2}/annotations".FormatUri(owner, repo, id); } /// @@ -3886,7 +3886,7 @@ public static Uri ReferenceCheckRuns(long repositoryId, string reference) /// The that returns the check runs for the specified reference. public static Uri ReferenceCheckRuns(string owner, string repo, string reference) { - return "repositories/{0}/{1}/commits/{2}/check-runs".FormatUri(owner, repo, reference); + return "repos/{0}/{1}/commits/{2}/check-runs".FormatUri(owner, repo, reference); } /// @@ -3909,7 +3909,7 @@ public static Uri CheckSuiteRuns(long repositoryId, long id) /// The that returns the specified pull request. public static Uri CheckSuiteRuns(string owner, string repo, long id) { - return "repositories/{0}/{1}/check-suites/{2}/check-runs".FormatUri(owner, repo, id); + return "repos/{0}/{1}/check-suites/{2}/check-runs".FormatUri(owner, repo, id); } } } From f6eeee04ee02353e583f7dcb1267d016c2c599dd Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 09:54:00 -0400 Subject: [PATCH 13/82] Add checks installation permission --- Octokit/Models/Response/InstallationPermissions.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index 6aa0d548df..7c5b73fdb2 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -9,7 +9,7 @@ public class InstallationPermissions { public InstallationPermissions() { } - public InstallationPermissions(InstallationPermissionLevel? metadata, InstallationPermissionLevel? administration, InstallationPermissionLevel? statuses, InstallationPermissionLevel? deployments, InstallationPermissionLevel? issues, InstallationPermissionLevel? pages, InstallationPermissionLevel? pullRequests, InstallationPermissionLevel? contents, InstallationPermissionLevel? singleFile, InstallationPermissionLevel? repositoryProjects, InstallationPermissionLevel? members, InstallationPermissionLevel? organizationProjects, InstallationPermissionLevel? teamDiscussions) + public InstallationPermissions(InstallationPermissionLevel? metadata, InstallationPermissionLevel? administration, InstallationPermissionLevel? statuses, InstallationPermissionLevel? deployments, InstallationPermissionLevel? issues, InstallationPermissionLevel? pages, InstallationPermissionLevel? pullRequests, InstallationPermissionLevel? contents, InstallationPermissionLevel? singleFile, InstallationPermissionLevel? repositoryProjects, InstallationPermissionLevel? members, InstallationPermissionLevel? organizationProjects, InstallationPermissionLevel? teamDiscussions, InstallationPermissionLevel? checks) { Metadata = metadata; Administration = administration; @@ -24,6 +24,7 @@ public InstallationPermissions(InstallationPermissionLevel? metadata, Installati Members = members; OrganizationProjects = organizationProjects; TeamDiscussions = teamDiscussions; + Checks = checks; } /// @@ -86,6 +87,12 @@ public InstallationPermissions(InstallationPermissionLevel? metadata, Installati /// public StringEnum? RepositoryProjects { get; protected set; } + /// + /// Checks + /// Detailed information about CI checks + /// + public StringEnum? Checks { get; protected set; } + /// /// Organization members (only applicable when installed for an Organization ) /// Organization members and teams. From 97b24de0182bdd54bb1b931fba9208bec4d8051f Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:03:06 -0400 Subject: [PATCH 14/82] Use StringEnums where appropriate --- Octokit/Models/Common/CheckRunAnnotation.cs | 30 ++++++++++++++------- Octokit/Models/Response/CheckRun.cs | 4 +-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Octokit/Models/Common/CheckRunAnnotation.cs b/Octokit/Models/Common/CheckRunAnnotation.cs index b67ef1e4f6..c77c462e50 100644 --- a/Octokit/Models/Common/CheckRunAnnotation.cs +++ b/Octokit/Models/Common/CheckRunAnnotation.cs @@ -2,16 +2,28 @@ namespace Octokit { - public sealed class CheckRunAnnotation + public class CheckRunAnnotation { - string Filename { get; set; } - string BlobHref { get; set; } - int StartLine { get; set; } - int EndLine { get; set; } - CheckWarningLevel WarningLevel { get; set; } - string Message { get; set; } - string Title { get; set; } - string RawDetails { get; set; } + public CheckRunAnnotation(string filename, string blobHref, int startLine, int endLine, CheckWarningLevel warningLevel, string message, string title, string rawDetails) + { + Filename = filename; + BlobHref = blobHref; + StartLine = startLine; + EndLine = endLine; + WarningLevel = warningLevel; + Message = message; + Title = title; + RawDetails = rawDetails; + } + + public string Filename { get; protected set; } + public string BlobHref { get; protected set; } + public int StartLine { get; protected set; } + public int EndLine { get; protected set; } + public StringEnum WarningLevel { get; protected set; } + public string Message { get; protected set; } + public string Title { get; protected set; } + public string RawDetails { get; protected set; } } public enum CheckWarningLevel diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index 2171d6564c..5c4eefa446 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -28,8 +28,8 @@ public CheckRun(long id, string headSha, string externalId, string url, string h public string ExternalId { get; protected set; } public string Url { get; protected set; } public string HtmlUrl { get; protected set; } - public CheckStatus Status { get; protected set; } - public CheckConclusion Conclusion { get; protected set; } + public StringEnum Status { get; protected set; } + public StringEnum Conclusion { get; protected set; } public DateTimeOffset StartedAt { get; protected set; } public DateTimeOffset CompletedAt { get; protected set; } public CheckRunOutput Output { get; protected set; } From cfa63a868aebaf4b2539446ac07920515556e84a Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:10:44 -0400 Subject: [PATCH 15/82] Cleanup check run output models --- Octokit/Models/Common/CheckRunAnnotation.cs | 4 ++++ Octokit/Models/Common/CheckRunImage.cs | 20 +++++++++++++++++ Octokit/Models/Common/CheckRunOutput.cs | 24 +++++++++++++++++++++ Octokit/Models/Request/CheckRunImage.cs | 9 -------- Octokit/Models/Request/CheckRunOutput.cs | 12 ----------- 5 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 Octokit/Models/Common/CheckRunImage.cs create mode 100644 Octokit/Models/Common/CheckRunOutput.cs delete mode 100644 Octokit/Models/Request/CheckRunImage.cs delete mode 100644 Octokit/Models/Request/CheckRunOutput.cs diff --git a/Octokit/Models/Common/CheckRunAnnotation.cs b/Octokit/Models/Common/CheckRunAnnotation.cs index c77c462e50..e51e6efda1 100644 --- a/Octokit/Models/Common/CheckRunAnnotation.cs +++ b/Octokit/Models/Common/CheckRunAnnotation.cs @@ -4,6 +4,10 @@ namespace Octokit { public class CheckRunAnnotation { + public CheckRunAnnotation() + { + } + public CheckRunAnnotation(string filename, string blobHref, int startLine, int endLine, CheckWarningLevel warningLevel, string message, string title, string rawDetails) { Filename = filename; diff --git a/Octokit/Models/Common/CheckRunImage.cs b/Octokit/Models/Common/CheckRunImage.cs new file mode 100644 index 0000000000..b8c5b129f5 --- /dev/null +++ b/Octokit/Models/Common/CheckRunImage.cs @@ -0,0 +1,20 @@ +namespace Octokit +{ + public class CheckRunImage + { + public CheckRunImage() + { + } + + public CheckRunImage(string alt, string imageUrl, string caption) + { + Alt = alt; + ImageUrl = imageUrl; + Caption = caption; + } + + public string Alt { get; protected set; } + public string ImageUrl { get; protected set; } + public string Caption { get; protected set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Common/CheckRunOutput.cs b/Octokit/Models/Common/CheckRunOutput.cs new file mode 100644 index 0000000000..dc040c5936 --- /dev/null +++ b/Octokit/Models/Common/CheckRunOutput.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public class CheckRunOutput + { + public CheckRunOutput() + { + } + + public CheckRunOutput(string title, string summary, IReadOnlyList annotations, IReadOnlyList images) + { + Title = title; + Summary = summary; + Annotations = annotations; + Images = images; + } + + public string Title { get; protected set; } + public string Summary { get; protected set; } + public IReadOnlyList Annotations { get; protected set; } + public IReadOnlyList Images { get; protected set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckRunImage.cs b/Octokit/Models/Request/CheckRunImage.cs deleted file mode 100644 index d2b826a4ba..0000000000 --- a/Octokit/Models/Request/CheckRunImage.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Octokit -{ - public sealed class CheckRunImage - { - string Alt { get; set; } - string ImageUrl { get; set; } - string Caption { get; set; } - } -} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckRunOutput.cs b/Octokit/Models/Request/CheckRunOutput.cs deleted file mode 100644 index c87c966e41..0000000000 --- a/Octokit/Models/Request/CheckRunOutput.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; - -namespace Octokit -{ - public sealed class CheckRunOutput - { - public string Title { get; set; } - public string Summary { get; set; } - public List Annotations { get; set; } - public List Images { get; set; } - } -} \ No newline at end of file From 70d84bfc6f51dd8b46b49dd1b1f4542526eb5af0 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:18:23 -0400 Subject: [PATCH 16/82] Flesh out CheckSuite model --- Octokit/Models/Response/CheckSuite.cs | 33 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/CheckSuite.cs b/Octokit/Models/Response/CheckSuite.cs index e4a31f950a..4b3db093e7 100644 --- a/Octokit/Models/Response/CheckSuite.cs +++ b/Octokit/Models/Response/CheckSuite.cs @@ -1,7 +1,38 @@ -namespace Octokit +using System.Collections.Generic; + +namespace Octokit { public class CheckSuite { + public CheckSuite() + { + } + + public CheckSuite(long id, string headBranch, string headSha, CheckStatus status, CheckConclusion conclusion, string url, string before, string after, IReadOnlyList pullRequests, GitHubApp app, Repository repository) + { + Id = id; + HeadBranch = headBranch; + HeadSha = headSha; + Status = status; + Conclusion = conclusion; + Url = url; + Before = before; + After = after; + PullRequests = pullRequests; + App = app; + Repository = repository; + } + public long Id { get; protected set; } + public string HeadBranch { get; protected set; } + public string HeadSha { get; protected set; } + public StringEnum Status { get; protected set; } + public StringEnum Conclusion { get; protected set; } + public string Url { get; protected set; } + public string Before { get; protected set; } + public string After { get; protected set; } + public IReadOnlyList PullRequests { get; protected set; } + public GitHubApp App { get; protected set; } + public Repository Repository { get; protected set; } } } From 21cf83552584680d3a084c5bffd2475189cde00f Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:19:11 -0400 Subject: [PATCH 17/82] Delete CheckRunsList --- Octokit/Models/Response/CheckRunsList.cs | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Octokit/Models/Response/CheckRunsList.cs diff --git a/Octokit/Models/Response/CheckRunsList.cs b/Octokit/Models/Response/CheckRunsList.cs deleted file mode 100644 index 3a29348768..0000000000 --- a/Octokit/Models/Response/CheckRunsList.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace Octokit -{ - public class CheckRunsList - { - public int TotalCount { get; protected set; } - public IReadOnlyList CheckRuns { get; protected set; } - } -} From f39a637831f22eb91aecadfc61d933d161a99900 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:21:41 -0400 Subject: [PATCH 18/82] Remove a sealed, fix some line endings --- Octokit/Models/Request/CheckRunRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Request/CheckRunRequest.cs b/Octokit/Models/Request/CheckRunRequest.cs index b6834f3c2e..cfd1f6837a 100644 --- a/Octokit/Models/Request/CheckRunRequest.cs +++ b/Octokit/Models/Request/CheckRunRequest.cs @@ -2,7 +2,7 @@ namespace Octokit { - public sealed class CheckRunRequest : RequestParameters + public class CheckRunRequest : RequestParameters { public string CheckName { get; set; } public CheckStatus? Status { get; set; } From 0cac0158d0011428573387b7edd32e86fedd0811 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:36:34 -0400 Subject: [PATCH 19/82] Adding check suite models --- .../Models/Common/AutoTriggerChecksObject.cs | 18 ++++++++++++++++++ Octokit/Models/Common/CheckSuitePreference.cs | 17 +++++++++++++++++ Octokit/Models/Request/CheckSuiteRequest.cs | 8 ++++++++ .../Models/Request/CheckSuiteTriggerRequest.cs | 7 +++++++ Octokit/Models/Request/NewCheckSuite.cs | 7 +++++++ 5 files changed, 57 insertions(+) create mode 100644 Octokit/Models/Common/AutoTriggerChecksObject.cs create mode 100644 Octokit/Models/Common/CheckSuitePreference.cs create mode 100644 Octokit/Models/Request/CheckSuiteRequest.cs create mode 100644 Octokit/Models/Request/CheckSuiteTriggerRequest.cs create mode 100644 Octokit/Models/Request/NewCheckSuite.cs diff --git a/Octokit/Models/Common/AutoTriggerChecksObject.cs b/Octokit/Models/Common/AutoTriggerChecksObject.cs new file mode 100644 index 0000000000..d95002ac7b --- /dev/null +++ b/Octokit/Models/Common/AutoTriggerChecksObject.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace Octokit +{ + public class AutoTriggerChecksObject + { + public AutoTriggerChecksObject() + { + } + + public AutoTriggerChecksObject(IReadOnlyList autoTriggerChecks) + { + AutoTriggerChecks = autoTriggerChecks; + } + + public IReadOnlyList AutoTriggerChecks { get; protected set; } + } +} diff --git a/Octokit/Models/Common/CheckSuitePreference.cs b/Octokit/Models/Common/CheckSuitePreference.cs new file mode 100644 index 0000000000..1d04bdfb9f --- /dev/null +++ b/Octokit/Models/Common/CheckSuitePreference.cs @@ -0,0 +1,17 @@ +namespace Octokit +{ + public class CheckSuitePreference + { + public CheckSuitePreference() + { + } + public CheckSuitePreference(long appId, bool setting) + { + AppId = appId; + Setting = setting; + } + + public long AppId { get; protected set; } + public bool Setting { get; protected set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/CheckSuiteRequest.cs b/Octokit/Models/Request/CheckSuiteRequest.cs new file mode 100644 index 0000000000..e8495f5045 --- /dev/null +++ b/Octokit/Models/Request/CheckSuiteRequest.cs @@ -0,0 +1,8 @@ +namespace Octokit +{ + public class CheckSuiteRequest + { + public long AppId { get; set; } + public string CheckName { get; set; } + } +} diff --git a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs new file mode 100644 index 0000000000..59b74232d6 --- /dev/null +++ b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs @@ -0,0 +1,7 @@ +namespace Octokit +{ + public class CheckSuiteTriggerRequest + { + public string HeadSha { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/NewCheckSuite.cs b/Octokit/Models/Request/NewCheckSuite.cs new file mode 100644 index 0000000000..37584c9e53 --- /dev/null +++ b/Octokit/Models/Request/NewCheckSuite.cs @@ -0,0 +1,7 @@ +namespace Octokit +{ + public class NewCheckSuite : CheckSuiteTriggerRequest + { + public string HeadBranch { get; set; } + } +} From 6688ecee4c4b92550ca27690ead36a9956072d26 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:43:40 -0400 Subject: [PATCH 20/82] Skeleton check suite client implementation --- Octokit/Clients/CheckSuitesClient.cs | 85 ++++++++++++++++++++++++++- Octokit/Clients/ICheckSuitesClient.cs | 21 ++++++- 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 134ce56e33..1b98a9e759 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -1,9 +1,92 @@ -namespace Octokit +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit { public class CheckSuitesClient : ApiClient, ICheckSuitesClient { public CheckSuitesClient(ApiConnection apiConnection) : base(apiConnection) { } + + public Task Create(long repositoryId, NewCheckSuite newCheckSuite) + { + throw new System.NotImplementedException(); + } + + public Task Create(string owner, string name, NewCheckSuite newCheckSuite) + { + throw new System.NotImplementedException(); + } + + public Task Get(long repositoryId, long checkSuiteId) + { + throw new System.NotImplementedException(); + } + + public Task Get(string owner, string name, long checkSuiteId) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(long repositoryId, string reference) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(string owner, string name, string reference) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(long repositoryId, string reference, ApiOptions options) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(string owner, string name, string reference, ApiOptions options) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) + { + throw new System.NotImplementedException(); + } + + public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) + { + throw new System.NotImplementedException(); + } + + public Task Request(long repositoryId, CheckSuiteTriggerRequest request) + { + throw new System.NotImplementedException(); + } + + public Task Request(string owner, string name, CheckSuiteTriggerRequest request) + { + throw new System.NotImplementedException(); + } + + public Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + { + throw new System.NotImplementedException(); + } + + public Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) + { + throw new System.NotImplementedException(); + } } } \ No newline at end of file diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 39675ec0c6..4b543b92ff 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -1,6 +1,25 @@ -namespace Octokit +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit { public interface ICheckSuitesClient { + Task Get(long repositoryId, long checkSuiteId); + Task Get(string owner, string name, long checkSuiteId); + Task> GetAllForReference(long repositoryId, string reference); + Task> GetAllForReference(string owner, string name, string reference); + Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); + Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); + Task> GetAllForReference(long repositoryId, string reference, ApiOptions options); + Task> GetAllForReference(string owner, string name, string reference, ApiOptions options); + Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); + Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); + Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); + Task Create(long repositoryId, NewCheckSuite newCheckSuite); + Task Create(string owner, string name, NewCheckSuite newCheckSuite); + Task Request(long repositoryId, CheckSuiteTriggerRequest request); + Task Request(string owner, string name, CheckSuiteTriggerRequest request); } } \ No newline at end of file From 5b40de8d64d2367beaf268e8f5270112763da97a Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 10:54:57 -0400 Subject: [PATCH 21/82] Add check suite ApiUrls --- Octokit/Helpers/ApiUrls.cs | 96 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 4 deletions(-) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 8697633655..6684d972ae 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -3823,21 +3823,21 @@ public static Uri CheckRun(string owner, string repo, long id) } /// - /// Returns the that lists the check runs for the repository. + /// Returns the that handles the check runs for the repository. /// /// The Id of the repository - /// The that returns the check runs for the specified reference. + /// The that handles the check runs for the repository. public static Uri CheckRuns(long repositoryId) { return "repositories/{0}/check-runs".FormatUri(repositoryId); } /// - /// Returns the that lists the check runs for the repository. + /// Returns the that handles the check runs for the repository. /// /// The owner of repo /// The name of repo - /// The that returns the check runs for the specified reference. + /// The that handles the check runs for the repository. public static Uri CheckRuns(string owner, string repo) { return "repos/{0}/{1}/check-runs".FormatUri(owner, repo); @@ -3911,5 +3911,93 @@ public static Uri CheckSuiteRuns(string owner, string repo, long id) { return "repos/{0}/{1}/check-suites/{2}/check-runs".FormatUri(owner, repo, id); } + + /// + /// Returns the that returns the specified check suite. + /// + /// The Id of the repository + /// The check run Id + /// The that returns the specified check suite. + public static Uri CheckSuite(long repositoryId, long id) + { + return "repositories/{0}/check-suites/{1}".FormatUri(repositoryId, id); + } + + /// + /// Returns the that returns the specified check suite. + /// + /// The owner of repo + /// The name of repo + /// The check run Id + /// The that returns the specified check suite. + public static Uri CheckSuite(string owner, string repo, long id) + { + return "repos/{0}/{1}/check-suites/{2}".FormatUri(owner, repo, id); + } + + /// + /// Returns the that lists the check suites for the specified reference. + /// + /// The Id of the repository + /// The git reference + /// The that returns the check suites for the specified reference. + public static Uri ReferenceCheckSuites(long repositoryId, string reference) + { + return "repositories/{0}/commits/{1}/check-suites".FormatUri(repositoryId, reference); + } + + /// + /// Returns the that lists the check suites for the specified reference. + /// + /// The owner of repo + /// The name of repo + /// The git reference + /// The that returns the check suites for the specified reference. + public static Uri ReferenceCheckSuites(string owner, string repo, string reference) + { + return "repos/{0}/{1}/commits/{2}/check-suites".FormatUri(owner, repo, reference); + } + + /// + /// Returns the that handles the check suites for the repository. + /// + /// The Id of the repository + /// The that handles the check suites for the repository. + public static Uri CheckSuites(long repositoryId) + { + return "repositories/{0}/check-suites".FormatUri(repositoryId); + } + + /// + /// Returns the that handles the check suites for the repository. + /// + /// The owner of repo + /// The name of repo + /// The that handles the check suites for the repository. + public static Uri CheckSuites(string owner, string repo) + { + return "repos/{0}/{1}/check-suites".FormatUri(owner, repo); + } + + /// + /// Returns the that handles the check suite preferences for the repository. + /// + /// The Id of the repository + /// The that handles the check suite preferences for the repository. + public static Uri CheckSuitePreferences(long repositoryId) + { + return "repositories/{0}/check-suites/preferences".FormatUri(repositoryId); + } + + /// + /// Returns the that handles the check suite preferences for the repository. + /// + /// The owner of repo + /// The name of repo + /// The that handles the check suite preferences for the repository. + public static Uri CheckSuitePreferences(string owner, string repo) + { + return "repos/{0}/{1}/check-suites/preferences".FormatUri(owner, repo); + } } } From f5683fa590b52866a34d66e006707bf4ede1b15a Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 11:01:00 -0400 Subject: [PATCH 22/82] Flesh out check suites client --- Octokit/Clients/CheckSuitesClient.cs | 82 +++++++++++++++---- Octokit/Clients/ICheckSuitesClient.cs | 4 +- .../Models/Response/CheckSuitePreferences.cs | 18 ++++ 3 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 Octokit/Models/Response/CheckSuitePreferences.cs diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 1b98a9e759..f194734cae 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -11,82 +11,134 @@ public CheckSuitesClient(ApiConnection apiConnection) : base(apiConnection) public Task Create(long repositoryId, NewCheckSuite newCheckSuite) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); } public Task Create(string owner, string name, NewCheckSuite newCheckSuite) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); } public Task Get(long repositoryId, long checkSuiteId) { - throw new System.NotImplementedException(); + return ApiConnection.Get(ApiUrls.CheckSuite(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); } public Task Get(string owner, string name, long checkSuiteId) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Get(ApiUrls.CheckSuite(owner, name, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); } public Task> GetAllForReference(long repositoryId, string reference) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(repositoryId, reference, ApiOptions.None); } public Task> GetAllForReference(string owner, string name, string reference) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(owner, name, reference, ApiOptions.None); } public Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + + return GetAllForReference(owner, name, reference, request, ApiOptions.None); } 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, ApiOptions options) + 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, CheckSuiteRequest request, ApiOptions options) { + Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + throw new System.NotImplementedException(); } public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); + throw new System.NotImplementedException(); } public Task Request(long repositoryId, CheckSuiteTriggerRequest request) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNull(request, nameof(request)); + + return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), request, AcceptHeaders.ChecksApiPreview); } public Task Request(string owner, string name, CheckSuiteTriggerRequest request) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(request, nameof(request)); + + return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), request, AcceptHeaders.ChecksApiPreview); } - public Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + public Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview); } - public Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) + public Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) { - throw new System.NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); } } } \ No newline at end of file diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 4b543b92ff..808b2e462d 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -15,8 +15,8 @@ public interface ICheckSuitesClient Task> GetAllForReference(string owner, string name, string reference, ApiOptions options); Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); - Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); - Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); + Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); + Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); Task Create(long repositoryId, NewCheckSuite newCheckSuite); Task Create(string owner, string name, NewCheckSuite newCheckSuite); Task Request(long repositoryId, CheckSuiteTriggerRequest request); diff --git a/Octokit/Models/Response/CheckSuitePreferences.cs b/Octokit/Models/Response/CheckSuitePreferences.cs new file mode 100644 index 0000000000..b57019b251 --- /dev/null +++ b/Octokit/Models/Response/CheckSuitePreferences.cs @@ -0,0 +1,18 @@ +namespace Octokit +{ + public class CheckSuitePreferences + { + public CheckSuitePreferences() + { + } + + public CheckSuitePreferences(AutoTriggerChecksObject preferences, Repository repository) + { + Preferences = preferences; + Repository = repository; + } + + public AutoTriggerChecksObject Preferences { get; protected set; } + public Repository Repository { get; protected set; } + } +} From 3534c640aa008a1ad54bdd020aec5424f30efa0b Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 11:51:51 -0400 Subject: [PATCH 23/82] Add parameterless CheckRun constructor --- Octokit/Models/Response/CheckRun.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index 5c4eefa446..3f07d06ee1 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -5,6 +5,10 @@ namespace Octokit { public class CheckRun { + public CheckRun() + { + } + public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion conclusion, DateTimeOffset startedAt, DateTimeOffset completedAt, CheckRunOutput output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList pullRequests) { Id = id; From bd9ceb8daa4a75be209c590d45f9aa7104f49f66 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 12:23:22 -0400 Subject: [PATCH 24/82] Add DebuggerDisplay to checks models --- Octokit/Models/Common/AutoTriggerChecksObject.cs | 6 ++++++ Octokit/Models/Common/CheckRunAnnotation.cs | 5 +++++ Octokit/Models/Common/CheckRunImage.cs | 8 +++++++- Octokit/Models/Common/CheckRunOutput.cs | 5 +++++ Octokit/Models/Common/CheckSuitePreference.cs | 9 ++++++++- Octokit/Models/Request/CheckRunRequest.cs | 4 ++++ Octokit/Models/Request/CheckRunUpdate.cs | 5 +++++ Octokit/Models/Request/CheckSuiteRequest.cs | 8 +++++++- Octokit/Models/Request/CheckSuiteTriggerRequest.cs | 8 +++++++- Octokit/Models/Request/NewCheckRun.cs | 8 +++++++- Octokit/Models/Request/NewCheckSuite.cs | 7 ++++++- Octokit/Models/Response/CheckRun.cs | 4 ++++ Octokit/Models/Response/CheckSuite.cs | 5 +++++ Octokit/Models/Response/CheckSuitePreferences.cs | 8 +++++++- 14 files changed, 83 insertions(+), 7 deletions(-) diff --git a/Octokit/Models/Common/AutoTriggerChecksObject.cs b/Octokit/Models/Common/AutoTriggerChecksObject.cs index d95002ac7b..e28e1dfe91 100644 --- a/Octokit/Models/Common/AutoTriggerChecksObject.cs +++ b/Octokit/Models/Common/AutoTriggerChecksObject.cs @@ -1,7 +1,11 @@ using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class AutoTriggerChecksObject { public AutoTriggerChecksObject() @@ -14,5 +18,7 @@ public AutoTriggerChecksObject(IReadOnlyList autoTriggerCh } public IReadOnlyList AutoTriggerChecks { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "AutoTriggerChecks: {0}", string.Join(", ", AutoTriggerChecks.Select(x => x.DebuggerDisplay))); } } diff --git a/Octokit/Models/Common/CheckRunAnnotation.cs b/Octokit/Models/Common/CheckRunAnnotation.cs index e51e6efda1..e8d912ffc4 100644 --- a/Octokit/Models/Common/CheckRunAnnotation.cs +++ b/Octokit/Models/Common/CheckRunAnnotation.cs @@ -1,7 +1,10 @@ using Octokit.Internal; +using System.Diagnostics; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunAnnotation { public CheckRunAnnotation() @@ -28,6 +31,8 @@ public CheckRunAnnotation(string filename, string blobHref, int startLine, int e public string Message { get; protected set; } public string Title { get; protected set; } public string RawDetails { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Title: {0}, Filename: {1}, WarningLevel: {2}", Title ?? "", Filename, WarningLevel.DebuggerDisplay); } public enum CheckWarningLevel diff --git a/Octokit/Models/Common/CheckRunImage.cs b/Octokit/Models/Common/CheckRunImage.cs index b8c5b129f5..ca8cac06e5 100644 --- a/Octokit/Models/Common/CheckRunImage.cs +++ b/Octokit/Models/Common/CheckRunImage.cs @@ -1,5 +1,9 @@ -namespace Octokit +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunImage { public CheckRunImage() @@ -16,5 +20,7 @@ public CheckRunImage(string alt, string imageUrl, string caption) public string Alt { get; protected set; } public string ImageUrl { get; protected set; } public string Caption { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "ImageUrl: {0}", ImageUrl); } } \ No newline at end of file diff --git a/Octokit/Models/Common/CheckRunOutput.cs b/Octokit/Models/Common/CheckRunOutput.cs index dc040c5936..6d907aa884 100644 --- a/Octokit/Models/Common/CheckRunOutput.cs +++ b/Octokit/Models/Common/CheckRunOutput.cs @@ -1,7 +1,10 @@ using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunOutput { public CheckRunOutput() @@ -20,5 +23,7 @@ public CheckRunOutput(string title, string summary, IReadOnlyList Annotations { get; protected set; } public IReadOnlyList Images { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "Title: {0}", Title); } } \ No newline at end of file diff --git a/Octokit/Models/Common/CheckSuitePreference.cs b/Octokit/Models/Common/CheckSuitePreference.cs index 1d04bdfb9f..b8e9e3dd8b 100644 --- a/Octokit/Models/Common/CheckSuitePreference.cs +++ b/Octokit/Models/Common/CheckSuitePreference.cs @@ -1,10 +1,15 @@ -namespace Octokit +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuitePreference { public CheckSuitePreference() { } + public CheckSuitePreference(long appId, bool setting) { AppId = appId; @@ -13,5 +18,7 @@ public CheckSuitePreference(long appId, bool setting) public long AppId { get; protected set; } public bool Setting { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "{0}: {1}", AppId, Setting ? "On" : "Off"); } } \ No newline at end of file diff --git a/Octokit/Models/Request/CheckRunRequest.cs b/Octokit/Models/Request/CheckRunRequest.cs index cfd1f6837a..dde60f16d8 100644 --- a/Octokit/Models/Request/CheckRunRequest.cs +++ b/Octokit/Models/Request/CheckRunRequest.cs @@ -1,12 +1,16 @@ using Octokit.Internal; +using System.Diagnostics; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunRequest : RequestParameters { public string CheckName { get; set; } public CheckStatus? Status { get; set; } public CheckRunRequestFilter? Filter { get; set; } + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "CheckName: {0}", CheckName); } public enum CheckRunRequestFilter diff --git a/Octokit/Models/Request/CheckRunUpdate.cs b/Octokit/Models/Request/CheckRunUpdate.cs index 4f1d1b371f..9599618d17 100644 --- a/Octokit/Models/Request/CheckRunUpdate.cs +++ b/Octokit/Models/Request/CheckRunUpdate.cs @@ -1,8 +1,11 @@ using Octokit.Internal; using System; +using System.Diagnostics; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunUpdate { public string Name { get; set; } @@ -13,6 +16,8 @@ public class CheckRunUpdate public CheckConclusion Conclusion { get; set; } public DateTimeOffset CompletedAt { get; set; } public CheckRunOutput Output { get; set; } + + internal virtual string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Name: {0}, Conclusion: {1}", Name, Conclusion); } public enum CheckStatus diff --git a/Octokit/Models/Request/CheckSuiteRequest.cs b/Octokit/Models/Request/CheckSuiteRequest.cs index e8495f5045..358048273b 100644 --- a/Octokit/Models/Request/CheckSuiteRequest.cs +++ b/Octokit/Models/Request/CheckSuiteRequest.cs @@ -1,8 +1,14 @@ -namespace Octokit +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteRequest { public long AppId { get; set; } public string CheckName { get; set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "AppId: {0}, CheckName: {1}", AppId, CheckName); } } diff --git a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs index 59b74232d6..3e9c03fb0b 100644 --- a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs +++ b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs @@ -1,7 +1,13 @@ -namespace Octokit +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteTriggerRequest { public string HeadSha { get; set; } + + internal virtual string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadSha: {0}", HeadSha); } } \ No newline at end of file diff --git a/Octokit/Models/Request/NewCheckRun.cs b/Octokit/Models/Request/NewCheckRun.cs index d0ada5772b..3807a721dc 100644 --- a/Octokit/Models/Request/NewCheckRun.cs +++ b/Octokit/Models/Request/NewCheckRun.cs @@ -1,8 +1,14 @@ -namespace Octokit +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewCheckRun : CheckRunUpdate { public string HeadBranch { get; set; } public string HeadSha { get; set; } + + internal override string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadBranch: {0}, HeadSha{1}, {2}", HeadBranch, HeadSha, base.DebuggerDisplay); } } diff --git a/Octokit/Models/Request/NewCheckSuite.cs b/Octokit/Models/Request/NewCheckSuite.cs index 37584c9e53..bbb7e33170 100644 --- a/Octokit/Models/Request/NewCheckSuite.cs +++ b/Octokit/Models/Request/NewCheckSuite.cs @@ -1,7 +1,12 @@ -namespace Octokit +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewCheckSuite : CheckSuiteTriggerRequest { public string HeadBranch { get; set; } + internal override string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadBranch: {0}, {1}", HeadBranch, base.DebuggerDisplay); } } diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index 3f07d06ee1..a1e8622c8d 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -1,8 +1,11 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRun { public CheckRun() @@ -41,5 +44,6 @@ public CheckRun(long id, string headSha, string externalId, string url, string h public CheckSuite CheckSuite { get; protected set; } public GitHubApp App { get; protected set; } public IReadOnlyList PullRequests { get; protected set; } + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0}, HeadSha: {1}, Conclusion: {2}", Id, HeadSha, Conclusion); } } diff --git a/Octokit/Models/Response/CheckSuite.cs b/Octokit/Models/Response/CheckSuite.cs index 4b3db093e7..9ee226b244 100644 --- a/Octokit/Models/Response/CheckSuite.cs +++ b/Octokit/Models/Response/CheckSuite.cs @@ -1,7 +1,10 @@ using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuite { public CheckSuite() @@ -34,5 +37,7 @@ public CheckSuite(long id, string headBranch, string headSha, CheckStatus status public IReadOnlyList PullRequests { get; protected set; } public GitHubApp App { get; protected set; } public Repository Repository { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0}, HeadBranch: {1}, HeadSha: {2}, Conclusion: {3}", Id, HeadBranch, HeadSha, Conclusion); } } diff --git a/Octokit/Models/Response/CheckSuitePreferences.cs b/Octokit/Models/Response/CheckSuitePreferences.cs index b57019b251..d91390cb8e 100644 --- a/Octokit/Models/Response/CheckSuitePreferences.cs +++ b/Octokit/Models/Response/CheckSuitePreferences.cs @@ -1,5 +1,9 @@ -namespace Octokit +using System.Diagnostics; +using System.Globalization; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuitePreferences { public CheckSuitePreferences() @@ -14,5 +18,7 @@ public CheckSuitePreferences(AutoTriggerChecksObject preferences, Repository rep public AutoTriggerChecksObject Preferences { get; protected set; } public Repository Repository { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Preferences: {0}, Repository: {1}", Preferences.DebuggerDisplay, Repository.DebuggerDisplay); } } From e18655050a9c5804ed65bdb7ac288ce50a3fe6e6 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 12:52:10 -0400 Subject: [PATCH 25/82] Add observable checks interfaces --- .../Clients/IObservableCheckRunsClient.cs | 26 +++++++++++++++++++ .../Clients/IObservableCheckSuitesClient.cs | 24 +++++++++++++++++ .../Clients/IObservableChecksClient.cs | 8 ++++++ Octokit.Reactive/IObservableGitHubClient.cs | 1 + Octokit.Reactive/ObservableGitHubClient.cs | 2 ++ 5 files changed, 61 insertions(+) create mode 100644 Octokit.Reactive/Clients/IObservableCheckRunsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableChecksClient.cs diff --git a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs new file mode 100644 index 0000000000..d012a767db --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs @@ -0,0 +1,26 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableCheckRunsClient + { + IObservable Create(long repositoryId, NewCheckRun newCheckRun); + IObservable Create(string owner, string name, NewCheckRun newCheckRun); + IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); + IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); + IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); + IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); + IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); + IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); + IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); + IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); + IObservable Get(long repositoryId, long checkRunId); + IObservable Get(string owner, string name, long checkRunId); + IObservable GetAllAnnotations(long repositoryId, long checkRunId); + IObservable GetAllAnnotations(string owner, string name, long checkRunId); + IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); + IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs new file mode 100644 index 0000000000..60d8316c97 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -0,0 +1,24 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableCheckSuitesClient + { + IObservable Get(long repositoryId, long checkSuiteId); + IObservable Get(string owner, string name, long checkSuiteId); + IObservable GetAllForReference(long repositoryId, string reference); + IObservable GetAllForReference(string owner, string name, string reference); + IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); + IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); + IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options); + IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options); + IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); + IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); + IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); + IObservable Create(long repositoryId, NewCheckSuite newCheckSuite); + IObservable Create(string owner, string name, NewCheckSuite newCheckSuite); + IObservable Request(long repositoryId, CheckSuiteTriggerRequest request); + IObservable Request(string owner, string name, CheckSuiteTriggerRequest request); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableChecksClient.cs b/Octokit.Reactive/Clients/IObservableChecksClient.cs new file mode 100644 index 0000000000..3b90549838 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableChecksClient.cs @@ -0,0 +1,8 @@ +namespace Octokit.Reactive +{ + public interface IObservableChecksClient + { + IObservableCheckRunsClient Runs { get; } + IObservableCheckSuitesClient Suites { get; } + } +} diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 2de5664e3e..1636c3d772 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -32,5 +32,6 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableEnterpriseClient Enterprise { get; } IObservableMigrationClient Migration { get; } IObservableReactionsClient Reaction { get; } + IObservableChecksClient Checks { get; } } } \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index a7fd8ce636..106d061c9d 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -48,6 +48,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Enterprise = new ObservableEnterpriseClient(gitHubClient); Migration = new ObservableMigrationClient(gitHubClient); Reaction = new ObservableReactionsClient(gitHubClient); + //Checks = new ObservableChecksClient(gitHubClient); } public IConnection Connection @@ -85,6 +86,7 @@ public void SetRequestTimeout(TimeSpan timeout) public IObservableEnterpriseClient Enterprise { get; private set; } public IObservableMigrationClient Migration { get; private set; } public IObservableReactionsClient Reaction { get; private set; } + public IObservableChecksClient Checks { get; private set; } /// /// Gets the latest API Info - this will be null if no API calls have been made From 8a6a59f8c8da498959f097538ad08955eed02dcd Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 8 May 2018 14:12:59 -0400 Subject: [PATCH 26/82] Add return values to POST and PATCH check clients --- Octokit.Reactive/ObservableChecksClient.cs | 13 +++++++++++++ Octokit.Reactive/ObservableGitHubClient.cs | 2 +- Octokit/Clients/CheckRunsClient.cs | 8 ++++---- Octokit/Clients/CheckSuitesClient.cs | 8 ++++---- Octokit/Clients/ICheckRunsClient.cs | 8 ++++---- Octokit/Clients/ICheckSuitesClient.cs | 8 ++++---- 6 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 Octokit.Reactive/ObservableChecksClient.cs diff --git a/Octokit.Reactive/ObservableChecksClient.cs b/Octokit.Reactive/ObservableChecksClient.cs new file mode 100644 index 0000000000..11743f0980 --- /dev/null +++ b/Octokit.Reactive/ObservableChecksClient.cs @@ -0,0 +1,13 @@ +namespace Octokit.Reactive +{ + internal class ObservableChecksClient : IObservableChecksClient + { + public ObservableChecksClient(IGitHubClient gitHubClient) + { + } + + public IObservableCheckRunsClient Runs => throw new System.NotImplementedException(); + + public IObservableCheckSuitesClient Suites => throw new System.NotImplementedException(); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 106d061c9d..99250c6e1c 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -48,7 +48,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Enterprise = new ObservableEnterpriseClient(gitHubClient); Migration = new ObservableMigrationClient(gitHubClient); Reaction = new ObservableReactionsClient(gitHubClient); - //Checks = new ObservableChecksClient(gitHubClient); + Checks = new ObservableChecksClient(gitHubClient); } public IConnection Connection diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index 887148d530..7175f4d702 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -10,14 +10,14 @@ public CheckRunsClient(IApiConnection apiConnection) : base(apiConnection) { } - public Task Create(long repositoryId, NewCheckRun newCheckRun) + public Task Create(long repositoryId, NewCheckRun newCheckRun) { Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); return ApiConnection.Post(ApiUrls.CheckRuns(repositoryId), newCheckRun, AcceptHeaders.ChecksApiPreview); } - public Task Create(string owner, string name, NewCheckRun newCheckRun) + public Task Create(string owner, string name, NewCheckRun newCheckRun) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -111,14 +111,14 @@ public Task> GetAllForCheckSuite(string owner, string na throw new NotImplementedException(); } - public Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) + public Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) { Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); return ApiConnection.Patch(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); } - public Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) + public Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index f194734cae..53bdabba21 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -9,14 +9,14 @@ public CheckSuitesClient(ApiConnection apiConnection) : base(apiConnection) { } - public Task Create(long repositoryId, NewCheckSuite newCheckSuite) + public Task Create(long repositoryId, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); } - public Task Create(string owner, string name, NewCheckSuite newCheckSuite) + public Task Create(string owner, string name, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -109,14 +109,14 @@ public Task> GetAllForReference(string owner, string n throw new System.NotImplementedException(); } - public Task Request(long repositoryId, CheckSuiteTriggerRequest request) + public Task Request(long repositoryId, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), request, AcceptHeaders.ChecksApiPreview); } - public Task Request(string owner, string name, CheckSuiteTriggerRequest request) + public Task Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs index 939e5422b9..572e7c9128 100644 --- a/Octokit/Clients/ICheckRunsClient.cs +++ b/Octokit/Clients/ICheckRunsClient.cs @@ -5,10 +5,10 @@ namespace Octokit { public interface ICheckRunsClient { - Task Create(long repositoryId, NewCheckRun newCheckRun); - Task Create(string owner, string name, NewCheckRun newCheckRun); - Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); - Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); + Task Create(long repositoryId, NewCheckRun newCheckRun); + Task Create(string owner, string name, NewCheckRun newCheckRun); + Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); + Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 808b2e462d..241c448d68 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -17,9 +17,9 @@ public interface ICheckSuitesClient Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); - Task Create(long repositoryId, NewCheckSuite newCheckSuite); - Task Create(string owner, string name, NewCheckSuite newCheckSuite); - Task Request(long repositoryId, CheckSuiteTriggerRequest request); - Task Request(string owner, string name, CheckSuiteTriggerRequest request); + Task Create(long repositoryId, NewCheckSuite newCheckSuite); + Task Create(string owner, string name, NewCheckSuite newCheckSuite); + Task Request(long repositoryId, CheckSuiteTriggerRequest request); + Task Request(string owner, string name, CheckSuiteTriggerRequest request); } } \ No newline at end of file From e58fee9aab8b92b87c31d2058a5b17b33a52c21d Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 8 May 2018 18:37:24 -0400 Subject: [PATCH 27/82] Fix some check suite client return values --- Octokit/Clients/CheckSuitesClient.cs | 16 ++++++++-------- Octokit/Clients/ICheckSuitesClient.cs | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 53bdabba21..8b35dacd1f 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -9,20 +9,20 @@ public CheckSuitesClient(ApiConnection apiConnection) : base(apiConnection) { } - public Task Create(long repositoryId, NewCheckSuite newCheckSuite) + public Task Create(long repositoryId, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); } - public Task Create(string owner, string name, NewCheckSuite newCheckSuite) + public Task Create(string owner, string name, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); } public Task Get(long repositoryId, long checkSuiteId) @@ -109,20 +109,20 @@ public Task> GetAllForReference(string owner, string n throw new System.NotImplementedException(); } - public Task Request(long repositoryId, CheckSuiteTriggerRequest request) + public Task Request(long repositoryId, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); - return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), request, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), request, AcceptHeaders.ChecksApiPreview); } - public Task Request(string owner, string name, CheckSuiteTriggerRequest request) + public Task Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); - return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), request, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), request, AcceptHeaders.ChecksApiPreview); } public Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 241c448d68..926ed7c740 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -17,9 +17,9 @@ public interface ICheckSuitesClient Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); - Task Create(long repositoryId, NewCheckSuite newCheckSuite); - Task Create(string owner, string name, NewCheckSuite newCheckSuite); - Task Request(long repositoryId, CheckSuiteTriggerRequest request); - Task Request(string owner, string name, CheckSuiteTriggerRequest request); + Task Create(long repositoryId, NewCheckSuite newCheckSuite); + Task Create(string owner, string name, NewCheckSuite newCheckSuite); + Task Request(long repositoryId, CheckSuiteTriggerRequest request); + Task Request(string owner, string name, CheckSuiteTriggerRequest request); } } \ No newline at end of file From b71a37610659455b0a082a2d233b0fa414d3027f Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 8 May 2018 20:30:44 -0400 Subject: [PATCH 28/82] Skeleton reactive checks implementation --- .../Clients/ObservableCheckRunsClient.cs | 104 ++++++++++++++++++ .../Clients/ObservableCheckSuitesClient.cs | 94 ++++++++++++++++ .../Clients/ObservableChecksClient.cs | 15 +++ Octokit.Reactive/ObservableChecksClient.cs | 13 --- 4 files changed, 213 insertions(+), 13 deletions(-) create mode 100644 Octokit.Reactive/Clients/ObservableCheckRunsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableChecksClient.cs delete mode 100644 Octokit.Reactive/ObservableChecksClient.cs diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs new file mode 100644 index 0000000000..9dfabd14ff --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs @@ -0,0 +1,104 @@ +using System; + +namespace Octokit.Reactive +{ + public class ObservableCheckRunsClient : IObservableCheckRunsClient + { + readonly ICheckRunsClient _client; + + public ObservableCheckRunsClient(IGitHubClient gitHubClient) + { + _client = gitHubClient.Checks.Runs; + } + + public IObservable Create(long repositoryId, NewCheckRun newCheckRun) + { + throw new NotImplementedException(); + } + + public IObservable Create(string owner, string name, NewCheckRun newCheckRun) + { + throw new NotImplementedException(); + } + + public IObservable Get(long repositoryId, long checkRunId) + { + throw new NotImplementedException(); + } + + public IObservable Get(string owner, string name, long checkRunId) + { + throw new NotImplementedException(); + } + + public IObservable GetAllAnnotations(long repositoryId, long checkRunId) + { + throw new NotImplementedException(); + } + + public IObservable GetAllAnnotations(string owner, string name, long checkRunId) + { + throw new NotImplementedException(); + } + + public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) + { + throw new NotImplementedException(); + } + + public IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs new file mode 100644 index 0000000000..a52f045723 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -0,0 +1,94 @@ +using System; + +namespace Octokit.Reactive +{ + public class ObservableCheckSuitesClient : IObservableCheckSuitesClient + { + readonly ICheckSuitesClient _client; + + public ObservableCheckSuitesClient(IGitHubClient gitHubClient) + { + _client = gitHubClient.Checks.Suites; + } + + public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) + { + throw new NotImplementedException(); + } + + public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) + { + throw new NotImplementedException(); + } + + public IObservable Get(long repositoryId, long checkSuiteId) + { + throw new NotImplementedException(); + } + + public IObservable Get(string owner, string name, long checkSuiteId) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) + { + throw new NotImplementedException(); + } + + public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) + { + throw new NotImplementedException(); + } + + public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) + { + throw new NotImplementedException(); + } + + public IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + { + throw new NotImplementedException(); + } + + public IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableChecksClient.cs b/Octokit.Reactive/Clients/ObservableChecksClient.cs new file mode 100644 index 0000000000..4b19f9bfa7 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableChecksClient.cs @@ -0,0 +1,15 @@ +namespace Octokit.Reactive +{ + public class ObservableChecksClient : IObservableChecksClient + { + public ObservableChecksClient(IGitHubClient gitHubClient) + { + Runs = new ObservableCheckRunsClient(gitHubClient); + Suites = new ObservableCheckSuitesClient(gitHubClient); + } + + public IObservableCheckRunsClient Runs { get; private set; } + + public IObservableCheckSuitesClient Suites { get; private set; } + } +} \ No newline at end of file diff --git a/Octokit.Reactive/ObservableChecksClient.cs b/Octokit.Reactive/ObservableChecksClient.cs deleted file mode 100644 index 11743f0980..0000000000 --- a/Octokit.Reactive/ObservableChecksClient.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Octokit.Reactive -{ - internal class ObservableChecksClient : IObservableChecksClient - { - public ObservableChecksClient(IGitHubClient gitHubClient) - { - } - - public IObservableCheckRunsClient Runs => throw new System.NotImplementedException(); - - public IObservableCheckSuitesClient Suites => throw new System.NotImplementedException(); - } -} \ No newline at end of file From b75dced0b8d3d819d0051d0ac2342139fe5318d6 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 8 May 2018 20:48:59 -0400 Subject: [PATCH 29/82] Implement observable checks clients --- .../Clients/ObservableCheckRunsClient.cs | 82 ++++++++++++++++--- .../Clients/ObservableCheckSuitesClient.cs | 78 +++++++++++++++--- 2 files changed, 136 insertions(+), 24 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs index 9dfabd14ff..ceae9588b6 100644 --- a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs @@ -1,104 +1,162 @@ using System; +using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; namespace Octokit.Reactive { public class ObservableCheckRunsClient : IObservableCheckRunsClient { readonly ICheckRunsClient _client; + readonly IConnection _connection; public ObservableCheckRunsClient(IGitHubClient gitHubClient) { _client = gitHubClient.Checks.Runs; + _connection = gitHubClient.Connection; } public IObservable Create(long repositoryId, NewCheckRun newCheckRun) { - throw new NotImplementedException(); + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return _client.Create(repositoryId, newCheckRun).ToObservable(); } public IObservable Create(string owner, string name, NewCheckRun newCheckRun) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return _client.Create(owner, name, newCheckRun).ToObservable(); } public IObservable Get(long repositoryId, long checkRunId) { - throw new NotImplementedException(); + return _client.Get(repositoryId, checkRunId).ToObservable(); } public IObservable Get(string owner, string name, long checkRunId) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Get(owner, name, checkRunId).ToObservable(); } public IObservable GetAllAnnotations(long repositoryId, long checkRunId) { - throw new NotImplementedException(); + return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); } public IObservable GetAllAnnotations(string owner, string name, long checkRunId) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); } public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) { - throw new NotImplementedException(); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } public IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) { - throw new NotImplementedException(); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); } public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); } public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + Ensure.ArgumentNotNull(options, nameof(options)); + throw new NotImplementedException(); } public IObservable 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(); } public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + throw new NotImplementedException(); } public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + throw new NotImplementedException(); } public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + throw new NotImplementedException(); } public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + throw new NotImplementedException(); } public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) { - throw new NotImplementedException(); + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + + return _client.Update(repositoryId, checkRunId, checkRunUpdate).ToObservable(); } public IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + + return _client.Update(owner, name, checkRunId, checkRunUpdate).ToObservable(); } } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index a52f045723..d7766230d5 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -1,94 +1,148 @@ using System; +using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; namespace Octokit.Reactive { public class ObservableCheckSuitesClient : IObservableCheckSuitesClient { readonly ICheckSuitesClient _client; + readonly IConnection _connection; public ObservableCheckSuitesClient(IGitHubClient gitHubClient) { _client = gitHubClient.Checks.Suites; + _connection = gitHubClient.Connection; } public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) { - throw new NotImplementedException(); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(repositoryId, newCheckSuite).ToObservable(); } public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(owner, name, newCheckSuite).ToObservable(); } public IObservable Get(long repositoryId, long checkSuiteId) { - throw new NotImplementedException(); + return _client.Get(repositoryId, checkSuiteId).ToObservable(); } public IObservable Get(string owner, string name, long checkSuiteId) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Get(owner, name, checkSuiteId).ToObservable(); } public IObservable GetAllForReference(long repositoryId, string reference) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(repositoryId, reference, ApiOptions.None); } public IObservable GetAllForReference(string owner, string name, string reference) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(owner, name, reference, ApiOptions.None); } public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + + return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + + return GetAllForReference(owner, name, reference, request, ApiOptions.None); } public IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(options, nameof(options)); + throw new NotImplementedException(); } public IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(options, nameof(options)); + throw new NotImplementedException(); } public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); + throw new NotImplementedException(); } public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); + throw new NotImplementedException(); } public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) { - throw new NotImplementedException(); + return _client.Request(repositoryId, request).ToObservable(); } public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Request(owner, name, request).ToObservable(); } public IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) { - throw new NotImplementedException(); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return _client.UpdatePreferences(repositoryId, preferences).ToObservable(); } public IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) { - throw new NotImplementedException(); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return _client.UpdatePreferences(owner, name, preferences).ToObservable(); } } } \ No newline at end of file From 86c19a507c5f191f5c159027e78d748002cfc531 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 8 May 2018 20:55:16 -0400 Subject: [PATCH 30/82] Remove rogue tabs --- .../Clients/ObservableCheckRunsClient.cs | 312 +++++++++--------- .../Clients/ObservableCheckSuitesClient.cs | 282 ++++++++-------- .../Clients/ObservableChecksClient.cs | 10 +- 3 files changed, 302 insertions(+), 302 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs index ceae9588b6..345bf69253 100644 --- a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs @@ -4,159 +4,159 @@ namespace Octokit.Reactive { - public class ObservableCheckRunsClient : IObservableCheckRunsClient - { - readonly ICheckRunsClient _client; - readonly IConnection _connection; - - public ObservableCheckRunsClient(IGitHubClient gitHubClient) - { - _client = gitHubClient.Checks.Runs; - _connection = gitHubClient.Connection; - } - - public IObservable Create(long repositoryId, NewCheckRun newCheckRun) - { - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - - return _client.Create(repositoryId, newCheckRun).ToObservable(); - } - - public IObservable Create(string owner, string name, NewCheckRun newCheckRun) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - - return _client.Create(owner, name, newCheckRun).ToObservable(); - } - - public IObservable Get(long repositoryId, long checkRunId) - { - return _client.Get(repositoryId, checkRunId).ToObservable(); - } - - public IObservable Get(string owner, string name, long checkRunId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return _client.Get(owner, name, checkRunId).ToObservable(); - } - - public IObservable GetAllAnnotations(long repositoryId, long checkRunId) - { - return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); - } - - public IObservable GetAllAnnotations(string owner, string name, long checkRunId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); - } - - public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) - { - Ensure.ArgumentNotNull(options, nameof(options)); - - return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - - public IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(options, nameof(options)); - - return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - - public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); - } - - public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); - } - - public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - - public IObservable 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(); - } - - public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - throw new NotImplementedException(); - } - - public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) - { - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - - return _client.Update(repositoryId, checkRunId, checkRunUpdate).ToObservable(); - } - - public IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - - return _client.Update(owner, name, checkRunId, checkRunUpdate).ToObservable(); - } - } -} \ No newline at end of file + public class ObservableCheckRunsClient : IObservableCheckRunsClient + { + readonly ICheckRunsClient _client; + readonly IConnection _connection; + + public ObservableCheckRunsClient(IGitHubClient gitHubClient) + { + _client = gitHubClient.Checks.Runs; + _connection = gitHubClient.Connection; + } + + public IObservable Create(long repositoryId, NewCheckRun newCheckRun) + { + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return _client.Create(repositoryId, newCheckRun).ToObservable(); + } + + public IObservable Create(string owner, string name, NewCheckRun newCheckRun) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return _client.Create(owner, name, newCheckRun).ToObservable(); + } + + public IObservable Get(long repositoryId, long checkRunId) + { + return _client.Get(repositoryId, checkRunId).ToObservable(); + } + + public IObservable Get(string owner, string name, long checkRunId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Get(owner, name, checkRunId).ToObservable(); + } + + public IObservable GetAllAnnotations(long repositoryId, long checkRunId) + { + return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); + } + + public IObservable GetAllAnnotations(string owner, string name, long checkRunId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); + } + + public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + } + + public IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + } + + public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); + } + + public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); + } + + public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + { + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); + } + + public IObservable 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(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + + throw new NotImplementedException(); + } + + public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) + { + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + + return _client.Update(repositoryId, checkRunId, checkRunUpdate).ToObservable(); + } + + public IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + + return _client.Update(owner, name, checkRunId, checkRunUpdate).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index d7766230d5..1da7c67748 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -4,145 +4,145 @@ namespace Octokit.Reactive { - public class ObservableCheckSuitesClient : IObservableCheckSuitesClient - { - readonly ICheckSuitesClient _client; - readonly IConnection _connection; - - public ObservableCheckSuitesClient(IGitHubClient gitHubClient) - { - _client = gitHubClient.Checks.Suites; - _connection = gitHubClient.Connection; - } - - public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) - { - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - - return _client.Create(repositoryId, newCheckSuite).ToObservable(); - } - - public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - - return _client.Create(owner, name, newCheckSuite).ToObservable(); - } - - public IObservable Get(long repositoryId, long checkSuiteId) - { - return _client.Get(repositoryId, checkSuiteId).ToObservable(); - } - - public IObservable Get(string owner, string name, long checkSuiteId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return _client.Get(owner, name, checkSuiteId).ToObservable(); - } - - public IObservable GetAllForReference(long repositoryId, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - - return GetAllForReference(repositoryId, reference, ApiOptions.None); - } - - public IObservable GetAllForReference(string owner, string name, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - - return GetAllForReference(owner, name, reference, ApiOptions.None); - } - - public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(request, nameof(request)); - - return GetAllForReference(repositoryId, reference, request, ApiOptions.None); - } - - public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(request, nameof(request)); - - return GetAllForReference(owner, name, reference, request, ApiOptions.None); - } - - public IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(request, nameof(request)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(request, nameof(request)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - - public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) - { - return _client.Request(repositoryId, request).ToObservable(); - } - - public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return _client.Request(owner, name, request).ToObservable(); - } - - public IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) - { - Ensure.ArgumentNotNull(preferences, nameof(preferences)); - - return _client.UpdatePreferences(repositoryId, preferences).ToObservable(); - } - - public IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(preferences, nameof(preferences)); - - return _client.UpdatePreferences(owner, name, preferences).ToObservable(); - } - } + public class ObservableCheckSuitesClient : IObservableCheckSuitesClient + { + readonly ICheckSuitesClient _client; + readonly IConnection _connection; + + public ObservableCheckSuitesClient(IGitHubClient gitHubClient) + { + _client = gitHubClient.Checks.Suites; + _connection = gitHubClient.Connection; + } + + public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) + { + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(repositoryId, newCheckSuite).ToObservable(); + } + + public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(owner, name, newCheckSuite).ToObservable(); + } + + public IObservable Get(long repositoryId, long checkSuiteId) + { + return _client.Get(repositoryId, checkSuiteId).ToObservable(); + } + + public IObservable Get(string owner, string name, long checkSuiteId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Get(owner, name, checkSuiteId).ToObservable(); + } + + public IObservable GetAllForReference(long repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(repositoryId, reference, ApiOptions.None); + } + + public IObservable GetAllForReference(string owner, string name, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(owner, name, reference, ApiOptions.None); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + + return GetAllForReference(repositoryId, reference, request, ApiOptions.None); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + + return GetAllForReference(owner, name, reference, request, ApiOptions.None); + } + + public IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); + } + + public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); + } + + public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) + { + return _client.Request(repositoryId, request).ToObservable(); + } + + public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Request(owner, name, request).ToObservable(); + } + + public IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + { + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return _client.UpdatePreferences(repositoryId, preferences).ToObservable(); + } + + public IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return _client.UpdatePreferences(owner, name, preferences).ToObservable(); + } + } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableChecksClient.cs b/Octokit.Reactive/Clients/ObservableChecksClient.cs index 4b19f9bfa7..d840750fa0 100644 --- a/Octokit.Reactive/Clients/ObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/ObservableChecksClient.cs @@ -3,13 +3,13 @@ public class ObservableChecksClient : IObservableChecksClient { public ObservableChecksClient(IGitHubClient gitHubClient) - { - Runs = new ObservableCheckRunsClient(gitHubClient); - Suites = new ObservableCheckSuitesClient(gitHubClient); - } + { + Runs = new ObservableCheckRunsClient(gitHubClient); + Suites = new ObservableCheckSuitesClient(gitHubClient); + } public IObservableCheckRunsClient Runs { get; private set; } public IObservableCheckSuitesClient Suites { get; private set; } - } + } } \ No newline at end of file From 1002e4a97aa6ed2d073f38293e8a2359745a5796 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 9 May 2018 11:41:45 -0400 Subject: [PATCH 31/82] Add CheckSuiteEventPayload --- .../Response/ActivityPayloads/CheckSuiteEventPayload.cs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs diff --git a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs new file mode 100644 index 0000000000..d2475d4e48 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs @@ -0,0 +1,8 @@ +namespace Octokit +{ + public class CheckSuiteEventPayload : ActivityPayload + { + public string Action { get; protected set; } + public CheckSuite CheckSuite { get; protected set; } + } +} From 6176d067f52ba7a86ecae8d91da51339130e8b7b Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 9 May 2018 11:42:36 -0400 Subject: [PATCH 32/82] Add CheckRunEventPayload --- .../Response/ActivityPayloads/CheckRunEventPayload.cs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs diff --git a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs new file mode 100644 index 0000000000..9f0cd3b9d4 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs @@ -0,0 +1,8 @@ +namespace Octokit +{ + public class CheckRunEventPayload : ActivityPayload + { + public string Action { get; protected set; } + public CheckRun CheckRun { get; protected set; } + } +} From 03505c963853f8b617e9d5163515c21708cfda59 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 9 May 2018 11:43:51 -0400 Subject: [PATCH 33/82] Add DebuggerDisplay attributes to checks API payloads --- .../Models/Response/ActivityPayloads/CheckRunEventPayload.cs | 5 ++++- .../Response/ActivityPayloads/CheckSuiteEventPayload.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs index 9f0cd3b9d4..a3b76b1a45 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs @@ -1,5 +1,8 @@ -namespace Octokit +using System.Diagnostics; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunEventPayload : ActivityPayload { public string Action { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs index d2475d4e48..3a0d324d8a 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs @@ -1,5 +1,8 @@ -namespace Octokit +using System.Diagnostics; + +namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteEventPayload : ActivityPayload { public string Action { get; protected set; } From 7d9f6e78aecc78f1ddf90d1b0840d318178c201f Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 11 May 2018 10:02:37 -0400 Subject: [PATCH 34/82] Properly nullables check suite/run conclusion --- Octokit/Models/Response/CheckRun.cs | 4 ++-- Octokit/Models/Response/CheckSuite.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index a1e8622c8d..e64fa996c7 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -12,7 +12,7 @@ public CheckRun() { } - public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion conclusion, DateTimeOffset startedAt, DateTimeOffset completedAt, CheckRunOutput output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList pullRequests) + public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion? conclusion, DateTimeOffset startedAt, DateTimeOffset completedAt, CheckRunOutput output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList pullRequests) { Id = id; HeadSha = headSha; @@ -36,7 +36,7 @@ public CheckRun(long id, string headSha, string externalId, string url, string h public string Url { get; protected set; } public string HtmlUrl { get; protected set; } public StringEnum Status { get; protected set; } - public StringEnum Conclusion { get; protected set; } + public StringEnum? Conclusion { get; protected set; } public DateTimeOffset StartedAt { get; protected set; } public DateTimeOffset CompletedAt { get; protected set; } public CheckRunOutput Output { get; protected set; } diff --git a/Octokit/Models/Response/CheckSuite.cs b/Octokit/Models/Response/CheckSuite.cs index 9ee226b244..03efc0e2d2 100644 --- a/Octokit/Models/Response/CheckSuite.cs +++ b/Octokit/Models/Response/CheckSuite.cs @@ -11,7 +11,7 @@ public CheckSuite() { } - public CheckSuite(long id, string headBranch, string headSha, CheckStatus status, CheckConclusion conclusion, string url, string before, string after, IReadOnlyList pullRequests, GitHubApp app, Repository repository) + public CheckSuite(long id, string headBranch, string headSha, CheckStatus status, CheckConclusion? conclusion, string url, string before, string after, IReadOnlyList pullRequests, GitHubApp app, Repository repository) { Id = id; HeadBranch = headBranch; @@ -30,7 +30,7 @@ public CheckSuite(long id, string headBranch, string headSha, CheckStatus status public string HeadBranch { get; protected set; } public string HeadSha { get; protected set; } public StringEnum Status { get; protected set; } - public StringEnum Conclusion { get; protected set; } + public StringEnum? Conclusion { get; protected set; } public string Url { get; protected set; } public string Before { get; protected set; } public string After { get; protected set; } From afb682bcc824ebc142048018ef7f72a033be8b16 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 11 May 2018 10:18:41 -0400 Subject: [PATCH 35/82] Add CheckSuiteEventTests --- Octokit.Tests/Models/CheckSuiteEventTests.cs | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Octokit.Tests/Models/CheckSuiteEventTests.cs diff --git a/Octokit.Tests/Models/CheckSuiteEventTests.cs b/Octokit.Tests/Models/CheckSuiteEventTests.cs new file mode 100644 index 0000000000..cccfa91454 --- /dev/null +++ b/Octokit.Tests/Models/CheckSuiteEventTests.cs @@ -0,0 +1,23 @@ +using Octokit.Internal; +using Xunit; + +namespace Octokit.Tests.Models +{ + public class CheckSuiteEventTests + { + [Fact] + public void CanBeDeserialized() + { + const string json = "{\r\n \"action\": \"rerequested\",\r\n \"check_suite\": {\r\n \"id\": 276096,\r\n \"head_branch\": null,\r\n \"head_sha\": \"73955d02043135d48809add98052c2170522158f\",\r\n \"status\": \"queued\",\r\n \"conclusion\": null,\r\n \"url\": \"https://api.github.com/repos/tgstation/tgstation/check-suites/276096\",\r\n \"before\": null,\r\n \"after\": null,\r\n \"pull_requests\": [\r\n\r\n ],\r\n \"app\": {\r\n \"id\": 9880,\r\n \"owner\": {\r\n \"login\": \"Cyberboss\",\r\n \"id\": 8171642,\r\n \"avatar_url\": \"https://avatars3.githubusercontent.com/u/8171642?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/Cyberboss\",\r\n \"html_url\": \"https://github.com/Cyberboss\",\r\n \"followers_url\": \"https://api.github.com/users/Cyberboss/followers\",\r\n \"following_url\": \"https://api.github.com/users/Cyberboss/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/Cyberboss/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/Cyberboss/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/Cyberboss/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/Cyberboss/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/Cyberboss/repos\",\r\n \"events_url\": \"https://api.github.com/users/Cyberboss/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/Cyberboss/received_events\",\r\n \"type\": \"User\",\r\n \"site_admin\": false\r\n },\r\n \"name\": \"MapDiffBot\",\r\n \"description\": \"Creates diff images of BYOND .dmm maps\",\r\n \"external_url\": \"https://github.com/MapDiffBot/MapDiffBot\",\r\n \"html_url\": \"https://github.com/apps/mapdiffbot\",\r\n \"created_at\": 1520618356,\r\n \"updated_at\": 1521225691\r\n },\r\n \"created_at\": \"2018-05-11T05:42:21Z\",\r\n \"updated_at\": \"2018-05-11T13:45:34Z\",\r\n \"unique_check_runs_count\": 1,\r\n \"check_runs_url\": \"https://api.github.com/repos/tgstation/tgstation/check-suites/276096/check-runs\",\r\n \"head_commit\": {\r\n \"id\": \"73955d02043135d48809add98052c2170522158f\",\r\n \"tree_id\": \"ef367b2a31c69d095c45e1b357afb9c78c4b6631\",\r\n \"message\": \"Remove a duplicate pipe in MetaStation maint\",\r\n \"timestamp\": \"2018-05-07T22:36:13-07:00\",\r\n \"author\": {\r\n \"name\": \"Tad Hardesty\",\r\n \"email\": \"tad@platymuus.com\"\r\n },\r\n \"committer\": {\r\n \"name\": \"Tad Hardesty\",\r\n \"email\": \"tad@platymuus.com\"\r\n }\r\n }\r\n },\r\n \"repository\": {\r\n \"id\": 3234987,\r\n \"name\": \"tgstation\",\r\n \"full_name\": \"tgstation/tgstation\",\r\n \"owner\": {\r\n \"login\": \"tgstation\",\r\n \"id\": 1363778,\r\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/1363778?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/tgstation\",\r\n \"html_url\": \"https://github.com/tgstation\",\r\n \"followers_url\": \"https://api.github.com/users/tgstation/followers\",\r\n \"following_url\": \"https://api.github.com/users/tgstation/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/tgstation/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/tgstation/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/tgstation/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/tgstation/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/tgstation/repos\",\r\n \"events_url\": \"https://api.github.com/users/tgstation/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/tgstation/received_events\",\r\n \"type\": \"Organization\",\r\n \"site_admin\": false\r\n },\r\n \"private\": false,\r\n \"html_url\": \"https://github.com/tgstation/tgstation\",\r\n \"description\": \"the /tg/station branch of SS13\",\r\n \"fork\": false,\r\n \"url\": \"https://api.github.com/repos/tgstation/tgstation\",\r\n \"forks_url\": \"https://api.github.com/repos/tgstation/tgstation/forks\",\r\n \"keys_url\": \"https://api.github.com/repos/tgstation/tgstation/keys{/key_id}\",\r\n \"collaborators_url\": \"https://api.github.com/repos/tgstation/tgstation/collaborators{/collaborator}\",\r\n \"teams_url\": \"https://api.github.com/repos/tgstation/tgstation/teams\",\r\n \"hooks_url\": \"https://api.github.com/repos/tgstation/tgstation/hooks\",\r\n \"issue_events_url\": \"https://api.github.com/repos/tgstation/tgstation/issues/events{/number}\",\r\n \"events_url\": \"https://api.github.com/repos/tgstation/tgstation/events\",\r\n \"assignees_url\": \"https://api.github.com/repos/tgstation/tgstation/assignees{/user}\",\r\n \"branches_url\": \"https://api.github.com/repos/tgstation/tgstation/branches{/branch}\",\r\n \"tags_url\": \"https://api.github.com/repos/tgstation/tgstation/tags\",\r\n \"blobs_url\": \"https://api.github.com/repos/tgstation/tgstation/git/blobs{/sha}\",\r\n \"git_tags_url\": \"https://api.github.com/repos/tgstation/tgstation/git/tags{/sha}\",\r\n \"git_refs_url\": \"https://api.github.com/repos/tgstation/tgstation/git/refs{/sha}\",\r\n \"trees_url\": \"https://api.github.com/repos/tgstation/tgstation/git/trees{/sha}\",\r\n \"statuses_url\": \"https://api.github.com/repos/tgstation/tgstation/statuses/{sha}\",\r\n \"languages_url\": \"https://api.github.com/repos/tgstation/tgstation/languages\",\r\n \"stargazers_url\": \"https://api.github.com/repos/tgstation/tgstation/stargazers\",\r\n \"contributors_url\": \"https://api.github.com/repos/tgstation/tgstation/contributors\",\r\n \"subscribers_url\": \"https://api.github.com/repos/tgstation/tgstation/subscribers\",\r\n \"subscription_url\": \"https://api.github.com/repos/tgstation/tgstation/subscription\",\r\n \"commits_url\": \"https://api.github.com/repos/tgstation/tgstation/commits{/sha}\",\r\n \"git_commits_url\": \"https://api.github.com/repos/tgstation/tgstation/git/commits{/sha}\",\r\n \"comments_url\": \"https://api.github.com/repos/tgstation/tgstation/comments{/number}\",\r\n \"issue_comment_url\": \"https://api.github.com/repos/tgstation/tgstation/issues/comments{/number}\",\r\n \"contents_url\": \"https://api.github.com/repos/tgstation/tgstation/contents/{+path}\",\r\n \"compare_url\": \"https://api.github.com/repos/tgstation/tgstation/compare/{base}...{head}\",\r\n \"merges_url\": \"https://api.github.com/repos/tgstation/tgstation/merges\",\r\n \"archive_url\": \"https://api.github.com/repos/tgstation/tgstation/{archive_format}{/ref}\",\r\n \"downloads_url\": \"https://api.github.com/repos/tgstation/tgstation/downloads\",\r\n \"issues_url\": \"https://api.github.com/repos/tgstation/tgstation/issues{/number}\",\r\n \"pulls_url\": \"https://api.github.com/repos/tgstation/tgstation/pulls{/number}\",\r\n \"milestones_url\": \"https://api.github.com/repos/tgstation/tgstation/milestones{/number}\",\r\n \"notifications_url\": \"https://api.github.com/repos/tgstation/tgstation/notifications{?since,all,participating}\",\r\n \"labels_url\": \"https://api.github.com/repos/tgstation/tgstation/labels{/name}\",\r\n \"releases_url\": \"https://api.github.com/repos/tgstation/tgstation/releases{/id}\",\r\n \"deployments_url\": \"https://api.github.com/repos/tgstation/tgstation/deployments\",\r\n \"created_at\": \"2012-01-21T17:32:47Z\",\r\n \"updated_at\": \"2018-05-11T06:24:11Z\",\r\n \"pushed_at\": \"2018-05-11T12:11:58Z\",\r\n \"git_url\": \"git://github.com/tgstation/tgstation.git\",\r\n \"ssh_url\": \"git@github.com:tgstation/tgstation.git\",\r\n \"clone_url\": \"https://github.com/tgstation/tgstation.git\",\r\n \"svn_url\": \"https://github.com/tgstation/tgstation\",\r\n \"homepage\": \"https://www.tgstation13.org/\",\r\n \"size\": 1126165,\r\n \"stargazers_count\": 515,\r\n \"watchers_count\": 515,\r\n \"language\": \"DM\",\r\n \"has_issues\": true,\r\n \"has_projects\": true,\r\n \"has_downloads\": true,\r\n \"has_wiki\": true,\r\n \"has_pages\": false,\r\n \"forks_count\": 1783,\r\n \"mirror_url\": null,\r\n \"archived\": false,\r\n \"open_issues_count\": 1211,\r\n \"license\": {\r\n \"key\": \"agpl-3.0\",\r\n \"name\": \"GNU Affero General Public License v3.0\",\r\n \"spdx_id\": \"AGPL-3.0\",\r\n \"url\": \"https://api.github.com/licenses/agpl-3.0\"\r\n },\r\n \"forks\": 1783,\r\n \"open_issues\": 1211,\r\n \"watchers\": 515,\r\n \"default_branch\": \"master\"\r\n },\r\n \"organization\": {\r\n \"login\": \"tgstation\",\r\n \"id\": 1363778,\r\n \"url\": \"https://api.github.com/orgs/tgstation\",\r\n \"repos_url\": \"https://api.github.com/orgs/tgstation/repos\",\r\n \"events_url\": \"https://api.github.com/orgs/tgstation/events\",\r\n \"hooks_url\": \"https://api.github.com/orgs/tgstation/hooks\",\r\n \"issues_url\": \"https://api.github.com/orgs/tgstation/issues\",\r\n \"members_url\": \"https://api.github.com/orgs/tgstation/members{/member}\",\r\n \"public_members_url\": \"https://api.github.com/orgs/tgstation/public_members{/member}\",\r\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/1363778?v=4\",\r\n \"description\": \"\"\r\n },\r\n \"sender\": {\r\n \"login\": \"Cyberboss\",\r\n \"id\": 8171642,\r\n \"avatar_url\": \"https://avatars3.githubusercontent.com/u/8171642?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/Cyberboss\",\r\n \"html_url\": \"https://github.com/Cyberboss\",\r\n \"followers_url\": \"https://api.github.com/users/Cyberboss/followers\",\r\n \"following_url\": \"https://api.github.com/users/Cyberboss/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/Cyberboss/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/Cyberboss/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/Cyberboss/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/Cyberboss/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/Cyberboss/repos\",\r\n \"events_url\": \"https://api.github.com/users/Cyberboss/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/Cyberboss/received_events\",\r\n \"type\": \"User\",\r\n \"site_admin\": false\r\n },\r\n \"installation\": {\r\n \"id\": 103621\r\n }\r\n}"; + + + var serializer = new SimpleJsonSerializer(); + + var payload = serializer.Deserialize(json); + + Assert.Equal("rerequested", payload.Action); + Assert.Equal("73955d02043135d48809add98052c2170522158f", payload.CheckSuite.HeadSha); + Assert.Equal(CheckStatus.Queued, payload.CheckSuite.Status.Value); + } + } +} From b90d0567d1ee2e40f0d1ad93579387a61e9da9dd Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 11 May 2018 10:20:46 -0400 Subject: [PATCH 36/82] Fix checks client accessor naming issues --- Octokit.Reactive/Clients/ObservableCheckRunsClient.cs | 2 +- Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs | 2 +- Octokit/Clients/ChecksClient.cs | 8 ++++---- Octokit/Clients/IChecksClient.cs | 4 ++-- Octokit/GitHubClient.cs | 4 ++-- Octokit/IGitHubClient.cs | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs index 345bf69253..1d9cc6b393 100644 --- a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs @@ -11,7 +11,7 @@ public class ObservableCheckRunsClient : IObservableCheckRunsClient public ObservableCheckRunsClient(IGitHubClient gitHubClient) { - _client = gitHubClient.Checks.Runs; + _client = gitHubClient.Check.Run; _connection = gitHubClient.Connection; } diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 1da7c67748..3e0b987cd8 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -11,7 +11,7 @@ public class ObservableCheckSuitesClient : IObservableCheckSuitesClient public ObservableCheckSuitesClient(IGitHubClient gitHubClient) { - _client = gitHubClient.Checks.Suites; + _client = gitHubClient.Check.Suite; _connection = gitHubClient.Connection; } diff --git a/Octokit/Clients/ChecksClient.cs b/Octokit/Clients/ChecksClient.cs index edbbcd1f3f..1587c17a6f 100644 --- a/Octokit/Clients/ChecksClient.cs +++ b/Octokit/Clients/ChecksClient.cs @@ -2,13 +2,13 @@ { public class ChecksClient : IChecksClient { - public ICheckRunsClient Runs { get; private set; } - public ICheckSuitesClient Suites { get; private set; } + public ICheckRunsClient Run { get; private set; } + public ICheckSuitesClient Suite { get; private set; } public ChecksClient(ApiConnection apiConnection) { - Runs = new CheckRunsClient(apiConnection); - Suites = new CheckSuitesClient(apiConnection); + Run = new CheckRunsClient(apiConnection); + Suite = new CheckSuitesClient(apiConnection); } } } \ No newline at end of file diff --git a/Octokit/Clients/IChecksClient.cs b/Octokit/Clients/IChecksClient.cs index 83b0f2983f..113678204a 100644 --- a/Octokit/Clients/IChecksClient.cs +++ b/Octokit/Clients/IChecksClient.cs @@ -2,8 +2,8 @@ { public interface IChecksClient { - ICheckRunsClient Runs { get; } + ICheckRunsClient Run { get; } - ICheckSuitesClient Suites { get; } + ICheckSuitesClient Suite { get; } } } diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index a329793907..c830978c21 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -110,7 +110,7 @@ public GitHubClient(IConnection connection) Search = new SearchClient(apiConnection); User = new UsersClient(apiConnection); Reaction = new ReactionsClient(apiConnection); - Checks = new ChecksClient(apiConnection); + Check = new ChecksClient(apiConnection); } /// @@ -303,7 +303,7 @@ public Uri BaseAddress /// /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/ /// - public IChecksClient Checks { get; private set; } + public IChecksClient Check { get; private set; } static Uri FixUpBaseUri(Uri uri) { diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 0eff3d5c1c..032536b634 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -156,6 +156,6 @@ public interface IGitHubClient : IApiInfoProvider /// /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/ /// - IChecksClient Checks { get; } + IChecksClient Check { get; } } } From febec7209e2d61ea35b82349f4e8d5113055f457 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 11 May 2018 10:52:12 -0400 Subject: [PATCH 37/82] Add missing Text field to CheckRunOutput --- Octokit/Models/Common/CheckRunOutput.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Common/CheckRunOutput.cs b/Octokit/Models/Common/CheckRunOutput.cs index 6d907aa884..84003394a3 100644 --- a/Octokit/Models/Common/CheckRunOutput.cs +++ b/Octokit/Models/Common/CheckRunOutput.cs @@ -11,16 +11,18 @@ public CheckRunOutput() { } - public CheckRunOutput(string title, string summary, IReadOnlyList annotations, IReadOnlyList images) + public CheckRunOutput(string title, string summary, string text, IReadOnlyList annotations, IReadOnlyList images) { Title = title; Summary = summary; + Text = text; Annotations = annotations; Images = images; } public string Title { get; protected set; } public string Summary { get; protected set; } + public string Text { get; protected set; } public IReadOnlyList Annotations { get; protected set; } public IReadOnlyList Images { get; protected set; } From 029580704998ebfe84f86795f0a8aa7b1e17fa13 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 11 May 2018 15:10:33 -0400 Subject: [PATCH 38/82] Marks CheckRunUpdate's conclusion as nullable --- Octokit/Models/Request/CheckRunUpdate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Request/CheckRunUpdate.cs b/Octokit/Models/Request/CheckRunUpdate.cs index 9599618d17..a339046dcf 100644 --- a/Octokit/Models/Request/CheckRunUpdate.cs +++ b/Octokit/Models/Request/CheckRunUpdate.cs @@ -13,7 +13,7 @@ public class CheckRunUpdate public string ExternalId { get; set; } public CheckStatus? Status { get; set; } public DateTimeOffset StartedAt { get; set; } - public CheckConclusion Conclusion { get; set; } + public CheckConclusion? Conclusion { get; set; } public DateTimeOffset CompletedAt { get; set; } public CheckRunOutput Output { get; set; } From 9a3790386159ef3a6cd88a948a3a2a23f905a757 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 11 May 2018 15:15:17 -0400 Subject: [PATCH 39/82] Fix reactive checks client naming --- Octokit.Reactive/Clients/IObservableChecksClient.cs | 4 ++-- Octokit.Reactive/Clients/ObservableChecksClient.cs | 8 ++++---- Octokit.Reactive/IObservableGitHubClient.cs | 2 +- Octokit.Reactive/ObservableGitHubClient.cs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableChecksClient.cs b/Octokit.Reactive/Clients/IObservableChecksClient.cs index 3b90549838..b614861e85 100644 --- a/Octokit.Reactive/Clients/IObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/IObservableChecksClient.cs @@ -2,7 +2,7 @@ { public interface IObservableChecksClient { - IObservableCheckRunsClient Runs { get; } - IObservableCheckSuitesClient Suites { get; } + IObservableCheckRunsClient Run { get; } + IObservableCheckSuitesClient Suite { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableChecksClient.cs b/Octokit.Reactive/Clients/ObservableChecksClient.cs index d840750fa0..b73d6ddf8b 100644 --- a/Octokit.Reactive/Clients/ObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/ObservableChecksClient.cs @@ -4,12 +4,12 @@ public class ObservableChecksClient : IObservableChecksClient { public ObservableChecksClient(IGitHubClient gitHubClient) { - Runs = new ObservableCheckRunsClient(gitHubClient); - Suites = new ObservableCheckSuitesClient(gitHubClient); + Run = new ObservableCheckRunsClient(gitHubClient); + Suite = new ObservableCheckSuitesClient(gitHubClient); } - public IObservableCheckRunsClient Runs { get; private set; } + public IObservableCheckRunsClient Run { get; private set; } - public IObservableCheckSuitesClient Suites { get; private set; } + public IObservableCheckSuitesClient Suite { get; private set; } } } \ No newline at end of file diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 1636c3d772..bacdc13d72 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -32,6 +32,6 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableEnterpriseClient Enterprise { get; } IObservableMigrationClient Migration { get; } IObservableReactionsClient Reaction { get; } - IObservableChecksClient Checks { get; } + IObservableChecksClient Check { get; } } } \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 99250c6e1c..f891ec847d 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -48,7 +48,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Enterprise = new ObservableEnterpriseClient(gitHubClient); Migration = new ObservableMigrationClient(gitHubClient); Reaction = new ObservableReactionsClient(gitHubClient); - Checks = new ObservableChecksClient(gitHubClient); + Check = new ObservableChecksClient(gitHubClient); } public IConnection Connection @@ -86,7 +86,7 @@ public void SetRequestTimeout(TimeSpan timeout) public IObservableEnterpriseClient Enterprise { get; private set; } public IObservableMigrationClient Migration { get; private set; } public IObservableReactionsClient Reaction { get; private set; } - public IObservableChecksClient Checks { get; private set; } + public IObservableChecksClient Check { get; private set; } /// /// Gets the latest API Info - this will be null if no API calls have been made From 57d8848343f473c8d7795830f64e6cce86cbc5c9 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 14 May 2018 10:06:50 -0400 Subject: [PATCH 40/82] Today I learned DateTimeOffset is a struct Makes CheckRunUpdate's DateTimeOffsets nullable --- Octokit/Models/Request/CheckRunUpdate.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Request/CheckRunUpdate.cs b/Octokit/Models/Request/CheckRunUpdate.cs index a339046dcf..4d354266aa 100644 --- a/Octokit/Models/Request/CheckRunUpdate.cs +++ b/Octokit/Models/Request/CheckRunUpdate.cs @@ -12,9 +12,9 @@ public class CheckRunUpdate public string DetailsUrl { get; set; } public string ExternalId { get; set; } public CheckStatus? Status { get; set; } - public DateTimeOffset StartedAt { get; set; } + public DateTimeOffset? StartedAt { get; set; } public CheckConclusion? Conclusion { get; set; } - public DateTimeOffset CompletedAt { get; set; } + public DateTimeOffset? CompletedAt { get; set; } public CheckRunOutput Output { get; set; } internal virtual string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Name: {0}, Conclusion: {1}", Name, Conclusion); From a489ee45e55fef64f6b1037594fec3b48925fbe4 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 14 May 2018 10:24:21 -0400 Subject: [PATCH 41/82] Modify check clients to put slug version before repo id version --- .../Clients/IObservableCheckRunsClient.cs | 18 +++--- .../Clients/IObservableCheckSuitesClient.cs | 16 ++--- .../Clients/ObservableCheckRunsClient.cs | 54 ++++++++--------- .../Clients/ObservableCheckSuitesClient.cs | 56 +++++++++--------- Octokit/Clients/CheckRunsClient.cs | 59 ++++++++++--------- Octokit/Clients/CheckSuitesClient.cs | 53 +++++++++-------- Octokit/Clients/ICheckRunsClient.cs | 18 +++--- Octokit/Clients/ICheckSuitesClient.cs | 16 ++--- 8 files changed, 146 insertions(+), 144 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs index d012a767db..4cce38ca27 100644 --- a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs @@ -4,23 +4,23 @@ namespace Octokit.Reactive { public interface IObservableCheckRunsClient { - IObservable Create(long repositoryId, NewCheckRun newCheckRun); IObservable Create(string owner, string name, NewCheckRun newCheckRun); - IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); + IObservable Create(long repositoryId, NewCheckRun newCheckRun); IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); - IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); + IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); - IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); + IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); - IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); + IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); - IObservable Get(long repositoryId, long checkRunId); + IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); IObservable Get(string owner, string name, long checkRunId); - IObservable GetAllAnnotations(long repositoryId, long checkRunId); + IObservable Get(long repositoryId, long checkRunId); IObservable GetAllAnnotations(string owner, string name, long checkRunId); - IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); + IObservable GetAllAnnotations(long repositoryId, long checkRunId); IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); + IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs index 60d8316c97..b76050a7b9 100644 --- a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -4,21 +4,21 @@ namespace Octokit.Reactive { public interface IObservableCheckSuitesClient { - IObservable Get(long repositoryId, long checkSuiteId); IObservable Get(string owner, string name, long checkSuiteId); - IObservable GetAllForReference(long repositoryId, string reference); + IObservable Get(long repositoryId, long checkSuiteId); IObservable GetAllForReference(string owner, string name, string reference); - IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); + IObservable GetAllForReference(long repositoryId, string reference); IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); - IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options); + IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options); - IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options); IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); - IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); + IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); - IObservable Create(long repositoryId, NewCheckSuite newCheckSuite); + IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); IObservable Create(string owner, string name, NewCheckSuite newCheckSuite); - IObservable Request(long repositoryId, CheckSuiteTriggerRequest request); + IObservable Create(long repositoryId, NewCheckSuite newCheckSuite); IObservable Request(string owner, string name, CheckSuiteTriggerRequest request); + IObservable Request(long repositoryId, CheckSuiteTriggerRequest request); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs index 1d9cc6b393..a8e79c805a 100644 --- a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs @@ -15,13 +15,6 @@ public ObservableCheckRunsClient(IGitHubClient gitHubClient) _connection = gitHubClient.Connection; } - public IObservable Create(long repositoryId, NewCheckRun newCheckRun) - { - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - - return _client.Create(repositoryId, newCheckRun).ToObservable(); - } - public IObservable Create(string owner, string name, NewCheckRun newCheckRun) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -31,9 +24,11 @@ public IObservable Create(string owner, string name, NewCheckRun newCh return _client.Create(owner, name, newCheckRun).ToObservable(); } - public IObservable Get(long repositoryId, long checkRunId) + public IObservable Create(long repositoryId, NewCheckRun newCheckRun) { - return _client.Get(repositoryId, checkRunId).ToObservable(); + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return _client.Create(repositoryId, newCheckRun).ToObservable(); } public IObservable Get(string owner, string name, long checkRunId) @@ -44,9 +39,9 @@ public IObservable Get(string owner, string name, long checkRunId) return _client.Get(owner, name, checkRunId).ToObservable(); } - public IObservable GetAllAnnotations(long repositoryId, long checkRunId) + public IObservable Get(long repositoryId, long checkRunId) { - return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); + return _client.Get(repositoryId, checkRunId).ToObservable(); } public IObservable GetAllAnnotations(string owner, string name, long checkRunId) @@ -57,11 +52,9 @@ public IObservable GetAllAnnotations(string owner, string na return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); } - public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) + public IObservable GetAllAnnotations(long repositoryId, long checkRunId) { - Ensure.ArgumentNotNull(options, nameof(options)); - - return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); } public IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) @@ -73,11 +66,11 @@ public IObservable GetAllAnnotations(string owner, string na return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } - public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) + public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) { - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + Ensure.ArgumentNotNull(options, nameof(options)); - return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); + return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) @@ -89,12 +82,11 @@ public IObservable GetAllForCheckSuite(string owner, string name, long return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); } - public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - Ensure.ArgumentNotNull(options, nameof(options)); - throw new NotImplementedException(); + return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); } public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) @@ -107,10 +99,10 @@ public IObservable GetAllForCheckSuite(string owner, string name, long throw new NotImplementedException(); } - public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) + public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + Ensure.ArgumentNotNull(options, nameof(options)); throw new NotImplementedException(); } @@ -125,7 +117,7 @@ public IObservable GetAllForReference(string owner, string name, strin throw new NotImplementedException(); } - public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); @@ -143,11 +135,12 @@ public IObservable GetAllForReference(string owner, string name, strin throw new NotImplementedException(); } - public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) + public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - return _client.Update(repositoryId, checkRunId, checkRunUpdate).ToObservable(); + throw new NotImplementedException(); } public IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) @@ -158,5 +151,12 @@ public IObservable Update(string owner, string name, long checkRunId, return _client.Update(owner, name, checkRunId, checkRunUpdate).ToObservable(); } + + public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) + { + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); + + return _client.Update(repositoryId, checkRunId, checkRunUpdate).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 3e0b987cd8..67b3c8e281 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -15,25 +15,20 @@ public ObservableCheckSuitesClient(IGitHubClient gitHubClient) _connection = gitHubClient.Connection; } - public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) - { - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - - return _client.Create(repositoryId, newCheckSuite).ToObservable(); - } - public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - + return _client.Create(owner, name, newCheckSuite).ToObservable(); } - public IObservable Get(long repositoryId, long checkSuiteId) + public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) { - return _client.Get(repositoryId, checkSuiteId).ToObservable(); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(repositoryId, newCheckSuite).ToObservable(); } public IObservable Get(string owner, string name, long checkSuiteId) @@ -44,11 +39,9 @@ public IObservable Get(string owner, string name, long checkSuiteId) return _client.Get(owner, name, checkSuiteId).ToObservable(); } - public IObservable GetAllForReference(long repositoryId, string reference) + public IObservable Get(long repositoryId, long checkSuiteId) { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - - return GetAllForReference(repositoryId, reference, ApiOptions.None); + return _client.Get(repositoryId, checkSuiteId).ToObservable(); } public IObservable GetAllForReference(string owner, string name, string reference) @@ -60,12 +53,11 @@ public IObservable GetAllForReference(string owner, string name, str return GetAllForReference(owner, name, reference, ApiOptions.None); } - public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) + public IObservable GetAllForReference(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(request, nameof(request)); - return GetAllForReference(repositoryId, reference, request, ApiOptions.None); + return GetAllForReference(repositoryId, reference, ApiOptions.None); } public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) @@ -78,12 +70,12 @@ public IObservable GetAllForReference(string owner, string name, str return GetAllForReference(owner, name, reference, request, ApiOptions.None); } - public IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options) + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(options, nameof(options)); + Ensure.ArgumentNotNull(request, nameof(request)); - throw new NotImplementedException(); + return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } public IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options) @@ -96,10 +88,9 @@ public IObservable GetAllForReference(string owner, string name, str throw new NotImplementedException(); } - public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) + public IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); throw new NotImplementedException(); @@ -116,9 +107,13 @@ public IObservable GetAllForReference(string owner, string name, str throw new NotImplementedException(); } - public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { - return _client.Request(repositoryId, request).ToObservable(); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); + + throw new NotImplementedException(); } public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) @@ -129,11 +124,9 @@ public IObservable Request(string owner, string name, CheckSuiteTrig return _client.Request(owner, name, request).ToObservable(); } - public IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) { - Ensure.ArgumentNotNull(preferences, nameof(preferences)); - - return _client.UpdatePreferences(repositoryId, preferences).ToObservable(); + return _client.Request(repositoryId, request).ToObservable(); } public IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) @@ -144,5 +137,12 @@ public IObservable UpdatePreferences(string owner, string return _client.UpdatePreferences(owner, name, preferences).ToObservable(); } + + public IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + { + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return _client.UpdatePreferences(repositoryId, preferences).ToObservable(); + } } } \ No newline at end of file diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index 7175f4d702..c4f5894fc5 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -10,6 +10,15 @@ public CheckRunsClient(IApiConnection apiConnection) : base(apiConnection) { } + public Task Create(string owner, string name, NewCheckRun newCheckRun) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); + + return ApiConnection.Post(ApiUrls.CheckRuns(owner, name), newCheckRun, AcceptHeaders.ChecksApiPreview); + } + public Task Create(long repositoryId, NewCheckRun newCheckRun) { Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); @@ -17,13 +26,12 @@ public Task Create(long repositoryId, NewCheckRun newCheckRun) return ApiConnection.Post(ApiUrls.CheckRuns(repositoryId), newCheckRun, AcceptHeaders.ChecksApiPreview); } - public Task Create(string owner, string name, NewCheckRun newCheckRun) + public Task Get(string owner, string name, long checkRunId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - return ApiConnection.Post(ApiUrls.CheckRuns(owner, name), newCheckRun, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Get(ApiUrls.CheckRun(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview); } public Task Get(long repositoryId, long checkRunId) @@ -31,12 +39,14 @@ public Task Get(long repositoryId, long checkRunId) return ApiConnection.Get(ApiUrls.CheckRun(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview); } - public Task Get(string owner, string name, long checkRunId) + public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - return ApiConnection.Get(ApiUrls.CheckRun(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview); + return GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None); } public Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) @@ -47,14 +57,13 @@ public Task> GetAllForReference(long repositoryId, strin return GetAllForReference(repositoryId, reference, checkRunRequest, ApiOptions.None); } - public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) + public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - return GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None); + return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); } public Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) @@ -64,13 +73,15 @@ public Task> GetAllForCheckSuite(long repositoryId, long return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); } - public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) + public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); + Ensure.ArgumentNotNull(options, nameof(options)); - return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); + throw new NotImplementedException(); } public Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) @@ -82,11 +93,10 @@ public Task> GetAllForReference(long repositoryId, strin throw new NotImplementedException(); } - public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) + public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); @@ -101,14 +111,13 @@ public Task> GetAllForCheckSuite(long repositoryId, long throw new NotImplementedException(); } - public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) + public Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - Ensure.ArgumentNotNull(options, nameof(options)); + Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - throw new NotImplementedException(); + return ApiConnection.Patch(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); } public Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) @@ -118,38 +127,30 @@ public Task Update(long repositoryId, long checkRunId, CheckRunUpdate return ApiConnection.Patch(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); } - public Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) + public Task> GetAllAnnotations(string owner, string name, long checkRunId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - return ApiConnection.Patch(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); + return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); } + public Task> GetAllAnnotations(long repositoryId, long checkRunId) { return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); } - public Task> GetAllAnnotations(string owner, string name, long checkRunId) + public Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); + return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } public Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) { return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } - - public Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } } } diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 8b35dacd1f..7c53ab38bf 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -9,6 +9,15 @@ public CheckSuitesClient(ApiConnection apiConnection) : base(apiConnection) { } + public Task Create(string owner, string name, NewCheckSuite newCheckSuite) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); + } + public Task Create(long repositoryId, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); @@ -16,13 +25,12 @@ public Task Create(long repositoryId, NewCheckSuite newCheckSuite) return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); } - public Task Create(string owner, string name, NewCheckSuite newCheckSuite) + public Task Get(string owner, string name, long checkSuiteId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Get(ApiUrls.CheckSuite(owner, name, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); } public Task Get(long repositoryId, long checkSuiteId) @@ -30,12 +38,13 @@ public Task Get(long repositoryId, long checkSuiteId) return ApiConnection.Get(ApiUrls.CheckSuite(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); } - public Task Get(string owner, string name, long checkSuiteId) + public Task> GetAllForReference(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - return ApiConnection.Get(ApiUrls.CheckSuite(owner, name, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); + return GetAllForReference(owner, name, reference, ApiOptions.None); } public Task> GetAllForReference(long repositoryId, string reference) @@ -45,13 +54,14 @@ public Task> GetAllForReference(long repositoryId, str return GetAllForReference(repositoryId, reference, ApiOptions.None); } - public Task> GetAllForReference(string owner, string name, string reference) + public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + Ensure.ArgumentNotNull(request, nameof(request)); - return GetAllForReference(owner, name, reference, ApiOptions.None); + return GetAllForReference(owner, name, reference, request, ApiOptions.None); } public Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) @@ -61,14 +71,14 @@ public Task> GetAllForReference(long repositoryId, str return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } - public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) + 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)); - return GetAllForReference(owner, name, reference, request, ApiOptions.None); + throw new System.NotImplementedException(); } public Task> GetAllForReference(long repositoryId, string reference, ApiOptions options) @@ -79,12 +89,13 @@ public Task> GetAllForReference(long repositoryId, str throw new System.NotImplementedException(); } - public Task> GetAllForReference(string owner, string name, string reference, ApiOptions request) + public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(options, nameof(options)); throw new System.NotImplementedException(); } @@ -98,17 +109,16 @@ public Task> GetAllForReference(long repositoryId, str throw new System.NotImplementedException(); } - public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) + public Task Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); - Ensure.ArgumentNotNull(options, nameof(options)); - throw new System.NotImplementedException(); + return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), request, AcceptHeaders.ChecksApiPreview); } + public Task Request(long repositoryId, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); @@ -116,13 +126,13 @@ public Task Request(long repositoryId, CheckSuiteTriggerRequest requ return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), request, AcceptHeaders.ChecksApiPreview); } - public Task Request(string owner, string name, CheckSuiteTriggerRequest request) + public Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(request, nameof(request)); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); - return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), request, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); } public Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) @@ -131,14 +141,5 @@ public Task UpdatePreferences(long repositoryId, AutoTrig return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview); } - - public Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(preferences, nameof(preferences)); - - return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); - } } } \ No newline at end of file diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs index 572e7c9128..d381c69f44 100644 --- a/Octokit/Clients/ICheckRunsClient.cs +++ b/Octokit/Clients/ICheckRunsClient.cs @@ -5,23 +5,23 @@ namespace Octokit { public interface ICheckRunsClient { - Task Create(long repositoryId, NewCheckRun newCheckRun); Task Create(string owner, string name, NewCheckRun newCheckRun); - Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); + Task Create(long repositoryId, NewCheckRun newCheckRun); Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); - Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); + Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); - Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); + Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); - Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); + Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); + Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); - Task Get(long repositoryId, long checkRunId); + Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); Task Get(string owner, string name, long checkRunId); - Task> GetAllAnnotations(long repositoryId, long checkRunId); + Task Get(long repositoryId, long checkRunId); Task> GetAllAnnotations(string owner, string name, long checkRunId); - Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); + Task> GetAllAnnotations(long repositoryId, long checkRunId); Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); + Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); } } diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 926ed7c740..b425218ef1 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -5,21 +5,21 @@ namespace Octokit { public interface ICheckSuitesClient { - Task Get(long repositoryId, long checkSuiteId); Task Get(string owner, string name, long checkSuiteId); - Task> GetAllForReference(long repositoryId, string reference); + Task Get(long repositoryId, long checkSuiteId); Task> GetAllForReference(string owner, string name, string reference); - Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); + Task> GetAllForReference(long repositoryId, string reference); Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); - Task> GetAllForReference(long repositoryId, string reference, ApiOptions options); + Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); Task> GetAllForReference(string owner, string name, string reference, ApiOptions options); - Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + Task> GetAllForReference(long repositoryId, string reference, ApiOptions options); Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); - Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); + Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); - Task Create(long repositoryId, NewCheckSuite newCheckSuite); + Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); Task Create(string owner, string name, NewCheckSuite newCheckSuite); - Task Request(long repositoryId, CheckSuiteTriggerRequest request); + Task Create(long repositoryId, NewCheckSuite newCheckSuite); Task Request(string owner, string name, CheckSuiteTriggerRequest request); + Task Request(long repositoryId, CheckSuiteTriggerRequest request); } } \ No newline at end of file From 42720f86da34295b56f6cdcc7e0d566f1e23311e Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 14 May 2018 12:02:19 -0400 Subject: [PATCH 42/82] Add nullable to CheckRun.CompletedAt --- Octokit/Models/Response/CheckRun.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index e64fa996c7..7038e6fb26 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -12,7 +12,7 @@ public CheckRun() { } - public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion? conclusion, DateTimeOffset startedAt, DateTimeOffset completedAt, CheckRunOutput output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList pullRequests) + public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion? conclusion, DateTimeOffset startedAt, DateTimeOffset? completedAt, CheckRunOutput output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList pullRequests) { Id = id; HeadSha = headSha; @@ -38,7 +38,7 @@ public CheckRun(long id, string headSha, string externalId, string url, string h public StringEnum Status { get; protected set; } public StringEnum? Conclusion { get; protected set; } public DateTimeOffset StartedAt { get; protected set; } - public DateTimeOffset CompletedAt { get; protected set; } + public DateTimeOffset? CompletedAt { get; protected set; } public CheckRunOutput Output { get; protected set; } public string Name { get; protected set; } public CheckSuite CheckSuite { get; protected set; } From 199489c69928bc3a7781cb0932149cfdaadcbc5f Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 15 May 2018 10:33:51 -0400 Subject: [PATCH 43/82] Implement parameterless ICheckRunsClient.GetAllForReference and GetAllForCheckSuite --- Octokit/Clients/CheckRunsClient.cs | 29 +++++++++++++++++++++++++++++ Octokit/Clients/ICheckRunsClient.cs | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index c4f5894fc5..b5142b4feb 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -39,6 +39,35 @@ public Task Get(long repositoryId, long checkRunId) return ApiConnection.Get(ApiUrls.CheckRun(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview); } + public Task> GetAllForReference(long repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(repositoryId, reference, new CheckRunRequest(), ApiOptions.None); + } + + public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return GetAllForCheckSuite(owner, name, checkSuiteId, new CheckRunRequest(), ApiOptions.None); + } + + public Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId) + { + return GetAllForCheckSuite(repositoryId, checkSuiteId, new CheckRunRequest(), ApiOptions.None); + } + + public Task> GetAllForReference(string owner, string name, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(owner, name, reference, new CheckRunRequest(), ApiOptions.None); + } + public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs index d381c69f44..e9a1eb2759 100644 --- a/Octokit/Clients/ICheckRunsClient.cs +++ b/Octokit/Clients/ICheckRunsClient.cs @@ -9,6 +9,10 @@ public interface ICheckRunsClient Task Create(long repositoryId, NewCheckRun newCheckRun); Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); + Task> GetAllForReference(string owner, string name, string reference); + Task> GetAllForReference(long repositoryId, string reference); + Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId); + Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId); Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); From 594cfba9be3ae87ecafb3eb6d524adb8c038dae3 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 15 May 2018 10:39:56 -0400 Subject: [PATCH 44/82] Add missing RequestParameters base to CheckSuiteRequest --- Octokit/Models/Request/CheckSuiteRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Request/CheckSuiteRequest.cs b/Octokit/Models/Request/CheckSuiteRequest.cs index 358048273b..52c31fc54b 100644 --- a/Octokit/Models/Request/CheckSuiteRequest.cs +++ b/Octokit/Models/Request/CheckSuiteRequest.cs @@ -4,7 +4,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuiteRequest + public class CheckSuiteRequest : RequestParameters { public long AppId { get; set; } public string CheckName { get; set; } From a1d3c7a7d13a6856ee647c6aa2bf02ffb2fe97d6 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 15 May 2018 10:40:17 -0400 Subject: [PATCH 45/82] Implement checks API GetAll methods --- Octokit/Clients/CheckRunsClient.cs | 21 +++++++++------ Octokit/Clients/CheckSuitesClient.cs | 33 +++++++---------------- Octokit/Clients/ICheckSuitesClient.cs | 2 -- Octokit/Models/Response/CheckRunList.cs | 21 +++++++++++++++ Octokit/Models/Response/CheckSuiteList.cs | 21 +++++++++++++++ 5 files changed, 64 insertions(+), 34 deletions(-) create mode 100644 Octokit/Models/Response/CheckRunList.cs create mode 100644 Octokit/Models/Response/CheckSuiteList.cs 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; } + } +} From b3c1b5687a7b6edbf421486cbe8e85db6a589b76 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 15 May 2018 12:06:38 -0400 Subject: [PATCH 46/82] Bring parity to Reactive checks clients --- .../Clients/IObservableCheckRunsClient.cs | 4 +++ .../Clients/IObservableCheckSuitesClient.cs | 2 -- .../Clients/ObservableCheckRunsClient.cs | 33 +++++++++++++++++-- .../Clients/ObservableCheckSuitesClient.cs | 24 ++------------ 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs index 4cce38ca27..797d5a6db4 100644 --- a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs @@ -8,6 +8,10 @@ public interface IObservableCheckRunsClient IObservable Create(long repositoryId, NewCheckRun newCheckRun); IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); + IObservable GetAllForReference(string owner, string name, string reference); + IObservable GetAllForReference(long repositoryId, string reference); + IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId); + IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId); IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs index b76050a7b9..9cc0d7bb36 100644 --- a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -10,8 +10,6 @@ public interface IObservableCheckSuitesClient IObservable GetAllForReference(long repositoryId, string reference); IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); - IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options); - IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options); IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs index a8e79c805a..656e8aa047 100644 --- a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs @@ -73,6 +73,19 @@ public IObservable GetAllAnnotations(long repositoryId, long return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); } + public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return GetAllForCheckSuite(owner, name, checkSuiteId, new CheckRunRequest(), ApiOptions.None); + } + + public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId) + { + return GetAllForCheckSuite(repositoryId, checkSuiteId, new CheckRunRequest(), ApiOptions.None); + } + public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -107,6 +120,22 @@ public IObservable GetAllForCheckSuite(long repositoryId, long checkSu throw new NotImplementedException(); } + public IObservable GetAllForReference(string owner, string name, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(owner, name, reference, new CheckRunRequest(), ApiOptions.None); + } + + public IObservable GetAllForReference(long repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); + + return GetAllForReference(repositoryId, reference, new CheckRunRequest(), ApiOptions.None); + } + public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -114,7 +143,7 @@ public IObservable GetAllForReference(string owner, string name, strin Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - throw new NotImplementedException(); + return GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None); } public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) @@ -122,7 +151,7 @@ public IObservable GetAllForReference(long repositoryId, string refere Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - throw new NotImplementedException(); + return GetAllForReference(repositoryId, reference, checkRunRequest, ApiOptions.None); } public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 67b3c8e281..611be0a246 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -50,14 +50,14 @@ public IObservable GetAllForReference(string owner, string name, str 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 IObservable 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 IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) @@ -77,25 +77,7 @@ public IObservable GetAllForReference(long repositoryId, string refe return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } - - public IObservable GetAllForReference(string owner, string name, string reference, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(long repositoryId, string reference, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - + public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); From 439046888ccb36917f9a18d5f284dd688d979c14 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 28 May 2018 23:50:42 +1000 Subject: [PATCH 47/82] fix project settings to get GitHubApp helper working again --- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 9ed8fc2720..c38f326981 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -19,7 +19,7 @@ false - + $(DefineConstants);GITHUBJWT_HELPER_AVAILABLE @@ -45,7 +45,7 @@ - + 0.0.2 From 2cbc605d5c50e9eae8c15a7f17551962ee8311d6 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 28 May 2018 23:52:53 +1000 Subject: [PATCH 48/82] remove un-needed InstallationId setting - provide helper method to find installation based on owner --- .../Clients/GitHubAppsClientTests.cs | 13 ++++++++----- Octokit.Tests.Integration/Helper.cs | 14 +++++++++----- script/configure-integration-tests.ps1 | 1 - 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs b/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs index 79113beda8..84c416ea27 100644 --- a/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs @@ -65,7 +65,6 @@ public async Task GetsAllInstallations() { var result = await _github.GitHubApps.GetAllInstallationsForCurrent(); - Assert.True(result.Any(x => x.Id == Helper.GitHubAppInstallationId)); foreach (var installation in result) { Assert.Equal(Helper.GitHubAppId, installation.AppId); @@ -91,8 +90,10 @@ public TheGetInstallationMethod() [GitHubAppsTest] public async Task GetsInstallation() { - var installationId = Helper.GitHubAppInstallationId; - + // Get the installation Id + var installationId = Helper.GetGitHubAppInstallationForOwner(Helper.UserName).Id; + + // Get the installation by Id var result = await _github.GitHubApps.GetInstallation(installationId); Assert.True(result.AppId == Helper.GitHubAppId); @@ -116,10 +117,12 @@ public TheCreateInstallationTokenMethod() } [GitHubAppsTest] - public async Task GetsInstallation() + public async Task CreatesInstallationToken() { - var installationId = Helper.GitHubAppInstallationId; + // Get the installation Id + var installationId = Helper.GetGitHubAppInstallationForOwner(Helper.UserName).Id; + // Create installation token var result = await _github.GitHubApps.CreateInstallationToken(installationId); Assert.NotNull(result.Token); diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 15953eb6bf..5f0252ca73 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -171,11 +171,6 @@ public static string GitHubAppSlug get { return Environment.GetEnvironmentVariable("OCTOKIT_GITHUBAPP_SLUG"); } } - public static long GitHubAppInstallationId - { - get { return Convert.ToInt64(Environment.GetEnvironmentVariable("OCTOKIT_GITHUBAPP_INSTALLATIONID")); } - } - public static void DeleteRepo(IConnection connection, Repository repository) { if (repository != null) @@ -304,6 +299,15 @@ public static GitHubClient GetAuthenticatedGitHubAppsClient() }; } + public static Installation GetGitHubAppInstallationForOwner(string owner) + { + var client = GetAuthenticatedGitHubAppsClient(); + var installations = client.GitHubApps.GetAllInstallationsForCurrent().Result; + var installation = installations.First(x => x.Account.Login == owner); + + return installation; + } + public static void DeleteInvitations(IConnection connection, List invitees, int teamId) { try diff --git a/script/configure-integration-tests.ps1 b/script/configure-integration-tests.ps1 index c3943e5e0d..e06dacb83b 100644 --- a/script/configure-integration-tests.ps1 +++ b/script/configure-integration-tests.ps1 @@ -102,7 +102,6 @@ if (AskYesNoQuestion "Do you wish to setup GitHubApps integration test settings? { VerifyEnvironmentVariable "GitHub App ID" "OCTOKIT_GITHUBAPP_ID" VerifyEnvironmentVariable "GitHub App SLUG" "OCTOKIT_GITHUBAPP_SLUG" - VerifyEnvironmentVariable "GitHub App Installation ID" "OCTOKIT_GITHUBAPP_INSTALLATIONID" VerifyEnvironmentVariable "GitHub App Pem File" "OCTOKIT_GITHUBAPP_PEMFILE" } From ceee35e84233cd2a554f5eb61195196f8d918141 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 28 May 2018 23:53:08 +1000 Subject: [PATCH 49/82] fix up request object ctors based on required/optional parameters --- Octokit/Models/Request/NewCheckRun.cs | 10 ++++++++-- Octokit/Models/Request/NewCheckSuite.cs | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Octokit/Models/Request/NewCheckRun.cs b/Octokit/Models/Request/NewCheckRun.cs index 3807a721dc..888e8f4438 100644 --- a/Octokit/Models/Request/NewCheckRun.cs +++ b/Octokit/Models/Request/NewCheckRun.cs @@ -6,8 +6,14 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewCheckRun : CheckRunUpdate { - public string HeadBranch { get; set; } - public string HeadSha { get; set; } + public NewCheckRun(string name, string headBranch, string headSha) : base(name) + { + HeadBranch = headBranch; + HeadSha = headSha; + } + + public string HeadBranch { get; private set; } + public string HeadSha { get; private set; } internal override string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadBranch: {0}, HeadSha{1}, {2}", HeadBranch, HeadSha, base.DebuggerDisplay); } diff --git a/Octokit/Models/Request/NewCheckSuite.cs b/Octokit/Models/Request/NewCheckSuite.cs index bbb7e33170..542d72e518 100644 --- a/Octokit/Models/Request/NewCheckSuite.cs +++ b/Octokit/Models/Request/NewCheckSuite.cs @@ -4,9 +4,17 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class NewCheckSuite : CheckSuiteTriggerRequest + public class NewCheckSuite { + public NewCheckSuite(string headSha) + { + HeadSha = headSha; + } + + public string HeadSha { get; private set; } + public string HeadBranch { get; set; } - internal override string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadBranch: {0}, {1}", HeadBranch, base.DebuggerDisplay); + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadSha: {0} HeadBranch: {1}", HeadSha, HeadBranch); } } From 1f22ffeb88fa0e9d7fb4432811a30298584b6bb2 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 28 May 2018 23:53:35 +1000 Subject: [PATCH 50/82] fix up request object ctors based on required/optional parameters --- Octokit/Models/Request/CheckRunUpdate.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Request/CheckRunUpdate.cs b/Octokit/Models/Request/CheckRunUpdate.cs index 4d354266aa..1b2b4d8436 100644 --- a/Octokit/Models/Request/CheckRunUpdate.cs +++ b/Octokit/Models/Request/CheckRunUpdate.cs @@ -8,7 +8,12 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunUpdate { - public string Name { get; set; } + public CheckRunUpdate(string name) + { + Name = name; + } + + public string Name { get; private set; } public string DetailsUrl { get; set; } public string ExternalId { get; set; } public CheckStatus? Status { get; set; } From 36973a35a494dc6123486ade370d3b539eccf28c Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 28 May 2018 23:54:49 +1000 Subject: [PATCH 51/82] add some initial integration tests for CheckSuites and CheckRuns including some helper methods --- .../Clients/CheckRunsClientTests.cs | 74 +++++++++++++++ .../Clients/CheckSuitesClientTests.cs | 94 +++++++++++++++++++ Octokit.Tests.Integration/Helper.cs | 52 ++++++++++ 3 files changed, 220 insertions(+) create mode 100644 Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs new file mode 100644 index 0000000000..ba9426e5dc --- /dev/null +++ b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs @@ -0,0 +1,74 @@ +using Octokit.Tests.Integration.Helpers; +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class CheckRunsClientTests + { + public class TheGetMethod + { + IGitHubClient _github; + IGitHubClient _githubAppInstallation; + + public TheGetMethod() + { + _github = Helper.GetAuthenticatedClient(); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); + } + + [GitHubAppsTest] + public async Task GetsCheckRun() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Create a Check Run + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var newCheckRun = new NewCheckRun("checks", "master", headCommit.Sha); + var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun); + + // Get Check Run + var result = await _github.Check.Run.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, checkRun.Id); + + // Check result + Assert.Equal(checkRun.Id, result.Id); + Assert.Equal(newCheckRun.HeadSha, result.HeadSha); + } + } + } + + public class TheCreateMethod + { + IGitHubClient _github; + IGitHubClient _githubAppInstallation; + + public TheCreateMethod() + { + _github = Helper.GetAuthenticatedClient(); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); + } + + [GitHubAppsTest] + public async Task CreatesCheckRun() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var newCheckRun = new NewCheckRun("checks", "master", headCommit.Sha); + + var result = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun); + + Assert.NotNull(result); + Assert.Equal(headCommit.Sha, result.HeadSha); + } + } + } + } +} diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs new file mode 100644 index 0000000000..12369b3b8d --- /dev/null +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -0,0 +1,94 @@ +using Octokit.Tests.Integration.Helpers; +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class CheckSuitesClientTests + { + public class TheGetMethod + { + IGitHubClient _github; + IGitHubClient _githubAppInstallation; + + public TheGetMethod() + { + _github = Helper.GetAuthenticatedClient(); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); + } + + [GitHubAppsTest] + public async Task GetsCheckSuite() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Turn off auto creation of check suite for this repo + var preference = new AutoTriggerChecksObject(new[] { new CheckSuitePreference(Helper.GitHubAppId, false) }); + var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + + // Create a new feature branch + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); + + // Create a check suite for the feature branch + var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha) + { + HeadBranch = "my-feature" + }; + var checkSuite = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckSuite); + + // Get Check Suite + var result = await _github.Check.Suite.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); + + // Check result + Assert.Equal(checkSuite.Id, result.Id); + Assert.Equal(newCheckSuite.HeadSha, result.HeadSha); + } + } + } + + public class TheCreateMethod + { + IGitHubClient _github; + IGitHubClient _githubAppInstallation; + + public TheCreateMethod() + { + _github = Helper.GetAuthenticatedClient(); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); + } + + [GitHubAppsTest] + public async Task CreatesCheckSuite() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Turn off auto creation of check suite for this repo + var preference = new AutoTriggerChecksObject(new[] { new CheckSuitePreference(Helper.GitHubAppId, false) }); + var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + + // Create a new feature branch + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); + + // Create a check suite for the feature branch + var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha) + { + HeadBranch = "my-feature" + }; + var result = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckSuite); + + // Check result + Assert.NotNull(result); + Assert.Equal(featureBranch.Object.Sha, result.HeadSha); + } + } + } + } +} diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 5f0252ca73..c7d9bc3387 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Reflection; +using System.Threading.Tasks; namespace Octokit.Tests.Integration { @@ -308,6 +310,19 @@ public static Installation GetGitHubAppInstallationForOwner(string owner) return installation; } + public static GitHubClient GetAuthenticatedGitHubAppInstallationForOwner(string owner) + { + var client = GetAuthenticatedGitHubAppsClient(); + var installation = GetGitHubAppInstallationForOwner(owner); + + var token = client.GitHubApps.CreateInstallationToken(installation.Id).Result.Token; + + return new GitHubClient(new ProductHeaderValue("OctokitTests"), TargetUrl) + { + Credentials = new Credentials(token) + }; + } + public static void DeleteInvitations(IConnection connection, List invitees, int teamId) { try @@ -331,5 +346,42 @@ public static string InviteMemberToTeam(IConnection connection, int teamId, stri return login; } + + public async static Task CreateFeatureBranch(string owner, string repo, string parentSha, string branchName) + { + var github = Helper.GetAuthenticatedClient(); + + // Create content blob + var baselineBlob = new NewBlob + { + Content = "I am overwriting this blob with something new", + Encoding = EncodingType.Utf8 + }; + var baselineBlobResult = await github.Git.Blob.Create(owner, repo, baselineBlob); + + // Create tree item + var treeItem = new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = "README.md", + Sha = baselineBlobResult.Sha + }; + + // Create tree + var newTree = new NewTree(); + newTree.Tree.Add(treeItem); + var tree = await github.Git.Tree.Create(owner, repo, newTree); + + // Create commit + var newCommit = new NewCommit("this is the new commit", tree.Sha, parentSha); + var commit = await github.Git.Commit.Create(owner, repo, newCommit); + + // Create branch + var branch = await github.Git.Reference.Create(owner, repo, new NewReference($"refs/heads/{branchName}", commit.Sha)); + + // Return commit + return branch; + } } } From 68c291cca3aff38b71608ef4889a171d5568714b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 29 May 2018 00:25:18 +1000 Subject: [PATCH 52/82] Add test for Request CheckSuite Fix Request CheckSuite to use correct Uri Fix Request CheckSuite return type as it doesnt return an object Fix CheckSuiteTriggerRequest ctor to make required fields mandatory --- .../Clients/IObservableCheckSuitesClient.cs | 4 +-- .../Clients/ObservableCheckSuitesClient.cs | 4 +-- .../Clients/CheckSuitesClientTests.cs | 27 +++++++++++++++++++ Octokit/Clients/CheckSuitesClient.cs | 23 +++++++++++++--- Octokit/Clients/ICheckSuitesClient.cs | 4 +-- Octokit/Helpers/ApiUrls.cs | 21 +++++++++++++++ .../Request/CheckSuiteTriggerRequest.cs | 7 ++++- 7 files changed, 79 insertions(+), 11 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs index 9cc0d7bb36..87ee2d87ab 100644 --- a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -16,7 +16,7 @@ public interface IObservableCheckSuitesClient IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); IObservable Create(string owner, string name, NewCheckSuite newCheckSuite); IObservable Create(long repositoryId, NewCheckSuite newCheckSuite); - IObservable Request(string owner, string name, CheckSuiteTriggerRequest request); - IObservable Request(long repositoryId, CheckSuiteTriggerRequest request); + IObservable Request(string owner, string name, CheckSuiteTriggerRequest request); + IObservable Request(long repositoryId, CheckSuiteTriggerRequest request); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 611be0a246..a2eab90d9d 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -98,7 +98,7 @@ public IObservable GetAllForReference(long repositoryId, string refe throw new NotImplementedException(); } - public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) + public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -106,7 +106,7 @@ public IObservable Request(string owner, string name, CheckSuiteTrig return _client.Request(owner, name, request).ToObservable(); } - public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) + public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) { return _client.Request(repositoryId, request).ToObservable(); } diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 12369b3b8d..6443e3af85 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -90,5 +90,32 @@ public async Task CreatesCheckSuite() } } } + + public class TheRequestMethod + { + IGitHubClient _github; + IGitHubClient _githubAppInstallation; + + public TheRequestMethod() + { + _github = Helper.GetAuthenticatedClient(); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); + } + + [GitHubAppsTest] + public async Task RequestsCheckSuite() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryOwner, repoContext.RepositoryName, new CheckSuiteTriggerRequest(headCommit.Sha)); + + Assert.True(result); + } + } + } } } diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 28398af878..9ff8c72e6d 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Net; using System.Threading.Tasks; namespace Octokit @@ -94,21 +95,35 @@ public async Task> GetAllForReference(long repositoryI return results.SelectMany(x => x.CheckSuites).ToList(); } - public Task Request(string owner, string name, CheckSuiteTriggerRequest request) + public async Task Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); - return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), request, AcceptHeaders.ChecksApiPreview); + var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRequests(owner, name), request, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false); + + if (httpStatusCode != HttpStatusCode.Created) + { + throw new ApiException("Invalid Status Code returned. Expected a 201", httpStatusCode); + } + + return httpStatusCode == HttpStatusCode.Created; } - public Task Request(long repositoryId, CheckSuiteTriggerRequest request) + public async Task Request(long repositoryId, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); - return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), request, AcceptHeaders.ChecksApiPreview); + var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRequests(repositoryId), request, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false); + + if (httpStatusCode != HttpStatusCode.Created) + { + throw new ApiException("Invalid Status Code returned. Expected a 201", httpStatusCode); + } + + return httpStatusCode == HttpStatusCode.Created; } public Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 18f96dab11..dec0911d89 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -17,7 +17,7 @@ public interface ICheckSuitesClient Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); Task Create(string owner, string name, NewCheckSuite newCheckSuite); Task Create(long repositoryId, NewCheckSuite newCheckSuite); - Task Request(string owner, string name, CheckSuiteTriggerRequest request); - Task Request(long repositoryId, CheckSuiteTriggerRequest request); + Task Request(string owner, string name, CheckSuiteTriggerRequest request); + Task Request(long repositoryId, CheckSuiteTriggerRequest request); } } \ No newline at end of file diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 6684d972ae..e67ddd7067 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -3979,6 +3979,27 @@ public static Uri CheckSuites(string owner, string repo) return "repos/{0}/{1}/check-suites".FormatUri(owner, repo); } + /// + /// Returns the that handles the check suite requests for the repository. + /// + /// The Id of the repository + /// The that handles the check suite requests for the repository. + public static Uri CheckSuiteRequests(long repositoryId) + { + return "repositories/{0}/check-suite-requests".FormatUri(repositoryId); + } + + /// + /// Returns the that handles the check suite requests for the repository. + /// + /// The owner of repo + /// The name of repo + /// The that handles the check suite requests for the repository. + public static Uri CheckSuiteRequests(string owner, string repo) + { + return "repos/{0}/{1}/check-suite-requests".FormatUri(owner, repo); + } + /// /// Returns the that handles the check suite preferences for the repository. /// diff --git a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs index 3e9c03fb0b..883a910c5e 100644 --- a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs +++ b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs @@ -6,7 +6,12 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteTriggerRequest { - public string HeadSha { get; set; } + public CheckSuiteTriggerRequest(string headSha) + { + HeadSha = headSha; + } + + public string HeadSha { get; private set; } internal virtual string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadSha: {0}", HeadSha); } From c861eecd7b3d9f157967ca02c55489a2e38b1128 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 29 May 2018 00:27:12 +1000 Subject: [PATCH 53/82] simplify Get CheckSuite test to not require as much data setup --- .../Clients/CheckSuitesClientTests.cs | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 6443e3af85..588d050a70 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -26,27 +26,16 @@ public async Task GetsCheckSuite() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - // Turn off auto creation of check suite for this repo - var preference = new AutoTriggerChecksObject(new[] { new CheckSuitePreference(Helper.GitHubAppId, false) }); - var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); - - // Create a new feature branch + // Need to get a CheckSuiteId so we can test the Get method var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); - var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); - - // Create a check suite for the feature branch - var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha) - { - HeadBranch = "my-feature" - }; - var checkSuite = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckSuite); - - // Get Check Suite + var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).First(); + + // Get Check Suite by Id var result = await _github.Check.Suite.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); // Check result Assert.Equal(checkSuite.Id, result.Id); - Assert.Equal(newCheckSuite.HeadSha, result.HeadSha); + Assert.Equal(headCommit.Sha, result.HeadSha); } } } From 74305532635d8845cbb6e7759a8758102c4fd8d9 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 29 May 2018 00:27:36 +1000 Subject: [PATCH 54/82] Add test for CheckSuite GetAllForReference --- .../Clients/CheckRunsClientTests.cs | 2 -- .../Clients/CheckSuitesClientTests.cs | 32 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs index ba9426e5dc..6e5157a6ab 100644 --- a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs @@ -1,6 +1,4 @@ using Octokit.Tests.Integration.Helpers; -using System; -using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 588d050a70..394bce044f 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -1,5 +1,4 @@ using Octokit.Tests.Integration.Helpers; -using System; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -40,6 +39,37 @@ public async Task GetsCheckSuite() } } + public class TheGetAllForReferenceMethod + { + IGitHubClient _github; + IGitHubClient _githubAppInstallation; + + public TheGetAllForReferenceMethod() + { + _github = Helper.GetAuthenticatedClient(); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); + } + + [GitHubAppsTest] + public async Task GetsAllCheckSuites() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); + + Assert.NotEmpty(checkSuites); + foreach (var checkSuite in checkSuites) + { + Assert.Equal(headCommit.Sha, checkSuite.HeadSha); + } + } + } + } + public class TheCreateMethod { IGitHubClient _github; From d242c3a8af8230d8d86c7c3c6d63f2894446e779 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 29 May 2018 00:31:47 +1000 Subject: [PATCH 55/82] Add test for CheckSuite UpdatePreferences --- .../Clients/CheckSuitesClientTests.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 394bce044f..446da5b823 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -70,6 +70,38 @@ public async Task GetsAllCheckSuites() } } + public class TheUpdatePreferencesMethod + { + IGitHubClient _github; + IGitHubClient _githubAppInstallation; + + public TheUpdatePreferencesMethod() + { + _github = Helper.GetAuthenticatedClient(); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); + } + + [GitHubAppsTest] + public async Task UpdatesPreferences() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var preference = new AutoTriggerChecksObject(new[] + { + new CheckSuitePreference(Helper.GitHubAppId, false) + }); + + var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + + Assert.Equal(repoContext.RepositoryId, response.Repository.Id); + Assert.Equal(Helper.GitHubAppId, response.Preferences.AutoTriggerChecks[0].AppId); + Assert.Equal(false, response.Preferences.AutoTriggerChecks[0].Setting); + } + } + } + public class TheCreateMethod { IGitHubClient _github; From 64f8ac83b8dead0c56bf2366c81246d7dd00dce0 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 30 Jun 2018 22:19:59 +1000 Subject: [PATCH 56/82] rename response models --- Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs | 4 ++-- Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs | 4 ++-- .../Clients/CheckSuitesClientTests.cs | 6 +++--- Octokit/Clients/CheckSuitesClient.cs | 9 +++++---- Octokit/Clients/ICheckSuitesClient.cs | 4 ++-- ...rence.cs => CheckSuiteAutoTriggerChecksPreference.cs} | 6 +++--- ...toTriggerChecksObject.cs => CheckSuitePreferences.cs} | 8 ++++---- ...tePreferences.cs => CheckSuitePreferencesResponse.cs} | 9 +++++---- 8 files changed, 26 insertions(+), 24 deletions(-) rename Octokit/Models/Common/{CheckSuitePreference.cs => CheckSuiteAutoTriggerChecksPreference.cs} (71%) rename Octokit/Models/Common/{AutoTriggerChecksObject.cs => CheckSuitePreferences.cs} (61%) rename Octokit/Models/Response/{CheckSuitePreferences.cs => CheckSuitePreferencesResponse.cs} (64%) diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs index 87ee2d87ab..349a3282c5 100644 --- a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -12,8 +12,8 @@ public interface IObservableCheckSuitesClient IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); - IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences); - IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); + IObservable UpdatePreferences(string owner, string name, CheckSuitePreferences preferences); + IObservable UpdatePreferences(long repositoryId, CheckSuitePreferences preferences); IObservable Create(string owner, string name, NewCheckSuite newCheckSuite); IObservable Create(long repositoryId, NewCheckSuite newCheckSuite); IObservable Request(string owner, string name, CheckSuiteTriggerRequest request); diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index a2eab90d9d..5ce9361a3e 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -111,7 +111,7 @@ public IObservable Request(long repositoryId, CheckSuiteTriggerRequest req return _client.Request(repositoryId, request).ToObservable(); } - public IObservable UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) + public IObservable UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -120,7 +120,7 @@ public IObservable UpdatePreferences(string owner, string return _client.UpdatePreferences(owner, name, preferences).ToObservable(); } - public IObservable UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + public IObservable UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) { Ensure.ArgumentNotNull(preferences, nameof(preferences)); diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 446da5b823..6635a97fde 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -88,9 +88,9 @@ public async Task UpdatesPreferences() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var preference = new AutoTriggerChecksObject(new[] + var preference = new CheckSuitePreferences(new[] { - new CheckSuitePreference(Helper.GitHubAppId, false) + new CheckSuiteAutoTriggerChecksPreference(Helper.GitHubAppId, false) }); var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); @@ -121,7 +121,7 @@ public async Task CreatesCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Turn off auto creation of check suite for this repo - var preference = new AutoTriggerChecksObject(new[] { new CheckSuitePreference(Helper.GitHubAppId, false) }); + var preference = new CheckSuitePreferences(new[] { new CheckSuiteAutoTriggerChecksPreference(Helper.GitHubAppId, false) }); var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 9ff8c72e6d..88d633ca46 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -70,6 +70,7 @@ public Task> GetAllForReference(long repositoryId, str { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); + return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } @@ -126,20 +127,20 @@ public async Task Request(long repositoryId, CheckSuiteTriggerRequest requ return httpStatusCode == HttpStatusCode.Created; } - public Task UpdatePreferences(string owner, string name, AutoTriggerChecksObject preferences) + public Task UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(preferences, nameof(preferences)); - return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); } - public Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences) + public Task UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) { Ensure.ArgumentNotNull(preferences, nameof(preferences)); - return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview); } } } \ No newline at end of file diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index dec0911d89..841149e38e 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -13,8 +13,8 @@ public interface ICheckSuitesClient Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); 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); - Task UpdatePreferences(long repositoryId, AutoTriggerChecksObject preferences); + Task UpdatePreferences(string owner, string name, CheckSuitePreferences preferences); + Task UpdatePreferences(long repositoryId, CheckSuitePreferences preferences); Task Create(string owner, string name, NewCheckSuite newCheckSuite); Task Create(long repositoryId, NewCheckSuite newCheckSuite); Task Request(string owner, string name, CheckSuiteTriggerRequest request); diff --git a/Octokit/Models/Common/CheckSuitePreference.cs b/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs similarity index 71% rename from Octokit/Models/Common/CheckSuitePreference.cs rename to Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs index b8e9e3dd8b..9a8f189c5a 100644 --- a/Octokit/Models/Common/CheckSuitePreference.cs +++ b/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs @@ -4,13 +4,13 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuitePreference + public class CheckSuiteAutoTriggerChecksPreference { - public CheckSuitePreference() + public CheckSuiteAutoTriggerChecksPreference() { } - public CheckSuitePreference(long appId, bool setting) + public CheckSuiteAutoTriggerChecksPreference(long appId, bool setting) { AppId = appId; Setting = setting; diff --git a/Octokit/Models/Common/AutoTriggerChecksObject.cs b/Octokit/Models/Common/CheckSuitePreferences.cs similarity index 61% rename from Octokit/Models/Common/AutoTriggerChecksObject.cs rename to Octokit/Models/Common/CheckSuitePreferences.cs index e28e1dfe91..88808d0642 100644 --- a/Octokit/Models/Common/AutoTriggerChecksObject.cs +++ b/Octokit/Models/Common/CheckSuitePreferences.cs @@ -6,18 +6,18 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class AutoTriggerChecksObject + public class CheckSuitePreferences { - public AutoTriggerChecksObject() + public CheckSuitePreferences() { } - public AutoTriggerChecksObject(IReadOnlyList autoTriggerChecks) + public CheckSuitePreferences(IReadOnlyList autoTriggerChecks) { AutoTriggerChecks = autoTriggerChecks; } - public IReadOnlyList AutoTriggerChecks { get; protected set; } + public IReadOnlyList AutoTriggerChecks { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "AutoTriggerChecks: {0}", string.Join(", ", AutoTriggerChecks.Select(x => x.DebuggerDisplay))); } diff --git a/Octokit/Models/Response/CheckSuitePreferences.cs b/Octokit/Models/Response/CheckSuitePreferencesResponse.cs similarity index 64% rename from Octokit/Models/Response/CheckSuitePreferences.cs rename to Octokit/Models/Response/CheckSuitePreferencesResponse.cs index d91390cb8e..a3c247b807 100644 --- a/Octokit/Models/Response/CheckSuitePreferences.cs +++ b/Octokit/Models/Response/CheckSuitePreferencesResponse.cs @@ -4,19 +4,20 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuitePreferences + public class CheckSuitePreferencesResponse { - public CheckSuitePreferences() + public CheckSuitePreferencesResponse() { } - public CheckSuitePreferences(AutoTriggerChecksObject preferences, Repository repository) + public CheckSuitePreferencesResponse(CheckSuitePreferences preferences, Repository repository) { Preferences = preferences; Repository = repository; } - public AutoTriggerChecksObject Preferences { get; protected set; } + public CheckSuitePreferences Preferences { get; protected set; } + public Repository Repository { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Preferences: {0}, Repository: {1}", Preferences.DebuggerDisplay, Repository.DebuggerDisplay); From 0a6176e0756b743a6077f0b51439ee572b1f45cf Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 2 Jul 2018 10:24:54 +1000 Subject: [PATCH 57/82] rename CheckSuitesList to CheckSuitesResponse and use as response to the GetAll calls --- Octokit/Clients/CheckSuitesClient.cs | 26 ++++++++++++------- Octokit/Clients/ICheckSuitesClient.cs | 12 ++++----- ...eckSuiteList.cs => CheckSuitesResponse.cs} | 6 ++--- 3 files changed, 25 insertions(+), 19 deletions(-) rename Octokit/Models/Response/{CheckSuiteList.cs => CheckSuitesResponse.cs} (66%) diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 88d633ca46..029faa2208 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -40,7 +40,7 @@ public Task Get(long repositoryId, long checkSuiteId) return ApiConnection.Get(ApiUrls.CheckSuite(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); } - public Task> GetAllForReference(string owner, string name, string reference) + public Task GetAllForReference(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -49,14 +49,14 @@ public Task> GetAllForReference(string owner, string n return GetAllForReference(owner, name, reference, new CheckSuiteRequest(), ApiOptions.None); } - public Task> GetAllForReference(long repositoryId, string reference) + public Task GetAllForReference(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); return GetAllForReference(repositoryId, reference, new CheckSuiteRequest(), ApiOptions.None); } - public Task> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) + public Task GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -66,7 +66,7 @@ public Task> GetAllForReference(string owner, string n return GetAllForReference(owner, name, reference, request, ApiOptions.None); } - public Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) + public Task GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); @@ -74,7 +74,7 @@ public Task> GetAllForReference(long repositoryId, str return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } - public async 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)); @@ -82,18 +82,24 @@ public async Task> GetAllForReference(string owner, st Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); - return results.SelectMany(x => x.CheckSuites).ToList(); + var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + + return new CheckSuitesResponse( + results.Max(x => x.TotalCount), + results.SelectMany(x => x.CheckSuites).ToList()); } - public async 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)); - var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); - return results.SelectMany(x => x.CheckSuites).ToList(); + var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + + return new CheckSuitesResponse( + results.Max(x => x.TotalCount), + results.SelectMany(x => x.CheckSuites).ToList()); } public async Task Request(string owner, string name, CheckSuiteTriggerRequest request) diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 841149e38e..addcadb554 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -7,12 +7,12 @@ public interface ICheckSuitesClient { Task Get(string owner, string name, long checkSuiteId); Task Get(long repositoryId, long checkSuiteId); - Task> GetAllForReference(string owner, string name, string reference); - 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, CheckSuiteRequest request, ApiOptions options); - Task> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + Task GetAllForReference(string owner, string name, string reference); + 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, CheckSuiteRequest request, ApiOptions options); + Task GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); Task UpdatePreferences(string owner, string name, CheckSuitePreferences preferences); Task UpdatePreferences(long repositoryId, CheckSuitePreferences preferences); Task Create(string owner, string name, NewCheckSuite newCheckSuite); diff --git a/Octokit/Models/Response/CheckSuiteList.cs b/Octokit/Models/Response/CheckSuitesResponse.cs similarity index 66% rename from Octokit/Models/Response/CheckSuiteList.cs rename to Octokit/Models/Response/CheckSuitesResponse.cs index 687906c5e5..b14f4d7e4c 100644 --- a/Octokit/Models/Response/CheckSuiteList.cs +++ b/Octokit/Models/Response/CheckSuitesResponse.cs @@ -2,13 +2,13 @@ namespace Octokit { - public class CheckSuiteList + public class CheckSuitesResponse { - public CheckSuiteList() + public CheckSuitesResponse() { } - public CheckSuiteList(int totalCount, IReadOnlyList checkSuites) + public CheckSuitesResponse(int totalCount, IReadOnlyList checkSuites) { TotalCount = totalCount; CheckSuites = checkSuites; From 8aeb8057d6f509971f46ef516ebede1d070b959b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 2 Jul 2018 10:25:29 +1000 Subject: [PATCH 58/82] Fix tests --- Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 6635a97fde..e49621d75f 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -27,7 +27,7 @@ public async Task GetsCheckSuite() { // Need to get a CheckSuiteId so we can test the Get method var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); - var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).First(); + var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id var result = await _github.Check.Suite.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); @@ -61,8 +61,8 @@ public async Task GetsAllCheckSuites() var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); - Assert.NotEmpty(checkSuites); - foreach (var checkSuite in checkSuites) + Assert.NotEmpty(checkSuites.CheckSuites); + foreach (var checkSuite in checkSuites.CheckSuites) { Assert.Equal(headCommit.Sha, checkSuite.HeadSha); } From 43214318998c21af59a0c17621d8cab45080419c Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 2 Jul 2018 10:25:46 +1000 Subject: [PATCH 59/82] Fix observable --- .../Clients/IObservableCheckSuitesClient.cs | 12 ++++++------ .../Clients/ObservableCheckSuitesClient.cs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs index 349a3282c5..74503029fd 100644 --- a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -6,12 +6,12 @@ public interface IObservableCheckSuitesClient { IObservable Get(string owner, string name, long checkSuiteId); IObservable Get(long repositoryId, long checkSuiteId); - IObservable GetAllForReference(string owner, string name, string reference); - IObservable GetAllForReference(long repositoryId, string reference); - IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); - IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); - IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); - IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + IObservable GetAllForReference(string owner, string name, string reference); + IObservable GetAllForReference(long repositoryId, string reference); + IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); + IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); + IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); + IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); IObservable UpdatePreferences(string owner, string name, CheckSuitePreferences preferences); IObservable UpdatePreferences(long repositoryId, CheckSuitePreferences preferences); IObservable Create(string owner, string name, NewCheckSuite newCheckSuite); diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 5ce9361a3e..fc7a364afa 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -44,7 +44,7 @@ public IObservable Get(long repositoryId, long checkSuiteId) return _client.Get(repositoryId, checkSuiteId).ToObservable(); } - public IObservable GetAllForReference(string owner, string name, string reference) + public IObservable GetAllForReference(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -53,14 +53,14 @@ public IObservable GetAllForReference(string owner, string name, str return GetAllForReference(owner, name, reference, new CheckSuiteRequest(), ApiOptions.None); } - public IObservable GetAllForReference(long repositoryId, string reference) + public IObservable GetAllForReference(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); return GetAllForReference(repositoryId, reference, new CheckSuiteRequest(), ApiOptions.None); } - public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) + public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -70,7 +70,7 @@ public IObservable GetAllForReference(string owner, string name, str return GetAllForReference(owner, name, reference, request, ApiOptions.None); } - public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); @@ -78,7 +78,7 @@ public IObservable GetAllForReference(long repositoryId, string refe return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } - public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) + public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -89,7 +89,7 @@ public IObservable GetAllForReference(string owner, string name, str throw new NotImplementedException(); } - public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) + public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); From f28b770cc1aeb467ae8c2026252c1e8cd50b6dfb Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 2 Jul 2018 10:26:14 +1000 Subject: [PATCH 60/82] fix model convention tests --- .../Models/Common/CheckSuiteAutoTriggerChecksPreference.cs | 1 + Octokit/Models/Response/CheckSuitesResponse.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs b/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs index 9a8f189c5a..d16d8f1b96 100644 --- a/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs +++ b/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs @@ -17,6 +17,7 @@ public CheckSuiteAutoTriggerChecksPreference(long appId, bool setting) } public long AppId { get; protected set; } + public bool Setting { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "{0}: {1}", AppId, Setting ? "On" : "Off"); diff --git a/Octokit/Models/Response/CheckSuitesResponse.cs b/Octokit/Models/Response/CheckSuitesResponse.cs index b14f4d7e4c..b410e4ae10 100644 --- a/Octokit/Models/Response/CheckSuitesResponse.cs +++ b/Octokit/Models/Response/CheckSuitesResponse.cs @@ -1,7 +1,10 @@ using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; namespace Octokit { + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuitesResponse { public CheckSuitesResponse() @@ -17,5 +20,7 @@ public CheckSuitesResponse(int totalCount, IReadOnlyList checkSuites public int TotalCount { get; protected set; } public IReadOnlyList CheckSuites { get; protected set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, CheckSuites: {1}", TotalCount, CheckSuites.Count); } } From 368ad79ff3e17585fe32f4ec13a8c532153f2d9d Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 2 Jul 2018 13:23:59 +1000 Subject: [PATCH 61/82] remove CheckRuns so we can focus only on CheckSuites for now --- .../Clients/IObservableCheckRunsClient.cs | 30 --- .../Clients/IObservableChecksClient.cs | 1 - .../Clients/ObservableCheckRunsClient.cs | 191 ------------------ .../Clients/ObservableChecksClient.cs | 3 - .../Clients/CheckRunsClientTests.cs | 72 ------- Octokit/Clients/CheckRunsClient.cs | 190 ----------------- Octokit/Clients/ChecksClient.cs | 2 - Octokit/Clients/ICheckRunsClient.cs | 31 --- Octokit/Clients/IChecksClient.cs | 2 - Octokit/Helpers/ApiUrls.cs | 113 ----------- Octokit/Models/Common/CheckRunAnnotation.cs | 49 ----- Octokit/Models/Common/CheckRunImage.cs | 26 --- Octokit/Models/Common/CheckRunOutput.cs | 31 --- Octokit/Models/Common/CheckStatus.cs | 37 ++++ Octokit/Models/Request/CheckRunRequest.cs | 23 --- Octokit/Models/Request/CheckRunUpdate.cs | 60 ------ Octokit/Models/Request/NewCheckRun.cs | 20 -- .../ActivityPayloads/CheckRunEventPayload.cs | 11 - Octokit/Models/Response/CheckRun.cs | 49 ----- Octokit/Models/Response/CheckRunList.cs | 21 -- 20 files changed, 37 insertions(+), 925 deletions(-) delete mode 100644 Octokit.Reactive/Clients/IObservableCheckRunsClient.cs delete mode 100644 Octokit.Reactive/Clients/ObservableCheckRunsClient.cs delete mode 100644 Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs delete mode 100644 Octokit/Clients/CheckRunsClient.cs delete mode 100644 Octokit/Clients/ICheckRunsClient.cs delete mode 100644 Octokit/Models/Common/CheckRunAnnotation.cs delete mode 100644 Octokit/Models/Common/CheckRunImage.cs delete mode 100644 Octokit/Models/Common/CheckRunOutput.cs create mode 100644 Octokit/Models/Common/CheckStatus.cs delete mode 100644 Octokit/Models/Request/CheckRunRequest.cs delete mode 100644 Octokit/Models/Request/CheckRunUpdate.cs delete mode 100644 Octokit/Models/Request/NewCheckRun.cs delete mode 100644 Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs delete mode 100644 Octokit/Models/Response/CheckRun.cs delete mode 100644 Octokit/Models/Response/CheckRunList.cs diff --git a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs deleted file mode 100644 index 797d5a6db4..0000000000 --- a/Octokit.Reactive/Clients/IObservableCheckRunsClient.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace Octokit.Reactive -{ - public interface IObservableCheckRunsClient - { - IObservable Create(string owner, string name, NewCheckRun newCheckRun); - IObservable Create(long repositoryId, NewCheckRun newCheckRun); - IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); - IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); - IObservable GetAllForReference(string owner, string name, string reference); - IObservable GetAllForReference(long repositoryId, string reference); - IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId); - IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId); - IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); - IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); - IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); - IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); - IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); - IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); - IObservable Get(string owner, string name, long checkRunId); - IObservable Get(long repositoryId, long checkRunId); - IObservable GetAllAnnotations(string owner, string name, long checkRunId); - IObservable GetAllAnnotations(long repositoryId, long checkRunId); - IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); - IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); - } -} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableChecksClient.cs b/Octokit.Reactive/Clients/IObservableChecksClient.cs index b614861e85..db486e507e 100644 --- a/Octokit.Reactive/Clients/IObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/IObservableChecksClient.cs @@ -2,7 +2,6 @@ { public interface IObservableChecksClient { - IObservableCheckRunsClient Run { get; } IObservableCheckSuitesClient Suite { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs deleted file mode 100644 index 656e8aa047..0000000000 --- a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs +++ /dev/null @@ -1,191 +0,0 @@ -using System; -using System.Reactive.Threading.Tasks; -using Octokit.Reactive.Internal; - -namespace Octokit.Reactive -{ - public class ObservableCheckRunsClient : IObservableCheckRunsClient - { - readonly ICheckRunsClient _client; - readonly IConnection _connection; - - public ObservableCheckRunsClient(IGitHubClient gitHubClient) - { - _client = gitHubClient.Check.Run; - _connection = gitHubClient.Connection; - } - - public IObservable Create(string owner, string name, NewCheckRun newCheckRun) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - - return _client.Create(owner, name, newCheckRun).ToObservable(); - } - - public IObservable Create(long repositoryId, NewCheckRun newCheckRun) - { - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - - return _client.Create(repositoryId, newCheckRun).ToObservable(); - } - - public IObservable Get(string owner, string name, long checkRunId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return _client.Get(owner, name, checkRunId).ToObservable(); - } - - public IObservable Get(long repositoryId, long checkRunId) - { - return _client.Get(repositoryId, checkRunId).ToObservable(); - } - - public IObservable GetAllAnnotations(string owner, string name, long checkRunId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); - } - - public IObservable GetAllAnnotations(long repositoryId, long checkRunId) - { - return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); - } - - public IObservable GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(options, nameof(options)); - - return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - - public IObservable GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) - { - Ensure.ArgumentNotNull(options, nameof(options)); - - return _connection.GetAndFlattenAllPages(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - - public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return GetAllForCheckSuite(owner, name, checkSuiteId, new CheckRunRequest(), ApiOptions.None); - } - - public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId) - { - return GetAllForCheckSuite(repositoryId, checkSuiteId, new CheckRunRequest(), ApiOptions.None); - } - - public IObservable GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); - } - - public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); - } - - public IObservable 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(); - } - - public IObservable GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - Ensure.ArgumentNotNull(options, nameof(options)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(string owner, string name, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - - return GetAllForReference(owner, name, reference, new CheckRunRequest(), ApiOptions.None); - } - - public IObservable GetAllForReference(long repositoryId, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - - return GetAllForReference(repositoryId, reference, new CheckRunRequest(), ApiOptions.None); - } - - public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None); - } - - public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForReference(repositoryId, reference, checkRunRequest, ApiOptions.None); - } - - public IObservable GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - throw new NotImplementedException(); - } - - public IObservable GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - throw new NotImplementedException(); - } - - public IObservable Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - - return _client.Update(owner, name, checkRunId, checkRunUpdate).ToObservable(); - } - - public IObservable Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) - { - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - - return _client.Update(repositoryId, checkRunId, checkRunUpdate).ToObservable(); - } - } -} diff --git a/Octokit.Reactive/Clients/ObservableChecksClient.cs b/Octokit.Reactive/Clients/ObservableChecksClient.cs index b73d6ddf8b..1eb8c0e384 100644 --- a/Octokit.Reactive/Clients/ObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/ObservableChecksClient.cs @@ -4,12 +4,9 @@ public class ObservableChecksClient : IObservableChecksClient { public ObservableChecksClient(IGitHubClient gitHubClient) { - Run = new ObservableCheckRunsClient(gitHubClient); Suite = new ObservableCheckSuitesClient(gitHubClient); } - public IObservableCheckRunsClient Run { get; private set; } - public IObservableCheckSuitesClient Suite { get; private set; } } } \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs deleted file mode 100644 index 6e5157a6ab..0000000000 --- a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Octokit.Tests.Integration.Helpers; -using System.Threading.Tasks; -using Xunit; - -namespace Octokit.Tests.Integration.Clients -{ - public class CheckRunsClientTests - { - public class TheGetMethod - { - IGitHubClient _github; - IGitHubClient _githubAppInstallation; - - public TheGetMethod() - { - _github = Helper.GetAuthenticatedClient(); - - // Authenticate as a GitHubApp Installation - _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); - } - - [GitHubAppsTest] - public async Task GetsCheckRun() - { - using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) - { - // Create a Check Run - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); - var newCheckRun = new NewCheckRun("checks", "master", headCommit.Sha); - var checkRun = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun); - - // Get Check Run - var result = await _github.Check.Run.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, checkRun.Id); - - // Check result - Assert.Equal(checkRun.Id, result.Id); - Assert.Equal(newCheckRun.HeadSha, result.HeadSha); - } - } - } - - public class TheCreateMethod - { - IGitHubClient _github; - IGitHubClient _githubAppInstallation; - - public TheCreateMethod() - { - _github = Helper.GetAuthenticatedClient(); - - // Authenticate as a GitHubApp Installation - _githubAppInstallation = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName); - } - - [GitHubAppsTest] - public async Task CreatesCheckRun() - { - using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) - { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); - - var newCheckRun = new NewCheckRun("checks", "master", headCommit.Sha); - - var result = await _githubAppInstallation.Check.Run.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckRun); - - Assert.NotNull(result); - Assert.Equal(headCommit.Sha, result.HeadSha); - } - } - } - } -} diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs deleted file mode 100644 index 5a1616214c..0000000000 --- a/Octokit/Clients/CheckRunsClient.cs +++ /dev/null @@ -1,190 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Octokit -{ - public class CheckRunsClient : ApiClient, ICheckRunsClient - { - public CheckRunsClient(IApiConnection apiConnection) : base(apiConnection) - { - } - - public Task Create(string owner, string name, NewCheckRun newCheckRun) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - - return ApiConnection.Post(ApiUrls.CheckRuns(owner, name), newCheckRun, AcceptHeaders.ChecksApiPreview); - } - - public Task Create(long repositoryId, NewCheckRun newCheckRun) - { - Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - - return ApiConnection.Post(ApiUrls.CheckRuns(repositoryId), newCheckRun, AcceptHeaders.ChecksApiPreview); - } - - public Task Get(string owner, string name, long checkRunId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return ApiConnection.Get(ApiUrls.CheckRun(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview); - } - - public Task Get(long repositoryId, long checkRunId) - { - return ApiConnection.Get(ApiUrls.CheckRun(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview); - } - - public Task> GetAllForReference(long repositoryId, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - - return GetAllForReference(repositoryId, reference, new CheckRunRequest(), ApiOptions.None); - } - - public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return GetAllForCheckSuite(owner, name, checkSuiteId, new CheckRunRequest(), ApiOptions.None); - } - - public Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId) - { - return GetAllForCheckSuite(repositoryId, checkSuiteId, new CheckRunRequest(), ApiOptions.None); - } - - public Task> GetAllForReference(string owner, string name, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - - return GetAllForReference(owner, name, reference, new CheckRunRequest(), ApiOptions.None); - } - - public Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForReference(owner, name, reference, checkRunRequest, ApiOptions.None); - } - - public Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForReference(repositoryId, reference, checkRunRequest, ApiOptions.None); - } - - public Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForCheckSuite(owner, name, checkSuiteId, checkRunRequest, ApiOptions.None); - } - - public Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest) - { - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - - return GetAllForCheckSuite(repositoryId, checkSuiteId, checkRunRequest, ApiOptions.None); - } - - public async Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - Ensure.ArgumentNotNull(options, nameof(options)); - - 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 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)); - - var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckRuns(repositoryId, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); - return results.SelectMany(x => x.CheckRuns).ToList(); - } - - 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)); - - 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 async Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) - { - Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); - Ensure.ArgumentNotNull(options, nameof(options)); - - 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) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - - return ApiConnection.Patch(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); - } - - public Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) - { - Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - - return ApiConnection.Patch(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); - } - - public Task> GetAllAnnotations(string owner, string name, long checkRunId) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return GetAllAnnotations(owner, name, checkRunId, ApiOptions.None); - } - - public Task> GetAllAnnotations(long repositoryId, long checkRunId) - { - return GetAllAnnotations(repositoryId, checkRunId, ApiOptions.None); - } - - public Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - - public Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) - { - return ApiConnection.GetAll(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); - } - } -} diff --git a/Octokit/Clients/ChecksClient.cs b/Octokit/Clients/ChecksClient.cs index 1587c17a6f..c6ceea00ae 100644 --- a/Octokit/Clients/ChecksClient.cs +++ b/Octokit/Clients/ChecksClient.cs @@ -2,12 +2,10 @@ { public class ChecksClient : IChecksClient { - public ICheckRunsClient Run { get; private set; } public ICheckSuitesClient Suite { get; private set; } public ChecksClient(ApiConnection apiConnection) { - Run = new CheckRunsClient(apiConnection); Suite = new CheckSuitesClient(apiConnection); } } diff --git a/Octokit/Clients/ICheckRunsClient.cs b/Octokit/Clients/ICheckRunsClient.cs deleted file mode 100644 index e9a1eb2759..0000000000 --- a/Octokit/Clients/ICheckRunsClient.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Octokit -{ - public interface ICheckRunsClient - { - Task Create(string owner, string name, NewCheckRun newCheckRun); - Task Create(long repositoryId, NewCheckRun newCheckRun); - Task Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate); - Task Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate); - Task> GetAllForReference(string owner, string name, string reference); - Task> GetAllForReference(long repositoryId, string reference); - Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId); - Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId); - Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest); - Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest); - Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest); - Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest); - Task> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - Task> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options); - Task> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); - Task> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options); - Task Get(string owner, string name, long checkRunId); - Task Get(long repositoryId, long checkRunId); - Task> GetAllAnnotations(string owner, string name, long checkRunId); - Task> GetAllAnnotations(long repositoryId, long checkRunId); - Task> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options); - Task> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options); - } -} diff --git a/Octokit/Clients/IChecksClient.cs b/Octokit/Clients/IChecksClient.cs index 113678204a..b929690378 100644 --- a/Octokit/Clients/IChecksClient.cs +++ b/Octokit/Clients/IChecksClient.cs @@ -2,8 +2,6 @@ { public interface IChecksClient { - ICheckRunsClient Run { get; } - ICheckSuitesClient Suite { get; } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index e67ddd7067..ca33a6c740 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -3799,119 +3799,6 @@ public static Uri RepositoryLicense(long repositoryId) return "repositories/{0}/license".FormatUri(repositoryId); } - /// - /// Returns the that returns the specified check run. - /// - /// The Id of the repository - /// The check run Id - /// The that returns the specified check run. - public static Uri CheckRun(long repositoryId, long id) - { - return "repositories/{0}/check-runs/{1}".FormatUri(repositoryId, id); - } - - /// - /// Returns the that returns the specified check run. - /// - /// The owner of repo - /// The name of repo - /// The check run Id - /// The that returns the specified check run. - public static Uri CheckRun(string owner, string repo, long id) - { - return "repos/{0}/{1}/check-runs/{2}".FormatUri(owner, repo, id); - } - - /// - /// Returns the that handles the check runs for the repository. - /// - /// The Id of the repository - /// The that handles the check runs for the repository. - public static Uri CheckRuns(long repositoryId) - { - return "repositories/{0}/check-runs".FormatUri(repositoryId); - } - - /// - /// Returns the that handles the check runs for the repository. - /// - /// The owner of repo - /// The name of repo - /// The that handles the check runs for the repository. - public static Uri CheckRuns(string owner, string repo) - { - return "repos/{0}/{1}/check-runs".FormatUri(owner, repo); - } - - /// - /// Returns the that returns the specified check run's annotations. - /// - /// The Id of the repository - /// The check run Id - /// The that returns the specified check run's annotations. - public static Uri CheckRunAnnotations(long repositoryId, long id) - { - return "repositories/{0}/check-runs/{1}/annotations".FormatUri(repositoryId, id); - } - - /// - /// Returns the that returns the specified check run's annotations. - /// - /// The owner of repo - /// The name of repo - /// The check run Id - /// The that returns the specified check run's annotations. - public static Uri CheckRunAnnotations(string owner, string repo, long id) - { - return "repos/{0}/{1}/check-runs/{2}/annotations".FormatUri(owner, repo, id); - } - - /// - /// Returns the that lists the check runs for the specified reference. - /// - /// The Id of the repository - /// The git reference - /// The that returns the check runs for the specified reference. - public static Uri ReferenceCheckRuns(long repositoryId, string reference) - { - return "repositories/{0}/commits/{1}/check-runs".FormatUri(repositoryId, reference); - } - - /// - /// Returns the that lists the check runs for the specified reference. - /// - /// The owner of repo - /// The name of repo - /// The git reference - /// The that returns the check runs for the specified reference. - public static Uri ReferenceCheckRuns(string owner, string repo, string reference) - { - return "repos/{0}/{1}/commits/{2}/check-runs".FormatUri(owner, repo, reference); - } - - /// - /// Returns the that lists the check runs for the specified check suite. - /// - /// The Id of the repository - /// The Id of the check suite - /// The that returns the check runs for the specified reference. - public static Uri CheckSuiteRuns(long repositoryId, long id) - { - return "repositories/{0}/check-suites/{1}/check-runs".FormatUri(repositoryId, id); - } - - /// - /// Returns the that returns the specified pull request. - /// - /// The owner of repo - /// The name of repo - /// The Id of the check suite - /// The that returns the specified pull request. - public static Uri CheckSuiteRuns(string owner, string repo, long id) - { - return "repos/{0}/{1}/check-suites/{2}/check-runs".FormatUri(owner, repo, id); - } - /// /// Returns the that returns the specified check suite. /// diff --git a/Octokit/Models/Common/CheckRunAnnotation.cs b/Octokit/Models/Common/CheckRunAnnotation.cs deleted file mode 100644 index e8d912ffc4..0000000000 --- a/Octokit/Models/Common/CheckRunAnnotation.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Octokit.Internal; -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunAnnotation - { - public CheckRunAnnotation() - { - } - - public CheckRunAnnotation(string filename, string blobHref, int startLine, int endLine, CheckWarningLevel warningLevel, string message, string title, string rawDetails) - { - Filename = filename; - BlobHref = blobHref; - StartLine = startLine; - EndLine = endLine; - WarningLevel = warningLevel; - Message = message; - Title = title; - RawDetails = rawDetails; - } - - public string Filename { get; protected set; } - public string BlobHref { get; protected set; } - public int StartLine { get; protected set; } - public int EndLine { get; protected set; } - public StringEnum WarningLevel { get; protected set; } - public string Message { get; protected set; } - public string Title { get; protected set; } - public string RawDetails { get; protected set; } - - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Title: {0}, Filename: {1}, WarningLevel: {2}", Title ?? "", Filename, WarningLevel.DebuggerDisplay); - } - - public enum CheckWarningLevel - { - [Parameter(Value = "notice")] - Notice, - - [Parameter(Value = "warning")] - Warning, - - [Parameter(Value = "failure")] - Failure, - } -} \ No newline at end of file diff --git a/Octokit/Models/Common/CheckRunImage.cs b/Octokit/Models/Common/CheckRunImage.cs deleted file mode 100644 index ca8cac06e5..0000000000 --- a/Octokit/Models/Common/CheckRunImage.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunImage - { - public CheckRunImage() - { - } - - public CheckRunImage(string alt, string imageUrl, string caption) - { - Alt = alt; - ImageUrl = imageUrl; - Caption = caption; - } - - public string Alt { get; protected set; } - public string ImageUrl { get; protected set; } - public string Caption { get; protected set; } - - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "ImageUrl: {0}", ImageUrl); - } -} \ No newline at end of file diff --git a/Octokit/Models/Common/CheckRunOutput.cs b/Octokit/Models/Common/CheckRunOutput.cs deleted file mode 100644 index 84003394a3..0000000000 --- a/Octokit/Models/Common/CheckRunOutput.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunOutput - { - public CheckRunOutput() - { - } - - public CheckRunOutput(string title, string summary, string text, IReadOnlyList annotations, IReadOnlyList images) - { - Title = title; - Summary = summary; - Text = text; - Annotations = annotations; - Images = images; - } - - public string Title { get; protected set; } - public string Summary { get; protected set; } - public string Text { get; protected set; } - public IReadOnlyList Annotations { get; protected set; } - public IReadOnlyList Images { get; protected set; } - - internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "Title: {0}", Title); - } -} \ No newline at end of file diff --git a/Octokit/Models/Common/CheckStatus.cs b/Octokit/Models/Common/CheckStatus.cs new file mode 100644 index 0000000000..c940781a23 --- /dev/null +++ b/Octokit/Models/Common/CheckStatus.cs @@ -0,0 +1,37 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum CheckStatus + { + [Parameter(Value = "queued")] + Queued, + + [Parameter(Value = "in_progress")] + InProgress, + + [Parameter(Value = "completed")] + Completed, + } + + public enum CheckConclusion + { + [Parameter(Value = "success")] + Success, + + [Parameter(Value = "failure")] + Failure, + + [Parameter(Value = "neutral")] + Neutral, + + [Parameter(Value = "cancelled")] + Cancelled, + + [Parameter(Value = "timed_out")] + TimedOut, + + [Parameter(Value = "action_required")] + ActionRequired, + } +} diff --git a/Octokit/Models/Request/CheckRunRequest.cs b/Octokit/Models/Request/CheckRunRequest.cs deleted file mode 100644 index dde60f16d8..0000000000 --- a/Octokit/Models/Request/CheckRunRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Octokit.Internal; -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunRequest : RequestParameters - { - public string CheckName { get; set; } - public CheckStatus? Status { get; set; } - public CheckRunRequestFilter? Filter { get; set; } - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "CheckName: {0}", CheckName); - } - - public enum CheckRunRequestFilter - { - [Parameter(Value = "latest")] - Latest, - [Parameter(Value = "all")] - All - } -} diff --git a/Octokit/Models/Request/CheckRunUpdate.cs b/Octokit/Models/Request/CheckRunUpdate.cs deleted file mode 100644 index 1b2b4d8436..0000000000 --- a/Octokit/Models/Request/CheckRunUpdate.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Octokit.Internal; -using System; -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunUpdate - { - public CheckRunUpdate(string name) - { - Name = name; - } - - public string Name { get; private set; } - public string DetailsUrl { get; set; } - public string ExternalId { get; set; } - public CheckStatus? Status { get; set; } - public DateTimeOffset? StartedAt { get; set; } - public CheckConclusion? Conclusion { get; set; } - public DateTimeOffset? CompletedAt { get; set; } - public CheckRunOutput Output { get; set; } - - internal virtual string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Name: {0}, Conclusion: {1}", Name, Conclusion); - } - - public enum CheckStatus - { - [Parameter(Value = "queued")] - Queued, - - [Parameter(Value = "in_progress")] - InProgress, - - [Parameter(Value = "completed")] - Completed, - } - - public enum CheckConclusion - { - [Parameter(Value = "success")] - Success, - - [Parameter(Value = "failure")] - Failure, - - [Parameter(Value = "neutral")] - Neutral, - - [Parameter(Value = "cancelled")] - Cancelled, - - [Parameter(Value = "timed_out")] - TimedOut, - - [Parameter(Value = "action_required")] - ActionRequired, - } -} diff --git a/Octokit/Models/Request/NewCheckRun.cs b/Octokit/Models/Request/NewCheckRun.cs deleted file mode 100644 index 888e8f4438..0000000000 --- a/Octokit/Models/Request/NewCheckRun.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class NewCheckRun : CheckRunUpdate - { - public NewCheckRun(string name, string headBranch, string headSha) : base(name) - { - HeadBranch = headBranch; - HeadSha = headSha; - } - - public string HeadBranch { get; private set; } - public string HeadSha { get; private set; } - - internal override string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadBranch: {0}, HeadSha{1}, {2}", HeadBranch, HeadSha, base.DebuggerDisplay); - } -} diff --git a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs deleted file mode 100644 index a3b76b1a45..0000000000 --- a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Diagnostics; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunEventPayload : ActivityPayload - { - public string Action { get; protected set; } - public CheckRun CheckRun { get; protected set; } - } -} diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs deleted file mode 100644 index 7038e6fb26..0000000000 --- a/Octokit/Models/Response/CheckRun.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRun - { - public CheckRun() - { - } - - public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion? conclusion, DateTimeOffset startedAt, DateTimeOffset? completedAt, CheckRunOutput output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList pullRequests) - { - Id = id; - HeadSha = headSha; - ExternalId = externalId; - Url = url; - HtmlUrl = htmlUrl; - Status = status; - Conclusion = conclusion; - StartedAt = startedAt; - CompletedAt = completedAt; - Output = output; - Name = name; - CheckSuite = checkSuite; - App = app; - PullRequests = pullRequests; - } - - public long Id { get; protected set; } - public string HeadSha { get; protected set; } - public string ExternalId { get; protected set; } - public string Url { get; protected set; } - public string HtmlUrl { get; protected set; } - public StringEnum Status { get; protected set; } - public StringEnum? Conclusion { get; protected set; } - public DateTimeOffset StartedAt { get; protected set; } - public DateTimeOffset? CompletedAt { get; protected set; } - public CheckRunOutput Output { get; protected set; } - public string Name { get; protected set; } - public CheckSuite CheckSuite { get; protected set; } - public GitHubApp App { get; protected set; } - public IReadOnlyList PullRequests { get; protected set; } - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0}, HeadSha: {1}, Conclusion: {2}", Id, HeadSha, Conclusion); - } -} diff --git a/Octokit/Models/Response/CheckRunList.cs b/Octokit/Models/Response/CheckRunList.cs deleted file mode 100644 index 8db48ca360..0000000000 --- a/Octokit/Models/Response/CheckRunList.cs +++ /dev/null @@ -1,21 +0,0 @@ -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; } - } -} From 0a981872f045289efad706c9be08e86f36a0151b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 2 Jul 2018 15:56:08 +1000 Subject: [PATCH 62/82] naming things is hard --- .../Clients/CheckSuitesClientTests.cs | 4 ++-- ...gerChecksPreference.cs => CheckSuitePreferenceBool.cs} | 8 ++++---- Octokit/Models/Common/CheckSuitePreferences.cs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename Octokit/Models/Common/{CheckSuiteAutoTriggerChecksPreference.cs => CheckSuitePreferenceBool.cs} (61%) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index e49621d75f..a1dda58ab1 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -90,7 +90,7 @@ public async Task UpdatesPreferences() { var preference = new CheckSuitePreferences(new[] { - new CheckSuiteAutoTriggerChecksPreference(Helper.GitHubAppId, false) + new CheckSuitePreferenceBool(Helper.GitHubAppId, false) }); var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); @@ -121,7 +121,7 @@ public async Task CreatesCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Turn off auto creation of check suite for this repo - var preference = new CheckSuitePreferences(new[] { new CheckSuiteAutoTriggerChecksPreference(Helper.GitHubAppId, false) }); + var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(Helper.GitHubAppId, false) }); var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch diff --git a/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs b/Octokit/Models/Common/CheckSuitePreferenceBool.cs similarity index 61% rename from Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs rename to Octokit/Models/Common/CheckSuitePreferenceBool.cs index d16d8f1b96..a783f851fd 100644 --- a/Octokit/Models/Common/CheckSuiteAutoTriggerChecksPreference.cs +++ b/Octokit/Models/Common/CheckSuitePreferenceBool.cs @@ -4,13 +4,13 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuiteAutoTriggerChecksPreference + public class CheckSuitePreferenceBool { - public CheckSuiteAutoTriggerChecksPreference() + public CheckSuitePreferenceBool() { } - public CheckSuiteAutoTriggerChecksPreference(long appId, bool setting) + public CheckSuitePreferenceBool(long appId, bool setting) { AppId = appId; Setting = setting; @@ -20,6 +20,6 @@ public CheckSuiteAutoTriggerChecksPreference(long appId, bool setting) public bool Setting { get; protected set; } - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "{0}: {1}", AppId, Setting ? "On" : "Off"); + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "{0}: {1}", AppId, Setting); } } \ No newline at end of file diff --git a/Octokit/Models/Common/CheckSuitePreferences.cs b/Octokit/Models/Common/CheckSuitePreferences.cs index 88808d0642..e1a26f8a73 100644 --- a/Octokit/Models/Common/CheckSuitePreferences.cs +++ b/Octokit/Models/Common/CheckSuitePreferences.cs @@ -12,12 +12,12 @@ public CheckSuitePreferences() { } - public CheckSuitePreferences(IReadOnlyList autoTriggerChecks) + public CheckSuitePreferences(IReadOnlyList autoTriggerChecks) { AutoTriggerChecks = autoTriggerChecks; } - public IReadOnlyList AutoTriggerChecks { get; protected set; } + public IReadOnlyList AutoTriggerChecks { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "AutoTriggerChecks: {0}", string.Join(", ", AutoTriggerChecks.Select(x => x.DebuggerDisplay))); } From aadf84cb047c2db0583dffe81020af9e44668614 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 5 Jul 2018 16:59:33 +1000 Subject: [PATCH 63/82] oh so many unit tests for CheckSuites methods --- .../Clients/CheckSuitesClientTests.cs | 397 ++++++++++++++++++ Octokit.Tests/Clients/ChecksClientTests.cs | 25 ++ Octokit.Tests/Helpers/MockedIApiConnection.cs | 21 + 3 files changed, 443 insertions(+) create mode 100644 Octokit.Tests/Clients/CheckSuitesClientTests.cs create mode 100644 Octokit.Tests/Clients/ChecksClientTests.cs create mode 100644 Octokit.Tests/Helpers/MockedIApiConnection.cs diff --git a/Octokit.Tests/Clients/CheckSuitesClientTests.cs b/Octokit.Tests/Clients/CheckSuitesClientTests.cs new file mode 100644 index 0000000000..2682dc76a5 --- /dev/null +++ b/Octokit.Tests/Clients/CheckSuitesClientTests.cs @@ -0,0 +1,397 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class CheckSuitesClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new CheckSuitesClient(null)); + } + } + + public class TheGetMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await client.Get("fake", "repo", 1); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "repos/fake/repo/check-suites/1"), + Arg.Any>(), + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await client.Get(1, 1); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "repositories/1/check-suites/1"), + Arg.Any>(), + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await Assert.ThrowsAsync(() => client.Get(null, "repo", 1)); + await Assert.ThrowsAsync(() => client.Get("fake", null, 1)); + await Assert.ThrowsAsync(() => client.Get(null, "repo", 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await Assert.ThrowsAsync(() => client.Get("", "repo", 1)); + await Assert.ThrowsAsync(() => client.Get("fake", "", 1)); + } + } + + public class TheGetAllForReferenceMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await client.GetAllForReference("fake", "repo", "ref"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"), + Args.EmptyDictionary, + "application/vnd.github.antiope-preview+json", + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await client.GetAllForReference(1, "ref"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-suites"), + Args.EmptyDictionary, + "application/vnd.github.antiope-preview+json", + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithRequest() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteRequest + { + AppId = 123, + CheckName = "build" + }; + + await client.GetAllForReference("fake", "repo", "ref", request); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"), + Arg.Is>(x => + x["app_id"] == "123" + && x["check_name"] == "build"), + "application/vnd.github.antiope-preview+json", + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithRequestWithRepositoryId() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteRequest + { + AppId = 123, + CheckName = "build" + }; + + await client.GetAllForReference(1, "ref", request); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-suites"), + Arg.Is>(x => + x["app_id"] == "123" + && x["check_name"] == "build"), + "application/vnd.github.antiope-preview+json", + Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteRequest(); + + await Assert.ThrowsAsync(() => client.GetAllForReference(null, "repo", "ref")); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", null, "ref")); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", null)); + + await Assert.ThrowsAsync(() => client.GetAllForReference(null, "repo", "ref", request)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", null, "ref", request)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", null, request)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "ref", null)); + + await Assert.ThrowsAsync(() => client.GetAllForReference(null, "repo", "ref", request, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", null, "ref", request, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", null, request, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "ref", null, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "ref", request, null)); + + await Assert.ThrowsAsync(() => client.GetAllForReference(1, null)); + + await Assert.ThrowsAsync(() => client.GetAllForReference(1, null, request)); + await Assert.ThrowsAsync(() => client.GetAllForReference(1, "ref", null)); + + await Assert.ThrowsAsync(() => client.GetAllForReference(1, null, request, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference(1, "ref", null, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference(1, "ref", request, null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteRequest(); + + await Assert.ThrowsAsync(() => client.GetAllForReference("", "repo", "ref")); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "", "ref")); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "")); + + await Assert.ThrowsAsync(() => client.GetAllForReference("", "repo", "ref", request)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "", "ref", request)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "", request)); + + await Assert.ThrowsAsync(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None)); + + await Assert.ThrowsAsync(() => client.GetAllForReference(1, "")); + + await Assert.ThrowsAsync(() => client.GetAllForReference(1, "", request)); + + await Assert.ThrowsAsync(() => client.GetAllForReference(1, "", request, ApiOptions.None)); + } + } + + public class TheUpdatePreferencesMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + + await client.UpdatePreferences("fake", "repo", preferences); + + connection.Received().Patch( + Arg.Is(u => u.ToString() == "repos/fake/repo/check-suites/preferences"), + preferences, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + + await client.UpdatePreferences(1, preferences); + + connection.Received().Patch( + Arg.Is(u => u.ToString() == "repositories/1/check-suites/preferences"), + preferences, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + + await Assert.ThrowsAsync(() => client.UpdatePreferences(null, "repo", preferences)); + await Assert.ThrowsAsync(() => client.UpdatePreferences("fake", null, preferences)); + await Assert.ThrowsAsync(() => client.UpdatePreferences("fake", "repo", null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + + await Assert.ThrowsAsync(() => client.UpdatePreferences("", "repo", preferences)); + await Assert.ThrowsAsync(() => client.UpdatePreferences("fake", "", preferences)); + } + } + + public class TheCreateMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + await client.Create("fake", "repo", newCheckSuite); + + connection.Received().Post( + Arg.Is(u => u.ToString() == "repos/fake/repo/check-suites"), + newCheckSuite, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + await client.Create(1, newCheckSuite); + + connection.Received().Post( + Arg.Is(u => u.ToString() == "repositories/1/check-suites"), + newCheckSuite, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + await Assert.ThrowsAsync(() => client.Create(null, "repo", newCheckSuite)); + await Assert.ThrowsAsync(() => client.Create("fake", null, newCheckSuite)); + await Assert.ThrowsAsync(() => client.Create("fake", "repo", null)); + + await Assert.ThrowsAsync(() => client.Create(1, null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + await Assert.ThrowsAsync(() => client.Create("", "repo", newCheckSuite)); + await Assert.ThrowsAsync(() => client.Create("fake", "", newCheckSuite)); + } + } + + public class TheRequestMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteTriggerRequest("123abc"); + + await client.Request("fake", "repo", request); + + connection.Connection.Received().Post( + Arg.Is(u => u.ToString() == "repos/fake/repo/check-suite-requests"), + request, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteTriggerRequest("123abc"); + + await client.Request(1, request); + + connection.Connection.Received().Post( + Arg.Is(u => u.ToString() == "repositories/1/check-suite-requests"), + request, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteTriggerRequest("123abc"); + + await Assert.ThrowsAsync(() => client.Request(null, "repo", request)); + await Assert.ThrowsAsync(() => client.Request("fake", null, request)); + await Assert.ThrowsAsync(() => client.Request("fake", "repo", null)); + + await Assert.ThrowsAsync(() => client.Request(1, null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + var request = new CheckSuiteTriggerRequest("123abc"); + + await Assert.ThrowsAsync(() => client.Request("", "repo", request)); + await Assert.ThrowsAsync(() => client.Request("fake", "", request)); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/ChecksClientTests.cs b/Octokit.Tests/Clients/ChecksClientTests.cs new file mode 100644 index 0000000000..015def3a4d --- /dev/null +++ b/Octokit.Tests/Clients/ChecksClientTests.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + /// + /// Client tests mostly just need to make sure they call the IApiConnection with the correct + /// relative Uri. No need to fake up the response. All *those* tests are in ApiConnectionTests.cs. + /// + public class ChecksClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ChecksClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Helpers/MockedIApiConnection.cs b/Octokit.Tests/Helpers/MockedIApiConnection.cs new file mode 100644 index 0000000000..8d40a37f5d --- /dev/null +++ b/Octokit.Tests/Helpers/MockedIApiConnection.cs @@ -0,0 +1,21 @@ +using System; +using System.Net; +using NSubstitute; + +namespace Octokit.Tests.Helpers +{ + public static class MockedIApiConnection + { + public static IApiConnection PostReturnsHttpStatus(HttpStatusCode status) + { + var connection = Substitute.For(); + connection.Post(Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(status); + + var apiConnection = Substitute.For(); + apiConnection.Connection.Returns(connection); + + return apiConnection; + } + } +} From bb4bf66bc49fc78c5729d60044917859b68f722b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 5 Jul 2018 17:00:11 +1000 Subject: [PATCH 64/82] make client mockable --- Octokit/Clients/CheckSuitesClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 029faa2208..8b91e75b9c 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -7,7 +7,7 @@ namespace Octokit { public class CheckSuitesClient : ApiClient, ICheckSuitesClient { - public CheckSuitesClient(ApiConnection apiConnection) : base(apiConnection) + public CheckSuitesClient(IApiConnection apiConnection) : base(apiConnection) { } From 95ce0c1b8808e418481af52d3a296848533a6226 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 5 Jul 2018 17:00:32 +1000 Subject: [PATCH 65/82] Fix issue with .Max() when no results returned --- Octokit/Clients/CheckSuitesClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 8b91e75b9c..d940c711cf 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -85,7 +85,7 @@ public async Task GetAllForReference(string owner, string n var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); return new CheckSuitesResponse( - results.Max(x => x.TotalCount), + results.Count > 0 ? results.Max(x => x.TotalCount) : 0, results.SelectMany(x => x.CheckSuites).ToList()); } @@ -98,7 +98,7 @@ public async Task GetAllForReference(long repositoryId, str var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); return new CheckSuitesResponse( - results.Max(x => x.TotalCount), + results.Count > 0 ? results.Max(x => x.TotalCount) : 0, results.SelectMany(x => x.CheckSuites).ToList()); } From 47482b6a64650d8ac22dca9bf6d5e7425da482a8 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Thu, 5 Jul 2018 17:00:47 +1000 Subject: [PATCH 66/82] fix request parameter names --- Octokit/Models/Request/CheckSuiteRequest.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Request/CheckSuiteRequest.cs b/Octokit/Models/Request/CheckSuiteRequest.cs index 52c31fc54b..e2f3d71157 100644 --- a/Octokit/Models/Request/CheckSuiteRequest.cs +++ b/Octokit/Models/Request/CheckSuiteRequest.cs @@ -1,12 +1,16 @@ using System.Diagnostics; using System.Globalization; +using Octokit.Internal; namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteRequest : RequestParameters { - public long AppId { get; set; } + [Parameter(Key = "app_id")] + public long? AppId { get; set; } + + [Parameter(Key = "check_name")] public string CheckName { get; set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "AppId: {0}, CheckName: {1}", AppId, CheckName); From c538f47fccfec82ac541f5a2914f6995103f797d Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 7 Jul 2018 20:52:57 +1000 Subject: [PATCH 67/82] add Xml doc comments --- Octokit/Clients/CheckSuitesClient.cs | 203 +++++++++++++++++++++----- Octokit/Clients/ChecksClient.cs | 16 ++ Octokit/Clients/ICheckSuitesClient.cs | 147 ++++++++++++++++++- Octokit/Clients/IChecksClient.cs | 12 ++ 4 files changed, 341 insertions(+), 37 deletions(-) diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index d940c711cf..d827247659 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -1,32 +1,34 @@ -using System.Collections.Generic; -using System.Linq; +using System.Linq; using System.Net; using System.Threading.Tasks; namespace Octokit { + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// public class CheckSuitesClient : ApiClient, ICheckSuitesClient { + /// + /// Initializes a new GitHub Check Suites API client. + /// + /// An API connection public CheckSuitesClient(IApiConnection apiConnection) : base(apiConnection) { } - public Task Create(string owner, string name, NewCheckSuite newCheckSuite) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - - return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); - } - - public Task Create(long repositoryId, NewCheckSuite newCheckSuite) - { - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - - return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); - } - + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The Id of the check suite public Task Get(string owner, string name, long checkSuiteId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -35,11 +37,28 @@ public Task Get(string owner, string name, long checkSuiteId) return ApiConnection.Get(ApiUrls.CheckSuite(owner, name, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); } + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite public Task Get(long repositoryId, long checkSuiteId) { return ApiConnection.Get(ApiUrls.CheckSuite(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for public Task GetAllForReference(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -49,6 +68,14 @@ public Task GetAllForReference(string owner, string name, s return GetAllForReference(owner, name, reference, new CheckSuiteRequest(), ApiOptions.None); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for public Task GetAllForReference(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); @@ -56,6 +83,16 @@ public Task GetAllForReference(long repositoryId, string re return GetAllForReference(repositoryId, reference, new CheckSuiteRequest(), ApiOptions.None); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name public Task GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -66,6 +103,15 @@ public Task GetAllForReference(string owner, string name, s return GetAllForReference(owner, name, reference, request, ApiOptions.None); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name public Task GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); @@ -74,6 +120,17 @@ public Task GetAllForReference(long repositoryId, string re return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response public async Task GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -89,6 +146,16 @@ public async Task GetAllForReference(string owner, string n results.SelectMany(x => x.CheckSuites).ToList()); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response public async Task GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); @@ -102,6 +169,81 @@ public async Task GetAllForReference(long repositoryId, str results.SelectMany(x => x.CheckSuites).ToList()); } + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The check suite preferences + public Task UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); + } + + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The check suite preferences + public Task UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) + { + Ensure.ArgumentNotNull(preferences, nameof(preferences)); + + return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview); + } + + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite to create + public Task Create(string owner, string name, NewCheckSuite newCheckSuite) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return ApiConnection.Post(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); + } + + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite to create + public Task Create(long repositoryId, NewCheckSuite newCheckSuite) + { + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return ApiConnection.Post(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); + } + + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite request public async Task Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -118,7 +260,14 @@ public async Task Request(string owner, string name, CheckSuiteTriggerRequ return httpStatusCode == HttpStatusCode.Created; } - + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite request public async Task Request(long repositoryId, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); @@ -132,21 +281,5 @@ public async Task Request(long repositoryId, CheckSuiteTriggerRequest requ return httpStatusCode == HttpStatusCode.Created; } - - public Task UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(preferences, nameof(preferences)); - - return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); - } - - public Task UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) - { - Ensure.ArgumentNotNull(preferences, nameof(preferences)); - - return ApiConnection.Patch(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview); - } } } \ No newline at end of file diff --git a/Octokit/Clients/ChecksClient.cs b/Octokit/Clients/ChecksClient.cs index c6ceea00ae..11ce4f8da4 100644 --- a/Octokit/Clients/ChecksClient.cs +++ b/Octokit/Clients/ChecksClient.cs @@ -1,9 +1,25 @@ namespace Octokit { + /// + /// A client for GitHub's Checks API. + /// + /// + /// See the Checks API documentation for more information. + /// public class ChecksClient : IChecksClient { + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// public ICheckSuitesClient Suite { get; private set; } + /// + /// Initializes a new GitHub Checks API client. + /// + /// An API connection public ChecksClient(ApiConnection apiConnection) { Suite = new CheckSuitesClient(apiConnection); diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index addcadb554..1e35b8190f 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -1,23 +1,166 @@ -using System.Collections.Generic; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Octokit { + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// public interface ICheckSuitesClient { + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The Id of the check suite Task Get(string owner, string name, long checkSuiteId); + + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite Task Get(long repositoryId, long checkSuiteId); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for Task GetAllForReference(string owner, string name, string reference); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for Task GetAllForReference(long repositoryId, string reference); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name Task GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name Task GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response Task GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response Task GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The check suite preferences Task UpdatePreferences(string owner, string name, CheckSuitePreferences preferences); + + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The check suite preferences Task UpdatePreferences(long repositoryId, CheckSuitePreferences preferences); + + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite to create Task Create(string owner, string name, NewCheckSuite newCheckSuite); + + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite to create Task Create(long repositoryId, NewCheckSuite newCheckSuite); + + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite request Task Request(string owner, string name, CheckSuiteTriggerRequest request); + + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite request Task Request(long repositoryId, CheckSuiteTriggerRequest request); } } \ No newline at end of file diff --git a/Octokit/Clients/IChecksClient.cs b/Octokit/Clients/IChecksClient.cs index b929690378..c973bc1e90 100644 --- a/Octokit/Clients/IChecksClient.cs +++ b/Octokit/Clients/IChecksClient.cs @@ -1,7 +1,19 @@ namespace Octokit { + /// + /// A client for GitHub's Checks API. + /// + /// + /// See the Checks API documentation for more information. + /// public interface IChecksClient { + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// ICheckSuitesClient Suite { get; } } } From 02d6ebec30e79198b9beb61124eb71a587d03110 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 7 Jul 2018 21:15:52 +1000 Subject: [PATCH 68/82] Add XmlDoc comments to request/common model objects --- Octokit/Models/Common/CheckSuitePreferenceBool.cs | 14 ++++++++++++++ Octokit/Models/Common/CheckSuitePreferences.cs | 10 ++++++++++ Octokit/Models/Request/CheckSuiteRequest.cs | 9 +++++++++ Octokit/Models/Request/CheckSuiteTriggerRequest.cs | 10 ++++++++++ 4 files changed, 43 insertions(+) diff --git a/Octokit/Models/Common/CheckSuitePreferenceBool.cs b/Octokit/Models/Common/CheckSuitePreferenceBool.cs index a783f851fd..c85615c73f 100644 --- a/Octokit/Models/Common/CheckSuitePreferenceBool.cs +++ b/Octokit/Models/Common/CheckSuitePreferenceBool.cs @@ -3,6 +3,9 @@ namespace Octokit { + /// + /// Enables or disables automatic creation of CheckSuite events upon pushes to the repository + /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuitePreferenceBool { @@ -10,14 +13,25 @@ public CheckSuitePreferenceBool() { } + /// + /// Enables or disables automatic creation of CheckSuite events upon pushes to the repository + /// + /// The Id of the GitHub App (required) + /// Set to true to enable automatic creation of CheckSuite events upon pushes to the repository, or false to disable them (required) public CheckSuitePreferenceBool(long appId, bool setting) { AppId = appId; Setting = setting; } + /// + /// The Id of the GitHub App + /// public long AppId { get; protected set; } + /// + /// Set to true to enable automatic creation of CheckSuite events upon pushes to the repository, or false to disable them + /// public bool Setting { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "{0}: {1}", AppId, Setting); diff --git a/Octokit/Models/Common/CheckSuitePreferences.cs b/Octokit/Models/Common/CheckSuitePreferences.cs index e1a26f8a73..c582d0ed33 100644 --- a/Octokit/Models/Common/CheckSuitePreferences.cs +++ b/Octokit/Models/Common/CheckSuitePreferences.cs @@ -5,6 +5,9 @@ namespace Octokit { + /// + /// Check Suite preferences + /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuitePreferences { @@ -12,11 +15,18 @@ public CheckSuitePreferences() { } + /// + /// Check Suite preferences + /// + /// Enables or disables automatic creation of CheckSuite events upon pushes to the repository. Enabled by default public CheckSuitePreferences(IReadOnlyList autoTriggerChecks) { AutoTriggerChecks = autoTriggerChecks; } + /// + /// Enables or disables automatic creation of CheckSuite events upon pushes to the repository. Enabled by default + /// public IReadOnlyList AutoTriggerChecks { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "AutoTriggerChecks: {0}", string.Join(", ", AutoTriggerChecks.Select(x => x.DebuggerDisplay))); diff --git a/Octokit/Models/Request/CheckSuiteRequest.cs b/Octokit/Models/Request/CheckSuiteRequest.cs index e2f3d71157..58b9a52c8a 100644 --- a/Octokit/Models/Request/CheckSuiteRequest.cs +++ b/Octokit/Models/Request/CheckSuiteRequest.cs @@ -4,12 +4,21 @@ namespace Octokit { + /// + /// Details to filter a check suite request, such as by App Id or check run name + /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteRequest : RequestParameters { + /// + /// Filters check suites by GitHub App Id + /// [Parameter(Key = "app_id")] public long? AppId { get; set; } + /// + /// Filters check suites by the name of the check run + /// [Parameter(Key = "check_name")] public string CheckName { get; set; } diff --git a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs index 883a910c5e..564f903d31 100644 --- a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs +++ b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs @@ -3,14 +3,24 @@ namespace Octokit { + /// + /// Request to trigger the creation of a check suite + /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteTriggerRequest { + /// + /// Request to trigger the creation of a check suite + /// + /// The sha of the head commit (required) public CheckSuiteTriggerRequest(string headSha) { HeadSha = headSha; } + /// + /// The sha of the head commit + /// public string HeadSha { get; private set; } internal virtual string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadSha: {0}", HeadSha); From 2a2929c091a0d1c4be83394ae2872d05c7f359e9 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 7 Jul 2018 21:17:21 +1000 Subject: [PATCH 69/82] rename class to match usage --- .../Clients/CheckSuitesClientTests.cs | 4 ++-- Octokit.Tests/Clients/CheckSuitesClientTests.cs | 8 ++++---- ...eferenceBool.cs => CheckSuitePreferenceAutoTrigger.cs} | 6 +++--- Octokit/Models/Common/CheckSuitePreferences.cs | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) rename Octokit/Models/Common/{CheckSuitePreferenceBool.cs => CheckSuitePreferenceAutoTrigger.cs} (87%) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index a1dda58ab1..34fd11f891 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -90,7 +90,7 @@ public async Task UpdatesPreferences() { var preference = new CheckSuitePreferences(new[] { - new CheckSuitePreferenceBool(Helper.GitHubAppId, false) + new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); @@ -121,7 +121,7 @@ public async Task CreatesCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Turn off auto creation of check suite for this repo - var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(Helper.GitHubAppId, false) }); + var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch diff --git a/Octokit.Tests/Clients/CheckSuitesClientTests.cs b/Octokit.Tests/Clients/CheckSuitesClientTests.cs index 2682dc76a5..b9424cd8a1 100644 --- a/Octokit.Tests/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests/Clients/CheckSuitesClientTests.cs @@ -218,7 +218,7 @@ public async Task RequestsCorrectUrl() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); await client.UpdatePreferences("fake", "repo", preferences); @@ -234,7 +234,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); await client.UpdatePreferences(1, preferences); @@ -250,7 +250,7 @@ public async Task EnsuresNonNullArguments() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); await Assert.ThrowsAsync(() => client.UpdatePreferences(null, "repo", preferences)); await Assert.ThrowsAsync(() => client.UpdatePreferences("fake", null, preferences)); @@ -263,7 +263,7 @@ public async Task EnsuresNonEmptyArguments() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceBool(123, true) }); + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); await Assert.ThrowsAsync(() => client.UpdatePreferences("", "repo", preferences)); await Assert.ThrowsAsync(() => client.UpdatePreferences("fake", "", preferences)); diff --git a/Octokit/Models/Common/CheckSuitePreferenceBool.cs b/Octokit/Models/Common/CheckSuitePreferenceAutoTrigger.cs similarity index 87% rename from Octokit/Models/Common/CheckSuitePreferenceBool.cs rename to Octokit/Models/Common/CheckSuitePreferenceAutoTrigger.cs index c85615c73f..0750446c51 100644 --- a/Octokit/Models/Common/CheckSuitePreferenceBool.cs +++ b/Octokit/Models/Common/CheckSuitePreferenceAutoTrigger.cs @@ -7,9 +7,9 @@ namespace Octokit /// Enables or disables automatic creation of CheckSuite events upon pushes to the repository /// [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuitePreferenceBool + public class CheckSuitePreferenceAutoTrigger { - public CheckSuitePreferenceBool() + public CheckSuitePreferenceAutoTrigger() { } @@ -18,7 +18,7 @@ public CheckSuitePreferenceBool() /// /// The Id of the GitHub App (required) /// Set to true to enable automatic creation of CheckSuite events upon pushes to the repository, or false to disable them (required) - public CheckSuitePreferenceBool(long appId, bool setting) + public CheckSuitePreferenceAutoTrigger(long appId, bool setting) { AppId = appId; Setting = setting; diff --git a/Octokit/Models/Common/CheckSuitePreferences.cs b/Octokit/Models/Common/CheckSuitePreferences.cs index c582d0ed33..8a3ad94ca4 100644 --- a/Octokit/Models/Common/CheckSuitePreferences.cs +++ b/Octokit/Models/Common/CheckSuitePreferences.cs @@ -19,7 +19,7 @@ public CheckSuitePreferences() /// Check Suite preferences /// /// Enables or disables automatic creation of CheckSuite events upon pushes to the repository. Enabled by default - public CheckSuitePreferences(IReadOnlyList autoTriggerChecks) + public CheckSuitePreferences(IReadOnlyList autoTriggerChecks) { AutoTriggerChecks = autoTriggerChecks; } @@ -27,7 +27,7 @@ public CheckSuitePreferences(IReadOnlyList autoTrigger /// /// Enables or disables automatic creation of CheckSuite events upon pushes to the repository. Enabled by default /// - public IReadOnlyList AutoTriggerChecks { get; protected set; } + public IReadOnlyList AutoTriggerChecks { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "AutoTriggerChecks: {0}", string.Join(", ", AutoTriggerChecks.Select(x => x.DebuggerDisplay))); } From a7a743eeccd5d9654f813bac9fe56eaa669747bb Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 8 Jul 2018 10:35:57 +1000 Subject: [PATCH 70/82] tidy ups --- Octokit.Tests/Clients/ChecksClientTests.cs | 8 -------- Octokit/Clients/ChecksClient.cs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Octokit.Tests/Clients/ChecksClientTests.cs b/Octokit.Tests/Clients/ChecksClientTests.cs index 015def3a4d..dfed4391d5 100644 --- a/Octokit.Tests/Clients/ChecksClientTests.cs +++ b/Octokit.Tests/Clients/ChecksClientTests.cs @@ -1,16 +1,8 @@ using System; -using System.Collections.Generic; -using System.Net; -using System.Threading.Tasks; -using NSubstitute; using Xunit; namespace Octokit.Tests.Clients { - /// - /// Client tests mostly just need to make sure they call the IApiConnection with the correct - /// relative Uri. No need to fake up the response. All *those* tests are in ApiConnectionTests.cs. - /// public class ChecksClientTests { public class TheCtor diff --git a/Octokit/Clients/ChecksClient.cs b/Octokit/Clients/ChecksClient.cs index 11ce4f8da4..17dcfcb766 100644 --- a/Octokit/Clients/ChecksClient.cs +++ b/Octokit/Clients/ChecksClient.cs @@ -8,14 +8,6 @@ /// public class ChecksClient : IChecksClient { - /// - /// A client for GitHub's Check Suites API. - /// - /// - /// See the Check Suites API documentation for more information. - /// - public ICheckSuitesClient Suite { get; private set; } - /// /// Initializes a new GitHub Checks API client. /// @@ -24,5 +16,13 @@ public ChecksClient(ApiConnection apiConnection) { Suite = new CheckSuitesClient(apiConnection); } + + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// + public ICheckSuitesClient Suite { get; private set; } } } \ No newline at end of file From 7e003d921612a183919571ccd4742f767e141b0c Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 8 Jul 2018 10:36:15 +1000 Subject: [PATCH 71/82] xmldoc for observable clients --- .../Clients/IObservableCheckSuitesClient.cs | 144 +++++++++++++++ .../Clients/IObservableChecksClient.cs | 12 ++ .../Clients/ObservableCheckSuitesClient.cs | 167 ++++++++++++++++-- .../Clients/ObservableChecksClient.cs | 12 ++ 4 files changed, 317 insertions(+), 18 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs index 74503029fd..07e0a5937b 100644 --- a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -2,21 +2,165 @@ namespace Octokit.Reactive { + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// public interface IObservableCheckSuitesClient { + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The Id of the check suite IObservable Get(string owner, string name, long checkSuiteId); + + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite IObservable Get(long repositoryId, long checkSuiteId); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for IObservable GetAllForReference(string owner, string name, string reference); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for IObservable GetAllForReference(long repositoryId, string reference); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options); + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options); + + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The check suite preferences IObservable UpdatePreferences(string owner, string name, CheckSuitePreferences preferences); + + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The check suite preferences IObservable UpdatePreferences(long repositoryId, CheckSuitePreferences preferences); + + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite to create IObservable Create(string owner, string name, NewCheckSuite newCheckSuite); + + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite to create IObservable Create(long repositoryId, NewCheckSuite newCheckSuite); + + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite request IObservable Request(string owner, string name, CheckSuiteTriggerRequest request); + + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite request IObservable Request(long repositoryId, CheckSuiteTriggerRequest request); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableChecksClient.cs b/Octokit.Reactive/Clients/IObservableChecksClient.cs index db486e507e..a5127ae78f 100644 --- a/Octokit.Reactive/Clients/IObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/IObservableChecksClient.cs @@ -1,7 +1,19 @@ namespace Octokit.Reactive { + /// + /// A client for GitHub's Checks API. + /// + /// + /// See the Checks API documentation for more information. + /// public interface IObservableChecksClient { + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// IObservableCheckSuitesClient Suite { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index fc7a364afa..22482858f7 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -4,6 +4,12 @@ namespace Octokit.Reactive { + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// public class ObservableCheckSuitesClient : IObservableCheckSuitesClient { readonly ICheckSuitesClient _client; @@ -15,22 +21,15 @@ public ObservableCheckSuitesClient(IGitHubClient gitHubClient) _connection = gitHubClient.Connection; } - public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - - return _client.Create(owner, name, newCheckSuite).ToObservable(); - } - - public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) - { - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - - return _client.Create(repositoryId, newCheckSuite).ToObservable(); - } - + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The Id of the check suite public IObservable Get(string owner, string name, long checkSuiteId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -39,11 +38,28 @@ public IObservable Get(string owner, string name, long checkSuiteId) return _client.Get(owner, name, checkSuiteId).ToObservable(); } + /// + /// Gets a single Check Suite by Id + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite public IObservable Get(long repositoryId, long checkSuiteId) { return _client.Get(repositoryId, checkSuiteId).ToObservable(); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for public IObservable GetAllForReference(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -53,6 +69,14 @@ public IObservable GetAllForReference(string owner, string return GetAllForReference(owner, name, reference, new CheckSuiteRequest(), ApiOptions.None); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for public IObservable GetAllForReference(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); @@ -60,6 +84,16 @@ public IObservable GetAllForReference(long repositoryId, st return GetAllForReference(repositoryId, reference, new CheckSuiteRequest(), ApiOptions.None); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -70,6 +104,15 @@ public IObservable GetAllForReference(string owner, string return GetAllForReference(owner, name, reference, request, ApiOptions.None); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); @@ -77,7 +120,18 @@ public IObservable GetAllForReference(long repositoryId, st return GetAllForReference(repositoryId, reference, request, ApiOptions.None); } - + + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response public IObservable GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -89,15 +143,67 @@ public IObservable GetAllForReference(string owner, string throw new NotImplementedException(); } + /// + /// Lists Check Suites for a commit reference (SHA, branch name or tag name) + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The reference (SHA, branch name or tag name) to list check suites for + /// Details to filter the request, such as by App Id or Check Name + /// Options to change the API response public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); throw new NotImplementedException(); } + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// The check suite preferences + public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(owner, name, newCheckSuite).ToObservable(); + } + + /// + /// Updates Check Suites prefrences on a repository, such as disabling automatic creation when code is pushed + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The check suite preferences + public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) + { + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(repositoryId, newCheckSuite).ToObservable(); + } + + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite to create public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -106,11 +212,28 @@ public IObservable Request(string owner, string name, CheckSuiteTriggerReq return _client.Request(owner, name, request).ToObservable(); } + /// + /// Creates a new Check Suite + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite to create public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) { return _client.Request(repositoryId, request).ToObservable(); } + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Details of the Check Suite request public IObservable UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -120,6 +243,14 @@ public IObservable UpdatePreferences(string owner return _client.UpdatePreferences(owner, name, preferences).ToObservable(); } + /// + /// Triggers GitHub to create a new check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// Details of the Check Suite request public IObservable UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) { Ensure.ArgumentNotNull(preferences, nameof(preferences)); diff --git a/Octokit.Reactive/Clients/ObservableChecksClient.cs b/Octokit.Reactive/Clients/ObservableChecksClient.cs index 1eb8c0e384..1d5d7d1a36 100644 --- a/Octokit.Reactive/Clients/ObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/ObservableChecksClient.cs @@ -1,5 +1,11 @@ namespace Octokit.Reactive { + /// + /// A client for GitHub's Checks API. + /// + /// + /// See the Checks API documentation for more information. + /// public class ObservableChecksClient : IObservableChecksClient { public ObservableChecksClient(IGitHubClient gitHubClient) @@ -7,6 +13,12 @@ public ObservableChecksClient(IGitHubClient gitHubClient) Suite = new ObservableCheckSuitesClient(gitHubClient); } + /// + /// A client for GitHub's Check Suites API. + /// + /// + /// See the Check Suites API documentation for more information. + /// public IObservableCheckSuitesClient Suite { get; private set; } } } \ No newline at end of file From da3f94491205f94c53bab9f5e5c601b02eab785d Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 19:48:52 +1000 Subject: [PATCH 72/82] fix method order --- .../Clients/ObservableCheckSuitesClient.cs | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 22482858f7..9a8498658c 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -171,13 +171,13 @@ public IObservable GetAllForReference(long repositoryId, st /// The owner of the repository /// The name of the repository /// The check suite preferences - public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) + public IObservable UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); - return _client.Create(owner, name, newCheckSuite).ToObservable(); + return _client.UpdatePreferences(owner, name, preferences).ToObservable(); } /// @@ -188,11 +188,11 @@ public IObservable Create(string owner, string name, NewCheckSuite n /// /// The Id of the repository /// The check suite preferences - public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) + public IObservable UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) { - Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + Ensure.ArgumentNotNull(preferences, nameof(preferences)); - return _client.Create(repositoryId, newCheckSuite).ToObservable(); + return _client.UpdatePreferences(repositoryId, preferences).ToObservable(); } /// @@ -204,12 +204,13 @@ public IObservable Create(long repositoryId, NewCheckSuite newCheckS /// The owner of the repository /// The name of the repository /// Details of the Check Suite to create - public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) + public IObservable Create(string owner, string name, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - return _client.Request(owner, name, request).ToObservable(); + return _client.Create(owner, name, newCheckSuite).ToObservable(); } /// @@ -220,9 +221,11 @@ public IObservable Request(string owner, string name, CheckSuiteTriggerReq /// /// The Id of the repository /// Details of the Check Suite to create - public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) + public IObservable Create(long repositoryId, NewCheckSuite newCheckSuite) { - return _client.Request(repositoryId, request).ToObservable(); + Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); + + return _client.Create(repositoryId, newCheckSuite).ToObservable(); } /// @@ -234,13 +237,13 @@ public IObservable Request(long repositoryId, CheckSuiteTriggerRequest req /// The owner of the repository /// The name of the repository /// Details of the Check Suite request - public IObservable UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) + public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Ensure.ArgumentNotNull(preferences, nameof(preferences)); + Ensure.ArgumentNotNull(request, nameof(request)); - return _client.UpdatePreferences(owner, name, preferences).ToObservable(); + return _client.Request(owner, name, request).ToObservable(); } /// @@ -251,11 +254,12 @@ public IObservable UpdatePreferences(string owner /// /// The Id of the repository /// Details of the Check Suite request - public IObservable UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) + + public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) { - Ensure.ArgumentNotNull(preferences, nameof(preferences)); + Ensure.ArgumentNotNull(request, nameof(request)); - return _client.UpdatePreferences(repositoryId, preferences).ToObservable(); + return _client.Request(repositoryId, request).ToObservable(); } } } \ No newline at end of file From 56062d2c25a15ae7c9030ebaa9e2dc79ac9a3229 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 19:50:03 +1000 Subject: [PATCH 73/82] add observable unit tests and get them passing --- .../Clients/ObservableCheckSuitesClient.cs | 14 +- .../ObservableCheckSuitesClientTests.cs | 373 ++++++++++++++++++ 2 files changed, 381 insertions(+), 6 deletions(-) create mode 100644 Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 9a8498658c..40b080dcff 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -15,10 +15,12 @@ public class ObservableCheckSuitesClient : IObservableCheckSuitesClient readonly ICheckSuitesClient _client; readonly IConnection _connection; - public ObservableCheckSuitesClient(IGitHubClient gitHubClient) + public ObservableCheckSuitesClient(IGitHubClient client) { - _client = gitHubClient.Check.Suite; - _connection = gitHubClient.Connection; + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Check.Suite; + _connection = client.Connection; } /// @@ -140,7 +142,7 @@ public IObservable GetAllForReference(string owner, string Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - throw new NotImplementedException(); + return _connection.GetAndFlattenAllPages(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); } /// @@ -155,11 +157,11 @@ public IObservable GetAllForReference(string owner, string /// Options to change the API response public IObservable GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { + Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - throw new NotImplementedException(); + return _connection.GetAndFlattenAllPages(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); } /// diff --git a/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs new file mode 100644 index 0000000000..0c9fb1e2d5 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs @@ -0,0 +1,373 @@ +using System; +using System.Collections.Generic; +using System.Reactive.Threading.Tasks; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class ObservableObservableCheckSuitesClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableCheckSuitesClient(null)); + } + } + + public class TheGetMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + client.Get("fake", "repo", 1); + + gitHubClient.Check.Suite.Received().Get("fake", "repo", 1); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + client.Get(1, 1); + + gitHubClient.Check.Suite.Received().Get(1, 1); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + Assert.Throws(() => client.Get(null, "repo", 1)); + Assert.Throws(() => client.Get("fake", null, 1)); + Assert.Throws(() => client.Get(null, "repo", 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + Assert.Throws(() => client.Get("", "repo", 1)); + Assert.Throws(() => client.Get("fake", "", 1)); + } + } + + public class TheGetAllForReferenceMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var gitHubClient = new GitHubClient(connection); + var client = new ObservableCheckSuitesClient(gitHubClient); + + client.GetAllForReference("fake", "repo", "ref"); + + connection.Received().Get>( + Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"), + Args.EmptyDictionary, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For(); + var gitHubClient = new GitHubClient(connection); + var client = new ObservableCheckSuitesClient(gitHubClient); + + client.GetAllForReference(1, "ref"); + + connection.Received().Get>( + Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-suites"), + Args.EmptyDictionary, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRequest() + { + var connection = Substitute.For(); + var gitHubClient = new GitHubClient(connection); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteRequest + { + AppId = 123, + CheckName = "build" + }; + + client.GetAllForReference("fake", "repo", "ref", request); + + connection.Received().Get>( + Arg.Is(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"), + Arg.Is>(x => + x["app_id"] == "123" + && x["check_name"] == "build"), + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRequestWithRepositoryId() + { + var connection = Substitute.For(); + var gitHubClient = new GitHubClient(connection); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteRequest + { + AppId = 123, + CheckName = "build" + }; + + client.GetAllForReference(1, "ref", request); + + connection.Received().Get>( + Arg.Is(u => u.ToString() == "repositories/1/commits/ref/check-suites"), + Arg.Is>(x => + x["app_id"] == "123" + && x["check_name"] == "build"), + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteRequest(); + + Assert.Throws(() => client.GetAllForReference(null, "repo", "ref")); + Assert.Throws(() => client.GetAllForReference("fake", null, "ref")); + Assert.Throws(() => client.GetAllForReference("fake", "repo", null)); + + Assert.Throws(() => client.GetAllForReference(null, "repo", "ref", request)); + Assert.Throws(() => client.GetAllForReference("fake", null, "ref", request)); + Assert.Throws(() => client.GetAllForReference("fake", "repo", null, request)); + Assert.Throws(() => client.GetAllForReference("fake", "repo", "ref", null)); + + Assert.Throws(() => client.GetAllForReference(null, "repo", "ref", request, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference("fake", null, "ref", request, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference("fake", "repo", null, request, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference("fake", "repo", "ref", null, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference("fake", "repo", "ref", request, null)); + + Assert.Throws(() => client.GetAllForReference(1, null)); + + Assert.Throws(() => client.GetAllForReference(1, null, request)); + Assert.Throws(() => client.GetAllForReference(1, "ref", null)); + + Assert.Throws(() => client.GetAllForReference(1, null, request, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference(1, "ref", null, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference(1, "ref", request, null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteRequest(); + + Assert.Throws(() => client.GetAllForReference("", "repo", "ref")); + Assert.Throws(() => client.GetAllForReference("fake", "", "ref")); + Assert.Throws(() => client.GetAllForReference("fake", "repo", "")); + + Assert.Throws(() => client.GetAllForReference("", "repo", "ref", request)); + Assert.Throws(() => client.GetAllForReference("fake", "", "ref", request)); + Assert.Throws(() => client.GetAllForReference("fake", "repo", "", request)); + + Assert.Throws(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None)); + Assert.Throws(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None)); + + Assert.Throws(() => client.GetAllForReference(1, "")); + + Assert.Throws(() => client.GetAllForReference(1, "", request)); + + Assert.Throws(() => client.GetAllForReference(1, "", request, ApiOptions.None)); + } + } + + public class TheUpdatePreferencesMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); + + client.UpdatePreferences("fake", "repo", preferences); + + gitHubClient.Check.Suite.Received().UpdatePreferences("fake", "repo", preferences); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); + + client.UpdatePreferences(1, preferences); + + gitHubClient.Check.Suite.Received().UpdatePreferences(1, preferences); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); + + Assert.Throws(() => client.UpdatePreferences(null, "repo", preferences)); + Assert.Throws(() => client.UpdatePreferences("fake", null, preferences)); + Assert.Throws(() => client.UpdatePreferences("fake", "repo", null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) }); + + Assert.Throws(() => client.UpdatePreferences("", "repo", preferences)); + Assert.Throws(() => client.UpdatePreferences("fake", "", preferences)); + } + } + + public class TheCreateMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + client.Create("fake", "repo", newCheckSuite); + + gitHubClient.Check.Suite.Received().Create("fake", "repo", newCheckSuite); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + client.Create(1, newCheckSuite); + + gitHubClient.Check.Suite.Received().Create(1, newCheckSuite); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + Assert.Throws(() => client.Create(null, "repo", newCheckSuite)); + Assert.Throws(() => client.Create("fake", null, newCheckSuite)); + Assert.Throws(() => client.Create("fake", "repo", null)); + + Assert.Throws(() => client.Create(1, null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + + Assert.Throws(() => client.Create("", "repo", newCheckSuite)); + Assert.Throws(() => client.Create("fake", "", newCheckSuite)); + } + } + + public class TheRequestMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteTriggerRequest("123abc"); + + client.Request("fake", "repo", request); + + gitHubClient.Check.Suite.Received().Request("fake", "repo", request); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteTriggerRequest("123abc"); + + client.Request(1, request); + + gitHubClient.Check.Suite.Received().Request(1, request); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteTriggerRequest("123abc"); + + Assert.Throws(() => client.Request(null, "repo", request)); + Assert.Throws(() => client.Request("fake", null, request)); + Assert.Throws(() => client.Request("fake", "repo", null)); + + Assert.Throws(() => client.Request(1, null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + var request = new CheckSuiteTriggerRequest("123abc"); + + Assert.Throws(() => client.Request("", "repo", request)); + Assert.Throws(() => client.Request("fake", "", request)); + } + } + } +} From b1d3796dd8e697b3c80ec9c4add726fec7e89c43 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 19:54:40 +1000 Subject: [PATCH 74/82] Add Observable unit tests and get them passing --- .../Clients/ObservableChecksClient.cs | 6 ++++-- .../Reactive/ObservableChecksClientTests.cs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 Octokit.Tests/Reactive/ObservableChecksClientTests.cs diff --git a/Octokit.Reactive/Clients/ObservableChecksClient.cs b/Octokit.Reactive/Clients/ObservableChecksClient.cs index 1d5d7d1a36..90c4b72dcd 100644 --- a/Octokit.Reactive/Clients/ObservableChecksClient.cs +++ b/Octokit.Reactive/Clients/ObservableChecksClient.cs @@ -8,9 +8,11 @@ /// public class ObservableChecksClient : IObservableChecksClient { - public ObservableChecksClient(IGitHubClient gitHubClient) + public ObservableChecksClient(IGitHubClient client) { - Suite = new ObservableCheckSuitesClient(gitHubClient); + Ensure.ArgumentNotNull(client, nameof(client)); + + Suite = new ObservableCheckSuitesClient(client); } /// diff --git a/Octokit.Tests/Reactive/ObservableChecksClientTests.cs b/Octokit.Tests/Reactive/ObservableChecksClientTests.cs new file mode 100644 index 0000000000..6fbfd3a1be --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableChecksClientTests.cs @@ -0,0 +1,18 @@ +using System; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class ObservableChecksClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableChecksClient(null)); + } + } + } +} From 18b68bf3be2232aaf2ac030ea29dbec4884e0265 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 20:30:57 +1000 Subject: [PATCH 75/82] add observable integration tests --- .../ObservableCheckSuitesClientTests.cs | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs new file mode 100644 index 0000000000..dcd8d23425 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs @@ -0,0 +1,174 @@ +using System.Linq; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Octokit.Tests.Integration.Helpers; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableCheckSuitesClientTests + { + public class TheGetMethod + { + IObservableGitHubClient _github; + IObservableGitHubClient _githubAppInstallation; + + public TheGetMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName)); + } + + [GitHubAppsTest] + public async Task GetsCheckSuite() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Need to get a CheckSuiteId so we can test the Get method + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); + + // Get Check Suite by Id + var result = await _github.Check.Suite.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); + + // Check result + Assert.Equal(checkSuite.Id, result.Id); + Assert.Equal(headCommit.Sha, result.HeadSha); + } + } + } + + public class TheGetAllForReferenceMethod + { + IObservableGitHubClient _github; + IObservableGitHubClient _githubAppInstallation; + + public TheGetAllForReferenceMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName)); + } + + [GitHubAppsTest] + public async Task GetsAllCheckSuites() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); + + Assert.NotEmpty(checkSuites.CheckSuites); + foreach (var checkSuite in checkSuites.CheckSuites) + { + Assert.Equal(headCommit.Sha, checkSuite.HeadSha); + } + } + } + } + + public class TheUpdatePreferencesMethod + { + IObservableGitHubClient _github; + IObservableGitHubClient _githubAppInstallation; + + public TheUpdatePreferencesMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName)); + } + + [GitHubAppsTest] + public async Task UpdatesPreferences() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var preference = new CheckSuitePreferences(new[] + { + new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) + }); + + var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + + Assert.Equal(repoContext.RepositoryId, response.Repository.Id); + Assert.Equal(Helper.GitHubAppId, response.Preferences.AutoTriggerChecks[0].AppId); + Assert.Equal(false, response.Preferences.AutoTriggerChecks[0].Setting); + } + } + } + + public class TheCreateMethod + { + IObservableGitHubClient _github; + IObservableGitHubClient _githubAppInstallation; + + public TheCreateMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName)); + } + + [GitHubAppsTest] + public async Task CreatesCheckSuite() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Turn off auto creation of check suite for this repo + var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); + var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + + // Create a new feature branch + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); + + // Create a check suite for the feature branch + var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha) + { + HeadBranch = "my-feature" + }; + var result = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckSuite); + + // Check result + Assert.NotNull(result); + Assert.Equal(featureBranch.Object.Sha, result.HeadSha); + } + } + } + + public class TheRequestMethod + { + IObservableGitHubClient _github; + IObservableGitHubClient _githubAppInstallation; + + public TheRequestMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + // Authenticate as a GitHubApp Installation + _githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName)); + } + + [GitHubAppsTest] + public async Task RequestsCheckSuite() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryOwner, repoContext.RepositoryName, new CheckSuiteTriggerRequest(headCommit.Sha)); + + Assert.True(result); + } + } + } + } +} From 6b2603a7badff87bab3ba3bb810fcff8f5df763b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 20:34:35 +1000 Subject: [PATCH 76/82] tidy up ApiUrl method name --- Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs | 4 ++-- Octokit/Clients/CheckSuitesClient.cs | 4 ++-- Octokit/Helpers/ApiUrls.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 40b080dcff..6f854baf80 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -142,7 +142,7 @@ public IObservable GetAllForReference(string owner, string Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages(ApiUrls.CheckSuitesForReference(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); } /// @@ -161,7 +161,7 @@ public IObservable GetAllForReference(long repositoryId, st Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages(ApiUrls.CheckSuitesForReference(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); } /// diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index d827247659..549405a03c 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -139,7 +139,7 @@ public async Task GetAllForReference(string owner, string n Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll(ApiUrls.CheckSuitesForReference(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); return new CheckSuitesResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -162,7 +162,7 @@ public async Task GetAllForReference(long repositoryId, str Ensure.ArgumentNotNull(options, nameof(options)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - var results = await ApiConnection.GetAll(ApiUrls.ReferenceCheckSuites(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll(ApiUrls.CheckSuitesForReference(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); return new CheckSuitesResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 6f1a644dc2..e06d70cefb 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -3858,7 +3858,7 @@ public static Uri CheckSuite(string owner, string repo, long id) /// The Id of the repository /// The git reference /// The that returns the check suites for the specified reference. - public static Uri ReferenceCheckSuites(long repositoryId, string reference) + public static Uri CheckSuitesForReference(long repositoryId, string reference) { return "repositories/{0}/commits/{1}/check-suites".FormatUri(repositoryId, reference); } @@ -3870,7 +3870,7 @@ public static Uri ReferenceCheckSuites(long repositoryId, string reference) /// The name of repo /// The git reference /// The that returns the check suites for the specified reference. - public static Uri ReferenceCheckSuites(string owner, string repo, string reference) + public static Uri CheckSuitesForReference(string owner, string repo, string reference) { return "repos/{0}/{1}/commits/{2}/check-suites".FormatUri(owner, repo, reference); } From 87b5b4326b99e4bd4ba04388102e5cc887170dcb Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 20:43:12 +1000 Subject: [PATCH 77/82] whitespace/using tidy ups --- .../Clients/CheckSuitesClientTests.cs | 8 ++++---- Octokit/Clients/CheckSuitesClient.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 34fd11f891..c473f15e3e 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -1,6 +1,6 @@ -using Octokit.Tests.Integration.Helpers; -using System.Linq; +using System.Linq; using System.Threading.Tasks; +using Octokit.Tests.Integration.Helpers; using Xunit; namespace Octokit.Tests.Integration.Clients @@ -28,7 +28,7 @@ public async Task GetsCheckSuite() // Need to get a CheckSuiteId so we can test the Get method var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); - + // Get Check Suite by Id var result = await _github.Check.Suite.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); @@ -94,7 +94,7 @@ public async Task UpdatesPreferences() }); var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); - + Assert.Equal(repoContext.RepositoryId, response.Repository.Id); Assert.Equal(Helper.GitHubAppId, response.Preferences.AutoTriggerChecks[0].AppId); Assert.Equal(false, response.Preferences.AutoTriggerChecks[0].Setting); diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 549405a03c..cdcee1a857 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -273,7 +273,7 @@ public async Task Request(long repositoryId, CheckSuiteTriggerRequest requ Ensure.ArgumentNotNull(request, nameof(request)); var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRequests(repositoryId), request, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false); - + if (httpStatusCode != HttpStatusCode.Created) { throw new ApiException("Invalid Status Code returned. Expected a 201", httpStatusCode); From 21e95a1da757529b420093b6755d3811d3b623b5 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 20:44:25 +1000 Subject: [PATCH 78/82] Ensure CheckSuiteEventPayload class is handled in deserializer and add to activity test --- Octokit.Tests/Clients/EventsClientTests.cs | 1 + Octokit/Http/SimpleJsonSerializer.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index 803f6fb487..3c9a79d2ac 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -553,6 +553,7 @@ public async Task EnsuresNonNullArguments() private readonly Dictionary _activityTypes = new Dictionary { + {"CheckSuiteEvent", typeof(CheckSuiteEventPayload)}, {"CommitCommentEvent", typeof(CommitCommentPayload)}, {"ForkEvent", typeof(ForkEventPayload)}, {"IssueCommentEvent", typeof(IssueCommentPayload)}, diff --git a/Octokit/Http/SimpleJsonSerializer.cs b/Octokit/Http/SimpleJsonSerializer.cs index 0d0395a092..1fd2bc55bc 100644 --- a/Octokit/Http/SimpleJsonSerializer.cs +++ b/Octokit/Http/SimpleJsonSerializer.cs @@ -206,6 +206,8 @@ private static Type GetPayloadType(string activityType) { switch (activityType) { + case "CheckSuiteEvent": + return typeof(CheckSuiteEventPayload); case "CommitCommentEvent": return typeof(CommitCommentPayload); case "ForkEvent": From 145c329f08bd043d8728d17bd63ff9023fa93543 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 10 Jul 2018 21:19:59 +1000 Subject: [PATCH 79/82] add response model XmlDoc comments --- Octokit/Models/Response/CheckSuite.cs | 43 +++++++++++++++++++ .../Response/CheckSuitePreferencesResponse.cs | 6 +++ .../Models/Response/CheckSuitesResponse.cs | 6 +++ 3 files changed, 55 insertions(+) diff --git a/Octokit/Models/Response/CheckSuite.cs b/Octokit/Models/Response/CheckSuite.cs index 03efc0e2d2..d2eac05171 100644 --- a/Octokit/Models/Response/CheckSuite.cs +++ b/Octokit/Models/Response/CheckSuite.cs @@ -26,16 +26,59 @@ public CheckSuite(long id, string headBranch, string headSha, CheckStatus status Repository = repository; } + /// + /// The Id of this check suite + /// public long Id { get; protected set; } + + /// + /// The head branch of the commit this check suite is associated with + /// public string HeadBranch { get; protected set; } + + /// + /// The commit this check suite is associated with + /// public string HeadSha { get; protected set; } + + /// + /// The summarized status of the check runs included in this check suite + /// public StringEnum Status { get; protected set; } + + /// + /// The summarized conclusion of the check runs included in this check suite + /// public StringEnum? Conclusion { get; protected set; } + + /// + /// The GitHub Api URL of this check suite + /// public string Url { get; protected set; } + + /// + /// The hash of the commit prior to the HeadSha + /// public string Before { get; protected set; } + + /// + /// The hash of the commit after the HeadSha + /// public string After { get; protected set; } + + /// + /// The pull requests that are associated with the check suite (via the HeadSha) + /// public IReadOnlyList PullRequests { get; protected set; } + + /// + /// The GitHub App that is associated with this check suite + /// public GitHubApp App { get; protected set; } + + /// + /// The repository that is associated with this check suite + /// public Repository Repository { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0}, HeadBranch: {1}, HeadSha: {2}, Conclusion: {3}", Id, HeadBranch, HeadSha, Conclusion); diff --git a/Octokit/Models/Response/CheckSuitePreferencesResponse.cs b/Octokit/Models/Response/CheckSuitePreferencesResponse.cs index a3c247b807..ca1a1d6688 100644 --- a/Octokit/Models/Response/CheckSuitePreferencesResponse.cs +++ b/Octokit/Models/Response/CheckSuitePreferencesResponse.cs @@ -16,8 +16,14 @@ public CheckSuitePreferencesResponse(CheckSuitePreferences preferences, Reposito Repository = repository; } + /// + /// The check suite preferences + /// public CheckSuitePreferences Preferences { get; protected set; } + /// + /// The repository the check suite preferences are related to + /// public Repository Repository { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Preferences: {0}, Repository: {1}", Preferences.DebuggerDisplay, Repository.DebuggerDisplay); diff --git a/Octokit/Models/Response/CheckSuitesResponse.cs b/Octokit/Models/Response/CheckSuitesResponse.cs index b410e4ae10..b41d8ddae6 100644 --- a/Octokit/Models/Response/CheckSuitesResponse.cs +++ b/Octokit/Models/Response/CheckSuitesResponse.cs @@ -17,8 +17,14 @@ public CheckSuitesResponse(int totalCount, IReadOnlyList checkSuites CheckSuites = checkSuites; } + /// + /// The total number of check suites that match the request filter + /// public int TotalCount { get; protected set; } + /// + /// The retrieved check suites + /// public IReadOnlyList CheckSuites { get; protected set; } internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, CheckSuites: {1}", TotalCount, CheckSuites.Count); From dadc3cea0100c012e5873d491718d20e05b836b2 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Wed, 11 Jul 2018 22:09:00 +1000 Subject: [PATCH 80/82] missed one xmldoc --- Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 6f854baf80..78c67d2096 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -15,6 +15,10 @@ public class ObservableCheckSuitesClient : IObservableCheckSuitesClient readonly ICheckSuitesClient _client; readonly IConnection _connection; + /// + /// Initializes a new GitHub Check Suites API client. + /// + /// An used to make the requests public ObservableCheckSuitesClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, nameof(client)); From d36e2017b1b447d7b3e9a0b7c6178792d4003039 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Wed, 11 Jul 2018 22:37:08 +1000 Subject: [PATCH 81/82] add xmldoc to NewCheckSuite request and remove HeadBranch property as it doesnt exist anymore --- .../Clients/CheckSuitesClientTests.cs | 5 +---- .../Reactive/ObservableCheckSuitesClientTests.cs | 5 +---- Octokit.Tests/Clients/CheckSuitesClientTests.cs | 8 ++++---- .../Reactive/ObservableCheckSuitesClientTests.cs | 8 ++++---- Octokit/Models/Request/NewCheckSuite.cs | 11 ++++++++--- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index c473f15e3e..ea402cc30a 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -129,10 +129,7 @@ public async Task CreatesCheckSuite() var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch - var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha) - { - HeadBranch = "my-feature" - }; + var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha); var result = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckSuite); // Check result diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs index dcd8d23425..696007369e 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs @@ -131,10 +131,7 @@ public async Task CreatesCheckSuite() var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch - var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha) - { - HeadBranch = "my-feature" - }; + var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha); var result = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryOwner, repoContext.RepositoryName, newCheckSuite); // Check result diff --git a/Octokit.Tests/Clients/CheckSuitesClientTests.cs b/Octokit.Tests/Clients/CheckSuitesClientTests.cs index b9424cd8a1..5223dd0a59 100644 --- a/Octokit.Tests/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests/Clients/CheckSuitesClientTests.cs @@ -278,7 +278,7 @@ public async Task RequestsCorrectUrl() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); await client.Create("fake", "repo", newCheckSuite); @@ -294,7 +294,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); await client.Create(1, newCheckSuite); @@ -310,7 +310,7 @@ public async Task EnsuresNonNullArguments() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); await Assert.ThrowsAsync(() => client.Create(null, "repo", newCheckSuite)); await Assert.ThrowsAsync(() => client.Create("fake", null, newCheckSuite)); @@ -325,7 +325,7 @@ public async Task EnsuresNonEmptyArguments() var connection = Substitute.For(); var client = new CheckSuitesClient(connection); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); await Assert.ThrowsAsync(() => client.Create("", "repo", newCheckSuite)); await Assert.ThrowsAsync(() => client.Create("fake", "", newCheckSuite)); diff --git a/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs index 0c9fb1e2d5..fd76da6edf 100644 --- a/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs @@ -266,7 +266,7 @@ public async Task RequestsCorrectUrl() var gitHubClient = Substitute.For(); var client = new ObservableCheckSuitesClient(gitHubClient); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); client.Create("fake", "repo", newCheckSuite); @@ -279,7 +279,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() var gitHubClient = Substitute.For(); var client = new ObservableCheckSuitesClient(gitHubClient); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); client.Create(1, newCheckSuite); @@ -292,7 +292,7 @@ public async Task EnsuresNonNullArguments() var gitHubClient = Substitute.For(); var client = new ObservableCheckSuitesClient(gitHubClient); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); Assert.Throws(() => client.Create(null, "repo", newCheckSuite)); Assert.Throws(() => client.Create("fake", null, newCheckSuite)); @@ -307,7 +307,7 @@ public async Task EnsuresNonEmptyArguments() var gitHubClient = Substitute.For(); var client = new ObservableCheckSuitesClient(gitHubClient); - var newCheckSuite = new NewCheckSuite("123abc") { HeadBranch = "feature" }; + var newCheckSuite = new NewCheckSuite("123abc"); Assert.Throws(() => client.Create("", "repo", newCheckSuite)); Assert.Throws(() => client.Create("fake", "", newCheckSuite)); diff --git a/Octokit/Models/Request/NewCheckSuite.cs b/Octokit/Models/Request/NewCheckSuite.cs index 542d72e518..d841b37ef5 100644 --- a/Octokit/Models/Request/NewCheckSuite.cs +++ b/Octokit/Models/Request/NewCheckSuite.cs @@ -6,15 +6,20 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewCheckSuite { + /// + /// Creates a new Check Suite + /// + /// Required. The sha of the head commit. public NewCheckSuite(string headSha) { HeadSha = headSha; } + /// + /// Required. The sha of the head commit. + /// public string HeadSha { get; private set; } - public string HeadBranch { get; set; } - - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadSha: {0} HeadBranch: {1}", HeadSha, HeadBranch); + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "HeadSha: {0}", HeadSha); } } From bdb1c234be3f5bc020e71130d610d1a87a0a738b Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Fri, 13 Jul 2018 20:07:37 +1000 Subject: [PATCH 82/82] add some extra check suites integration tests --- .../Clients/CheckSuitesClientTests.cs | 105 ++++++++++++++++-- .../ObservableCheckSuitesClientTests.cs | 105 ++++++++++++++++-- 2 files changed, 192 insertions(+), 18 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index ea402cc30a..f2f4901db0 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -26,7 +26,7 @@ public async Task GetsCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -37,6 +37,24 @@ public async Task GetsCheckSuite() Assert.Equal(headCommit.Sha, result.HeadSha); } } + + [GitHubAppsTest] + public async Task GetsCheckSuiteWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Need to get a CheckSuiteId so we can test the Get method + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); + + // Get Check Suite by Id + var result = await _github.Check.Suite.Get(repoContext.RepositoryId, checkSuite.Id); + + // Check result + Assert.Equal(checkSuite.Id, result.Id); + Assert.Equal(headCommit.Sha, result.HeadSha); + } + } } public class TheGetAllForReferenceMethod @@ -57,7 +75,7 @@ public async Task GetsAllCheckSuites() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); @@ -68,6 +86,23 @@ public async Task GetsAllCheckSuites() } } } + + [GitHubAppsTest] + public async Task GetsAllCheckSuitesWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha); + + Assert.NotEmpty(checkSuites.CheckSuites); + foreach (var checkSuite in checkSuites.CheckSuites) + { + Assert.Equal(headCommit.Sha, checkSuite.HeadSha); + } + } + } } public class TheUpdatePreferencesMethod @@ -92,12 +127,28 @@ public async Task UpdatesPreferences() { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); + var result = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); - var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + Assert.Equal(repoContext.RepositoryId, result.Repository.Id); + Assert.Equal(Helper.GitHubAppId, result.Preferences.AutoTriggerChecks[0].AppId); + Assert.Equal(false, result.Preferences.AutoTriggerChecks[0].Setting); + } + } + + [GitHubAppsTest] + public async Task UpdatesPreferencesWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var preference = new CheckSuitePreferences(new[] + { + new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) + }); + var result = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryId, preference); - Assert.Equal(repoContext.RepositoryId, response.Repository.Id); - Assert.Equal(Helper.GitHubAppId, response.Preferences.AutoTriggerChecks[0].AppId); - Assert.Equal(false, response.Preferences.AutoTriggerChecks[0].Setting); + Assert.Equal(repoContext.RepositoryId, result.Repository.Id); + Assert.Equal(Helper.GitHubAppId, result.Preferences.AutoTriggerChecks[0].AppId); + Assert.Equal(false, result.Preferences.AutoTriggerChecks[0].Setting); } } } @@ -122,10 +173,10 @@ public async Task CreatesCheckSuite() { // Turn off auto creation of check suite for this repo var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); - var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -137,6 +188,29 @@ public async Task CreatesCheckSuite() Assert.Equal(featureBranch.Object.Sha, result.HeadSha); } } + + [GitHubAppsTest] + public async Task CreatesCheckSuiteWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Turn off auto creation of check suite for this repo + var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); + await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryId, preference); + + // Create a new feature branch + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); + + // Create a check suite for the feature branch + var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha); + var result = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryId, newCheckSuite); + + // Check result + Assert.NotNull(result); + Assert.Equal(featureBranch.Object.Sha, result.HeadSha); + } + } } public class TheRequestMethod @@ -157,13 +231,26 @@ public async Task RequestsCheckSuite() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryOwner, repoContext.RepositoryName, new CheckSuiteTriggerRequest(headCommit.Sha)); Assert.True(result); } } + + [GitHubAppsTest] + public async Task RequestsCheckSuiteWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryId, new CheckSuiteTriggerRequest(headCommit.Sha)); + + Assert.True(result); + } + } } } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs index 696007369e..61983e0b2c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs @@ -28,7 +28,7 @@ public async Task GetsCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -39,6 +39,24 @@ public async Task GetsCheckSuite() Assert.Equal(headCommit.Sha, result.HeadSha); } } + + [GitHubAppsTest] + public async Task GetsCheckSuiteWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Need to get a CheckSuiteId so we can test the Get method + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); + + // Get Check Suite by Id + var result = await _github.Check.Suite.Get(repoContext.RepositoryId, checkSuite.Id); + + // Check result + Assert.Equal(checkSuite.Id, result.Id); + Assert.Equal(headCommit.Sha, result.HeadSha); + } + } } public class TheGetAllForReferenceMethod @@ -59,7 +77,7 @@ public async Task GetsAllCheckSuites() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); @@ -70,6 +88,23 @@ public async Task GetsAllCheckSuites() } } } + + [GitHubAppsTest] + public async Task GetsAllCheckSuitesWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha); + + Assert.NotEmpty(checkSuites.CheckSuites); + foreach (var checkSuite in checkSuites.CheckSuites) + { + Assert.Equal(headCommit.Sha, checkSuite.HeadSha); + } + } + } } public class TheUpdatePreferencesMethod @@ -94,12 +129,28 @@ public async Task UpdatesPreferences() { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); + var result = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); - var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + Assert.Equal(repoContext.RepositoryId, result.Repository.Id); + Assert.Equal(Helper.GitHubAppId, result.Preferences.AutoTriggerChecks[0].AppId); + Assert.Equal(false, result.Preferences.AutoTriggerChecks[0].Setting); + } + } + + [GitHubAppsTest] + public async Task UpdatesPreferencesWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var preference = new CheckSuitePreferences(new[] + { + new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) + }); + var result = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryId, preference); - Assert.Equal(repoContext.RepositoryId, response.Repository.Id); - Assert.Equal(Helper.GitHubAppId, response.Preferences.AutoTriggerChecks[0].AppId); - Assert.Equal(false, response.Preferences.AutoTriggerChecks[0].Setting); + Assert.Equal(repoContext.RepositoryId, result.Repository.Id); + Assert.Equal(Helper.GitHubAppId, result.Preferences.AutoTriggerChecks[0].AppId); + Assert.Equal(false, result.Preferences.AutoTriggerChecks[0].Setting); } } } @@ -124,10 +175,10 @@ public async Task CreatesCheckSuite() { // Turn off auto creation of check suite for this repo var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); - var response = await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); + await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -139,6 +190,29 @@ public async Task CreatesCheckSuite() Assert.Equal(featureBranch.Object.Sha, result.HeadSha); } } + + [GitHubAppsTest] + public async Task CreatesCheckSuiteWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + // Turn off auto creation of check suite for this repo + var preference = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(Helper.GitHubAppId, false) }); + await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryId, preference); + + // Create a new feature branch + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); + + // Create a check suite for the feature branch + var newCheckSuite = new NewCheckSuite(featureBranch.Object.Sha); + var result = await _githubAppInstallation.Check.Suite.Create(repoContext.RepositoryId, newCheckSuite); + + // Check result + Assert.NotNull(result); + Assert.Equal(featureBranch.Object.Sha, result.HeadSha); + } + } } public class TheRequestMethod @@ -159,13 +233,26 @@ public async Task RequestsCheckSuite() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryOwner, repoContext.RepositoryName, new CheckSuiteTriggerRequest(headCommit.Sha)); Assert.True(result); } } + + [GitHubAppsTest] + public async Task RequestsCheckSuiteWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) + { + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + + var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryId, new CheckSuiteTriggerRequest(headCommit.Sha)); + + Assert.True(result); + } + } } } }