Add Repository Deploy Keys client

This commit is contained in:
Henrik Andersson
2014-06-14 18:22:21 +10:00
parent ee062e0c30
commit e28f3ec3db
11 changed files with 213 additions and 3 deletions
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Octokit
{
public interface IRepositoryDeployKeysClient
{
/// <summary>
/// Get a single deploy key by number for a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="number">The id of the deploy key.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")]
Task<DeployKey> Get(string owner, string name, int number);
/// <summary>
/// Get all deploy keys for a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
Task<IReadOnlyList<DeployKey>> GetForRepository(string owner, string name);
/// <summary>
/// Creates a new deploy key for a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="newDeployKey">The deploy key to create for the repository.</param>
/// <returns></returns>
Task<DeployKey> Create(string owner, string name, NewDeployKey newDeployKey);
/// <summary>
/// Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
/// </summary>
/// <param name="owner"></param>
/// <param name="name"></param>
/// <param name="number"></param>
/// <param name="newDeployKey"></param>
/// <returns></returns>
/// Task<DeployKey> Update(string owner, string name, int number, NewDeployKey newDeployKey);
/// <summary>
/// Deletes a deploy key from a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="number">The id of the deploy key to delete.</param>
/// <returns></returns>
Task Delete(string owner, string name, int number);
}
}
+9
View File
@@ -29,6 +29,7 @@ namespace Octokit
PullRequest = new PullRequestsClient(apiConnection);
RepositoryComments = new RepositoryCommentsClient(apiConnection);
Commits = new RepositoryCommitsClient(apiConnection);
DeployKeys = new RepositoryDeployKeysClient(apiConnection);
}
/// <summary>
@@ -301,6 +302,14 @@ namespace Octokit
/// </remarks>
public IRepositoryCommentsClient RepositoryComments { get; private set; }
/// <summary>
/// Client for manging deploy keys in a repository
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/keys/">Repository Deploy Keys API documentation</a> for more information.
/// </remarks>
public IRepositoryDeployKeysClient DeployKeys { get; private set; }
/// <summary>
/// Gets all the branches for the specified repository.
/// </summary>
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's repository deploy keys API.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/keys/">Repository deploy keys API documentation</a> for more information.
/// </remarks>
public class RepositoryDeployKeysClient : ApiClient, IRepositoryDeployKeysClient
{
/// <summary>
/// Instantiates a new GitHub repository deploy keys API client.
/// </summary>
/// <param name="apiConnection">The API connection.</param>
public RepositoryDeployKeysClient(IApiConnection apiConnection)
: base(apiConnection)
{
}
/// <summary>
/// Get a single deploy key by number for a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="number">The id of the deploy key.</param>
public Task<DeployKey> Get(string owner, string name, int number)
{
throw new NotImplementedException();
}
/// <summary>
/// Get all deploy keys for a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
public Task<IReadOnlyList<DeployKey>> GetForRepository(string owner, string name)
{
throw new NotImplementedException();
}
/// <summary>
/// Creates a new deploy key for a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="newDeployKey">The deploy key to create for the repository.</param>
/// <returns></returns>
public Task<DeployKey> Create(string owner, string name, NewDeployKey newDeployKey)
{
throw new NotImplementedException();
}
/// <summary>
/// Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
/// </summary>
/// <param name="owner"></param>
/// <param name="name"></param>
/// <param name="number"></param>
/// <param name="newDeployKey"></param>
/// <returns></returns>
/// Task<DeployKey> Update(string owner, string name, int number, NewDeployKey newDeployKey);
/// <summary>
/// Deletes a deploy key from a repository.
/// </summary>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="number">The id of the deploy key to delete.</param>
/// <returns></returns>
public Task Delete(string owner, string name, int number)
{
throw new NotImplementedException();
}
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Octokit
{
public class NewDeployKey
{
public string Title { get; set; }
public string Key { get; set; }
}
}
+28
View File
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class DeployKey
{
public int Id { get; set; }
public string Key { get; set; }
public string Url { get; set; }
public string Title { get; set; }
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture,
"Deploy Key: Id: {0} Key: {1} Url: {2} Title: {3}", Id, Key, Url, Title);
}
}
}
}
+5 -1
View File
@@ -320,6 +320,10 @@
<Compile Include="Models\Request\OauthLoginRequest.cs" />
<Compile Include="Models\Request\OauthTokenRequest.cs" />
<Compile Include="Models\Response\OauthToken.cs" />
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
<Compile Include="Models\Request\NewDeployKey.cs" />
<Compile Include="Models\Response\DeployKey.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
+5 -1
View File
@@ -331,6 +331,10 @@
<Compile Include="Models\Request\OauthLoginRequest.cs" />
<Compile Include="Models\Request\OauthTokenRequest.cs" />
<Compile Include="Models\Response\OauthToken.cs" />
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
<Compile Include="Models\Request\NewDeployKey.cs" />
<Compile Include="Models\Response\DeployKey.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
</Project>
</Project>
+5 -1
View File
@@ -326,6 +326,10 @@
<Compile Include="Models\Request\OauthLoginRequest.cs" />
<Compile Include="Models\Request\OauthTokenRequest.cs" />
<Compile Include="Models\Response\OauthToken.cs" />
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
<Compile Include="Models\Request\NewDeployKey.cs" />
<Compile Include="Models\Response\DeployKey.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
+4
View File
@@ -317,6 +317,10 @@
<Compile Include="Models\Request\OauthLoginRequest.cs" />
<Compile Include="Models\Request\OauthTokenRequest.cs" />
<Compile Include="Models\Response\OauthToken.cs" />
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
<Compile Include="Models\Request\NewDeployKey.cs" />
<Compile Include="Models\Response\DeployKey.cs" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
+4
View File
@@ -321,6 +321,10 @@
<Compile Include="Models\Request\OauthLoginRequest.cs" />
<Compile Include="Models\Request\OauthTokenRequest.cs" />
<Compile Include="Models\Response\OauthToken.cs" />
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
<Compile Include="Models\Request\NewDeployKey.cs" />
<Compile Include="Models\Response\DeployKey.cs" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
+4
View File
@@ -56,18 +56,22 @@
<Compile Include="Clients\ActivitiesClient.cs" />
<Compile Include="Clients\IOAuthClient.cs" />
<Compile Include="Clients\IRepositoryCommitsClient.cs" />
<Compile Include="Clients\IRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\OAuthClient.cs" />
<Compile Include="Clients\RepositoryCommentsClient.cs" />
<Compile Include="Clients\IRepositoryCommentsClient.cs" />
<Compile Include="Clients\FeedsClient.cs" />
<Compile Include="Clients\IFeedsClient.cs" />
<Compile Include="Clients\RepositoryCommitsClient.cs" />
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
<Compile Include="Exceptions\RepositoryExistsException.cs" />
<Compile Include="Helpers\ApiErrorExtensions.cs" />
<Compile Include="Helpers\ConcurrentCache.cs" />
<Compile Include="Helpers\HttpClientExtensions.cs" />
<Compile Include="Http\ProductHeaderValue.cs" />
<Compile Include="Models\Request\NewDeployKey.cs" />
<Compile Include="Models\Response\DeployKey.cs" />
<Compile Include="Models\Request\OauthLoginRequest.cs" />
<Compile Include="Models\Request\OauthTokenRequest.cs" />
<Compile Include="Models\Response\GitHubCommit.cs" />