diff --git a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs index 07e0a5937b..a40f3853c6 100644 --- a/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/IObservableCheckSuitesClient.cs @@ -151,6 +151,7 @@ public interface IObservableCheckSuitesClient /// The owner of the repository /// The name of the repository /// Details of the Check Suite request + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] IObservable Request(string owner, string name, CheckSuiteTriggerRequest request); /// @@ -161,6 +162,28 @@ public interface IObservableCheckSuitesClient /// /// The Id of the repository /// Details of the Check Suite request + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] IObservable Request(long repositoryId, CheckSuiteTriggerRequest request); + + /// + /// Triggers GitHub to rerequest an existing 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 + /// The Id of the check suite + IObservable Rerequest(string owner, string name, long checkSuiteId); + + /// + /// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite + IObservable Rerequest(long repositoryId, long checkSuiteId); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 78c67d2096..df86d8a5a5 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -243,6 +243,7 @@ public IObservable Create(long repositoryId, NewCheckSuite newCheckS /// The owner of the repository /// The name of the repository /// Details of the Check Suite request + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] public IObservable Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -260,12 +261,42 @@ public IObservable Request(string owner, string name, CheckSuiteTriggerReq /// /// The Id of the repository /// Details of the Check Suite request - + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] public IObservable Request(long repositoryId, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); return _client.Request(repositoryId, request).ToObservable(); } + + /// + /// Triggers GitHub to rerequest an existing 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 + /// The Id of the check suite + public IObservable Rerequest(string owner, string name, long checkSuiteId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Rerequest(owner, name, checkSuiteId).ToObservable(); + } + + /// + /// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite + public IObservable Rerequest(long repositoryId, long checkSuiteId) + { + return _client.Rerequest(repositoryId, checkSuiteId).ToObservable(); + } } } \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs index 4aa479d077..f51c7eb5d1 100644 --- a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs @@ -409,7 +409,7 @@ public async Task GetsAllAnnotations() { Annotations = new[] { - new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning") + new NewCheckRunAnnotation("file.txt", 1, 1, CheckAnnotationLevel.Warning, "this is a warning") } } }; @@ -421,7 +421,7 @@ public async Task GetsAllAnnotations() // Check result Assert.Equal(1, annotations.Count); Assert.Equal("this is a warning", annotations.First().Message); - Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel); + Assert.Equal(CheckAnnotationLevel.Warning, annotations.First().AnnotationLevel); } } @@ -442,7 +442,7 @@ public async Task GetsAllAnnotationsWithRepositoryId() { Annotations = new[] { - new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning") + new NewCheckRunAnnotation("file.txt", 1, 1, CheckAnnotationLevel.Warning, "this is a warning") } } }; @@ -454,7 +454,7 @@ public async Task GetsAllAnnotationsWithRepositoryId() // Check result Assert.Equal(1, annotations.Count); Assert.Equal("this is a warning", annotations.First().Message); - Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel); + Assert.Equal(CheckAnnotationLevel.Warning, annotations.First().AnnotationLevel); } } } diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index f2f4901db0..1512dc8ebf 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -213,12 +213,12 @@ public async Task CreatesCheckSuiteWithRepositoryId() } } - public class TheRequestMethod + public class TheRerequestMethod { IGitHubClient _github; IGitHubClient _githubAppInstallation; - public TheRequestMethod() + public TheRerequestMethod() { _github = Helper.GetAuthenticatedClient(); @@ -227,26 +227,32 @@ public TheRequestMethod() } [GitHubAppsTest] - public async Task RequestsCheckSuite() + public async Task RerequestsCheckSuite() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + // 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(); - var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryOwner, repoContext.RepositoryName, new CheckSuiteTriggerRequest(headCommit.Sha)); + // Get Check Suite by Id + var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); Assert.True(result); } } [GitHubAppsTest] - public async Task RequestsCheckSuiteWithRepositoryId() + public async Task RerequestsCheckSuiteWithRepositoryId() { 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(); - var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryId, new CheckSuiteTriggerRequest(headCommit.Sha)); + // Get Check Suite by Id + var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryId, checkSuite.Id); Assert.True(result); } diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs index e084c3ae1e..aa178b568e 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs @@ -410,7 +410,7 @@ public async Task GetsAllAnnotations() { Annotations = new[] { - new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning") + new NewCheckRunAnnotation("file.txt", 1, 1, CheckAnnotationLevel.Warning, "this is a warning") } } }; @@ -422,7 +422,7 @@ public async Task GetsAllAnnotations() // Check result Assert.Equal(1, annotations.Count); Assert.Equal("this is a warning", annotations.First().Message); - Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel); + Assert.Equal(CheckAnnotationLevel.Warning, annotations.First().AnnotationLevel); } } @@ -443,7 +443,7 @@ public async Task GetsAllAnnotationsWithRepositoryId() { Annotations = new[] { - new NewCheckRunAnnotation("file.txt", "blob", 1, 1, CheckWarningLevel.Warning, "this is a warning") + new NewCheckRunAnnotation("file.txt", 1, 1, CheckAnnotationLevel.Warning, "this is a warning") } } }; @@ -455,7 +455,7 @@ public async Task GetsAllAnnotationsWithRepositoryId() // Check result Assert.Equal(1, annotations.Count); Assert.Equal("this is a warning", annotations.First().Message); - Assert.Equal(CheckWarningLevel.Warning, annotations.First().WarningLevel); + Assert.Equal(CheckAnnotationLevel.Warning, annotations.First().AnnotationLevel); } } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs index 61983e0b2c..f4e752d65d 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs @@ -215,12 +215,12 @@ public async Task CreatesCheckSuiteWithRepositoryId() } } - public class TheRequestMethod + public class TheRerequestMethod { IObservableGitHubClient _github; IObservableGitHubClient _githubAppInstallation; - public TheRequestMethod() + public TheRerequestMethod() { _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); @@ -229,26 +229,30 @@ public TheRequestMethod() } [GitHubAppsTest] - public async Task RequestsCheckSuite() + public async Task RerequestsCheckSuite() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + // 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(); - var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryOwner, repoContext.RepositoryName, new CheckSuiteTriggerRequest(headCommit.Sha)); + var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); Assert.True(result); } } [GitHubAppsTest] - public async Task RequestsCheckSuiteWithRepositoryId() + public async Task RerequestsCheckSuiteWithRepositoryId() { 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(); - var result = await _githubAppInstallation.Check.Suite.Request(repoContext.RepositoryId, new CheckSuiteTriggerRequest(headCommit.Sha)); + var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryId, checkSuite.Id); Assert.True(result); } diff --git a/Octokit.Tests/Clients/CheckSuitesClientTests.cs b/Octokit.Tests/Clients/CheckSuitesClientTests.cs index 5223dd0a59..558610a28d 100644 --- a/Octokit.Tests/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests/Clients/CheckSuitesClientTests.cs @@ -332,6 +332,7 @@ public async Task EnsuresNonEmptyArguments() } } +#pragma warning disable CS0618 // Type or member is obsolete public class TheRequestMethod { [Fact] @@ -393,5 +394,57 @@ public async Task EnsuresNonEmptyArguments() await Assert.ThrowsAsync(() => client.Request("fake", "", request)); } } +#pragma warning restore CS0618 // Type or member is obsolete + + public class TheRerequestMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created); + var client = new CheckSuitesClient(connection); + + await client.Rerequest("fake", "repo", 1); + + connection.Connection.Received().Post( + Arg.Is(u => u.ToString() == "repos/fake/repo/check-suites/1/rerequest"), + Args.Object, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created); + var client = new CheckSuitesClient(connection); + + await client.Rerequest(1, 1); + + connection.Connection.Received().Post( + Arg.Is(u => u.ToString() == "repositories/1/check-suites/1/rerequest"), + Args.Object, + "application/vnd.github.antiope-preview+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await Assert.ThrowsAsync(() => client.Rerequest(null, "repo", 1)); + await Assert.ThrowsAsync(() => client.Rerequest("fake", null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new CheckSuitesClient(connection); + + await Assert.ThrowsAsync(() => client.Rerequest("", "repo", 1)); + await Assert.ThrowsAsync(() => client.Rerequest("fake", "", 1)); + } + } } } \ No newline at end of file diff --git a/Octokit.Tests/Clients/ProjectCardsClientTests.cs b/Octokit.Tests/Clients/ProjectCardsClientTests.cs index 35937cd7ad..20d1b6eb0a 100644 --- a/Octokit.Tests/Clients/ProjectCardsClientTests.cs +++ b/Octokit.Tests/Clients/ProjectCardsClientTests.cs @@ -115,7 +115,10 @@ public async Task PostsToCorrectURL() { var connection = Substitute.For(); var client = new ProjectCardsClient(connection); - var updateCard = new ProjectCardUpdate("someNewNote"); + var updateCard = new ProjectCardUpdate + { + Note = "someNewNote" + }; await client.Update(1, updateCard); @@ -129,7 +132,10 @@ public async Task PostsToCorrectURL() public async Task EnsuresNonNullArguments() { var client = new ProjectCardsClient(Substitute.For()); - var updateCard = new ProjectCardUpdate("someNewNote"); + var updateCard = new ProjectCardUpdate + { + Note = "someNewNote" + }; await Assert.ThrowsAsync(() => client.Update(1, null)); } diff --git a/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs index 2ccd59fa85..7cbd5e2425 100644 --- a/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs @@ -313,6 +313,7 @@ public async Task EnsuresNonEmptyArguments() } } +#pragma warning disable CS0618 // Type or member is obsolete public class TheRequestMethod { [Fact] @@ -368,5 +369,51 @@ public async Task EnsuresNonEmptyArguments() Assert.Throws(() => client.Request("fake", "", request)); } } +#pragma warning restore CS0618 // Type or member is obsolete + + public class TheRerequestMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + client.Rerequest("fake", "repo", 1); + + gitHubClient.Check.Suite.Received().Rerequest("fake", "repo", 1); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + client.Rerequest(1, 1); + + gitHubClient.Check.Suite.Received().Rerequest(1, 1); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + Assert.Throws(() => client.Rerequest(null, "repo", 1)); + Assert.Throws(() => client.Rerequest("fake", null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var gitHubClient = Substitute.For(); + var client = new ObservableCheckSuitesClient(gitHubClient); + + Assert.Throws(() => client.Rerequest("", "repo", 1)); + Assert.Throws(() => client.Rerequest("fake", "", 1)); + } + } } } diff --git a/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs b/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs index 3fa491ffdf..1023bb9535 100644 --- a/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs @@ -113,7 +113,10 @@ public void PostsToCorrectURL() { var gitHubClient = Substitute.For(); var client = new ObservableProjectCardsClient(gitHubClient); - var updateCard = new ProjectCardUpdate("someNewNote"); + var updateCard = new ProjectCardUpdate + { + Note = "someNewNote" + }; client.Update(1, updateCard); @@ -124,7 +127,10 @@ public void PostsToCorrectURL() public async Task EnsuresNonNullArguments() { var client = new ObservableProjectCardsClient(Substitute.For()); - var updateCard = new ProjectCardUpdate("someNewNote"); + var updateCard = new ProjectCardUpdate + { + Note = "someNewNote" + }; await Assert.ThrowsAsync(() => client.Update(1, null).ToTask()); } diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index cdcee1a857..71affd3375 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Net; using System.Threading.Tasks; @@ -244,6 +245,7 @@ public Task Create(long repositoryId, NewCheckSuite newCheckSuite) /// The owner of the repository /// The name of the repository /// Details of the Check Suite request + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] public async Task Request(string owner, string name, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -268,6 +270,7 @@ public async Task Request(string owner, string name, CheckSuiteTriggerRequ /// /// The Id of the repository /// Details of the Check Suite request + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] public async Task Request(long repositoryId, CheckSuiteTriggerRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); @@ -281,5 +284,49 @@ public async Task Request(long repositoryId, CheckSuiteTriggerRequest requ return httpStatusCode == HttpStatusCode.Created; } + + /// + /// Triggers GitHub to rerequest an existing 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 + /// The Id of the check suite + public async Task Rerequest(string owner, string name, long checkSuiteId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRerequest(owner, name, checkSuiteId), null, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false); + + if (httpStatusCode != HttpStatusCode.Created) + { + throw new ApiException("Invalid Status Code returned. Expected a 201", httpStatusCode); + } + + return httpStatusCode == HttpStatusCode.Created; + } + + /// + /// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite + public async Task Rerequest(long repositoryId, long checkSuiteId) + { + var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRerequest(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false); + + if (httpStatusCode != HttpStatusCode.Created) + { + throw new ApiException("Invalid Status Code returned. Expected a 201", httpStatusCode); + } + + return httpStatusCode == HttpStatusCode.Created; + } } } \ No newline at end of file diff --git a/Octokit/Clients/ICheckSuitesClient.cs b/Octokit/Clients/ICheckSuitesClient.cs index 836920938b..3eb77713ed 100644 --- a/Octokit/Clients/ICheckSuitesClient.cs +++ b/Octokit/Clients/ICheckSuitesClient.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; namespace Octokit { @@ -151,6 +152,7 @@ public interface ICheckSuitesClient /// The owner of the repository /// The name of the repository /// Details of the Check Suite request + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] Task Request(string owner, string name, CheckSuiteTriggerRequest request); /// @@ -161,6 +163,28 @@ public interface ICheckSuitesClient /// /// The Id of the repository /// Details of the Check Suite request + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] Task Request(long repositoryId, CheckSuiteTriggerRequest request); + + /// + /// Triggers GitHub to rerequest an existing 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 + /// The Id of the check suite + Task Rerequest(string owner, string name, long checkSuiteId); + + /// + /// Triggers GitHub to rerequest an existing check suite, without pushing new code to a repository + /// + /// + /// See the Check Suites API documentation for more information. + /// + /// The Id of the repository + /// The Id of the check suite + Task Rerequest(long repositoryId, long checkSuiteId); } } \ No newline at end of file diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index c7c8d3179b..089d6bb1db 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -4014,6 +4014,7 @@ public static Uri CheckSuites(string owner, string repo) /// /// The Id of the repository /// The that handles the check suite requests for the repository. + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] public static Uri CheckSuiteRequests(long repositoryId) { return "repositories/{0}/check-suite-requests".FormatUri(repositoryId); @@ -4025,11 +4026,35 @@ public static Uri CheckSuiteRequests(long repositoryId) /// The owner of repo /// The name of repo /// The that handles the check suite requests for the repository. + [Obsolete("This method has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] 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 requests for the repository. + /// + /// The Id of the repository + /// The Id of the check suite + /// The that handles the check suite requests for the repository. + public static Uri CheckSuiteRerequest(long repositoryId, long checkSuiteId) + { + return "repositories/{0}/check-suites/{1}/rerequest".FormatUri(repositoryId, checkSuiteId); + } + + /// + /// Returns the that handles the check suite requests for the repository. + /// + /// The owner of repo + /// The name of repo + /// The Id of the check suite + /// The that handles the check suite requests for the repository. + public static Uri CheckSuiteRerequest(string owner, string repo, long checkSuiteId) + { + return "repos/{0}/{1}/check-suites/{2}/rerequest".FormatUri(owner, repo, checkSuiteId); + } + /// /// Returns the that handles the check suite preferences for the repository. /// diff --git a/Octokit/Models/Common/CheckStatus.cs b/Octokit/Models/Common/CheckStatus.cs index 129da9d687..2d22b9afa3 100644 --- a/Octokit/Models/Common/CheckStatus.cs +++ b/Octokit/Models/Common/CheckStatus.cs @@ -1,4 +1,5 @@ -using Octokit.Internal; +using System; +using Octokit.Internal; namespace Octokit { @@ -35,6 +36,19 @@ public enum CheckConclusion ActionRequired, } + public enum CheckAnnotationLevel + { + [Parameter(Value = "notice")] + Notice, + + [Parameter(Value = "warning")] + Warning, + + [Parameter(Value = "failure")] + Failure, + } + + [Obsolete("This enum is replaced with CheckAnnotationLevel but may still be required on GitHub Enterprise 2.14")] public enum CheckWarningLevel { [Parameter(Value = "notice")] diff --git a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs index 74336620a0..f779de167c 100644 --- a/Octokit/Models/Request/CheckSuiteTriggerRequest.cs +++ b/Octokit/Models/Request/CheckSuiteTriggerRequest.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.Globalization; namespace Octokit @@ -6,6 +7,7 @@ namespace Octokit /// /// Request to trigger the creation of a check suite /// + [Obsolete("This request has been deprecated in the GitHub Api, however can still be used on GitHub Enterprise 2.14")] [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteTriggerRequest { diff --git a/Octokit/Models/Request/NewCheckRunAnnotation.cs b/Octokit/Models/Request/NewCheckRunAnnotation.cs index 3b0eced38b..97401a0238 100644 --- a/Octokit/Models/Request/NewCheckRunAnnotation.cs +++ b/Octokit/Models/Request/NewCheckRunAnnotation.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.Globalization; namespace Octokit @@ -9,12 +10,37 @@ public class NewCheckRunAnnotation /// /// Constructs a CheckRunCreateAnnotation request object /// + /// Required. The path of the file to add an annotation to. For example, assets/css/main.css + /// Required. The start line of the annotation + /// Required. The end line of the annotation + /// Required. The level of the annotation. Can be one of notice, warning, or failure + /// Required. A short description of the feedback for these lines of code. The maximum size is 64 KB + public NewCheckRunAnnotation(string path, int startLine, int endLine, CheckAnnotationLevel annotationLevel, string message) + { + Path = path; + StartLine = startLine; + EndLine = endLine; + AnnotationLevel = annotationLevel; + Message = message; + + // Ensure legacy properties are explicitly null +#pragma warning disable CS0618 // Type or member is obsolete + Filename = null; + BlobHref = null; + WarningLevel = null; +#pragma warning restore CS0618 // Type or member is obsolete + } + + /// + /// Constructs a CheckRunCreateAnnotation request object (using Filename, BlobHref and WarningLevel) + /// /// Required. The path of the file to add an annotation to. For example, assets/css/main.css /// Required. The file's full blob URL. You can find the blob_href in the response of the Get a single commit endpoint, by reading the blob_url from an element of the files array. You can also construct the blob URL from the head_sha, the repository, and the filename: https://github.com/:owner/:repo/blob/:head_sha/:filename /// Required. The start line of the annotation /// Required. The end line of the annotation /// Required. The warning level of the annotation. Can be one of notice, warning, or failure /// Required. A short description of the feedback for these lines of code. The maximum size is 64 KB + [Obsolete("This ctor taking Filename, BlobHref and WarningLevel is deprecated but may still be required on GitHub Enterprise 2.14")] public NewCheckRunAnnotation(string filename, string blobHref, int startLine, int endLine, CheckWarningLevel warningLevel, string message) { Filename = filename; @@ -23,16 +49,27 @@ public NewCheckRunAnnotation(string filename, string blobHref, int startLine, in EndLine = endLine; WarningLevel = warningLevel; Message = message; + + // Ensure new properties are explicitly null + Path = null; + AnnotationLevel = null; } /// /// Required. The path of the file to add an annotation to. For example, assets/css/main.css /// + [Obsolete("This property is replaced with Path but may still be required on GitHub Enterprise 2.14")] public string Filename { get; protected set; } + /// + /// Required. The path of the file to add an annotation to. For example, assets/css/main.css + /// + public string Path { get; protected set; } + /// /// Required. The file's full blob URL. You can find the blob_href in the response of the Get a single commit endpoint, by reading the blob_url from an element of the files array. You can also construct the blob URL from the head_sha, the repository, and the filename: https://github.com/:owner/:repo/blob/:head_sha/:filename /// + [Obsolete("This property is deprecated but may still be required on GitHub Enterprise 2.14")] public string BlobHref { get; protected set; } /// @@ -45,10 +82,26 @@ public NewCheckRunAnnotation(string filename, string blobHref, int startLine, in /// public int EndLine { get; protected set; } + /// + /// Required. The start line of the annotation + /// + public int? StartColumn { get; set; } + + /// + /// Required. The end line of the annotation + /// + public int? EndColumn { get; set; } + /// /// Required. The warning level of the annotation. Can be one of notice, warning, or failure /// - public StringEnum WarningLevel { get; protected set; } + [Obsolete("This property is replaced with AnnotationLevel but may still be required on GitHub Enterprise 2.14")] + public StringEnum? WarningLevel { get; protected set; } + + /// + /// Required. The level of the annotation. Can be one of notice, warning, or failure + /// + public StringEnum? AnnotationLevel { get; protected set; } /// /// Required. A short description of the feedback for these lines of code. The maximum size is 64 KB @@ -65,6 +118,8 @@ public NewCheckRunAnnotation(string filename, string blobHref, int startLine, in /// public string RawDetails { get; set; } - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Filename: {0}, StartLine: {1}, WarningLevel: {2}", Filename, StartLine, WarningLevel.DebuggerDisplay); +#pragma warning disable CS0618 // Type or member is obsolete + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Path: {0}, StartLine: {1}, AnnotationLevel: {2}", Path ?? Filename, StartLine, AnnotationLevel?.DebuggerDisplay ?? WarningLevel?.DebuggerDisplay); +#pragma warning restore CS0618 // Type or member is obsolete } } \ No newline at end of file diff --git a/Octokit/Models/Response/CheckRunAnnotation.cs b/Octokit/Models/Response/CheckRunAnnotation.cs index 790b155076..7437e59c54 100644 --- a/Octokit/Models/Response/CheckRunAnnotation.cs +++ b/Octokit/Models/Response/CheckRunAnnotation.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.Globalization; namespace Octokit @@ -10,13 +11,38 @@ public CheckRunAnnotation() { } - public CheckRunAnnotation(string filename, string blobHref, int startLine, int endLine, CheckWarningLevel warningLevel, string message, string title, string rawDetails) + public CheckRunAnnotation(string path, string blobHref, int startLine, int endLine, int? startColumn, int? endColumn, CheckAnnotationLevel? annotationLevel, string message, string title, string rawDetails) + { + Path = path; + BlobHref = blobHref; + StartLine = startLine; + EndLine = endLine; + StartColumn = startColumn; + EndColumn = endColumn; + AnnotationLevel = annotationLevel; + Message = message; + Title = title; + RawDetails = rawDetails; + + // Ensure legacy properties are explicitly null +#pragma warning disable CS0618 // Type or member is obsolete + Filename = null; + WarningLevel = null; +#pragma warning restore CS0618 // Type or member is obsolete + } + + [Obsolete("This ctor taking Filename, BlobHref and WarningLevel is deprecated but may still be required on GitHub Enterprise 2.14")] + public CheckRunAnnotation(string filename, string path, string blobHref, int startLine, int endLine, int? startColumn, int? endColumn, CheckWarningLevel? warningLevel, CheckAnnotationLevel? annotationLevel, string message, string title, string rawDetails) { Filename = filename; + Path = path; BlobHref = blobHref; StartLine = startLine; EndLine = endLine; + StartColumn = startColumn; + EndColumn = endColumn; WarningLevel = warningLevel; + AnnotationLevel = annotationLevel; Message = message; Title = title; RawDetails = rawDetails; @@ -25,8 +51,14 @@ public CheckRunAnnotation(string filename, string blobHref, int startLine, int e /// /// The path of the file the annotation refers to /// + [Obsolete("This property is replaced with Path but may still be required on GitHub Enterprise 2.14")] public string Filename { get; protected set; } + /// + /// The path of the file the annotation refers to + /// + public string Path { get; protected set; } + /// /// The file's full blob URL /// @@ -42,10 +74,26 @@ public CheckRunAnnotation(string filename, string blobHref, int startLine, int e /// public int EndLine { get; protected set; } + /// + /// The start line of the annotation + /// + public int? StartColumn { get; protected set; } + + /// + /// The end line of the annotation + /// + public int? EndColumn { get; protected set; } + /// /// The warning level of the annotation. Can be one of notice, warning, or failure /// - public StringEnum WarningLevel { get; protected set; } + [Obsolete("This property is replaced with AnnotationLevel but may still be required on GitHub Enterprise 2.14")] + public StringEnum? WarningLevel { get; protected set; } + + /// + /// The level of the annotation. Can be one of notice, warning, or failure + /// + public StringEnum? AnnotationLevel { get; protected set; } /// /// A short description of the feedback for these lines of code @@ -62,6 +110,8 @@ public CheckRunAnnotation(string filename, string blobHref, int startLine, int e /// public string RawDetails { get; protected set; } - internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Filename: {0}, StartLine: {1}, WarningLevel: {2}", Filename, StartLine, WarningLevel.DebuggerDisplay); +#pragma warning disable CS0618 // Type or member is obsolete + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Path: {0}, StartLine: {1}, WarningLevel: {2}", Path ?? Filename, StartLine, AnnotationLevel?.DebuggerDisplay ?? WarningLevel?.DebuggerDisplay); +#pragma warning restore CS0618 // Type or member is obsolete } } \ No newline at end of file