-
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.
[FEAT] Added enterprise pre-receive hooks client (#2375)
- Loading branch information
Showing
20 changed files
with
1,787 additions
and
0 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
77 changes: 77 additions & 0 deletions
77
Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.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,77 @@ | ||
using System; | ||
using System.Reactive; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// A client for GitHub's Enterprise Pre-receive Hooks API | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. | ||
///</remarks> | ||
public interface IObservableEnterprisePreReceiveHooksClient | ||
{ | ||
/// <summary> | ||
/// Gets all <see cref="PreReceiveHook"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveHook> GetAll(); | ||
|
||
/// <summary> | ||
/// Gets all <see cref="PreReceiveHook"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="options">Options for changing the API response</param> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveHook> GetAll(ApiOptions options); | ||
|
||
/// <summary> | ||
/// Gets a single <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="hookId">The id of the pre-receive hook</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveHook> Get(long hookId); | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook); | ||
|
||
/// <summary> | ||
/// Edits an existing <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="hookId">The id of the pre-receive hook</param> | ||
/// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook updatePreReceiveHook); | ||
|
||
/// <summary> | ||
/// Deletes an existing <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="hookId">The id of the pre-receive hook</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<Unit> Delete(long 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
114 changes: 114 additions & 0 deletions
114
Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.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,114 @@ | ||
using System; | ||
using System.Reactive; | ||
using System.Reactive.Threading.Tasks; | ||
using Octokit.Reactive.Internal; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// A client for GitHub's Enterprise Pre-receive Hooks API | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. | ||
///</remarks> | ||
public class ObservableEnterprisePreReceiveHooksClient : IObservableEnterprisePreReceiveHooksClient | ||
{ | ||
readonly IEnterprisePreReceiveHooksClient _client; | ||
readonly IConnection _connection; | ||
|
||
public ObservableEnterprisePreReceiveHooksClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, nameof(client)); | ||
|
||
_client = client.Enterprise.PreReceiveHook; | ||
_connection = client.Connection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets all <see cref="PreReceiveHook"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveHook> GetAll() | ||
{ | ||
return GetAll(ApiOptions.None); | ||
} | ||
|
||
/// <summary> | ||
/// Gets all <see cref="PreReceiveHook"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="options">Options for changing the API response</param> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveHook> GetAll(ApiOptions options) | ||
{ | ||
Ensure.ArgumentNotNull(options, nameof(options)); | ||
|
||
return _connection.GetAndFlattenAllPages<PreReceiveHook>(ApiUrls.AdminPreReceiveHooks(), null, AcceptHeaders.StableVersionJson, options); | ||
} | ||
|
||
/// <summary> | ||
/// Gets a single <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="hookId">The id of the pre-receive hook</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveHook> Get(long hookId) | ||
{ | ||
return _client.Get(hookId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook) | ||
{ | ||
Ensure.ArgumentNotNull(newPreReceiveHook, nameof(newPreReceiveHook)); | ||
|
||
return _client.Create(newPreReceiveHook).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Edits an existing <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="hookId">The id of the pre-receive hook</param> | ||
/// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook updatePreReceiveHook) | ||
{ | ||
Ensure.ArgumentNotNull(updatePreReceiveHook, nameof(updatePreReceiveHook)); | ||
|
||
return _client.Edit(hookId, updatePreReceiveHook).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes an existing <see cref="PreReceiveHook"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="hookId">The id of the pre-receive hook</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<Unit> Delete(long hookId) | ||
{ | ||
return _client.Delete(hookId).ToObservable(); | ||
} | ||
} | ||
} |
Oops, something went wrong.