Add a few missing team and organization APIs

This commit is contained in:
Andre Rodrigues
2014-08-07 12:59:30 +01:00
parent bcd90e33fc
commit 58bae6f9fc
5 changed files with 179 additions and 2 deletions
+24 -1
View File
@@ -30,9 +30,32 @@ namespace Octokit
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <returns></returns>
/// <returns>The users</returns>
Task<IReadOnlyList<User>> GetAll(string org);
/// <summary>
/// <para>
/// List all users who are members of an organization. A member is a user that
/// belongs to at least 1 team in the organization.
/// </para>
/// <para>
/// If the authenticated user is also an owner of this organization then both
/// concealed and public member will be returned.
/// </para>
/// <para>
/// If the requester is not an owner of the organization the query will be redirected
/// to the public members list.
/// </para>
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/orgs/members/#members-list">API documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="filter">The filter to use when getting the users</param>
/// <returns>The users</returns>
Task<IReadOnlyList<User>> GetAll(string org, string filter);
/// <summary>
/// List all users who have publicized their membership of the organization.
/// </summary>
+35
View File
@@ -72,5 +72,40 @@ namespace Octokit
/// <param name="login">The user to check.</param>
/// <returns><see langword="true"/> if the user is a member of the team; <see langword="false"/> otherwise.</returns>
Task<bool> IsMember(int id, string login);
/// <summary>
/// Add a member to the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task AddMember(int id, string login);
/// <summary>
/// Remove a member from the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task RemoveMember(int id, string login);
/// <summary>
/// Returns all team's repositories.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The team's repositories</returns>
Task<IReadOnlyList<Repository>> GetRepositories(int id);
/// <summary>
/// Add a repository to the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task AddRepository(int teamId, string organization, string repoName);
/// <summary>
/// Remove a repository from the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task RemoveRepository(int teamId, string organization, string repoName);
}
}
+30 -1
View File
@@ -39,7 +39,7 @@ namespace Octokit
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <returns></returns>
/// <returns>The users</returns>
public Task<IReadOnlyList<User>> GetAll(string org)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
@@ -47,6 +47,35 @@ namespace Octokit
return ApiConnection.GetAll<User>(ApiUrls.Members(org));
}
/// <summary>
/// <para>
/// List all users who are members of an organization. A member is a user that
/// belongs to at least 1 team in the organization.
/// </para>
/// <para>
/// If the authenticated user is also an owner of this organization then both
/// concealed and public member will be returned.
/// </para>
/// <para>
/// If the requester is not an owner of the organization the query will be redirected
/// to the public members list.
/// </para>
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/orgs/members/#members-list">API documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="filter">The filter to use when getting the users</param>
/// <returns>The users</returns>
public Task<IReadOnlyList<User>> GetAll(string org, string filter)
{
Ensure.ArgumentNotNullOrEmptyString(org, "org");
Ensure.ArgumentNotNullOrEmptyString(filter, "filter");
return ApiConnection.GetAll<User>(ApiUrls.Members(org, filter));
}
/// <summary>
/// List all users who have publicized their membership of the organization.
/// </summary>
+60
View File
@@ -128,5 +128,65 @@ namespace Octokit
return false;
}
}
/// <summary>
/// Add a member to the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
public Task AddMember(int id, string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");
var endpoint = ApiUrls.TeamMember(id, login);
return ApiConnection.Connection.Put(endpoint);
}
/// <summary>
/// Remove a member from the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
public Task RemoveMember(int id, string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, "login");
var endpoint = ApiUrls.TeamMember(id, login);
return ApiConnection.Delete(endpoint);
}
/// <summary>
/// Returns all team's repositories.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The team's repositories</returns>
public Task<IReadOnlyList<Repository>> GetRepositories(int id)
{
var endpoint = ApiUrls.TeamRepositories(id);
return ApiConnection.GetAll<Repository>(endpoint);
}
/// <summary>
/// Add a repository to the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
public Task AddRepository(int teamId, string organization, string repoName)
{
var endpoint = ApiUrls.TeamRepository(teamId, organization, repoName);
return ApiConnection.Put(endpoint);
}
/// <summary>
/// Remove a repository from the team
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
public Task RemoveRepository(int teamId, string organization, string repoName)
{
var endpoint = ApiUrls.TeamRepository(teamId, organization, repoName);
return ApiConnection.Delete(endpoint);
}
}
}
+30
View File
@@ -332,6 +332,16 @@ namespace Octokit
return "orgs/{0}/members".FormatUri(org);
}
/// <summary>
/// Returns the <see cref="Uri"/> that returns all of the members of the organization
/// </summary>
/// <param name="org">The organization</param>
/// <returns></returns>
public static Uri Members(string org, string filter)
{
return "orgs/{0}/members?filter={1}".FormatUri(org, filter);
}
/// <summary>
/// Returns the <see cref="Uri"/> that returns all of the public members of the organization
/// </summary>
@@ -988,6 +998,26 @@ namespace Octokit
return "teams/{0}/members".FormatUri(id);
}
/// <summary>
/// returns the <see cref="Uri"/> for the repositories
/// </summary>
/// <param name="id">The team id</param>
public static Uri TeamRepositories(int id)
{
return "teams/{0}/repos/".FormatUri(id);
}
/// <summary>
/// returns the <see cref="Uri"/> for a team repository
/// </summary>
/// <param name="id">The team id</param>
/// <param name="organization">The organization id</param>
/// <param name="repoName">The repository name</param>
public static Uri TeamRepository(int id, string organization, string repoName)
{
return "teams/{0}/repos/{1}/{2}".FormatUri(id, organization, repoName);
}
/// <summary>
/// returns the <see cref="Uri"/> for teams
/// use for update or deleting a team