#if NET_45
using System.Collections.Generic;
using System.Threading.Tasks;
#endif
namespace Octokit
{
///
/// A client for GitHub's Collaborators on a Repository.
///
///
/// See the Collaborators API documentation for more details.
///
public class RepoCollaboratorsClient : ApiClient, IRepoCollaboratorsClient
{
///
/// Initializes a new GitHub Repo Collaborators API client.
///
/// An API connection.
public RepoCollaboratorsClient(IApiConnection apiConnection)
: base(apiConnection)
{
}
///
/// Gets all the collaborators on a repository.
///
///
/// See the API documentation for more information.
///
/// The owner of the repository
/// The name of the repository
/// Thrown when a general API error occurs.
public Task> GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
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.
public Task> GetAll(int repositoryId)
{
return GetAll(repositoryId, ApiOptions.None);
}
///
/// Gets all the collaborators on a repository.
///
///
/// See the API documentation for more information.
///
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
/// Thrown when a general API error occurs.
public Task> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(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.
public Task> GetAll(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(ApiUrls.RepoCollaborators(repositoryId), options);
}
///
/// Checks if a user is a collaborator on a repository.
///
///
/// See the API documentation for more information.
///
/// The owner of the repository
/// The name of the repository
/// Username of the prospective collaborator
/// Thrown when a general API error occurs.
public async Task IsCollaborator(string owner, string name, string user)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(user, "user");
try
{
var response = await Connection.Get