using System; using System.Collections.Generic; using System.Net; using System.Threading; using System.Threading.Tasks; using Octokit.Internal; namespace Octokit { /// /// A connection for making HTTP requests against URI endpoints. /// public interface IConnection : IApiInfoProvider { /// /// Performs an asynchronous HTTP GET request that expects a containing HTML. /// /// URI endpoint to send request to /// Querystring parameters for the request /// representing the received HTTP response Task> GetHtml(Uri uri, IDictionary parameters); /// /// Performs an asynchronous HTTP GET request that expects a containing raw data. /// /// URI endpoint to send request to /// Querystring parameters for the request /// representing the received HTTP response /// The property will be null if the points to a directory instead of a file Task> GetRaw(Uri uri, IDictionary parameters); /// /// Performs an asynchronous HTTP GET request. /// Attempts to map the response to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// Querystring parameters for the request /// Specifies accepted response media types. /// representing the received HTTP response [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task> Get(Uri uri, IDictionary parameters, string accepts); /// /// Performs an asynchronous HTTP GET request. /// Attempts to map the response to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// Querystring parameters for the request /// Specifies accepted response media types. /// A token used to cancel the Get request /// representing the received HTTP response [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task> Get(Uri uri, IDictionary parameters, string accepts, CancellationToken cancellationToken); /// /// Performs an asynchronous HTTP GET request. /// Attempts to map the response to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// Expiration time of the request /// representing the received HTTP response [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task> Get(Uri uri, TimeSpan timeout); /// /// Performs an asynchronous HTTP PATCH request. /// /// URI endpoint to send request to /// representing the received HTTP response Task Patch(Uri uri); /// /// Performs an asynchronous HTTP PATCH request. /// /// URI endpoint to send request to /// Specifies accepted response media types. /// representing the received HTTP response Task Patch(Uri uri, string accepts); /// /// Performs an asynchronous HTTP PATCH request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// representing the received HTTP response Task> Patch(Uri uri, object body); /// /// Performs an asynchronous HTTP PATCH request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accepted response media types. /// representing the received HTTP response Task> Patch(Uri uri, object body, string accepts); /// /// Performs an asynchronous HTTP POST request. /// /// URI endpoint to send request to /// An optional token to monitor for cancellation requests /// The returned Task Post(Uri uri, CancellationToken cancellationToken = default); /// /// Performs an asynchronous HTTP POST request. /// /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accepted response media types. /// An optional token to monitor for cancellation requests /// The returned Task Post(Uri uri, object body, string accepts, CancellationToken cancellationToken = default); /// /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// An optional token to monitor for cancellation requests /// representing the received HTTP response Task> Post(Uri uri, CancellationToken cancellationToken = default); /// /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accepted response media types. /// Specifies the media type of the request body /// Extra parameters for authentication. /// An optional token to monitor for cancellation requests /// representing the received HTTP response Task> Post( Uri uri, object body, string accepts, string contentType, IDictionary parameters = null, CancellationToken cancellationToken = default); /// /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accepted response media types. /// Specifies the media type of the request body /// Two Factor Authentication Code /// An optional token to monitor for cancellation requests /// representing the received HTTP response Task> Post(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode, CancellationToken cancellationToken = default); /// /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accepted response media types. /// Specifies the media type of the request body /// /// An optional token to monitor for cancellation requests /// representing the received HTTP response Task> Post(Uri uri, object body, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken = default); /// /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type /// /// /// We have one case where we need to override the BaseAddress. This overload is for that case. /// https://developer.github.com/v3/oauth/#web-application-flow /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accepted response media types. /// Specifies the media type of the request body /// Allows overriding the base address for a post. /// An optional token to monitor for cancellation requests /// representing the received HTTP response Task> Post(Uri uri, object body, string accepts, string contentType, Uri baseAddress, CancellationToken cancellationToken = default); /// /// Performs an asynchronous HTTP PUT request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The body of the request /// representing the received HTTP response Task> Put(Uri uri, object body); /// /// Performs an asynchronous HTTP PUT request using the provided two factor authentication code. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Two factory authentication code to use /// representing the received HTTP response Task> Put(Uri uri, object body, string twoFactorAuthenticationCode); /// /// Performs an asynchronous HTTP PUT request using the provided two factor authentication code. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Two factory authentication code to use /// Specifies accepted response media types. /// representing the received HTTP response Task> Put(Uri uri, object body, string twoFactorAuthenticationCode, string accepts); /// /// Performs an asynchronous HTTP PUT request that expects an empty response. /// /// URI endpoint to send request to /// The returned Task Put(Uri uri); /// /// Performs an asynchronous HTTP PUT request that expects an empty response. /// /// URI endpoint to send request to /// Specifies accepted response media types. /// The returned Task Put(Uri uri, string accepts); /// /// Performs an asynchronous HTTP DELETE request that expects an empty response. /// /// URI endpoint to send request to /// The returned Task Delete(Uri uri); /// /// Performs an asynchronous HTTP DELETE request that expects an empty response. /// /// URI endpoint to send request to /// Two Factor Code /// The returned Task Delete(Uri uri, string twoFactorAuthenticationCode); /// /// Performs an asynchronous HTTP DELETE 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 Delete(Uri uri, object data); /// /// Performs an asynchronous HTTP DELETE request that expects an empty response. /// /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accept response media type /// The returned Task Delete(Uri uri, object data, string accepts); /// /// Performs an asynchronous HTTP DELETE request. /// /// The API resource's type. /// URI endpoint to send request to /// The object to serialize as the body of the request Task> Delete(Uri uri, object data); /// /// Performs an asynchronous HTTP DELETE request. /// Attempts to map the response body to an object of type /// /// The type to map the response to /// URI endpoint to send request to /// The object to serialize as the body of the request /// Specifies accept response media type Task> Delete(Uri uri, object data, string accepts); /// /// Base address for the connection. /// Uri BaseAddress { get; } /// /// Gets the used to provide credentials for the connection. /// ICredentialStore CredentialStore { get; } /// /// Gets or sets the credentials used by the connection. /// /// /// You can use this property if you only have a single hard-coded credential. Otherwise, pass in an /// to the constructor. /// Setting this property will change the to use /// the default with just these credentials. /// Credentials Credentials { get; set; } /// /// Set the GitHub Api request timeout. /// /// The Timeout value void SetRequestTimeout(TimeSpan timeout); } }