diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index 0ca0a385..7acad621 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -171,6 +171,20 @@ namespace Octokit.Reactive /// if the repository was added to the team; otherwise. IObservable AddRepository(int id, string organization, string repoName); + /// + /// Adds a to a . + /// + /// The team identifier. + /// Org to associate the repo with. + /// Name of the repo. + /// The permission to grant the team on this repository. + /// Thrown if you attempt to add a repository to a team that is not owned by the organization. + /// + /// See the API documentation for more information. + /// + /// if the repository was added to the team; otherwise. + IObservable AddRepository(int id, string organization, string repoName, TeamRepositoryUpdate permission); + /// /// Gets whether or not the given repository is managed by the given team. /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 31f9b7aa..1649472b 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -246,6 +246,25 @@ namespace Octokit.Reactive return _client.AddRepository(id, organization, repoName).ToObservable(); } + /// + /// Adds a to a . + /// + /// The team identifier. + /// Org to associate the repo with. + /// Name of the repo. + /// The permission to grant the team on this repository. + /// Thrown if you attempt to add a repository to a team that is not owned by the organization. + /// + /// See the API documentation for more information. + /// + /// if the repository was added to the team; otherwise. + public IObservable 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(); + } /// /// Remove a repository from the team diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index e4699ce9..1925dba9 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -162,10 +162,10 @@ namespace Octokit /// /// Add a repository to the team /// - /// The permission to grant the team on this repository + /// The permission to grant the team on this repository. /// Thrown when a general API error occurs. /// - Task AddRepository(int id, string organization, string repoName, PermissionType permission); + Task AddRepository(int id, string organization, string repoName, TeamRepositoryUpdate permission); /// /// Remove a repository from the team diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index cc267bc3..5e244336 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -317,7 +317,13 @@ namespace Octokit } } - public async Task AddRepository(int id, string organization, string repoName, PermissionType permission) + /// + /// Add a repository to the team + /// + /// The permission to grant the team on this repository. + /// Thrown when a general API error occurs. + /// + public async Task 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) diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 8f7412e1..229849f7 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -404,6 +404,21 @@ namespace Octokit return response.HttpResponse.StatusCode; } + /// + /// Performs an asynchronous HTTP PUT request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// The returned + public async Task Put(Uri uri, object body) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(body, "body"); + + var response = await SendData(uri, HttpMethod.Put, body, null, null, CancellationToken.None).ConfigureAwait(false); + return response.HttpResponse.StatusCode; + } + /// /// Performs an asynchronous HTTP DELETE request that expects an empty response. /// @@ -466,7 +481,7 @@ namespace Octokit /// The object to serialize as the body of the request /// Specifies accept response media type /// The returned - public async Task Delete(Uri uri,object data, string accepts) + public async Task Delete(Uri uri, object data, string accepts) { Ensure.ArgumentNotNull(uri, "uri"); Ensure.ArgumentNotNull(accepts, "accepts"); diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 39ddac53..d89c22c3 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -197,6 +197,14 @@ namespace Octokit /// The returned Task Put(Uri uri); + /// + /// Performs an asynchronous HTTP PUT request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// The returned + Task Put(Uri uri, object body); + /// /// Performs an asynchronous HTTP DELETE request that expects an empty response. /// diff --git a/Octokit/Models/Request/TeamRepositoryUpdate.cs b/Octokit/Models/Request/TeamRepositoryUpdate.cs index 1106572f..e5a64b6f 100644 --- a/Octokit/Models/Request/TeamRepositoryUpdate.cs +++ b/Octokit/Models/Request/TeamRepositoryUpdate.cs @@ -35,7 +35,7 @@ namespace Octokit { get { - return string.Format(CultureInfo.InvariantCulture, "Permission: {}", Permission); + return string.Format(CultureInfo.InvariantCulture, "Permission: {0}", Permission); } } }