mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 19:46:07 +00:00
add active lock reason to PR (#2543)
* add active lock reason to PR * update docs * refactor: extract lock and unlock from IIssuesClient create ILockUnlockClient so both IIssuesClient and IPullRequestClient can access lock and unlock methods. * refactor LockUnlock for reactive clients * Update doc to include lock unlock sample code * Use Assert.Null to check null value in test Co-authored-by: notauserx <notauserx@users.noreply.github.com>
This commit is contained in:
@@ -44,6 +44,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
IObservableIssueTimelineClient Timeline { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for locking/unlocking conversation on an issue
|
||||
/// </summary>
|
||||
IObservableLockUnlockClient LockUnlock { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single Issue by number.
|
||||
/// </summary>
|
||||
@@ -316,41 +321,5 @@ namespace Octokit.Reactive
|
||||
/// <param name="issueUpdate">An <see cref="IssueUpdate"/> instance describing the changes to make to the issue
|
||||
/// </param>
|
||||
IObservable<Issue> Update(long repositoryId, int number, IssueUpdate issueUpdate);
|
||||
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null);
|
||||
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null);
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
IObservable<Unit> Unlock(string owner, string name, int number);
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
IObservable<Unit> Unlock(long repositoryId, int number);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// Client to manage locking/unlocking a conversation for an Issue or a Pull request
|
||||
/// </summary>
|
||||
public interface IObservableLockUnlockClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null);
|
||||
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null);
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
IObservable<Unit> Unlock(string owner, string name, int number);
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
IObservable<Unit> Unlock(long repositoryId, int number);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
IObservablePullRequestReviewRequestsClient ReviewRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for locking/unlocking a conversation on a pull request
|
||||
/// </summary>
|
||||
IObservableLockUnlockClient LockUnlock { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single Pull Request by number.
|
||||
/// </summary>
|
||||
|
||||
@@ -48,6 +48,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
public IObservableIssueTimelineClient Timeline { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for locking/unlocking conversation on an issue
|
||||
/// </summary>
|
||||
public IObservableLockUnlockClient LockUnlock { get; protected set; }
|
||||
|
||||
public ObservableIssuesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
@@ -60,6 +65,7 @@ namespace Octokit.Reactive
|
||||
Milestone = new ObservableMilestonesClient(client);
|
||||
Comment = new ObservableIssueCommentsClient(client);
|
||||
Timeline = new ObservableIssueTimelineClient(client);
|
||||
LockUnlock = new ObservableLockUnlockClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -473,58 +479,6 @@ namespace Octokit.Reactive
|
||||
return _client.Update(repositoryId, number, issueUpdate).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
public IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Lock(owner, name, number, lockReason).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
public IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null)
|
||||
{
|
||||
return _client.Lock(repositoryId, number, lockReason).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
public IObservable<Unit> Unlock(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Unlock(owner, name, number).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
public IObservable<Unit> Unlock(long repositoryId, int number)
|
||||
{
|
||||
return _client.Unlock(repositoryId, number).ToObservable();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// Client to manage locking/unlocking a conversation for an Issue or a Pull request
|
||||
/// </summary>
|
||||
public class ObservableLockUnlockClient : IObservableLockUnlockClient
|
||||
{
|
||||
readonly ILockUnlockClient _client;
|
||||
|
||||
public ObservableLockUnlockClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Issue.LockUnlock;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
public IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Lock(owner, name, number, lockReason).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
/// <param name="lockReason">The reason for locking the issue</param>
|
||||
public IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null)
|
||||
{
|
||||
return _client.Lock(repositoryId, number, lockReason).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
public IObservable<Unit> Unlock(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Unlock(owner, name, number).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
/// <param name="number">The issue number</param>
|
||||
public IObservable<Unit> Unlock(long repositoryId, int number)
|
||||
{
|
||||
return _client.Unlock(repositoryId, number).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
public IObservablePullRequestReviewRequestsClient ReviewRequest { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for locking/unlocking a conversation on a pull request
|
||||
/// </summary>
|
||||
public IObservableLockUnlockClient LockUnlock { get; private set; }
|
||||
|
||||
public ObservablePullRequestsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
@@ -39,6 +44,7 @@ namespace Octokit.Reactive
|
||||
Review = new ObservablePullRequestReviewsClient(client);
|
||||
ReviewComment = new ObservablePullRequestReviewCommentsClient(client);
|
||||
ReviewRequest = new ObservablePullRequestReviewRequestsClient(client);
|
||||
LockUnlock = new ObservableLockUnlockClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user