add methods to set permission for team repositories

This commit is contained in:
maddin2016
2016-06-06 11:47:21 +02:00
parent 10cea07daf
commit 41ba208131
7 changed files with 68 additions and 6 deletions
@@ -171,6 +171,20 @@ namespace Octokit.Reactive
/// <returns><see langword="true"/> if the repository was added to the team; <see langword="false"/> otherwise.</returns>
IObservable<bool> AddRepository(int id, string organization, string repoName);
/// <summary>
/// Adds a <see cref="Repository"/> to a <see cref="Team"/>.
/// </summary>
/// <param name="id">The team identifier.</param>
/// <param name="organization">Org to associate the repo with.</param>
/// <param name="repoName">Name of the repo.</param>
/// <param name="permission">The permission to grant the team on this repository.</param>
/// <exception cref="ApiValidationException">Thrown if you attempt to add a repository to a team that is not owned by the organization.</exception>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#add-team-repo">API documentation</a> for more information.
/// </remarks>
/// <returns><see langword="true"/> if the repository was added to the team; <see langword="false"/> otherwise.</returns>
IObservable<bool> AddRepository(int id, string organization, string repoName, TeamRepositoryUpdate permission);
/// <summary>
/// Gets whether or not the given repository is managed by the given team.
/// </summary>
@@ -246,6 +246,25 @@ namespace Octokit.Reactive
return _client.AddRepository(id, organization, repoName).ToObservable();
}
/// <summary>
/// Adds a <see cref="Repository"/> to a <see cref="Team"/>.
/// </summary>
/// <param name="id">The team identifier.</param>
/// <param name="organization">Org to associate the repo with.</param>
/// <param name="repoName">Name of the repo.</param>
/// <param name="permission">The permission to grant the team on this repository.</param>
/// <exception cref="ApiValidationException">Thrown if you attempt to add a repository to a team that is not owned by the organization.</exception>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/orgs/teams/#add-team-repo">API documentation</a> for more information.
/// </remarks>
/// <returns><see langword="true"/> if the repository was added to the team; <see langword="false"/> otherwise.</returns>
public IObservable<bool> AddRepository(int id, string organization, string repoName, TeamRepositoryUpdate permission)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName");
return _client.AddRepository(id, organization, repoName, permission).ToObservable();
}
/// <summary>
/// Remove a repository from the team
+2 -2
View File
@@ -162,10 +162,10 @@ namespace Octokit
/// <summary>
/// Add a repository to the team
/// </summary>
/// <param name="permission">The permission to grant the team on this repository</param>
/// <param name="permission">The permission to grant the team on this repository.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
Task<bool> AddRepository(int id, string organization, string repoName, PermissionType permission);
Task<bool> AddRepository(int id, string organization, string repoName, TeamRepositoryUpdate permission);
/// <summary>
/// Remove a repository from the team
+8 -2
View File
@@ -317,7 +317,13 @@ namespace Octokit
}
}
public async Task<bool> AddRepository(int id, string organization, string repoName, PermissionType permission)
/// <summary>
/// Add a repository to the team
/// </summary>
/// <param name="permission">The permission to grant the team on this repository.</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns></returns>
public async Task<bool> AddRepository(int id, string organization, string repoName, TeamRepositoryUpdate permission)
{
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName");
@@ -326,7 +332,7 @@ namespace Octokit
try
{
var httpStatusCode = await ApiConnection.Connection.Put(endpoint).ConfigureAwait(false);
var httpStatusCode = await ApiConnection.Connection.Put(endpoint, permission).ConfigureAwait(false);
return httpStatusCode == HttpStatusCode.NoContent;
}
catch (NotFoundException)
+16 -1
View File
@@ -404,6 +404,21 @@ namespace Octokit
return response.HttpResponse.StatusCode;
}
/// <summary>
/// Performs an asynchronous HTTP PUT request that expects an empty response.
/// </summary>
/// <param name="uri">URI endpoint to send request to</param>
/// <param name="body">The object to serialize as the body of the request</param>
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
public async Task<HttpStatusCode> Put(Uri uri, object body)
{
Ensure.ArgumentNotNull(uri, "uri");
Ensure.ArgumentNotNull(body, "body");
var response = await SendData<object>(uri, HttpMethod.Put, body, null, null, CancellationToken.None).ConfigureAwait(false);
return response.HttpResponse.StatusCode;
}
/// <summary>
/// Performs an asynchronous HTTP DELETE request that expects an empty response.
/// </summary>
@@ -466,7 +481,7 @@ namespace Octokit
/// <param name="data">The object to serialize as the body of the request</param>
/// <param name="accepts">Specifies accept response media type</param>
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
public async Task<HttpStatusCode> Delete(Uri uri,object data, string accepts)
public async Task<HttpStatusCode> Delete(Uri uri, object data, string accepts)
{
Ensure.ArgumentNotNull(uri, "uri");
Ensure.ArgumentNotNull(accepts, "accepts");
+8
View File
@@ -197,6 +197,14 @@ namespace Octokit
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
Task<HttpStatusCode> Put(Uri uri);
/// <summary>
/// Performs an asynchronous HTTP PUT request that expects an empty response.
/// </summary>
/// <param name="uri">URI endpoint to send request to</param>
/// <param name="body">The object to serialize as the body of the request</param>
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
Task<HttpStatusCode> Put(Uri uri, object body);
/// <summary>
/// Performs an asynchronous HTTP DELETE request that expects an empty response.
/// </summary>
@@ -35,7 +35,7 @@ namespace Octokit
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Permission: {}", Permission);
return string.Format(CultureInfo.InvariantCulture, "Permission: {0}", Permission);
}
}
}