using System; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive { /// /// A client for GitHub's Git Trees API. /// /// /// See the Git Trees API documentation for more information. /// public class ObservableTreesClient : IObservableTreesClient { readonly ITreesClient _client; public ObservableTreesClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Git.Tree; } /// /// Gets a Tree Response for a given SHA. /// /// /// http://developer.github.com/v3/git/trees/#get-a-tree /// /// The owner of the repository /// The name of the repository /// The SHA that references the tree public IObservable Get(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return _client.Get(owner, name, reference).ToObservable(); } /// /// Gets a Tree Response for a given SHA. /// /// /// http://developer.github.com/v3/git/trees/#get-a-tree /// /// The ID of the repository /// The SHA that references the tree public IObservable Get(int repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return _client.Get(repositoryId, reference).ToObservable(); } /// /// Gets a Tree Response for a given SHA. /// /// /// https://developer.github.com/v3/git/trees/#get-a-tree-recursively /// /// The owner of the repository /// The name of the repository /// The SHA that references the tree public IObservable GetRecursive(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return _client.GetRecursive(owner, name, reference).ToObservable(); } /// /// Gets a Tree Response for a given SHA. /// /// /// https://developer.github.com/v3/git/trees/#get-a-tree-recursively /// /// The ID of the repository /// The SHA that references the tree public IObservable GetRecursive(int repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return _client.GetRecursive(repositoryId, reference).ToObservable(); } /// /// Creates a new Tree in the specified repo /// /// /// http://developer.github.com/v3/git/trees/#create-a-tree /// /// The owner of the repository /// The name of the repository /// The value of the new tree public IObservable Create(string owner, string name, NewTree newTree) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(newTree, "newTree"); return _client.Create(owner, name, newTree).ToObservable(); } /// /// Creates a new Tree in the specified repo /// /// /// http://developer.github.com/v3/git/trees/#create-a-tree /// /// The ID of the repository /// The value of the new tree public IObservable Create(int repositoryId, NewTree newTree) { Ensure.ArgumentNotNull(newTree, "newTree"); return _client.Create(repositoryId, newTree).ToObservable(); } } }