mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reactive.Threading.Tasks;
|
|
|
|
namespace Octokit.Reactive.Clients
|
|
{
|
|
public class ObservableRepositoriesClient : IObservableRepositoriesClient
|
|
{
|
|
readonly IRepositoriesClient _client;
|
|
|
|
public ObservableRepositoriesClient(IRepositoriesClient client)
|
|
{
|
|
Ensure.ArgumentNotNull(client, "client");
|
|
|
|
_client = client;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new repository for the current user.
|
|
/// </summary>
|
|
/// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param>
|
|
/// <returns>An <see cref="IObservable{Repository}"/> instance for the created repository</returns>
|
|
public IObservable<Repository> Create(NewRepository newRepository)
|
|
{
|
|
Ensure.ArgumentNotNull(newRepository, "newRepository");
|
|
if (string.IsNullOrEmpty(newRepository.Name))
|
|
throw new ArgumentException("The new repository's name must not be null.");
|
|
|
|
return _client.Create(newRepository).ToObservable();
|
|
}
|
|
|
|
public IObservable<Repository> Get(string owner, string name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
|
|
|
return _client.Get(owner, name).ToObservable();
|
|
}
|
|
|
|
public IObservable<IReadOnlyList<Repository>> GetAllForCurrent()
|
|
{
|
|
return _client.GetAllForCurrent().ToObservable();
|
|
}
|
|
|
|
public IObservable<IReadOnlyList<Repository>> GetAllForUser(string login)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
|
|
|
return _client.GetAllForUser(login).ToObservable();
|
|
}
|
|
|
|
public IObservable<IReadOnlyList<Repository>> GetAllForOrg(string organization)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
|
|
|
|
return _client.GetAllForOrg(organization).ToObservable();
|
|
}
|
|
|
|
public IObservable<Readme> GetReadme(string owner, string name)
|
|
{
|
|
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
|
|
|
return _client.GetReadme(owner, name).ToObservable();
|
|
}
|
|
}
|
|
}
|