diff --git a/Octokit.Reactive/Clients/IObservableReferencesClient.cs b/Octokit.Reactive/Clients/IObservableReferencesClient.cs index dac7fee9..23ac3a6c 100644 --- a/Octokit.Reactive/Clients/IObservableReferencesClient.cs +++ b/Octokit.Reactive/Clients/IObservableReferencesClient.cs @@ -25,6 +25,19 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] IObservable Get(string owner, string name, string reference); + + /// + /// Gets a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#get-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + IObservable Get(int repositoryId, string reference); /// /// Gets all references for a given repository @@ -37,6 +50,16 @@ namespace Octokit.Reactive /// IObservable GetAll(string owner, string name); + /// + /// Gets all references for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// + IObservable GetAll(int repositoryId); + /// /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" /// @@ -49,6 +72,17 @@ namespace Octokit.Reactive /// IObservable GetAllForSubNamespace(string owner, string name, string subNamespace); + /// + /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// The sub-namespace to get references for + /// + IObservable GetAllForSubNamespace(int repositoryId, string subNamespace); + /// /// Creates a reference for a given repository /// @@ -61,6 +95,17 @@ namespace Octokit.Reactive /// IObservable Create(string owner, string name, NewReference reference); + /// + /// Creates a reference for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#create-a-reference + /// + /// The ID of the repository + /// The reference to create + /// + IObservable Create(int repositoryId, NewReference reference); + /// /// Updates a reference for a given repository by reference name /// @@ -74,6 +119,18 @@ namespace Octokit.Reactive /// IObservable Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate); + /// + /// Updates a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#update-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// The updated reference data + /// + IObservable Update(int repositoryId, string reference, ReferenceUpdate referenceUpdate); + /// /// Deletes a reference for a given repository by reference name /// @@ -85,5 +142,16 @@ namespace Octokit.Reactive /// The name of the reference /// IObservable Delete(string owner, string name, string reference); + + /// + /// Deletes a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#delete-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + IObservable Delete(int repositoryId, string reference); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableReferencesClient.cs b/Octokit.Reactive/Clients/ObservableReferencesClient.cs index 50096c7d..8daa76a3 100644 --- a/Octokit.Reactive/Clients/ObservableReferencesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReferencesClient.cs @@ -43,6 +43,22 @@ namespace Octokit.Reactive return _reference.Get(owner, name, reference).ToObservable(); } + /// + /// Gets a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#get-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + public IObservable Get(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return _reference.Get(repositoryId, reference).ToObservable(); + } + /// /// Gets all references for a given repository /// @@ -60,6 +76,19 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.Reference(owner, name)); } + /// + /// Gets all references for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// + public IObservable GetAll(int repositoryId) + { + return _connection.GetAndFlattenAllPages(ApiUrls.Reference(repositoryId)); + } + /// /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" /// @@ -79,6 +108,22 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.Reference(owner, name, subNamespace)); } + /// + /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// The sub-namespace to get references for + /// + public IObservable GetAllForSubNamespace(int repositoryId, string subNamespace) + { + Ensure.ArgumentNotNullOrEmptyString(subNamespace, "subNamespace"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Reference(repositoryId, subNamespace)); + } + /// /// Creates a reference for a given repository /// @@ -98,6 +143,22 @@ namespace Octokit.Reactive return _reference.Create(owner, name, reference).ToObservable(); } + /// + /// Creates a reference for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#create-a-reference + /// + /// The ID of the repository + /// The reference to create + /// + public IObservable Create(int repositoryId, NewReference reference) + { + Ensure.ArgumentNotNull(reference, "reference"); + + return _reference.Create(repositoryId, reference).ToObservable(); + } + /// /// Updates a reference for a given repository by reference name /// @@ -119,6 +180,24 @@ namespace Octokit.Reactive return _reference.Update(owner, name, reference, referenceUpdate).ToObservable(); } + /// + /// Updates a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#update-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// The updated reference data + /// + public IObservable Update(int repositoryId, string reference, ReferenceUpdate referenceUpdate) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + Ensure.ArgumentNotNull(referenceUpdate, "update"); + + return _reference.Update(repositoryId, reference, referenceUpdate).ToObservable(); + } + /// /// Deletes a reference for a given repository by reference name /// @@ -137,5 +216,21 @@ namespace Octokit.Reactive return _reference.Delete(owner, name, reference).ToObservable(); } + + /// + /// Deletes a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#delete-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + public IObservable Delete(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return _reference.Delete(repositoryId, reference).ToObservable(); + } } } \ No newline at end of file diff --git a/Octokit/Clients/IReferencesClient.cs b/Octokit/Clients/IReferencesClient.cs index 10a9fe2c..c6c51fc2 100644 --- a/Octokit/Clients/IReferencesClient.cs +++ b/Octokit/Clients/IReferencesClient.cs @@ -23,9 +23,22 @@ namespace Octokit /// The name of the reference /// [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", - Justification = "Method makes a network request")] + Justification = "Method makes a network request")] Task Get(string owner, string name, string reference); + /// + /// Gets a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#get-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + Task Get(int repositoryId, string reference); + /// /// Gets all references for a given repository /// @@ -37,6 +50,16 @@ namespace Octokit /// Task> GetAll(string owner, string name); + /// + /// Gets all references for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// + Task> GetAll(int repositoryId); + /// /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" /// @@ -49,6 +72,17 @@ namespace Octokit /// Task> GetAllForSubNamespace(string owner, string name, string subNamespace); + /// + /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// The sub-namespace to get references for + /// + Task> GetAllForSubNamespace(int repositoryId, string subNamespace); + /// /// Creates a reference for a given repository /// @@ -61,6 +95,17 @@ namespace Octokit /// Task Create(string owner, string name, NewReference reference); + /// + /// Creates a reference for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#create-a-reference + /// + /// The ID of the repository + /// The reference to create + /// + Task Create(int repositoryId, NewReference reference); + /// /// Updates a reference for a given repository by reference name /// @@ -74,6 +119,18 @@ namespace Octokit /// Task Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate); + /// + /// Updates a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#update-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// The updated reference data + /// + Task Update(int repositoryId, string reference, ReferenceUpdate referenceUpdate); + /// /// Deletes a reference for a given repository by reference name /// @@ -85,5 +142,16 @@ namespace Octokit /// The name of the reference /// Task Delete(string owner, string name, string reference); + + /// + /// Deletes a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#delete-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + Task Delete(int repositoryId, string reference); } -} \ No newline at end of file +} diff --git a/Octokit/Clients/ReferencesClient.cs b/Octokit/Clients/ReferencesClient.cs index 14c60524..630e8827 100644 --- a/Octokit/Clients/ReferencesClient.cs +++ b/Octokit/Clients/ReferencesClient.cs @@ -39,6 +39,22 @@ namespace Octokit return ApiConnection.Get(ApiUrls.Reference(owner, name, reference)); } + /// + /// Gets a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#get-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + public Task Get(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return ApiConnection.Get(ApiUrls.Reference(repositoryId, reference)); + } + /// /// Gets all references for a given repository /// @@ -56,6 +72,19 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.Reference(owner, name)); } + /// + /// Gets all references for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// + public Task> GetAll(int repositoryId) + { + return ApiConnection.GetAll(ApiUrls.Reference(repositoryId)); + } + /// /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" /// @@ -77,6 +106,24 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.Reference(owner, name, subNamespace)); } + /// + /// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads" + /// + /// + /// http://developer.github.com/v3/git/refs/#get-all-references + /// + /// The ID of the repository + /// The sub-namespace to get references for + /// + public Task> GetAllForSubNamespace(int repositoryId, string subNamespace) + { + Ensure.ArgumentNotNullOrEmptyString(subNamespace, "subNamespace"); + + // TODO: Handle 404 when subNamespace cannot be found + + return ApiConnection.GetAll(ApiUrls.Reference(repositoryId, subNamespace)); + } + /// /// Creates a reference for a given repository /// @@ -96,6 +143,22 @@ namespace Octokit return ApiConnection.Post(ApiUrls.Reference(owner, name), reference); } + /// + /// Creates a reference for a given repository + /// + /// + /// http://developer.github.com/v3/git/refs/#create-a-reference + /// + /// The ID of the repository + /// The reference to create + /// + public Task Create(int repositoryId, NewReference reference) + { + Ensure.ArgumentNotNull(reference, "reference"); + + return ApiConnection.Post(ApiUrls.Reference(repositoryId), reference); + } + /// /// Updates a reference for a given repository by reference name /// @@ -117,6 +180,24 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.Reference(owner, name, reference), referenceUpdate); } + /// + /// Updates a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#update-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// The updated reference data + /// + public Task Update(int repositoryId, string reference, ReferenceUpdate referenceUpdate) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + Ensure.ArgumentNotNull(referenceUpdate, "update"); + + return ApiConnection.Patch(ApiUrls.Reference(repositoryId, reference), referenceUpdate); + } + /// /// Deletes a reference for a given repository by reference name /// @@ -135,5 +216,21 @@ namespace Octokit return ApiConnection.Delete(ApiUrls.Reference(owner, name, reference)); } + + /// + /// Deletes a reference for a given repository by reference name + /// + /// + /// http://developer.github.com/v3/git/refs/#delete-a-reference + /// + /// The ID of the repository + /// The name of the reference + /// + public Task Delete(int repositoryId, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return ApiConnection.Delete(ApiUrls.Reference(repositoryId, reference)); + } } }