-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Pull Request Review Request API. (#1588)
* Add Pull Request Review Request API. * Add Reactive Pull Request Review Request API. * Add PullRequestReviewRequestClient tests. * Add ObservablePullRequestReviewRequestClient tests. * Fix sub-client property naming. * Remove redundant model and update PullRequest model. * Add repositoryId based methods and missing Observable documentation. * Add missing parameter to PullRequest ctor. * Add integration tests for PullRequestReviewRequest. * Upgrade PullRequestReviewRequest integration tests. * Add integration tests for repositoryId methods and fix url bug. * Add missing unit tests and fix PR issues. * Add pagination support for PullRequestReviewRequst.GetAll and tests for it. * Revert changes on `PullRequestReviewCommentsClientTests.cs` * Small upgrades - remove unused using and compress property to expression body. * Revert use of expression body in property. * Add pagination tests for PullRequestReviewRequest.GetAll. * Change pagination tests to use 2 users. * Correct class/file name * Reword the integration test names for consistency Move the plumbing to create reviews into CreateTheWorld to clean up the actual tests * Fix DebuggerDisplay of requested reviewers * fix reviewRequestToCreate parameter to be consistent
- Loading branch information
1 parent
1359367
commit 97ae3cb
Showing
15 changed files
with
1,284 additions
and
1 deletion.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
Octokit.Reactive/Clients/IObservablePullRequestReviewRequestsClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.Reactive; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// A client for GitHub's Pull Request Review Requests API. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/pulls/review_requests/">Review Requests API documentation</a> for more information. | ||
/// </remarks> | ||
public interface IObservablePullRequestReviewRequestsClient | ||
{ | ||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
IObservable<User> GetAll(string owner, string name, int number); | ||
|
||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
/// <param name="options">Options for changing the API response</param> | ||
IObservable<User> GetAll(string owner, string name, int number, ApiOptions options); | ||
|
||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
IObservable<User> GetAll(long repositoryId, int number); | ||
|
||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
/// <param name="options">Options for changing the API response</param> | ||
IObservable<User> GetAll(long repositoryId, int number, ApiOptions options); | ||
|
||
/// <summary> | ||
/// Creates review requests on a pull request for specified users. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#create-a-review-request</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The Pull Request number</param> | ||
/// <param name="users">List of logins of user will be requested for review</param> | ||
IObservable<PullRequest> Create(string owner, string name, int number, PullRequestReviewRequest users); | ||
|
||
/// <summary> | ||
/// Creates review requests on a pull request for specified users. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#create-a-review-request</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The Pull Request number</param> | ||
/// <param name="users">List of logins of user will be requested for review</param> | ||
IObservable<PullRequest> Create(long repositoryId, int number, PullRequestReviewRequest users); | ||
|
||
/// <summary> | ||
/// Deletes review request for given users on a pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The pull request review comment number</param> | ||
/// <param name="users">List of logins of users that will be not longer requested for review</param> | ||
IObservable<Unit> Delete(string owner, string name, int number, PullRequestReviewRequest users); | ||
|
||
/// <summary> | ||
/// Deletes review request for given users on a pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The pull request review comment number</param> | ||
/// <param name="users">List of logins of users that will be not longer requested for review</param> | ||
IObservable<Unit> Delete(long repositoryId, int number, PullRequestReviewRequest users); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
Octokit.Reactive/Clients/ObservablePullRequestReviewRequestsClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
using System; | ||
using System.Reactive; | ||
using System.Reactive.Threading.Tasks; | ||
using Octokit.Reactive.Internal; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public class ObservablePullRequestReviewRequestsClient : IObservablePullRequestReviewRequestsClient | ||
{ | ||
readonly IPullRequestReviewRequestsClient _client; | ||
readonly IConnection _connection; | ||
|
||
public ObservablePullRequestReviewRequestsClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, "client"); | ||
|
||
_client = client.PullRequest.ReviewRequest; | ||
_connection = client.Connection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
public IObservable<User> GetAll(string owner, string name, int number) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(name, "name"); | ||
|
||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.PullRequestReviewRequests(owner, name, number), null, AcceptHeaders.PullRequestReviewsApiPreview); | ||
} | ||
|
||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
/// <param name="options">Options for changing the API response</param> | ||
public IObservable<User> GetAll(string owner, string name, int number, ApiOptions options) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(name, "name"); | ||
Ensure.ArgumentNotNull(options, "options"); | ||
|
||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.PullRequestReviewRequests(owner, name, number), null, AcceptHeaders.PullRequestReviewsApiPreview, options); | ||
} | ||
|
||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
public IObservable<User> GetAll(long repositoryId, int number) | ||
{ | ||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.PullRequestReviewRequests(repositoryId, number), null, AcceptHeaders.PullRequestReviewsApiPreview); | ||
} | ||
|
||
/// <summary> | ||
/// Gets review requests for a specified pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#list-review-requests</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The pull request number</param> | ||
/// <param name="options">Options for changing the API response</param> | ||
public IObservable<User> GetAll(long repositoryId, int number, ApiOptions options) | ||
{ | ||
Ensure.ArgumentNotNull(options, "options"); | ||
|
||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.PullRequestReviewRequests(repositoryId, number), null, AcceptHeaders.PullRequestReviewsApiPreview, options); | ||
} | ||
|
||
/// <summary> | ||
/// Creates review requests on a pull request for specified users. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#create-a-review-request</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The Pull Request number</param> | ||
/// <param name="users">List of logins of user will be requested for review</param> | ||
public IObservable<PullRequest> Create(string owner, string name, int number, PullRequestReviewRequest users) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(name, "name"); | ||
Ensure.ArgumentNotNull(users, "users"); | ||
|
||
return _client.Create(owner, name, number, users).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates review requests on a pull request for specified users. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#create-a-review-request</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The Pull Request number</param> | ||
/// <param name="users">List of logins of user will be requested for review</param> | ||
public IObservable<PullRequest> Create(long repositoryId, int number, PullRequestReviewRequest users) | ||
{ | ||
Ensure.ArgumentNotNull(users, "users"); | ||
|
||
return _client.Create(repositoryId, number, users).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes review request for given users on a pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request</remarks> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="name">The name of the repository</param> | ||
/// <param name="number">The pull request review comment number</param> | ||
/// <param name="users">List of logins of users that will be not longer requested for review</param> | ||
public IObservable<Unit> Delete(string owner, string name, int number, PullRequestReviewRequest users) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(name, "name"); | ||
Ensure.ArgumentNotNull(users, "users"); | ||
|
||
return _client.Delete(owner, name, number, users).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes review request for given users on a pull request. | ||
/// </summary> | ||
/// <remarks>https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request</remarks> | ||
/// <param name="repositoryId">The Id of the repository</param> | ||
/// <param name="number">The pull request review comment number</param> | ||
/// <param name="users">List of logins of users that will be not longer requested for review</param> | ||
public IObservable<Unit> Delete(long repositoryId, int number, PullRequestReviewRequest users) | ||
{ | ||
Ensure.ArgumentNotNull(users, "users"); | ||
|
||
return _client.Delete(repositoryId, number, users).ToObservable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.