mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 11:40:42 +00:00
[FEAT] Added enterprise pre-receive hooks client (#2375)
This commit is contained in:
@@ -63,5 +63,13 @@
|
||||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/">Enterprise Pre-receive Environments API documentation</a> for more information.
|
||||
///</remarks>
|
||||
IObservableEnterprisePreReceiveEnvironmentsClient PreReceiveEnvironment { get; }
|
||||
|
||||
/// <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>
|
||||
IObservableEnterprisePreReceiveHooksClient PreReceiveHook { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
Organization = new ObservableEnterpriseOrganizationClient(client);
|
||||
SearchIndexing = new ObservableEnterpriseSearchIndexingClient(client);
|
||||
PreReceiveEnvironment = new ObservableEnterprisePreReceiveEnvironmentsClient(client);
|
||||
PreReceiveHook = new ObservableEnterprisePreReceiveHooksClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,5 +77,13 @@
|
||||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/">Enterprise Pre-receive Environments API documentation</a> for more information.
|
||||
///</remarks>
|
||||
public IObservableEnterprisePreReceiveEnvironmentsClient PreReceiveEnvironment { get; private set; }
|
||||
|
||||
/// <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 IObservableEnterprisePreReceiveHooksClient PreReceiveHook { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user