using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using System; using System.Collections.Generic; namespace Octokit { /// /// A client for GitHub's OAuth API. /// /// /// See the OAuth API documentation for more details. /// public interface IAuthorizationsClient { /// /// Gets all s for the authenticated user. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// /// Thrown when the current user does not have permission to make the request. /// /// Thrown when a general API error occurs. /// A list of s for the authenticated user. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "It's an API call, so it's not a property.")] Task> GetAll(); /// /// Gets all s for the authenticated user. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// Options for changing the API response /// /// Thrown when the current user does not have permission to make the request. /// /// Thrown when a general API error occurs. /// A list of s for the authenticated user. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "It's an API call, so it's not a property.")] Task> GetAll(ApiOptions options); /// /// Gets a specific for the authenticated user. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// The Id of the to get /// /// Thrown when the current user does not have permission to make this request. /// /// Thrown when a general API error occurs. /// The specified . [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "It's fiiiine. It's fine. Trust us.")] Task Get(long id); /// /// Creates a new personal token for the authenticated user. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// Describes the new authorization to create /// /// Thrown when the current user does not have permission to make this request. /// /// /// Thrown when the current account has two-factor authentication enabled and an authentication code is required. /// /// Thrown when a general API error occurs. /// The created . Task Create(NewAuthorization newAuthorization); /// /// Creates a new personal token for the authenticated user. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// The two-factor authentication code in response to the current user's previous challenge /// Describes the new authorization to create /// /// Thrown when the current user does not have permission to make this request. /// /// /// Thrown when the current account has two-factor authentication enabled and an authentication code is required. /// /// Thrown when a general API error occurs. /// The created . Task Create(NewAuthorization newAuthorization, string twoFactorAuthenticationCode); /// /// Creates a new authorization for the specified OAuth application if an authorization for that application /// doesn’t already exist for the user; otherwise, it fails. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// Client Id of the OAuth application for the token /// The client secret /// Describes the new authorization to create /// /// Thrown when the current user does not have permission to make this request. /// /// /// Thrown when the current account has two-factor authentication enabled and an authentication code is required. /// /// Thrown when a general API error occurs. /// The created . Task Create( string clientId, string clientSecret, NewAuthorization newAuthorization); /// /// Creates a new authorization for the specified OAuth application if an authorization for that application /// doesn’t already exist for the user; otherwise, it fails. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// Client Id of the OAuth application for the token /// The client secret /// The two-factor authentication code in response to the current user's previous challenge /// Describes the new authorization to create /// /// Thrown when the current user does not have permission to make this request. /// /// /// Thrown when the current account has two-factor authentication enabled and an authentication code is required. /// /// Thrown when a general API error occurs. /// The created . Task Create( string clientId, string clientSecret, NewAuthorization newAuthorization, string twoFactorAuthenticationCode); /// /// Creates a new authorization for the specified OAuth application if an authorization for that application doesn’t already /// exist for the user; otherwise, returns the user’s existing authorization for that application. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// Client Id of the OAuth application for the token /// The client secret /// Describes the new authorization to create /// /// Thrown when the current user does not have permission to make this request. /// /// /// Thrown when the current account has two-factor authentication enabled and an authentication code is required. /// /// Thrown when a general API error occurs. /// The created . Task GetOrCreateApplicationAuthentication( string clientId, string clientSecret, NewAuthorization newAuthorization); /// /// Creates a new authorization for the specified OAuth application if an authorization for that application doesn’t already /// exist for the user; otherwise, returns the user’s existing authorization for that application. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// Client Id of the OAuth application for the token /// The client secret /// Describes the new authorization to create /// The two-factor authentication code in response to the current user's previous challenge /// /// Thrown when the current user does not have permission to make this request. /// /// /// Thrown when the current account has two-factor authentication enabled and an authentication code is required. /// /// Thrown when a general API error occurs. /// The created . Task GetOrCreateApplicationAuthentication( string clientId, string clientSecret, NewAuthorization newAuthorization, string twoFactorAuthenticationCode); /// /// Checks the validity of an OAuth token without running afoul of normal rate limits for failed login attempts. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// Client Id of the OAuth application for the token /// The OAuth token to check /// The valid . Task CheckApplicationAuthentication(string clientId, string accessToken); /// /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// ClientID of the OAuth application for the token /// The OAuth token to reset /// The valid with a new OAuth token Task ResetApplicationAuthentication(string clientId, string accessToken); /// /// Revokes a single OAuth token for an OAuth application. /// /// /// This method requires authentication. /// See the API documentation for more information. /// /// ClientID of the OAuth application for the token /// The OAuth token to revoke /// A for the request's execution. Task RevokeApplicationAuthentication(string clientId, string accessToken); /// /// Updates the specified . /// /// /// This method requires authentication. /// See the API /// documentation for more details. /// /// Id of the to update /// Describes the changes to make to the authorization /// /// Thrown when the current user does not have permission to make the request. /// /// Thrown when a general API error occurs. /// The updated . Task Update(long id, AuthorizationUpdate authorizationUpdate); /// /// Deletes the specified . /// /// /// This method requires authentication. /// See the API /// documentation for more details. /// /// The system-wide Id of the authorization to delete /// /// Thrown when the current user does not have permission to make the request. /// /// Thrown when a general API error occurs. /// A for the request's execution. Task Delete(long id); /// /// Deletes the specified . /// /// /// This method requires authentication. /// See the API /// documentation for more details. /// /// The system-wide Id of the authorization to delete /// Two factor authorization code /// /// Thrown when the current user does not have permission to make the request. /// /// Thrown when a general API error occurs. /// A for the request's execution. Task Delete(long id, string twoFactorAuthenticationCode); } }