From ae6c5b7405c236f54eaa844b0faeac5e241804cb Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Thu, 19 May 2016 15:07:56 +0700 Subject: [PATCH] added overloads with repositoryId for IObservableRepoCollaboratorsClient --- .../IObservableRepoCollaboratorsClient.cs | 59 +++++++++++++ .../ObservableRepoCollaboratorsClient.cs | 82 +++++++++++++++++++ Octokit/Clients/RepoCollaboratorsClient.cs | 2 + 3 files changed, 143 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index 9c657c6c..8d9b1373 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -23,6 +23,17 @@ namespace Octokit.Reactive /// A of s for the specified repository. IObservable GetAll(string owner, string name); + /// + /// Gets all the collaborators on a repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Thrown when a general API error occurs. + /// A of s for the specified repository. + IObservable GetAll(int repositoryId); + /// /// Gets all the collaborators on a repository. /// @@ -36,6 +47,18 @@ namespace Octokit.Reactive /// A of s for the specified repository. IObservable GetAll(string owner, string name, ApiOptions options); + /// + /// Gets all the collaborators on a repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Options for changing the API response + /// Thrown when a general API error occurs. + /// A of s for the specified repository. + IObservable GetAll(int repositoryId, ApiOptions options); + /// /// Checks if a user is a collaborator on a repository. /// @@ -49,6 +72,18 @@ namespace Octokit.Reactive /// True if user is a collaborator else false IObservable IsCollaborator(string owner, string name, string user); + /// + /// Checks if a user is a collaborator on a repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Username of the prospective collaborator + /// Thrown when a general API error occurs. + /// True if user is a collaborator else false + IObservable IsCollaborator(int repositoryId, string user); + /// /// Adds a new collaborator to the repository. /// @@ -62,6 +97,18 @@ namespace Octokit.Reactive /// IObservable Add(string owner, string name, string user); + /// + /// Adds a new collaborator to the repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Username of the new collaborator + /// Thrown when a general API error occurs. + /// + IObservable Add(int repositoryId, string user); + /// /// Deletes a collaborator from the repository. /// @@ -74,5 +121,17 @@ namespace Octokit.Reactive /// Thrown when a general API error occurs. /// IObservable Delete(string owner, string name, string user); + + /// + /// Deletes a collaborator from the repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Username of the removed collaborator + /// Thrown when a general API error occurs. + /// + IObservable Delete(int repositoryId, string user); } } diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index cfa537e8..1240f2f0 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -46,6 +46,20 @@ namespace Octokit.Reactive return GetAll(owner, name, ApiOptions.None); } + /// + /// Gets all the collaborators on a repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Thrown when a general API error occurs. + /// A of s for the specified repository. + public IObservable GetAll(int repositoryId) + { + return GetAll(repositoryId, ApiOptions.None); + } + /// /// Gets all the collaborators on a repository. /// @@ -66,6 +80,23 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.RepoCollaborators(owner, name), options); } + /// + /// Gets all the collaborators on a repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Options for changing the API response + /// Thrown when a general API error occurs. + /// A of s for the specified repository. + public IObservable GetAll(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepoCollaborators(repositoryId), options); + } + /// /// Checks if a user is a collaborator on a repository. /// @@ -86,6 +117,23 @@ namespace Octokit.Reactive return _client.IsCollaborator(owner, name, user).ToObservable(); } + /// + /// Checks if a user is a collaborator on a repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Username of the prospective collaborator + /// Thrown when a general API error occurs. + /// True if user is a collaborator else false + public IObservable IsCollaborator(int repositoryId, string user) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return _client.IsCollaborator(repositoryId, user).ToObservable(); + } + /// /// Adds a new collaborator to the repository. /// @@ -106,6 +154,23 @@ namespace Octokit.Reactive return _client.Add(owner, name, user).ToObservable(); } + /// + /// Adds a new collaborator to the repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Username of the new collaborator + /// Thrown when a general API error occurs. + /// + public IObservable Add(int repositoryId, string user) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return _client.Add(repositoryId, user).ToObservable(); + } + /// /// Deletes a collaborator from the repository. /// @@ -125,5 +190,22 @@ namespace Octokit.Reactive return _client.Delete(owner, name, user).ToObservable(); } + + /// + /// Deletes a collaborator from the repository. + /// + /// + /// See the API documentation for more information. + /// + /// The id of the repository + /// Username of the removed collaborator + /// Thrown when a general API error occurs. + /// + public IObservable Delete(int repositoryId, string user) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return _client.Delete(repositoryId, user).ToObservable(); + } } } diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index 272038af..18137e51 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -86,6 +86,8 @@ namespace Octokit /// A of s for the specified repository. public Task> GetAll(int repositoryId, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + return ApiConnection.GetAll(ApiUrls.RepoCollaborators(repositoryId), options); }