prepping repo collaborators client

This commit is contained in:
Haroon
2013-11-13 11:50:17 +00:00
parent 790ba0888f
commit 62a4f6c1e3
5 changed files with 90 additions and 0 deletions
@@ -0,0 +1,27 @@
#if NET_45
using System.Collections.Generic;
#endif
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Collaborators on a Repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details.
/// </remarks>
public interface IRepoCollaboratorsClient
{
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// </remarks>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>.</returns>
Task<IReadOnlyList<User>> GetAll(string owner, string repo);
}
}
+8
View File
@@ -135,5 +135,13 @@ namespace Octokit
/// that announced this feature.
/// </remarks>
ICommitStatusClient CommitStatus { get; }
/// <summary>
/// A client for GitHub's Repo Collaborators.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details
/// </remarks>
IRepoCollaboratorsClient RepoCollaboratorsClient { get; }
}
}
@@ -0,0 +1,44 @@
#if NET_45
using System.Collections.Generic;
#endif
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Collaborators on a Repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details.
/// </remarks>
public class RepoCollaboratorsClient : ApiClient, IRepoCollaboratorsClient
{
/// <summary>
/// Initializes a new GitHub Repo Collaborators API client.
/// </summary>
/// <param name="apiConnection">An API connection.</param>
public RepoCollaboratorsClient(IApiConnection apiConnection)
: base(apiConnection)
{
}
/// <summary>
/// Gets all the collaborators on a repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// </remarks>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>.</returns>
public Task<IReadOnlyList<User>> GetAll(string owner, string repo)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
var endpoint = "repos/{0}/{1}/collaborators".FormatUri(owner, repo);
return ApiConnection.GetAll<User>(endpoint);
}
}
}
+9
View File
@@ -21,6 +21,7 @@ namespace Octokit
public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
{
CommitStatus = new CommitStatusClient(apiConnection);
RepoCollaboratorsClient = new RepoCollaboratorsClient(apiConnection);
}
/// <summary>
@@ -194,5 +195,13 @@ namespace Octokit
/// that announced this feature.
/// </remarks>
public ICommitStatusClient CommitStatus { get; private set; }
/// <summary>
/// A client for GitHub's Repo Collaborators.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details
/// </remarks>
public IRepoCollaboratorsClient RepoCollaboratorsClient { get; private set; }
}
}
+2
View File
@@ -53,6 +53,8 @@
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Clients\ActivitiesClient.cs" />
<Compile Include="Clients\RepoCollaboratorsClient.cs" />
<Compile Include="Clients\IRepoCollaboratorsClient.cs" />
<Compile Include="Clients\EventsClient.cs" />
<Compile Include="Clients\IActivitiesClient.cs" />
<Compile Include="Models\Response\Activity.cs" />