Implement repo deploy keys client

Update comments
Add ApiUrls methods
This commit is contained in:
Henrik Andersson
2014-06-14 23:57:07 +10:00
parent e28f3ec3db
commit fd66ea5472
3 changed files with 79 additions and 4 deletions
+41 -4
View File
@@ -26,55 +26,92 @@ namespace Octokit
/// <summary>
/// Get a single deploy key by number for a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/keys/#get"> API documentation</a> for more information.
/// </remarks>
/// <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();
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(number, "number");
return ApiConnection.Get<DeployKey>(ApiUrls.RepositoryDeployKey(owner, name, number));
}
/// <summary>
/// Get all deploy keys for a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/keys/#list"> API documentation</a> for more information.
/// </remarks>
/// <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();
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return ApiConnection.Get<IReadOnlyList<DeployKey>>(ApiUrls.RepositoryDeployKeys(owner, name));
}
/// <summary>
/// Creates a new deploy key for a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/keys/#create"> API documentation</a> for more information.
/// </remarks>
/// <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();
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(newDeployKey, "newDeployKey");
if (string.IsNullOrWhiteSpace(newDeployKey.Title))
throw new ArgumentException("The new deploy key's title must not be null.");
if (string.IsNullOrWhiteSpace(newDeployKey.Key))
throw new ArgumentException("The new deploy key's key must not be null.");
return ApiConnection.Post<DeployKey>(ApiUrls.RepositoryDeployKeys(owner, name), newDeployKey);
}
/// <summary>
/// Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/repos/keys/#edit
/// </remarks>
/// <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>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/keys/#delete"> API documentation</a> for more information.
/// </remarks>
/// <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();
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(number, "number");
return ApiConnection.Delete(ApiUrls.RepositoryDeployKey(owner, name, number));
}
}
}