diff --git a/Octokit.Reactive/Clients/IObservableTreesClient.cs b/Octokit.Reactive/Clients/IObservableTreesClient.cs index ac10689a..696df956 100644 --- a/Octokit.Reactive/Clients/IObservableTreesClient.cs +++ b/Octokit.Reactive/Clients/IObservableTreesClient.cs @@ -2,6 +2,12 @@ using System; namespace Octokit.Reactive { + /// + /// A client for GitHub's Git Trees API. + /// + /// + /// See the Git Trees API documentation for more information. + /// public interface IObservableTreesClient { /// @@ -17,6 +23,18 @@ namespace Octokit.Reactive [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] IObservable Get(string owner, string name, string reference); + /// + /// 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 + /// The for the specified Tree. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] + IObservable Get(int repositoryId, string reference); + /// /// Gets a Tree Response for a given SHA. /// @@ -29,6 +47,17 @@ namespace Octokit.Reactive /// The for the specified Tree. IObservable GetRecursive(string owner, string name, string reference); + /// + /// 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 + /// The for the specified Tree. + IObservable GetRecursive(int repositoryId, string reference); + /// /// Creates a new Tree in the specified repo /// @@ -40,5 +69,16 @@ namespace Octokit.Reactive /// The value of the new tree /// The that was just created. IObservable Create(string owner, string name, NewTree newTree); + + /// + /// 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 + /// The that was just created. + IObservable Create(int repositoryId, NewTree newTree); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableTreesClient.cs b/Octokit.Reactive/Clients/ObservableTreesClient.cs index e018b10d..bfe13b16 100644 --- a/Octokit.Reactive/Clients/ObservableTreesClient.cs +++ b/Octokit.Reactive/Clients/ObservableTreesClient.cs @@ -3,6 +3,12 @@ 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; @@ -33,6 +39,22 @@ namespace Octokit.Reactive 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 + /// The for the specified 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. /// @@ -52,6 +74,22 @@ namespace Octokit.Reactive 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 + /// The for the specified 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 /// @@ -70,5 +108,21 @@ namespace Octokit.Reactive 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 + /// The that was just created. + public IObservable Create(int repositoryId, NewTree newTree) + { + Ensure.ArgumentNotNull(newTree, "newTree"); + + return _client.Create(repositoryId, newTree).ToObservable(); + } } } diff --git a/Octokit/Clients/ITreesClient.cs b/Octokit/Clients/ITreesClient.cs index 549621a4..fe74e1eb 100644 --- a/Octokit/Clients/ITreesClient.cs +++ b/Octokit/Clients/ITreesClient.cs @@ -23,6 +23,18 @@ namespace Octokit [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task Get(string owner, string name, string reference); + /// + /// 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 + /// The for the specified Tree. + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] + Task Get(int repositoryId, string reference); + /// /// Gets a Tree Response for a given SHA. /// @@ -35,6 +47,17 @@ namespace Octokit /// The for the specified Tree. Task GetRecursive(string owner, string name, string reference); + /// + /// 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 + /// The for the specified Tree. + Task GetRecursive(int repositoryId, string reference); + /// /// Creates a new Tree in the specified repo /// @@ -46,5 +69,16 @@ namespace Octokit /// The value of the new tree /// The that was just created. Task Create(string owner, string name, NewTree newTree); + + /// + /// 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 + /// The that was just created. + Task Create(int repositoryId, NewTree newTree); } } \ No newline at end of file diff --git a/Octokit/Clients/TreesClient.cs b/Octokit/Clients/TreesClient.cs index 5ac64675..829014c6 100644 --- a/Octokit/Clients/TreesClient.cs +++ b/Octokit/Clients/TreesClient.cs @@ -40,6 +40,22 @@ namespace Octokit return ApiConnection.Get(ApiUrls.Tree(owner, name, reference)); } + /// + /// 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 + /// The for the specified Tree. + public Task Get(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return ApiConnection.Get(ApiUrls.Tree(repositoryId, reference)); + } + /// /// Gets a Tree Response for a given SHA. /// @@ -59,6 +75,22 @@ namespace Octokit return ApiConnection.Get(ApiUrls.TreeRecursive(owner, name, reference)); } + /// + /// 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 + /// The for the specified Tree. + public Task GetRecursive(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return ApiConnection.Get(ApiUrls.TreeRecursive(repositoryId, reference)); + } + /// /// Creates a new Tree in the specified repo /// @@ -82,5 +114,26 @@ namespace Octokit return ApiConnection.Post(ApiUrls.Tree(owner, name), newTree); } + + /// + /// 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 + /// The that was just created. + public Task Create(int repositoryId, NewTree newTree) + { + Ensure.ArgumentNotNull(newTree, "newTree"); + + if (newTree.Tree.Any(t => string.IsNullOrWhiteSpace(t.Mode))) + { + throw new ArgumentException("You have specified items in the tree which do not have a Mode value set."); + } + + return ApiConnection.Post(ApiUrls.Tree(repositoryId), newTree); + } } }