using System;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
///
/// A client for GitHub Applications Installations API.
///
///
/// See the GitHub Apps Installations API documentation for more information.
///
public class ObservableGitHubAppInstallationsClient : IObservableGitHubAppInstallationsClient
{
private IGitHubAppInstallationsClient _client;
private readonly IConnection _connection;
public ObservableGitHubAppInstallationsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.GitHubApps.Installation;
_connection = client.Connection;
}
///
/// List repositories of the authenticated GitHub App Installation (requires GitHubApp Installation-Token auth).
///
/// https://developer.github.com/v3/apps/installations/#list-repositories
public IObservable GetAllRepositoriesForCurrent()
{
return GetAllRepositoriesForCurrent(ApiOptions.None);
}
///
/// List repositories of the authenticated GitHub App Installation (requires GitHubApp Installation-Token auth).
///
/// Options for changing the API response
/// https://developer.github.com/v3/apps/installations/#list-repositories
public IObservable GetAllRepositoriesForCurrent(ApiOptions options)
{
return _connection.GetAndFlattenAllPages(ApiUrls.InstallationRepositories(), null, AcceptHeaders.GitHubAppsPreview, options);
}
///
/// List repositories accessible to the user for an installation (requires GitHubApp User-To-Server Auth).
///
/// The Id of the installation
/// https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation
public IObservable GetAllRepositoriesForCurrentUser(long installationId)
{
return GetAllRepositoriesForCurrentUser(installationId, ApiOptions.None);
}
///
/// List repositories accessible to the user for an installation (requires GitHubApp User-To-Server Auth).
///
/// The Id of the installation
/// Options for changing the API response
/// https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation
public IObservable GetAllRepositoriesForCurrentUser(long installationId, ApiOptions options)
{
return _connection.GetAndFlattenAllPages(ApiUrls.UserInstallationRepositories(installationId), null, AcceptHeaders.GitHubAppsPreview, options);
}
}
}