-
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.
Merge pull request #776 from TeamBinary/pr-495ext
Fork/Hook issue #698
- Loading branch information
Showing
43 changed files
with
1,605 additions
and
12 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
Octokit.Reactive/Clients/IObservableRepositoryForksClient.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,21 @@ | ||
using System; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public interface IObservableRepositoryForksClient | ||
{ | ||
/// <summary> | ||
/// Gets the list of forks defined for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<Repository> GetAll(string owner, string repositoryName, RepositoryForksListRequest request); | ||
|
||
/// <summary> | ||
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/forks/#create-a-fork">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<Repository> Create(string owner, string repositoryName, NewRepositoryFork fork); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Octokit.Reactive/Clients/IObservableRepositoryHooksClient.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,64 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reactive; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public interface IObservableRepositoryHooksClient | ||
{ | ||
/// <summary> | ||
/// Gets the list of hooks defined for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#list">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<RepositoryHook> GetAll(string owner, string repositoryName); | ||
|
||
/// <summary> | ||
/// Gets a single hook defined for a repository by id | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#get-single-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] | ||
IObservable<RepositoryHook> Get(string owner, string repositoryName, int hookId); | ||
|
||
/// <summary> | ||
/// Creates a hook for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#create-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<RepositoryHook> Create(string owner, string repositoryName, NewRepositoryHook hook); | ||
|
||
/// <summary> | ||
/// Edits a hook for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<RepositoryHook> Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook); | ||
|
||
/// <summary> | ||
/// Tests a hook for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#test-a-hook">API documentation</a> for more information. | ||
/// This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook | ||
/// is not subscribed to push events, the server will respond with 204 but no test POST will be generated.</remarks> | ||
/// <returns></returns> | ||
IObservable<Unit> Test(string owner, string repositoryName, int hookId); | ||
|
||
/// <summary> | ||
/// This will trigger a ping event to be sent to the hook. | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<Unit> Ping(string owner, string repositoryName, int hookId); | ||
|
||
/// <summary> | ||
/// Deletes a hook for a repository | ||
/// </summary> | ||
/// <param name="owner"></param> | ||
/// <param name="repositoryName"></param> | ||
/// <param name="hookId"></param> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#delete-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<Unit> Delete(string owner, string repositoryName, int hookId); | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
Octokit.Reactive/Clients/ObservableRepositoryForksClient.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,53 @@ | ||
using System; | ||
using System.Reactive.Threading.Tasks; | ||
using Octokit.Reactive.Internal; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public class ObservableRepositoryForksClient : IObservableRepositoryForksClient | ||
{ | ||
readonly IRepositoryForksClient _client; | ||
readonly IConnection _connection; | ||
|
||
/// <summary> | ||
/// Initializes a new GitHub Repos Fork API client. | ||
/// </summary> | ||
/// <param name="client"></param> | ||
public ObservableRepositoryForksClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, "client"); | ||
_client = client.Repository.Forks; | ||
_connection = client.Connection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the list of forks defined for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<Repository> GetAll(string owner, string repositoryName, RepositoryForksListRequest request) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
if (request == null) | ||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.RepositoryForks(owner, repositoryName)); | ||
else | ||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary()); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/forks/#create-a-fork">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<Repository> Create(string owner, string repositoryName, NewRepositoryFork fork) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
Ensure.ArgumentNotNull(fork, "fork"); | ||
|
||
return _client.Create(owner, repositoryName, fork).ToObservable(); | ||
} | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
Octokit.Reactive/Clients/ObservableRepositoryHooksClient.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,119 @@ | ||
using System; | ||
using System.Reactive; | ||
using System.Reactive.Threading.Tasks; | ||
using Octokit.Reactive.Internal; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public class ObservableRepositoryHooksClient : IObservableRepositoryHooksClient | ||
{ | ||
readonly IRepositoryHooksClient _client; | ||
readonly IConnection _connection; | ||
|
||
public ObservableRepositoryHooksClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, "client"); | ||
|
||
_client = client.Repository.Hooks; | ||
_connection = client.Connection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the list of hooks defined for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#list">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<RepositoryHook> GetAll(string owner, string repositoryName) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _connection.GetAndFlattenAllPages<RepositoryHook>(ApiUrls.RepositoryHooks(owner, repositoryName)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets a single hook defined for a repository by id | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#get-single-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<RepositoryHook> Get(string owner, string repositoryName, int hookId) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _client.Get(owner, repositoryName, hookId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a hook for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#create-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<RepositoryHook> Create(string owner, string repositoryName, NewRepositoryHook hook) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
Ensure.ArgumentNotNull(hook, "hook"); | ||
|
||
return _client.Create(owner, repositoryName, hook).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Edits a hook for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<RepositoryHook> Edit(string owner, string repositoryName, int hookId, EditRepositoryHook hook) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
Ensure.ArgumentNotNull(hook, "hook"); | ||
|
||
return _client.Edit(owner, repositoryName, hookId, hook).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Tests a hook for a repository | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#test-a-hook">API documentation</a> for more information. | ||
/// This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook | ||
/// is not subscribed to push events, the server will respond with 204 but no test POST will be generated.</remarks> | ||
/// <returns></returns> | ||
public IObservable<Unit> Test(string owner, string repositoryName, int hookId) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _client.Test(owner, repositoryName, hookId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// This will trigger a ping event to be sent to the hook. | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<Unit> Ping(string owner, string repositoryName, int hookId) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _client.Ping(owner, repositoryName, hookId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes a hook for a repository | ||
/// </summary> | ||
/// <param name="owner"></param> | ||
/// <param name="repositoryName"></param> | ||
/// <param name="hookId"></param> | ||
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#delete-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<Unit> Delete(string owner, string repositoryName, int hookId) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _client.Delete(owner, repositoryName, hookId).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
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
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
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.