2using System.Globalization;
4using Microsoft.Extensions.Logging;
28 protected ILogger<AuthorityBase>
Logger {
get; }
92 AdditionalData = additionalData,
135 ILogger<AuthorityBase> logger)
137 DatabaseContext = databaseContext ??
throw new ArgumentNullException(nameof(databaseContext));
138 Logger = logger ??
throw new ArgumentNullException(nameof(logger));
149 Logger.LogWarning(rateLimitException,
"Exceeded GitHub rate limit!");
150 var secondsString = Math.Ceiling(rateLimitException.GetRetryAfterTimeSpan().TotalSeconds).ToString(CultureInfo.InvariantCulture);
154 AdditionalData = $
"Retry-After: {secondsString}s",
Represents an error message returned by the server.
Base implementation of IAuthority.
static AuthorityResponse< TResult > Forbid< TResult >()
Generates a HttpFailureResponse.Forbidden type AuthorityResponse<TResult>.
static AuthorityResponse< TResult > Gone< TResult >()
Generates a HttpFailureResponse.Forbidden type AuthorityResponse<TResult>.
static OrRightsConditional< TRights > Or< TRights >(RightsConditional< TRights > lhs, RightsConditional< TRights > rhs)
Helper to quickly construct an OrRightsConditional<TRights>.
static AuthorityResponse< TResult > Conflict< TResult >(ErrorCode errorCode, string? additionalData=null)
Generates a HttpFailureResponse.Conflict type AuthorityResponse<TResult>.
static AuthorityResponse< TResult > NotFound< TResult >()
Generates a HttpFailureResponse.NotFound type AuthorityResponse<TResult>.
static FlagRightsConditional< TRights > Flag< TRights >(TRights flag)
Helper to quickly construct a FlagRightsConditional<TRights>.
static AndRightsConditional< TRights > And< TRights >(RightsConditional< TRights > lhs, RightsConditional< TRights > rhs)
Helper to quickly construct an AndRightsConditional<TRights>.
static AuthorityResponse< TResult > Unauthorized< TResult >()
Generates a HttpFailureResponse.Unauthorized type AuthorityResponse<TResult>.
AuthorityBase(IDatabaseContext databaseContext, ILogger< AuthorityBase > logger)
Initializes a new instance of the AuthorityBase class.
AuthorityResponse< TResult > RateLimit< TResult >(RateLimitExceededException rateLimitException)
Generates a HttpFailureResponse.RateLimited type AuthorityResponse.
ILogger< AuthorityBase > Logger
Gets the ILogger for the AuthorityBase.
static AuthorityResponse< TResult > BadRequest< TResult >(ErrorCode errorCode)
Generates a HttpFailureResponse.BadRequest type AuthorityResponse<TResult>.
Represents a response from an authority.
Backend abstract implementation of IDatabaseContext.
Logical AND RightsConditional<TRights>.
Single flag RightsConditional<TRights>.
Logical OR RightsConditional<TRights>.
An conditional expression of TRights .
Business logic for interating with the server.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
HttpFailureResponse
Indicates the type of HTTP status code an failing AuthorityResponse should generate.