Merged master

This commit is contained in:
pltaylor
2013-11-13 20:49:15 -05:00
107 changed files with 2663 additions and 303 deletions
+30 -30
View File
@@ -16,7 +16,7 @@ namespace Octokit
/// <summary>
/// Initializes a new instance of the <see cref="ApiConnection"/> class.
/// </summary>
/// <param name="connection">A connection for making HTTP requests.</param>
/// <param name="connection">A connection for making HTTP requests</param>
public ApiConnection(IConnection connection) : this(connection, new ApiPagination())
{
}
@@ -24,8 +24,8 @@ namespace Octokit
/// <summary>
/// Initializes a new instance of the <see cref="ApiConnection"/> class.
/// </summary>
/// <param name="connection">A connection for making HTTP requests.</param>
/// <param name="pagination">A paginator for paging API responses.</param>
/// <param name="connection">A connection for making HTTP requests</param>
/// <param name="pagination">A paginator for paging API responses</param>
protected ApiConnection(IConnection connection, IApiPagination pagination)
{
Ensure.ArgumentNotNull(connection, "connection");
@@ -44,8 +44,8 @@ namespace Octokit
/// Gets the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource to get.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <returns>The API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public async Task<T> Get<T>(Uri uri, IDictionary<string, string> parameters)
@@ -59,8 +59,8 @@ namespace Octokit
/// <summary>
/// Gets the HTML content of the API resource at the specified URI.
/// </summary>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <returns>The API resource's HTML content.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public async Task<string> GetHtml(Uri uri, IDictionary<string, string> parameters)
@@ -75,7 +75,7 @@ namespace Octokit
/// Gets all API resources in the list at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource in the list.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public Task<IReadOnlyList<T>> GetAll<T>(Uri uri)
@@ -87,8 +87,8 @@ namespace Octokit
/// Gets all API resources in the list at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource in the list.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters)
@@ -100,9 +100,9 @@ namespace Octokit
/// Gets all API resources in the list at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource in the list.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="accepts">Accept header to use for the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <param name="accepts">Accept header to use for the API request</param>
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
@@ -117,8 +117,8 @@ namespace Octokit
/// Creates a new API resource in the list at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public Task<T> Post<T>(Uri uri, object data)
@@ -133,9 +133,9 @@ namespace Octokit
/// Creates a new API resource in the list at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
/// <param name="accepts">Accept header to use for the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param>
/// <param name="accepts">Accept header to use for the API request</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public Task<T> Post<T>(Uri uri, object data, string accepts)
@@ -147,10 +147,10 @@ namespace Octokit
/// Creates a new API resource in the list at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
/// <param name="accepts">Accept header to use for the API request.</param>
/// <param name="contentType">Content type of the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param>
/// <param name="accepts">Accept header to use for the API request</param>
/// <param name="contentType">Content type of the API request</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public async Task<T> Post<T>(Uri uri, object data, string accepts, string contentType)
@@ -170,8 +170,8 @@ namespace Octokit
/// Creates or replaces the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to create or replace.</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body.</param>
/// <param name="uri">URI of the API resource to create or replace</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public async Task<T> Put<T>(Uri uri, object data)
@@ -188,9 +188,9 @@ namespace Octokit
/// Creates or replaces the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to create or replace.</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body.</param>
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge.</param>
/// <param name="uri">URI of the API resource to create or replace</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param>
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public async Task<T> Put<T>(Uri uri, object data, string twoFactorAuthenticationCode)
@@ -208,8 +208,8 @@ namespace Octokit
/// Updates the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to update.</param>
/// /// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body.</param>
/// <param name="uri">URI of the API resource to update</param>
/// /// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param>
/// <returns>The updated API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
public async Task<T> Patch<T>(Uri uri, object data)
@@ -225,7 +225,7 @@ namespace Octokit
/// <summary>
/// Deletes the API object at the specified URI.
/// </summary>
/// <param name="uri">URI of the API resource to delete.</param>
/// <param name="uri">URI of the API resource to delete</param>
/// <returns>A <see cref="Task"/> for the request's execution.</returns>
public Task Delete(Uri uri)
{
+11 -10
View File
@@ -42,7 +42,7 @@ namespace Octokit
/// </param>
/// <param name="baseAddress">
/// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise
/// instance.</param>
/// instance</param>
public Connection(ProductHeaderValue productInformation, Uri baseAddress)
: this(productInformation, baseAddress, _anonymousCredentials)
{
@@ -55,7 +55,7 @@ namespace Octokit
/// The name (and optionally version) of the product using this library. This is sent to the server as part of
/// the user agent for analytics purposes.
/// </param>
/// <param name="credentialStore">Provides credentials to the client when making requests.</param>
/// <param name="credentialStore">Provides credentials to the client when making requests</param>
public Connection(ProductHeaderValue productInformation, ICredentialStore credentialStore)
: this(productInformation, _defaultGitHubApiUrl, credentialStore)
{
@@ -70,8 +70,8 @@ namespace Octokit
/// </param>
/// <param name="baseAddress">
/// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise
/// instance.</param>
/// <param name="credentialStore">Provides credentials to the client when making requests.</param>
/// instance</param>
/// <param name="credentialStore">Provides credentials to the client when making requests</param>
public Connection(ProductHeaderValue productInformation, Uri baseAddress, ICredentialStore credentialStore)
: this(productInformation, baseAddress, credentialStore, new HttpClientAdapter(), new SimpleJsonSerializer())
{
@@ -86,10 +86,10 @@ namespace Octokit
/// </param>
/// <param name="baseAddress">
/// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise
/// instance.</param>
/// <param name="credentialStore">Provides credentials to the client when making requests.</param>
/// <param name="httpClient">A raw <see cref="IHttpClient"/> used to make requests.</param>
/// <param name="serializer">Class used to serialize and deserialize JSON requests.</param>
/// instance</param>
/// <param name="credentialStore">Provides credentials to the client when making requests</param>
/// <param name="httpClient">A raw <see cref="IHttpClient"/> used to make requests</param>
/// <param name="serializer">Class used to serialize and deserialize JSON requests</param>
public Connection(
ProductHeaderValue productInformation,
Uri baseAddress,
@@ -205,16 +205,17 @@ namespace Octokit
return Run<T>(request);
}
public Task DeleteAsync(Uri uri)
public async Task<HttpStatusCode> DeleteAsync(Uri uri)
{
Ensure.ArgumentNotNull(uri, "uri");
return Run<object>(new Request
var response = await Run<object>(new Request
{
Method = HttpMethod.Delete,
BaseAddress = BaseAddress,
Endpoint = uri
});
return response.StatusCode;
}
public Uri BaseAddress { get; private set; }
+27 -27
View File
@@ -20,8 +20,8 @@ namespace Octokit
/// Gets the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource to get.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <returns>The API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
@@ -31,8 +31,8 @@ namespace Octokit
/// <summary>
/// Gets the HTML content of the API resource at the specified URI.
/// </summary>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <returns>The API resource's HTML content.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<string> GetHtml(Uri uri, IDictionary<string, string> parameters);
@@ -41,7 +41,7 @@ namespace Octokit
/// Gets all API resources in the list at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource in the list.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<IReadOnlyList<T>> GetAll<T>(Uri uri);
@@ -50,8 +50,8 @@ namespace Octokit
/// Gets all API resources in the list at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource in the list.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters);
@@ -60,9 +60,9 @@ namespace Octokit
/// Gets all API resources in the list at the specified URI.
/// </summary>
/// <typeparam name="T">Type of the API resource in the list.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="parameters">Parameters to add to the API request.</param>
/// <param name="accepts">Accept header to use for the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="parameters">Parameters to add to the API request</param>
/// <param name="accepts">Accept header to use for the API request</param>
/// <returns><see cref="IReadOnlyList{T}"/> of the The API resources in the list.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> parameters, string accepts);
@@ -71,8 +71,8 @@ namespace Octokit
/// Creates a new API resource in the list at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<T> Post<T>(Uri uri, object data);
@@ -81,9 +81,9 @@ namespace Octokit
/// Creates a new API resource in the list at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
/// <param name="accepts">Accept header to use for the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param>
/// <param name="accepts">Accept header to use for the API request</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<T> Post<T>(Uri uri, object data, string accepts);
@@ -92,10 +92,10 @@ namespace Octokit
/// Creates a new API resource in the list at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to get.</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
/// <param name="accepts">Accept header to use for the API request.</param>
/// <param name="contentType">Content type of the API request.</param>
/// <param name="uri">URI of the API resource to get</param>
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param>
/// <param name="accepts">Accept header to use for the API request</param>
/// <param name="contentType">Content type of the API request</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<T> Post<T>(Uri uri, object data, string accepts, string contentType);
@@ -104,8 +104,8 @@ namespace Octokit
/// Creates or replaces the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to create or replace.</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body.</param>
/// <param name="uri">URI of the API resource to create or replace</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<T> Put<T>(Uri uri, object data);
@@ -114,9 +114,9 @@ namespace Octokit
/// Creates or replaces the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to create or replace.</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body.</param>
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge.</param>
/// <param name="uri">URI of the API resource to create or replace</param>
/// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param>
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge</param>
/// <returns>The created API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<T> Put<T>(Uri uri, object data, string twoFactorAuthenticationCode);
@@ -125,8 +125,8 @@ namespace Octokit
/// Updates the API resource at the specified URI.
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI of the API resource to update.</param>
/// /// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body.</param>
/// <param name="uri">URI of the API resource to update</param>
/// /// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param>
/// <returns>The updated API resource.</returns>
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
Task<T> Patch<T>(Uri uri, object data);
@@ -134,7 +134,7 @@ namespace Octokit
/// <summary>
/// Deletes the API object at the specified URI.
/// </summary>
/// <param name="uri">URI of the API resource to delete.</param>
/// <param name="uri">URI of the API resource to delete</param>
/// <returns>A <see cref="Task"/> for the request's execution.</returns>
Task Delete(Uri uri);
}
+2 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
namespace Octokit
@@ -13,7 +14,7 @@ namespace Octokit
Task<IResponse<T>> PutAsync<T>(Uri uri, object body);
Task<IResponse<T>> PutAsync<T>(Uri uri, object body, string twoFactorAuthenticationCode);
Task DeleteAsync(Uri uri);
Task<HttpStatusCode> DeleteAsync(Uri uri);
Uri BaseAddress { get; }
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Octokit.Internal
/// Sends the specified request and returns a response.
/// </summary>
/// <typeparam name="T">The type of data to send</typeparam>
/// <param name="request">A <see cref="IRequest"/> that represents the HTTP request.</param>
/// <param name="request">A <see cref="IRequest"/> that represents the HTTP request</param>
/// <returns>A <see cref="Task{IResponse{T}}"/></returns>
Task<IResponse<T>> Send<T>(IRequest request);
}