using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Net; using System.Threading; using System.Threading.Tasks; namespace Octokit { /// /// A connection for making API requests against URI endpoints. /// Provides type-friendly convenience methods that wrap methods. /// public interface IApiConnection { /// /// The underlying connection. /// IConnection Connection { get; } /// /// Gets the API resource at the specified URI. /// /// Type of the API resource to get. /// URI of the API resource to get /// The API resource. /// Thrown when an API error occurs. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task Get(Uri uri); /// /// Gets the API resource at the specified URI. /// /// Type of the API resource to get. /// URI of the API resource to get /// Parameters to add to the API request /// The API resource. /// Thrown when an API error occurs. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "It's fiiiine. It's fine. Trust us.")] Task Get(Uri uri, IDictionary parameters); /// /// Gets the API resource at the specified URI. /// /// Type of the API resource to get. /// URI of the API resource to get /// Parameters to add to the API request /// Accept header to use for the API request /// The API resource. /// Thrown when an API error occurs. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "It's fiiiine. It's fine. Trust us.")] Task Get(Uri uri, IDictionary parameters, string accepts); /// /// Gets the HTML content of the API resource at the specified URI. /// /// URI of the API resource to get /// Parameters to add to the API request /// The API resource's HTML content. /// Thrown when an API error occurs. Task GetHtml(Uri uri, IDictionary parameters); /// /// Gets the raw content of the API resource at the specified URI. /// /// URI of the API resource to get /// Parameters to add to the API request /// The API resource's raw content or null if the points to a directory. /// Thrown when an API error occurs. Task GetRaw(Uri uri, IDictionary parameters); /// /// Gets the raw stream of the API resource at the specified URI. /// /// URI of the API resource to get /// Parameters to add to the API request /// The API resource's raw stream or null if the points to a directory. /// Thrown when an API error occurs. Task GetRawStream(Uri uri, IDictionary parameters); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// Options for changing the API response /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri, ApiOptions options); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// Parameters to add to the API request /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri, IDictionary parameters); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// Accept header to use for the API request /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri, string accepts); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// Parameters to add to the API request /// Options for changing the API response /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri, IDictionary parameters, ApiOptions options); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// Parameters to add to the API request /// Accept header to use for the API request /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri, IDictionary parameters, string accepts); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// Parameters to add to the API request /// Accept header to use for the API request /// Options for changing the API response /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri, IDictionary parameters, string accepts, ApiOptions options); /// /// Gets all API resources in the list at the specified URI. /// /// Type of the API resource in the list. /// URI of the API resource to get /// Parameters to add to the API request /// Accept header to use for the API request /// Options for changing the API response /// Function to preprocess HTTP response prior to deserialization (can be null) /// of the API resources in the list. /// Thrown when an API error occurs. Task> GetAll(Uri uri, IDictionary parameters, string accepts, ApiOptions options, Func preprocessResponseBody); /// /// Creates a new API resource in the list at the specified URI. /// /// URI endpoint to send request to /// An optional token to monitor for cancellation requests /// Representing the received HTTP response /// Thrown when an API error occurs. Task Post(Uri uri, CancellationToken cancellationToken = default); /// /// Creates a new API resource in the list at the specified URI. /// /// The API resource's type. /// URI endpoint to send request to /// An optional token to monitor for cancellation requests /// The created API resource. /// Thrown when an API error occurs. Task Post(Uri uri, CancellationToken cancellationToken = default); /// /// Creates a new API resource in the list at the specified URI. /// /// The API resource's type. /// URI of the API resource to get /// Object that describes the new API resource; this will be serialized and used as the request's body /// An optional token to monitor for cancellation requests /// The created API resource. /// Thrown when an API error occurs. Task Post(Uri uri, object data, CancellationToken cancellationToken = default); /// /// Creates a new API resource in the list at the specified URI. /// /// The API resource's type. /// URI of the API resource to get /// Object that describes the new API resource; this will be serialized and used as the request's body /// Accept header to use for the API request /// An optional token to monitor for cancellation requests /// The created API resource. /// Thrown when an API error occurs. Task Post(Uri uri, object data, string accepts, CancellationToken cancellationToken = default); /// /// Creates a new API resource in the list at the specified URI. /// /// The API resource's type. /// URI of the API resource to get /// Object that describes the new API resource; this will be serialized and used as the request's body /// Accept header to use for the API request /// Content type of the API request /// An optional token to monitor for cancellation requests /// The created API resource. /// Thrown when an API error occurs. Task Post(Uri uri, object data, string accepts, string contentType, CancellationToken cancellationToken = default); /// /// Creates a new API resource in the list at the specified URI. /// /// The API resource's type. /// URI of the API resource to get /// Object that describes the new API resource; this will be serialized and used as the request's body /// Accept header to use for the API request /// Content type of the API request /// Two Factor Authentication Code /// An optional token to monitor for cancellation requests /// The created API resource. /// Thrown when an API error occurs. Task Post(Uri uri, object data, string accepts, string contentType, string twoFactorAuthenticationCode, CancellationToken cancellationToken = default); /// /// Creates a new API resource in the list at the specified URI. /// /// The API resource's type. /// URI of the API resource to get /// Object that describes the new API resource; this will be serialized and used as the request's body /// Accept header to use for the API request /// Content type of the API request /// Timeout for the request /// An optional token to monitor for cancellation requests /// The created API resource. /// Thrown when an API error occurs. Task Post(Uri uri, object data, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken = default); /// /// Creates or replaces the API resource at the specified URI /// /// URI of the API resource to put /// A for the request's execution. Task Put(Uri uri); /// /// Creates or replaces the API resource at the specified URI /// /// URI of the API resource to put /// Object that describes the API resource; this will be serialized and used as the request's body /// A for the request's execution. Task Put(Uri uri, object data); /// /// Creates or replaces the API resource at the specified URI. /// /// The API resource's type. /// URI of the API resource to create or replace /// Object that describes the API resource; this will be serialized and used as the request's body /// The created API resource. /// Thrown when an API error occurs. Task Put(Uri uri, object data); /// /// Creates or replaces the API resource at the specified URI. /// /// The API resource's type. /// URI of the API resource to create or replace /// Object that describes the API resource; this will be serialized and used as the request's body /// The two-factor authentication code in response to the current user's previous challenge /// The created API resource. /// Thrown when an API error occurs. Task Put(Uri uri, object data, string twoFactorAuthenticationCode); /// /// Creates or replaces the API resource at the specified URI. /// /// The API resource's type. /// URI of the API resource to create or replace /// Object that describes the API resource; this will be serialized and used as the request's body /// The two-factor authentication code in response to the current user's previous challenge /// Accept header to use for the API request /// The created API resource. /// Thrown when an API error occurs. Task Put(Uri uri, object data, string twoFactorAuthenticationCode, string accepts); /// /// Updates the API resource at the specified URI. /// /// URI of the API resource to patch /// A for the request's execution. Task Patch(Uri uri); /// /// Updates the API resource at the specified URI. /// /// URI of the API resource to patch /// Accept header to use for the API request /// A for the request's execution. Task Patch(Uri uri, string accepts); /// /// Updates the API resource at the specified URI. /// /// The API resource's type. /// URI of the API resource to update /// Object that describes the API resource; this will be serialized and used as the request's body /// The updated API resource. /// Thrown when an API error occurs. Task Patch(Uri uri, object data); /// /// Updates the API resource at the specified URI. /// /// The API resource's type. /// URI of the API resource to update /// Object that describes the API resource; this will be serialized and used as the request's body /// Accept header to use for the API request /// The updated API resource. /// Thrown when an API error occurs. Task Patch(Uri uri, object data, string accepts); /// /// Deletes the API object at the specified URI. /// /// URI of the API resource to delete /// A for the request's execution. Task Delete(Uri uri); /// /// Deletes the API object at the specified URI. /// /// URI of the API resource to delete /// Two Factor Code /// A for the request's execution. Task Delete(Uri uri, string twoFactorAuthenticationCode); /// /// Deletes the API object at the specified URI. /// /// URI of the API resource to delete /// Object that describes the API resource; this will be serialized and used as the request's body /// A for the request's execution. 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 API resource's type. /// URI endpoint to send request to /// Specifies accept response media type /// The returned Task Delete(Uri uri, string accepts); /// /// Performs an asynchronous HTTP DELETE request. /// Attempts to map the response body to an object of type /// /// The API resource's type. /// 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); /// /// Executes a GET to the API object at the specified URI. This operation is appropriate for API calls which /// queue long running calculations and return a collection of a resource. /// It expects the API to respond with an initial 202 Accepted, and queries again until a 200 OK is received. /// It returns an empty collection if it receives a 204 No Content response. /// /// The API resource's type. /// URI of the API resource to update /// A token used to cancel this potentially long running request /// The updated API resource. /// Thrown when an API error occurs. Task> GetQueuedOperation(Uri uri, CancellationToken cancellationToken); } }