mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
[feat]: Added Environments API - GetAll list only feature
This commit is contained in:
@@ -226,10 +226,18 @@ namespace Octokit.Reactive
|
||||
/// Client for GitHub's Repository Deployments API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/deployment/">Collaborators API documentation</a> for more details
|
||||
/// See the <a href="https://docs.github.com/en/rest/deployments/deployments">Deployments API documentation</a> for more details
|
||||
/// </remarks>
|
||||
IObservableDeploymentsClient Deployment { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Envirinments API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/deployments/environments/">Envirinments API documentation</a> for more details
|
||||
/// </remarks>
|
||||
IObservableRepositoryDeployEnvironmentsClient Environment { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Statistics API.
|
||||
/// Note that the GitHub API uses caching on these endpoints,
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using Octokit.Models.Response;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableRepositoryDeployEnvironmentsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the environments for the specified repository. Any user with pull access
|
||||
/// to a repository can view deployments.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://docs.github.com/en/rest/deployments/environments#list-environments
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the environments for the specified repository. Any user with pull access
|
||||
/// to a repository can view deployments.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://docs.github.com/en/rest/deployments/environments#list-environments
|
||||
/// </remarks>
|
||||
/// <param name="repositoryId">The Id of the repository</param>
|
||||
IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the environments for the specified repository. Any user with pull access
|
||||
/// to a repository can view deployments.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://docs.github.com/en/rest/deployments/environments#list-environments
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="options">Paging options</param>
|
||||
IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name, ApiOptions options);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the environments for the specified repository. Any user with pull access
|
||||
/// to a repository can view deployments.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://docs.github.com/en/rest/deployments/environments#list-environments
|
||||
/// </remarks>
|
||||
/// <param name="repositoryId">Repository ID</param>
|
||||
/// <param name="options">Paging options</param>
|
||||
IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId, ApiOptions options);
|
||||
}
|
||||
}
|
||||
52
Octokit.Reactive/Clients/ObservableEnvironmentsClient.cs
Normal file
52
Octokit.Reactive/Clients/ObservableEnvironmentsClient.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Models.Response;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive.Clients
|
||||
{
|
||||
public class ObservableEnvironmentsClient : IObservableRepositoryDeployEnvironmentsClient
|
||||
{
|
||||
readonly IRepositoryDeployEnvironmentsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableEnvironmentsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Repository.Environment;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
public IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return GetAll(owner, name, ApiOptions.None);
|
||||
}
|
||||
|
||||
public IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId)
|
||||
{
|
||||
return GetAll(repositoryId, ApiOptions.None);
|
||||
}
|
||||
|
||||
public IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
return _connection.GetAndFlattenAllPages<DeploymentEnvironmentsResponse>(
|
||||
ApiUrls.DeploymentEnvironments(owner, name), options);
|
||||
}
|
||||
|
||||
public IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
return _connection.GetAndFlattenAllPages<DeploymentEnvironmentsResponse>(
|
||||
ApiUrls.DeploymentEnvironments(repositoryId), options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ namespace Octokit.Reactive
|
||||
Forks = new ObservableRepositoryForksClient(client);
|
||||
Collaborator = new ObservableRepoCollaboratorsClient(client);
|
||||
Deployment = new ObservableDeploymentsClient(client);
|
||||
Environment = new ObservableEnvironmentsClient(client);
|
||||
Statistics = new ObservableStatisticsClient(client);
|
||||
PullRequest = new ObservablePullRequestsClient(client);
|
||||
Branch = new ObservableRepositoryBranchesClient(client);
|
||||
@@ -347,10 +348,19 @@ namespace Octokit.Reactive
|
||||
/// Client for GitHub's Repository Deployments API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/deployment/">Collaborators API documentation</a> for more details
|
||||
/// See the <a href="https://docs.github.com/en/rest/deployments/deployments">Deployments API documentation</a> for more details
|
||||
/// </remarks>
|
||||
public IObservableDeploymentsClient Deployment { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Environments API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/deployments/environments#about-the-deployment-environments-api/">Environments API documentation</a> for more details
|
||||
/// </remarks>
|
||||
public IObservableRepositoryDeployEnvironmentsClient Environment { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Statistics API
|
||||
/// Note that the GitHub API uses caching on these endpoints,
|
||||
|
||||
Reference in New Issue
Block a user