mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 20:13:40 +00:00
Implement observable methods
This commit is contained in:
committed by
Brendan Forster
parent
e08ac388ff
commit
1c6f70ad63
@@ -29,5 +29,29 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
/// <returns>The <see cref="MaintenanceModeResponse"/>.</returns>
|
||||
IObservable<MaintenanceModeResponse> EditMaintenanceMode(UpdateMaintenanceRequest maintenance, string managementConsolePassword);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the authorized SSH keys for the GitHub Enterprise instance
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/enterprise/management_console/#retrieve-authorized-ssh-keys
|
||||
/// </remarks>
|
||||
IObservable<AuthorizedKey> GetAllAuthorizedKeys(string managementConsolePassword);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an authorized SSH key to the GitHub Enterprise instance
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/enterprise/management_console/#add-a-new-authorized-ssh-key
|
||||
/// </remarks>
|
||||
IObservable<AuthorizedKey> AddAuthorizedKey(AuthorizedKeyRequest authorizedKey, string managementConsolePassword);
|
||||
|
||||
/// <summary>
|
||||
/// Removes an authorized SSH key from the GitHub Enterprise instance
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/enterprise/management_console/#remove-an-authorized-ssh-key
|
||||
/// </remarks>
|
||||
IObservable<AuthorizedKey> DeleteAuthorizedKey(AuthorizedKeyRequest authorizedKey, string managementConsolePassword);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
@@ -12,12 +14,14 @@ namespace Octokit.Reactive
|
||||
public class ObservableEnterpriseManagementConsoleClient : IObservableEnterpriseManagementConsoleClient
|
||||
{
|
||||
readonly IEnterpriseManagementConsoleClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableEnterpriseManagementConsoleClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Enterprise.ManagementConsole;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,5 +52,50 @@ namespace Octokit.Reactive
|
||||
|
||||
return _client.EditMaintenanceMode(maintenance, managementConsolePassword).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the authorized SSH keys for the GitHub Enterprise instance
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/enterprise/management_console/#retrieve-authorized-ssh-keys
|
||||
/// </remarks>
|
||||
public IObservable<AuthorizedKey> GetAllAuthorizedKeys(string managementConsolePassword)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(managementConsolePassword, "managementConsolePassword");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<AuthorizedKey>(ApiUrls.EnterpriseManagementConsoleAuthorizedKeys(managementConsolePassword, _connection.BaseAddress));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an authorized SSH key to the GitHub Enterprise instance
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/enterprise/management_console/#add-a-new-authorized-ssh-key
|
||||
/// </remarks>
|
||||
public IObservable<AuthorizedKey> AddAuthorizedKey(AuthorizedKeyRequest authorizedKey, string managementConsolePassword)
|
||||
{
|
||||
Ensure.ArgumentNotNull(authorizedKey, "authorizedKey");
|
||||
Ensure.ArgumentNotNullOrEmptyString(managementConsolePassword, "managementConsolePassword");
|
||||
|
||||
return _client.AddAuthorizedKey(authorizedKey, managementConsolePassword)
|
||||
.ToObservable()
|
||||
.SelectMany(x => x); // HACK: POST is not compatible with GetAndFlattenPages
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an authorized SSH key from the GitHub Enterprise instance
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/enterprise/management_console/#remove-an-authorized-ssh-key
|
||||
/// </remarks>
|
||||
public IObservable<AuthorizedKey> DeleteAuthorizedKey(AuthorizedKeyRequest authorizedKey, string managementConsolePassword)
|
||||
{
|
||||
Ensure.ArgumentNotNull(authorizedKey, "authorizedKey");
|
||||
Ensure.ArgumentNotNullOrEmptyString(managementConsolePassword, "managementConsolePassword");
|
||||
|
||||
return _client.DeleteAuthorizedKey(authorizedKey, managementConsolePassword)
|
||||
.ToObservable()
|
||||
.SelectMany(x => x); // HACK: DELETE is not compatible with GetAndFlattenPages
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user