-
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.
Added a pre-receive environments client (#1796)
* Added pre-receive environment client https://developer.github.com/v3/enterprise-admin/pre_receive_environments * Added unit and integration tests for the pre-receive environments client * moved test setup outside of tests * fixed unit test * Added reactive components for pre-receive environment endpoints * Debugger display's and non public setters on response object conventions * removed redundant parameter attributes implemented update request independently of new request changed ints to longs for future proofing updated unit tests changed update integration tests to create a new update request to ensure optional values function * updating reactive environmentids to longs as well * also converting response id to a long * Fixed an incorrect unit test renamed some test variable names for consistency Added mockable ctors on responses, and parameterless ctors to maintain functionality * Adding missing state parameter * rename client member accessor to singular form in accordance with octokit naming conventions * fixup tests * add integration tests for observable client
- Loading branch information
1 parent
3345f76
commit f771147
Showing
20 changed files
with
1,883 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
100 changes: 100 additions & 0 deletions
100
Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveEnvironmentsClient.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,100 @@ | ||
using System; | ||
using System.Reactive; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// A client for GitHub's Enterprise Pre-receive Environments API | ||
/// </summary> | ||
/// <remarks> | ||
/// 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 interface IObservableEnterprisePreReceiveEnvironmentsClient | ||
{ | ||
/// <summary> | ||
/// Gets all <see cref="PreReceiveEnvironment"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#list-pre-receive-environments">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveEnvironment> GetAll(); | ||
|
||
/// <summary> | ||
/// Gets all <see cref="PreReceiveEnvironment"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#list-pre-receive-environments">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<PreReceiveEnvironment> GetAll(ApiOptions options); | ||
|
||
/// <summary> | ||
/// Gets a single <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#get-a-single-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveEnvironment> Get(long environmentId); | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#create-a-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="newPreReceiveEnvironment">A description of the pre-receive environment to create</param> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveEnvironment> Create(NewPreReceiveEnvironment newPreReceiveEnvironment); | ||
|
||
/// <summary> | ||
/// Edits an existing <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#edit-a-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <param name="updatePreReceiveEnvironment">A description of the pre-receive environment to edit</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveEnvironment> Edit(long environmentId, UpdatePreReceiveEnvironment updatePreReceiveEnvironment); | ||
|
||
/// <summary> | ||
/// Deletes an existing <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#delete-a-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<Unit> Delete(long environmentId); | ||
|
||
/// <summary> | ||
/// Gets the download status for an existing <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#get-a-pre-receive-environments-download-status">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveEnvironmentDownload> DownloadStatus(long environmentId); | ||
|
||
/// <summary> | ||
/// Triggers a new download of the <see cref="PreReceiveEnvironment"/>'s tarball from the environment's <see cref="PreReceiveEnvironment.ImageUrl"/>. | ||
/// When the download is finished, the newly downloaded tarball will overwrite the existing environment. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#trigger-a-pre-receive-environment-download">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
IObservable<PreReceiveEnvironmentDownload> TriggerDownload(long environmentId); | ||
} | ||
} |
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
143 changes: 143 additions & 0 deletions
143
Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClient.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,143 @@ | ||
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 Environments API | ||
/// </summary> | ||
/// <remarks> | ||
/// 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 class ObservableEnterprisePreReceiveEnvironmentsClient : IObservableEnterprisePreReceiveEnvironmentsClient | ||
{ | ||
readonly IEnterprisePreReceiveEnvironmentsClient _client; | ||
readonly IConnection _connection; | ||
|
||
public ObservableEnterprisePreReceiveEnvironmentsClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, nameof(client)); | ||
|
||
_client = client.Enterprise.PreReceiveEnvironment; | ||
_connection = client.Connection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets all <see cref="PreReceiveEnvironment"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#list-pre-receive-environments">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveEnvironment> GetAll() | ||
{ | ||
return GetAll(ApiOptions.None); | ||
} | ||
|
||
/// <summary> | ||
/// Gets all <see cref="PreReceiveEnvironment"/>s. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#list-pre-receive-environments">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<PreReceiveEnvironment> GetAll(ApiOptions options) | ||
{ | ||
Ensure.ArgumentNotNull(options, nameof(options)); | ||
|
||
return _connection.GetAndFlattenAllPages<PreReceiveEnvironment>(ApiUrls.AdminPreReceiveEnvironments(), null, AcceptHeaders.PreReceiveEnvironmentsPreview, options); | ||
} | ||
|
||
/// <summary> | ||
/// Gets a single <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#get-a-single-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveEnvironment> Get(long environmentId) | ||
{ | ||
return _client.Get(environmentId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#create-a-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="newPreReceiveEnvironment">A description of the pre-receive environment to create</param> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveEnvironment> Create(NewPreReceiveEnvironment newPreReceiveEnvironment) | ||
{ | ||
Ensure.ArgumentNotNull(newPreReceiveEnvironment, nameof(newPreReceiveEnvironment)); | ||
|
||
return _client.Create(newPreReceiveEnvironment).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Edits an existing <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#edit-a-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <param name="updatePreReceiveEnvironment">A description of the pre-receive environment to edit</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveEnvironment> Edit(long environmentId, UpdatePreReceiveEnvironment updatePreReceiveEnvironment) | ||
{ | ||
Ensure.ArgumentNotNull(updatePreReceiveEnvironment, nameof(updatePreReceiveEnvironment)); | ||
|
||
return _client.Edit(environmentId, updatePreReceiveEnvironment).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes an existing <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#delete-a-pre-receive-environment">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<Unit> Delete(long environmentId) | ||
{ | ||
return _client.Delete(environmentId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the download status for an existing <see cref="PreReceiveEnvironment"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#get-a-pre-receive-environments-download-status">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveEnvironmentDownload> DownloadStatus(long environmentId) | ||
{ | ||
return _client.DownloadStatus(environmentId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Triggers a new download of the <see cref="PreReceiveEnvironment"/>'s tarball from the environment's <see cref="PreReceiveEnvironment.ImageUrl"/>. | ||
/// When the download is finished, the newly downloaded tarball will overwrite the existing environment. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/#trigger-a-pre-receive-environment-download">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <param name="environmentId">The id of the pre-receive environment</param> | ||
/// <exception cref="NotFoundException">Thrown when the specified <paramref name="environmentId"/> does not exist.</exception> | ||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception> | ||
public IObservable<PreReceiveEnvironmentDownload> TriggerDownload(long environmentId) | ||
{ | ||
return _client.TriggerDownload(environmentId).ToObservable(); | ||
} | ||
} | ||
} |
Oops, something went wrong.