From b16ef25f3847ca2982887441c1aa5c8982d573ff Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 17 Jun 2016 15:46:28 +0700 Subject: [PATCH] added new overloads --- .../Clients/IObservableRepositoriesClient.cs | 168 +++++++++++- .../Clients/ObservableRepositoriesClient.cs | 236 +++++++++++++++- Octokit/Clients/IRepositoriesClient.cs | 183 ++++++++++++- Octokit/Clients/RepositoriesClient.cs | 254 +++++++++++++++++- 4 files changed, 822 insertions(+), 19 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 023fbb74..952dd82a 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -30,6 +30,14 @@ namespace Octokit.Reactive /// An for the operation IObservable Delete(string owner, string name); + /// + /// Deletes a repository for the specified owner and name. + /// + /// The ID of the repository + /// Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required. + /// An for the operation + IObservable Delete(int repositoryId); + /// /// Retrieves the for the specified owner and name. /// @@ -39,6 +47,14 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] IObservable Get(string owner, string name); + /// + /// Retrieves the for the specified owner and name. + /// + /// The ID of the repository + /// A + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] + IObservable Get(int repositoryId); + /// /// Retrieves every public . /// @@ -228,6 +244,17 @@ namespace Octokit.Reactive /// All es of the repository IObservable GetAllBranches(string owner, string name); + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + /// All es of the repository + IObservable GetAllBranches(int repositoryId); + /// /// Gets all the branches for the specified repository. /// @@ -241,6 +268,18 @@ namespace Octokit.Reactive /// All es of the repository IObservable GetAllBranches(string owner, string name, ApiOptions options); + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// Thrown when a general API error occurs. + /// All es of the repository + IObservable GetAllBranches(int repositoryId, ApiOptions options); + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -252,6 +291,16 @@ namespace Octokit.Reactive /// All contributors of the repository. IObservable GetAllContributors(string owner, string name); + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All contributors of the repository. + IObservable GetAllContributors(int repositoryId); + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -264,6 +313,17 @@ namespace Octokit.Reactive /// All contributors of the repository. IObservable GetAllContributors(string owner, string name, ApiOptions options); + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All contributors of the repository. + IObservable GetAllContributors(int repositoryId, ApiOptions options); + /// /// Gets all contributors for the specified repository. With the option to include anonymous contributors. /// @@ -276,6 +336,16 @@ namespace Octokit.Reactive /// All contributors of the repository. IObservable GetAllContributors(string owner, string name, bool includeAnonymous); + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// All contributors of the repository. + IObservable GetAllContributors(int repositoryId, bool includeAnonymous); /// /// Gets all contributors for the specified repository. With the option to include anonymous contributors. @@ -290,6 +360,18 @@ namespace Octokit.Reactive /// All contributors of the repository. IObservable GetAllContributors(string owner, string name, bool includeAnonymous, ApiOptions options); + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// Options for changing the API response + /// All contributors of the repository. + IObservable GetAllContributors(int repositoryId, bool includeAnonymous, ApiOptions options); + /// /// Gets all languages for the specified repository. /// @@ -301,6 +383,16 @@ namespace Octokit.Reactive /// All languages used in the repository and the number of bytes of each language. IObservable GetAllLanguages(string owner, string name); + /// + /// Gets all languages for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All languages used in the repository and the number of bytes of each language. + IObservable GetAllLanguages(int repositoryId); + /// /// Gets all teams for the specified repository. /// @@ -312,6 +404,16 @@ namespace Octokit.Reactive /// All s associated with the repository IObservable GetAllTeams(string owner, string name); + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All s associated with the repository + IObservable GetAllTeams(int repositoryId); + /// /// Gets all teams for the specified repository. /// @@ -324,6 +426,17 @@ namespace Octokit.Reactive /// All s associated with the repository IObservable GetAllTeams(string owner, string name, ApiOptions options); + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All s associated with the repository + IObservable GetAllTeams(int repositoryId, ApiOptions options); + /// /// Gets all tags for the specified repository. /// @@ -335,6 +448,16 @@ namespace Octokit.Reactive /// All of the repositories tags. IObservable GetAllTags(string owner, string name); + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All of the repositories tags. + IObservable GetAllTags(int repositoryId); + /// /// Gets all tags for the specified repository. /// @@ -347,6 +470,17 @@ namespace Octokit.Reactive /// All of the repositories tags. IObservable GetAllTags(string owner, string name, ApiOptions options); + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All of the repositories tags. + IObservable GetAllTags(int repositoryId, ApiOptions options); + /// /// Gets the specified branch. /// @@ -354,10 +488,21 @@ namespace Octokit.Reactive /// See the API documentation for more details /// /// The owner of the repository - /// The name of the repository + /// The name of the repository /// The name of the branch /// The specified - IObservable GetBranch(string owner, string repositoryName, string branchName); + IObservable GetBranch(string owner, string name, string branchName); + + /// + /// Gets the specified branch. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// The name of the branch + /// The specified + IObservable GetBranch(int repositoryId, string branchName); /// /// Updates the specified repository with the values given in @@ -368,6 +513,14 @@ namespace Octokit.Reactive /// The updated IObservable Edit(string owner, string name, RepositoryUpdate update); + /// + /// Updates the specified repository with the values given in + /// + /// The ID of the repository + /// New values to update the repository with + /// The updated + IObservable Edit(int repositoryId, RepositoryUpdate update); + /// /// Edit the specified branch with the values given in /// @@ -378,6 +531,15 @@ namespace Octokit.Reactive /// The updated IObservable EditBranch(string owner, string name, string branch, BranchUpdate update); + /// + /// Edit the specified branch with the values given in + /// + /// The ID of the repository + /// The name of the branch + /// New values to update the branch with + /// The updated + IObservable EditBranch(int repositoryId, string branch, BranchUpdate update); + /// /// A client for GitHub's Repo Collaborators. /// @@ -401,7 +563,7 @@ namespace Octokit.Reactive /// /// See the Commits API documentation for more details /// - [System.Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] + [Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] IObservableRepositoryCommitsClient Commits { get; } /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 26a4ddfe..be070242 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -89,6 +89,17 @@ namespace Octokit.Reactive return _client.Delete(owner, name).ToObservable(); } + /// + /// Deletes a repository for the specified owner and name. + /// + /// The ID of the repository + /// Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required. + /// An for the operation + public IObservable Delete(int repositoryId) + { + return _client.Delete(repositoryId).ToObservable(); + } + /// /// Retrieves the for the specified owner and name. /// @@ -103,6 +114,16 @@ namespace Octokit.Reactive return _client.Get(owner, name).ToObservable(); } + /// + /// Retrieves the for the specified owner and name. + /// + /// The ID of the repository + /// A + public IObservable Get(int repositoryId) + { + return _client.Get(repositoryId).ToObservable(); + } + /// /// Retrieves every public . /// @@ -344,6 +365,20 @@ namespace Octokit.Reactive return GetAllBranches(owner, name, ApiOptions.None); } + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + /// All es of the repository + public IObservable GetAllBranches(int repositoryId) + { + return GetAllBranches(repositoryId, ApiOptions.None); + } + /// /// Gets all the branches for the specified repository. /// @@ -364,6 +399,23 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.RepoBranches(owner, name), options); } + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// Thrown when a general API error occurs. + /// All es of the repository + public IObservable GetAllBranches(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepoBranches(repositoryId), options); + } + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -380,7 +432,20 @@ namespace Octokit.Reactive return GetAllContributors(owner, name, ApiOptions.None); } - + + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All contributors of the repository. + public IObservable GetAllContributors(int repositoryId) + { + return GetAllContributors(repositoryId, ApiOptions.None); + } + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -400,6 +465,22 @@ namespace Octokit.Reactive return GetAllContributors(owner, name, false, ApiOptions.None); } + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All contributors of the repository. + public IObservable GetAllContributors(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAllContributors(repositoryId, false, ApiOptions.None); + } + /// /// Gets all contributors for the specified repository. With the option to include anonymous contributors. /// @@ -418,6 +499,20 @@ namespace Octokit.Reactive return GetAllContributors(owner, name, false, ApiOptions.None); } + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// All contributors of the repository. + public IObservable GetAllContributors(int repositoryId, bool includeAnonymous) + { + return GetAllContributors(repositoryId, false, ApiOptions.None); + } + public IObservable GetAllContributors(string owner, string name, bool includeAnonymous, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -432,6 +527,28 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(endpoint, parameters); } + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// Options for changing the API response + /// All contributors of the repository. + public IObservable GetAllContributors(int repositoryId, bool includeAnonymous, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + var endpoint = ApiUrls.RepositoryContributors(repositoryId); + var parameters = new Dictionary(); + if (includeAnonymous) + parameters.Add("anon", "1"); + + return _connection.GetAndFlattenAllPages(endpoint, parameters); + } + /// /// Gets all languages for the specified repository. /// @@ -452,6 +569,22 @@ namespace Octokit.Reactive .Select(t => new RepositoryLanguage(t.Item1, t.Item2)); } + /// + /// Gets all languages for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All languages used in the repository and the number of bytes of each language. + public IObservable GetAllLanguages(int repositoryId) + { + var endpoint = ApiUrls.RepositoryLanguages(repositoryId); + return _connection + .GetAndFlattenAllPages>(endpoint) + .Select(t => new RepositoryLanguage(t.Item1, t.Item2)); + } + /// /// Gets all teams for the specified repository. /// @@ -469,6 +602,19 @@ namespace Octokit.Reactive return GetAllTeams(owner, name, ApiOptions.None); } + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All s associated with the repository + public IObservable GetAllTeams(int repositoryId) + { + return GetAllTeams(repositoryId, ApiOptions.None); + } + /// /// Gets all teams for the specified repository. /// @@ -488,6 +634,22 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryTeams(owner, name), options); } + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All s associated with the repository + public IObservable GetAllTeams(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryTeams(repositoryId), options); + } + /// /// Gets all tags for the specified repository. /// @@ -505,6 +667,19 @@ namespace Octokit.Reactive return GetAllTags(owner, name, ApiOptions.None); } + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All of the repositories tags. + public IObservable GetAllTags(int repositoryId) + { + return GetAllTags(repositoryId, ApiOptions.None); + } + /// /// Gets all tags for the specified repository. /// @@ -524,6 +699,22 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryTags(owner, name), options); } + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All of the repositories tags. + public IObservable GetAllTags(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryTags(repositoryId), options); + } + /// /// Gets the specified branch. /// @@ -531,12 +722,26 @@ namespace Octokit.Reactive /// See the API documentation for more details /// /// The owner of the repository - /// The name of the repository + /// The name of the repository /// The name of the branch /// The specified - public IObservable GetBranch(string owner, string repositoryName, string branchName) + public IObservable GetBranch(string owner, string name, string branchName) { - return _client.GetBranch(owner, repositoryName, branchName).ToObservable(); + return _client.GetBranch(owner, name, branchName).ToObservable(); + } + + /// + /// Gets the specified branch. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// The name of the branch + /// The specified + public IObservable GetBranch(int repositoryId, string branchName) + { + return _client.GetBranch(repositoryId, branchName).ToObservable(); } /// @@ -551,6 +756,17 @@ namespace Octokit.Reactive return _client.Edit(owner, name, update).ToObservable(); } + /// + /// Updates the specified repository with the values given in + /// + /// The ID of the repository + /// New values to update the repository with + /// The updated + public IObservable Edit(int repositoryId, RepositoryUpdate update) + { + return _client.Edit(repositoryId, update).ToObservable(); + } + /// /// Edit the specified branch with the values given in /// @@ -564,6 +780,18 @@ namespace Octokit.Reactive return _client.EditBranch(owner, name, branch, update).ToObservable(); } + /// + /// Edit the specified branch with the values given in + /// + /// The ID of the repository + /// The name of the branch + /// New values to update the branch with + /// The updated + public IObservable EditBranch(int repositoryId, string branch, BranchUpdate update) + { + return _client.EditBranch(repositoryId, branch, update).ToObservable(); + } + /// /// Compare two references in a repository /// diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index f5436f37..5ae6b1de 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -1,6 +1,6 @@ +using System; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -using System; #if NET_45 using System.Collections.Generic; #endif @@ -91,6 +91,17 @@ namespace Octokit /// Thrown when a general API error occurs. Task Delete(string owner, string name); + /// + /// Deletes the specified repository. + /// + /// + /// See the API documentation for more information. + /// Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required. + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + Task Delete(int repositoryId); + /// /// Gets the specified repository. /// @@ -104,6 +115,18 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task Get(string owner, string name); + /// + /// Gets the specified repository. + /// + /// + /// See the API documentation for more information. + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + /// A + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] + Task Get(int repositoryId); + /// /// Gets all public repositories. /// @@ -115,10 +138,9 @@ namespace Octokit /// Thrown when a general API error occurs. /// A of . [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", - Justification = "Makes a network request")] + Justification = "Makes a network request")] Task> GetAllPublic(); - /// /// Gets all public repositories since the integer ID of the last Repository that you've seen. /// @@ -143,7 +165,7 @@ namespace Octokit /// Thrown when a general API error occurs. /// A of . [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", - Justification = "Makes a network request")] + Justification = "Makes a network request")] Task> GetAllForCurrent(); /// @@ -170,7 +192,7 @@ namespace Octokit /// Thrown when a general API error occurs. /// A of . Task> GetAllForCurrent(RepositoryRequest request); - + /// /// Gets all repositories owned by the current user. /// @@ -343,6 +365,17 @@ namespace Octokit /// All es of the repository Task> GetAllBranches(string owner, string name); + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + /// All es of the repository + Task> GetAllBranches(int repositoryId); + /// /// Gets all the branches for the specified repository. /// @@ -356,6 +389,18 @@ namespace Octokit /// All es of the repository Task> GetAllBranches(string owner, string name, ApiOptions options); + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// Thrown when a general API error occurs. + /// All es of the repository + Task> GetAllBranches(int repositoryId, ApiOptions options); + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -367,6 +412,16 @@ namespace Octokit /// All contributors of the repository. Task> GetAllContributors(string owner, string name); + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All contributors of the repository. + Task> GetAllContributors(int repositoryId); + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -379,6 +434,17 @@ namespace Octokit /// All contributors of the repository. Task> GetAllContributors(string owner, string name, ApiOptions options); + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All contributors of the repository. + Task> GetAllContributors(int repositoryId, ApiOptions options); + /// /// Gets all contributors for the specified repository. With the option to include anonymous contributors. /// @@ -391,6 +457,17 @@ namespace Octokit /// All contributors of the repository. Task> GetAllContributors(string owner, string name, bool includeAnonymous); + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// All contributors of the repository. + Task> GetAllContributors(int repositoryId, bool includeAnonymous); + /// /// Gets all contributors for the specified repository. With the option to include anonymous contributors. /// @@ -404,6 +481,18 @@ namespace Octokit /// All contributors of the repository. Task> GetAllContributors(string owner, string name, bool includeAnonymous, ApiOptions options); + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// Options for changing the API response + /// All contributors of the repository. + Task> GetAllContributors(int repositoryId, bool includeAnonymous, ApiOptions options); + /// /// Gets all languages for the specified repository. /// @@ -415,6 +504,16 @@ namespace Octokit /// All languages used in the repository and the number of bytes of each language. Task> GetAllLanguages(string owner, string name); + /// + /// Gets all languages for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All languages used in the repository and the number of bytes of each language. + Task> GetAllLanguages(int repositoryId); + /// /// Gets all teams for the specified repository. /// @@ -426,6 +525,16 @@ namespace Octokit /// All s associated with the repository Task> GetAllTeams(string owner, string name); + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All s associated with the repository + Task> GetAllTeams(int repositoryId); + /// /// Gets all teams for the specified repository. /// @@ -438,6 +547,17 @@ namespace Octokit /// All s associated with the repository Task> GetAllTeams(string owner, string name, ApiOptions options); + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All s associated with the repository + Task> GetAllTeams(int repositoryId, ApiOptions options); + /// /// Gets all tags for the specified repository. /// @@ -449,6 +569,16 @@ namespace Octokit /// All of the repositories tags. Task> GetAllTags(string owner, string name); + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All of the repositories tags. + Task> GetAllTags(int repositoryId); + /// /// Gets all tags for the specified repository. /// @@ -461,6 +591,17 @@ namespace Octokit /// All of the repositories tags. Task> GetAllTags(string owner, string name, ApiOptions options); + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All of the repositories tags. + Task> GetAllTags(int repositoryId, ApiOptions options); + /// /// Gets the specified branch. /// @@ -468,10 +609,21 @@ namespace Octokit /// See the API documentation for more details /// /// The owner of the repository - /// The name of the repository + /// The name of the repository /// The name of the branch /// The specified - Task GetBranch(string owner, string repositoryName, string branchName); + Task GetBranch(string owner, string name, string branchName); + + /// + /// Gets the specified branch. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// The name of the branch + /// The specified + Task GetBranch(int repositoryId, string branchName); /// /// Updates the specified repository with the values given in @@ -482,6 +634,14 @@ namespace Octokit /// The updated Task Edit(string owner, string name, RepositoryUpdate update); + /// + /// Updates the specified repository with the values given in + /// + /// The ID of the repository + /// New values to update the repository with + /// The updated + Task Edit(int repositoryId, RepositoryUpdate update); + /// /// Edit the specified branch with the values given in /// @@ -492,6 +652,15 @@ namespace Octokit /// The updated Task EditBranch(string owner, string name, string branch, BranchUpdate update); + /// + /// Edit the specified branch with the values given in + /// + /// The ID of the repository + /// The name of the branch + /// New values to update the branch with + /// The updated + Task EditBranch(int repositoryId, string branch, BranchUpdate update); + /// /// A client for GitHub's Repository Pages API. /// diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 3176638f..a88f4078 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -155,6 +155,36 @@ namespace Octokit return ApiConnection.Delete(ApiUrls.Repository(owner, name)); } + /// + /// Deletes the specified repository. + /// + /// + /// See the API documentation for more information. + /// Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required. + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + public Task Delete(int repositoryId) + { + return ApiConnection.Delete(ApiUrls.Repository(repositoryId)); + } + + /// + /// Gets the specified branch. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// The name of the branch + /// The specified + public Task GetBranch(int repositoryId, string branchName) + { + Ensure.ArgumentNotNullOrEmptyString(branchName, "branchName"); + + return ApiConnection.Get(ApiUrls.RepoBranch(repositoryId, branchName), null, AcceptHeaders.ProtectedBranchesApiPreview); + } + /// /// Updates the specified repository with the values given in /// @@ -171,6 +201,19 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.Repository(owner, name), update); } + /// + /// Updates the specified repository with the values given in + /// + /// The ID of the repository + /// New values to update the repository with + /// The updated + public Task Edit(int repositoryId, RepositoryUpdate update) + { + Ensure.ArgumentNotNull(update, "update"); + + return ApiConnection.Patch(ApiUrls.Repository(repositoryId), update); + } + /// /// Edit the specified branch with the values given in /// @@ -189,6 +232,21 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.RepoBranch(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); } + /// + /// Edit the specified branch with the values given in + /// + /// The ID of the repository + /// The name of the branch + /// New values to update the branch with + /// The updated + public Task EditBranch(int repositoryId, string branch, BranchUpdate update) + { + Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); + Ensure.ArgumentNotNull(update, "update"); + + return ApiConnection.Patch(ApiUrls.RepoBranch(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); + } + /// /// Gets the specified repository. /// @@ -207,6 +265,20 @@ namespace Octokit return ApiConnection.Get(ApiUrls.Repository(owner, name)); } + /// + /// Gets the specified repository. + /// + /// + /// See the API documentation for more information. + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + /// A + public Task Get(int repositoryId) + { + return ApiConnection.Get(ApiUrls.Repository(repositoryId)); + } + /// /// Gets all public repositories. /// @@ -378,7 +450,10 @@ namespace Octokit /// that announced this feature. /// [Obsolete("Use Status instead")] - public ICommitStatusClient CommitStatus { get { return Status; } } + public ICommitStatusClient CommitStatus + { + get { return Status; } + } /// /// A client for GitHub's Commit Status API. @@ -527,6 +602,20 @@ namespace Octokit return GetAllBranches(owner, name, ApiOptions.None); } + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Thrown when a general API error occurs. + /// All es of the repository + public Task> GetAllBranches(int repositoryId) + { + return GetAllBranches(repositoryId, ApiOptions.None); + } + /// /// Gets all the branches for the specified repository. /// @@ -547,6 +636,23 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.RepoBranches(owner, name), null, AcceptHeaders.ProtectedBranchesApiPreview, options); } + /// + /// Gets all the branches for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// Thrown when a general API error occurs. + /// All es of the repository + public Task> GetAllBranches(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.RepoBranches(repositoryId), null, AcceptHeaders.ProtectedBranchesApiPreview, options); + } + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -564,6 +670,19 @@ namespace Octokit return GetAllContributors(owner, name, false); } + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All contributors of the repository. + public Task> GetAllContributors(int repositoryId) + { + return GetAllContributors(repositoryId, false); + } + /// /// Gets all contributors for the specified repository. Does not include anonymous contributors. /// @@ -583,6 +702,22 @@ namespace Octokit return GetAllContributors(owner, name, false, options); } + /// + /// Gets all contributors for the specified repository. Does not include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All contributors of the repository. + public Task> GetAllContributors(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAllContributors(repositoryId, false, options); + } + /// /// Gets all contributors for the specified repository. With the option to include anonymous contributors. /// @@ -601,6 +736,20 @@ namespace Octokit return GetAllContributors(owner, name, false, ApiOptions.None); } + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// All contributors of the repository. + public Task> GetAllContributors(int repositoryId, bool includeAnonymous) + { + return GetAllContributors(repositoryId, false, ApiOptions.None); + } + /// /// Gets all contributors for the specified repository. With the option to include anonymous contributors. /// @@ -625,6 +774,27 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.RepositoryContributors(owner, name), parameters, options); } + /// + /// Gets all contributors for the specified repository. With the option to include anonymous contributors. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// True if anonymous contributors should be included in result; Otherwise false + /// Options for changing the API response + /// All contributors of the repository. + public Task> GetAllContributors(int repositoryId, bool includeAnonymous, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + var parameters = new Dictionary(); + if (includeAnonymous) + parameters.Add("anon", "1"); + + return ApiConnection.GetAll(ApiUrls.RepositoryContributors(repositoryId), parameters, options); + } + /// /// Gets all languages for the specified repository. /// @@ -646,6 +816,23 @@ namespace Octokit data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); } + /// + /// Gets all languages for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All languages used in the repository and the number of bytes of each language. + public async Task> GetAllLanguages(int repositoryId) + { + var endpoint = ApiUrls.RepositoryLanguages(repositoryId); + var data = await ApiConnection.Get>(endpoint).ConfigureAwait(false); + + return new ReadOnlyCollection( + data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); + } + /// /// Gets all teams for the specified repository. /// @@ -663,6 +850,19 @@ namespace Octokit return GetAllTeams(owner, name, ApiOptions.None); } + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All s associated with the repository + public Task> GetAllTeams(int repositoryId) + { + return GetAllTeams(repositoryId, ApiOptions.None); + } + /// /// Gets all teams for the specified repository. /// @@ -682,6 +882,22 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.RepositoryTeams(owner, name), options); } + /// + /// Gets all teams for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All s associated with the repository + public Task> GetAllTeams(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.RepositoryTeams(repositoryId), options); + } + /// /// Gets all tags for the specified repository. /// @@ -699,6 +915,18 @@ namespace Octokit return GetAllTags(owner, name, ApiOptions.None); } + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// All of the repositories tags. + public Task> GetAllTags(int repositoryId) + { + return GetAllTags(repositoryId, ApiOptions.None); + } /// /// Gets all tags for the specified repository. @@ -719,6 +947,22 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.RepositoryTags(owner, name), options); } + /// + /// Gets all tags for the specified repository. + /// + /// + /// See the API documentation for more details + /// + /// The ID of the repository + /// Options for changing the API response + /// All of the repositories tags. + public Task> GetAllTags(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.RepositoryTags(repositoryId), options); + } + /// /// Gets the specified branch. /// @@ -726,16 +970,16 @@ namespace Octokit /// See the API documentation for more details /// /// The owner of the repository - /// The name of the repository + /// The name of the repository /// The name of the branch /// The specified - public Task GetBranch(string owner, string repositoryName, string branchName) + public Task GetBranch(string owner, string name, string branchName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branchName, "branchName"); - return ApiConnection.Get(ApiUrls.RepoBranch(owner, repositoryName, branchName), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoBranch(owner, name, branchName), null, AcceptHeaders.ProtectedBranchesApiPreview); } ///