public async static Task <HttpResponseMessage> QueryByActorId( [QueryParameter(Name = ActorPropertyName)] Guid actorId, Context context, AzureApplication application, EastFive.Api.SessionToken security, UrlHelper urlHelper, ContentResponse onFound, MultipartResponseAsync onFounds, ReferencedDocumentNotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized, ServiceUnavailableResponse onServiceUnavailable) { return(await await context.PasswordCredentials.GetPasswordCredentialByActorAsync( actorId, security, application, (credentials) => { var credentialResources = credentials .Select( passwordCredential => { var resource = Convert(passwordCredential, urlHelper); var response = onFound(resource); return response; }) .ToArray(); return onFounds(credentialResources); }, () => onNotFound().AsTask(), () => onUnauthorized().AsTask(), (why) => onServiceUnavailable().AsTask())); }
public static async Task <HttpResponseMessage> GetAllSecureAsync( [QueryParameter(Name = "ApiKeySecurity")] string apiSecurityKey, [QueryParameter(Name = "authorization")] IRef <Authorization> authorizationRef, ApiSecurity apiSecurity, AzureApplication application, HttpRequestMessage request, MultipartResponseAsync <Authorization> onContent, RedirectResponse onSuccess, NotFoundResponse onNotFound, ForbiddenResponse onFailure) { return(await await authorizationRef.StorageGetAsync( async authorization => { return await await Method.ById(authorization.Method, application, async method => { return await await method.ParseTokenAsync(authorization.parameters, application, (externalId, loginProvider) => { return Auth.Redirection.ProcessAsync(authorization, async updatedAuth => { }, method, externalId, authorization.parameters, Guid.NewGuid(), request.RequestUri, application, loginProvider, (uri) => onSuccess(uri), (why) => onFailure().AddReason(why), application.Telemetry); }, why => onFailure().AddReason(why).AsTask()); }, () => onFailure().AddReason("Method no longer supported").AsTask()); }, () => onNotFound().AsTask())); }
public static async Task <HttpResponseMessage> QueryBySessionAsync( [QueryParameter(Name = "session")] IRef <Session> sessionRef, Api.Azure.AzureApplication application, MultipartResponseAsync <Method> onContent, ReferencedDocumentNotFoundResponse <Session> onIntegrationNotFound) { return(await await sessionRef.StorageGetAsync( session => { var integrationProviders = application.LoginProviders .Where(loginProvider => loginProvider.Value.GetType().IsSubClassOfGeneric(typeof(IProvideSession))) .Select( async loginProvider => { var supportsIntegration = await(loginProvider.Value as IProvideSession).SupportsSessionAsync(session); return supportsIntegration.PairWithValue(loginProvider); }) .Await() .Where(kvp => kvp.Key) .SelectValues() .Select( (loginProvider) => { return new Method { authenticationId = new Ref <Method>(loginProvider.Value.Id), name = loginProvider.Value.Method, }; }); return onContent(integrationProviders); }, () => onIntegrationNotFound().AsTask())); }
public async static Task <HttpResponseMessage> GetByMethodAsync( [QueryParameter(Name = Authorization.MethodPropertyName)] IRef <Method> methodRef, Api.Azure.AzureApplication application, SessionToken security, MultipartResponseAsync <XIntegration> onContents, UnauthorizedResponse onUnauthorized) { if (!security.accountIdMaybe.HasValue) { return(onUnauthorized()); } var accountId = security.accountIdMaybe.Value; var integrations = GetIntegrationsByAccount(accountId) .Where(integration => integration.Value.Method.id == methodRef.id) .Select( kvp => { var integration = kvp.Key; return(Auth.Method.ById(kvp.Value.Method, application, method => { integration.methodName = method.name; return integration; }, () => default(XIntegration?))); }) .Await() .SelectWhereHasValue(); return(await onContents(integrations)); }
public async static Task <HttpResponseMessage> GetByAccountAsync( [QueryParameter(Name = AccountPropertyName)] Guid accountId, Api.Azure.AzureApplication application, SessionToken security, MultipartResponseAsync <XIntegration> onContents, ReferencedDocumentNotFoundResponse <object> onAccountNotFound, UnauthorizedResponse onUnauthorized) { if (!await application.CanAdministerCredentialAsync(accountId, security)) { return(onUnauthorized()); } var integrations = GetIntegrationsByAccount(accountId) .Select( kvp => { var integration = kvp.Key; return(Auth.Method.ById(kvp.Value.Method, application, method => { integration.methodName = method.name; return integration; }, () => default(XIntegration?))); }) .Await() .SelectWhereHasValue(); return(await onContents(integrations)); }
public static async Task <HttpResponseMessage> RunAsync( [UpdateId] IRefs <InvocationMessage> invocationMessageRefs, [HeaderLog] EastFive.Analytics.ILogger analyticsLog, InvokeApplicationDirect invokeApplication, MultipartResponseAsync onRun) { var messages = await invocationMessageRefs.refs .Select(invocationMessageRef => InvokeAsync(invocationMessageRef, invokeApplication, logging: analyticsLog)) .AsyncEnumerable() .ToArrayAsync(); return(await onRun(messages)); }
public static async Task <HttpResponseMessage> QueueUpBackupPartitions( [Property(Name = IdPropertyName)] IRef <RepositoryBackup> repositoryBackupRef, [Property(Name = StorageSettingCopyFromPropertyName)] string storageSettingCopyFrom, [Property(Name = StorageSettingCopyToPropertyName)] string storageSettingCopyTo, [Resource] RepositoryBackup repositoryBackup, AzureApplication application, RequestMessage <TableBackup> requestQuery, HttpRequestMessage request, EastFive.Analytics.ILogger logger, MultipartResponseAsync <InvocationMessage> onQueued, AlreadyExistsResponse onAlreadyExists) { logger.Trace($"Cleaning backup results"); var repo = AzureTableDriverDynamic.FromStorageString(storageSettingCopyTo); await DeleteAllAsync(GetRepository(storageSettingCopyTo)); CloudStorageAccount account = CloudStorageAccount .Parse(storageSettingCopyFrom); CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint, account.Credentials); return(await await repositoryBackup.StorageCreateAsync( (discard) => { var resourceInfoToProcess = tableClient .ListTables() .Distinct() .Select( async cloudTable => { var tableBackup = new TableBackup() { tableBackupRef = Ref <TableBackup> .NewRef(), backup = repositoryBackupRef, tableName = cloudTable.Name, when = DateTime.UtcNow, }; var invocationMessage = await requestQuery .HttpPost(tableBackup) .CompileRequest(request) .FunctionAsync(); logger.Trace($"Invocation[{invocationMessage.id}] will backup table `{tableBackup.tableName}`."); return invocationMessage; }) .AsyncEnumerable(); return onQueued(resourceInfoToProcess); }, () => onAlreadyExists().AsTask())); }
public static Task <HttpResponseMessage> ListAsync( [QueryParameter(Name = "last_modified")] DateTime day, [HeaderLog] EastFive.Analytics.ILogger analyticsLog, InvokeApplicationDirect invokeApplication, MultipartResponseAsync <InvocationMessage> onRun) { Expression <Func <InvocationMessage, bool> > expr = (im) => true; var messages = expr .StorageQuery() .Where(msg => DateTime.UtcNow - msg.lastModified < TimeSpan.FromDays(3.0)); return(onRun(messages)); }
public static Task <HttpResponseMessage> QueryAsync( Api.Azure.AzureApplication application, MultipartResponseAsync <Method> onContent) { return(onContent( application.LoginProviders .Select( (loginProvider) => { return new Method { authenticationId = loginProvider.Value.Id.AsRef <Method>(), name = loginProvider.Value.Method, }; }))); }
[Api.HttpGet] //(MatchAllBodyParameters = false)] public async static Task <HttpResponseMessage> GetByAccountAsync( [QueryParameter(Name = AccountPropertyName)] Guid accountId, Api.Azure.AzureApplication application, SessionToken security, MultipartResponseAsync <Integration> onContents, ReferencedDocumentNotFoundResponse <object> onAccountNotFound, UnauthorizedResponse onUnauthorized) { if (!await application.CanAdministerCredentialAsync(accountId, security)) { return(onUnauthorized()); } return(await await GetIntegrationsByAccountAsync(accountId, (kvps) => onContents(kvps.SelectKeys()), () => onAccountNotFound().AsTask())); }
public static async Task <HttpResponseMessage> QueryByIntegrationAsync( [QueryParameter(Name = "integration")] IRef <Integration> integrationRef, Api.Azure.AzureApplication application, EastFive.Api.SessionToken security, MultipartResponseAsync <Method> onContent, UnauthorizedResponse onUnauthorized, ReferencedDocumentNotFoundResponse <Integration> onIntegrationNotFound) { return(await await integrationRef.StorageGetAsync( async (integration) => { var accountId = integration.accountId; if (!await application.CanAdministerCredentialAsync(accountId, security)) { return onUnauthorized(); } var integrationProviders = application.LoginProviders .Where(loginProvider => loginProvider.Value.GetType().IsSubClassOfGeneric(typeof(IProvideIntegration))) .Select( async loginProvider => { var integrationProvider = loginProvider.Value as IProvideIntegration; var supportsIntegration = await integrationProvider.SupportsIntegrationAsync(accountId); return supportsIntegration.PairWithValue(loginProvider); }) .Await() .Where(kvp => kvp.Key) .SelectValues() .Select( (loginProvider) => { var integrationProvider = loginProvider.Value as IProvideIntegration; return new Method { authenticationId = new Ref <Method>(loginProvider.Value.Id), name = integrationProvider.GetDefaultName(new Dictionary <string, string>()), }; }); return await onContent(integrationProviders); }, () => onIntegrationNotFound().AsTask())); }