using System; using System.Linq; using xModels.Dtos; using System.Threading; using xIdentityModels.Dtos; using System.Threading.Tasks; using xIdentityModels.Models; using System.Linq.Expressions; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Query; namespace xIds.Interfaces { /// /// a Service For Manage Security Applications and also Api Key(s) ... /// public interface IXApplicationProvider { // #region Application ... /// /// Add Specified Item ... /// /// /// /// /// Task AddApplicationAsync( XApplicationDto item, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Update Specified Item ... /// /// /// /// /// /// Task UpdateApplicationAsync( int id, XApplicationDto item, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Remove Specified Item ... /// /// /// /// /// /// Task RemoveApplicationAsync( int id, bool softDelete = true, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Retrieve an Item by Providing it's ID ... /// /// /// /// /// /// /// Task GetApplicationAsync( int id, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve all Items ... /// /// /// /// /// /// /// Task> GetAllApplicationAsync( bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve all Items as Async Enumerable ... /// /// /// /// /// /// /// IAsyncEnumerable GetAllApplicationAsAsyncEnumerable( bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Find an Item By Providing a Conditional Expression ... /// /// /// /// /// /// /// Task FindOneApplicationAsync( Expression> predicate, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Find a Collection of Items By Providing a Conditional Expression ... /// /// /// /// /// /// /// /// Task> FindManyApplicationAsync( Expression> predicate, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve Items based on XQuery Pagination Structure ... /// /// /// /// /// /// /// /// /// Task> QueryApplicationAsync( XQuery query, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Expression> predicate = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); #endregion // #region ApiKey ... /// /// Add Specified Item ... /// /// /// /// /// Task AddApiKeyAsync( XApiKeyDto item, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Update Specified Item ... /// /// /// /// /// /// Task UpdateApiKeyAsync( Guid id, XApiKeyDto item, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Remove Specified Item ... /// /// /// /// /// /// Task RemoveApiKeyAsync( Guid id, bool softDelete = true, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Retrieve an Item by Providing it's ID ... /// /// /// /// /// /// /// Task GetApiKeyAsync( Guid id, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve all Items ... /// /// /// /// /// /// /// Task> GetAllApiKeyAsync( bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve all Items as Async Enumerable ... /// /// /// /// /// /// /// IAsyncEnumerable GetAllApiKeyAsAsyncEnumerable( bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Find an Item By Providing a Conditional Expression ... /// /// /// /// /// /// /// Task FindOneApiKeyAsync( Expression> predicate, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Find a Collection of Items By Providing a Conditional Expression ... /// /// /// /// /// /// /// /// Task> FindManyApiKeyAsync( Expression> predicate, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve Items based on XQuery Pagination Structure ... /// /// /// /// /// /// /// /// /// Task> QueryApiKeyAsync( XQuery query, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Expression> predicate = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); #endregion // #region ApiKeyUsage ... /// /// Add Specified Item ... /// /// /// /// /// Task AddApiKeyUsageAsync( XApiKeyUsageDto item, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Update Specified Item ... /// /// /// /// /// /// Task UpdateApiKeyUsageAsync( long id, XApiKeyUsageDto item, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Remove Specified Item ... /// /// /// /// /// /// Task RemoveApiKeyUsageAsync( long id, bool softDelete = true, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Retrieve an Item by Providing it's ID ... /// /// /// /// /// /// /// Task GetApiKeyUsageAsync( long id, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve all Items ... /// /// /// /// /// /// /// Task> GetAllApiKeyUsageAsync( bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve all Items as Async Enumerable ... /// /// /// /// /// /// /// IAsyncEnumerable GetAllApiKeyUsageAsAsyncEnumerable( bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Find an Item By Providing a Conditional Expression ... /// /// /// /// /// /// /// Task FindOneApiKeyUsageAsync( Expression> predicate, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Find a Collection of Items By Providing a Conditional Expression ... /// /// /// /// /// /// /// /// Task> FindManyApiKeyUsageAsync( Expression> predicate, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); /// /// Retrieve Items based on XQuery Pagination Structure ... /// /// /// /// /// /// /// /// /// Task> QueryApiKeyUsageAsync( XQuery query, bool ignoreSoftDeleteds = true, XUserClaimsInfoDto userInfo = null, Expression> predicate = null, Func, IOrderedQueryable> orderBuilder = null, Func, IIncludableQueryable> includeBuilder = null, CancellationToken cancellationToken = default ); #endregion // #region Custom Actions ... /// /// Generate a New ApiKey and Add It to DB ... /// /// /// /// /// /// /// /// /// Task CreateApiKey( int applicationId, TimeSpan? expiration = null, IEnumerable scopes = null, IEnumerable allowedIPs = null, int? rateLimit = null, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Revoke Specified Api Key ... /// /// /// /// /// Task RevokeApiKey( Guid apiKeyId, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Renew Specified Api Key ... /// /// /// /// /// /// Task RotateApiKey( Guid apiKeyId, TimeSpan? newExpiration = null, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Retrieve All Api Keys for Specified Application ... /// /// /// /// /// Task> GetApplicationApiKeys( int applicationId, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); /// /// Validate Specified Api Key in based on ClientIP ... /// /// /// /// /// /// /// Task ValidateApiKey( string apiKey, string clientIP, string requiredScope = null, XUserClaimsInfoDto userInfo = null, CancellationToken cancellationToken = default ); #endregion // #region Enrichers ... /// /// Enrich Api Key ... /// /// /// /// Task EnrichAsync( XApiKey source, CancellationToken cancellationToken = default ); /// /// Enrich Api Key ... /// /// /// /// Task EnrichAsync( XApiKeyDto source, CancellationToken cancellationToken = default ); /// /// Enrich Api Key Usage ... /// /// /// /// Task EnrichAsync( XApiKeyUsage source, CancellationToken cancellationToken = default ); /// /// Enrich Application ... /// /// /// /// Task EnrichAsync( XApplication source, CancellationToken cancellationToken = default ); /// /// Enrich Api Key Usage ... /// /// /// /// Task EnrichAsync( XApiKeyUsageDto source, CancellationToken cancellationToken = default ); /// /// Enrich Application ... /// /// /// /// Task EnrichAsync( XApplicationDto source, CancellationToken cancellationToken = default ); /// /// Enrich a Collection of Api Key(s) ... /// /// /// /// Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ); /// /// Enrich a Collection of Api Key(s) ... /// /// /// /// Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ); /// /// Enrich a Collection of Api Key Usage(s) ... /// /// /// /// Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ); /// /// Enrich a Collection of Application(s) ... /// /// /// /// Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ); /// /// Enrich a Collection of Api Key Usage(s) ... /// /// /// /// Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ); /// /// Enrich a Collection of Application(s) ... /// /// /// /// Task> EnrichRangeAsync( IEnumerable sources, CancellationToken cancellationToken = default ); #endregion } }