public static Task <IHttpResponse> UpdateProcessStepAsync( [QueryParameter(Name = ProcessStep.IdPropertyName, CheckFileName = true)] Guid processId, [PropertyOptional(Name = ProcessStep.ConfirmedByPropertyName)] Guid?confirmedById, [PropertyOptional(Name = ProcessStep.ConfirmedWhenPropertyName)] DateTime?confirmedWhen, [PropertyOptional(Name = ProcessStep.ResourceKeysPropertyName)] string[] resourceKeys, [PropertyOptional(Name = ProcessStep.ResourcesPropertyName)] Guid[] resources, EastFive.Api.Security security, IProvideUrl url, NoContentResponse onUpdated, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized, GeneralConflictResponse onFailure) { return(EastFive.Azure.Processes.UpdateAsync(processId, confirmedById, confirmedWhen, resourceKeys.NullToEmpty().Zip(resources.NullToEmpty(), (k, id) => k.PairWithValue(id)).ToArray(), security, () => onUpdated(), () => onNotFound(), () => onUnauthorized(), (why) => onFailure(why))); //return Connectors.UpdateConnectorAsync(id, // Flow, security.performingAsActorId, security.claims, // () => onUpdated(), // () => onNotFound(), // (why) => onFailure(why)); }
public async static Task <IHttpResponse> UpdateAsync( [UpdateId(Name = AuthorizationIdPropertyName)] IRef <Authorization> authorizationRef, [Property(Name = LocationLogoutReturnPropertyName)] Uri locationLogoutReturn, EastFive.Api.SessionToken?securityMaybe, NoContentResponse onUpdated, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized) { return(await authorizationRef.StorageUpdateAsync( async (authorization, saveAsync) => { if (authorization.deleted.HasValue) { return onNotFound(); } if (authorization.authorized) { authorization.LocationAuthentication = default(Uri); if (!securityMaybe.HasValue) { return onUnauthorized(); } } authorization.LocationLogoutReturn = locationLogoutReturn; await saveAsync(authorization); return onUpdated(); }, () => onNotFound())); }
public static IHttpResponse RedeemAsync( IApplication app, //Security security, NoContentResponse onBounced) { SpaHandler.SetupSpa(app); return(onBounced()); }
public static IHttpResponse FindAsync( //Security security, HttpApplication application, IHttpRequest request, IProvideUrl url, NoContentResponse onSuccess, ViewFileResponse <Api.Resources.Manifest> onHtml) { return(onSuccess()); }
public static async Task <IHttpResponse> EnqueueAsync( [UpdateId] IRef <InvocationMessage> invocationMessageRef, IAzureApplication application, NoContentResponse onNoContent) { await SendToQueueAsync(invocationMessageRef, application); return(onNoContent()); }
public static Task <IHttpResponse> HttpDeleteAsync <TResource>( this IRef <TResource> resourceRef, NoContentResponse onDeleted, NotFoundResponse onNotFound) where TResource : IReferenceable { return(resourceRef.StorageDeleteAsync( onDeleted: (discard) => onDeleted(), () => onNotFound())); }
public static Task <IHttpResponse> DeleteByIdAsync( [WorkflowParameter(Value = "{{TeamsNotification_}}")] [UpdateId(Name = IdPropertyName)] IRef <TeamsNotification> teamsNotificationId, NoContentResponse onDeleted, NotFoundResponse onNotFound) { return(teamsNotificationId.HttpDeleteAsync( onDeleted, onNotFound)); }
public static async Task <IHttpResponse> DeleteAsync( [UpdateId(Name = AuthorizationIdPropertyName)] IRef <Authorization> authorizationRef, IProvideUrl urlHelper, AzureApplication application, NoContentResponse onLogoutComplete, AcceptedBodyResponse onExternalSessionActive, NotFoundResponse onNotFound, GeneralFailureResponse onFailure) { return(await authorizationRef.StorageUpdateAsync( async (authorizationToDelete, updateAsync) => { authorizationToDelete.deleted = DateTime.UtcNow; if (!authorizationToDelete.authorized) { return onLogoutComplete().AddReason("Deleted"); } var locationLogout = await await Auth.Method.ById(authorizationToDelete.Method, application, (authentication) => { return authentication.GetLogoutUrlAsync( application, urlHelper, authorizationRef.id); }, () => default(Uri).AsTask()); authorizationToDelete.LocationLogout = locationLogout; await updateAsync(authorizationToDelete); bool NoRedirectRequired() { if (locationLogout.IsDefaultOrNull()) { return true; } if (!locationLogout.IsAbsoluteUri) { return true; } if (locationLogout.AbsoluteUri.IsNullOrWhiteSpace()) { return true; } return false; } if (NoRedirectRequired()) { return onLogoutComplete().AddReason("Logout Complete"); } return onExternalSessionActive(authorizationToDelete, "application/json") .AddReason($"External session removal required:{locationLogout.AbsoluteUri}"); }, () => onNotFound())); }
public static Task <IHttpResponse> DeleteAsync( [UpdateId(Name = SessionIdPropertyName)] IRef <Session> sessionRef, NoContentResponse onDeleted, NotFoundResponse onNotFound) { return(sessionRef.StorageDeleteAsync( onDeleted: (discard) => { return onDeleted(); }, onNotFound: () => onNotFound())); }
public static Task <IHttpResponse> DeleteByIdAsync( [QueryParameter(CheckFileName = true, Name = ProcessStep.IdPropertyName)] Guid processStepId, EastFive.Api.Security security, NoContentResponse onDeleted, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized) { return(EastFive.Azure.Processes.DeleteByIdAsync(processStepId, security, () => onDeleted(), () => onNotFound(), () => onUnauthorized())); }
public static Task <HttpResponseMessage> DeleteAsync( [UpdateId(Name = SessionIdPropertyName)] IRef <Session> sessionRef, Api.Azure.AzureApplication application, NoContentResponse onDeleted, NotFoundResponse onNotFound) { return(sessionRef.StorageDeleteAsync( () => { return onDeleted(); }, onNotFound: () => onNotFound())); }
public static Task <IHttpResponse> Update( [UpdateId] IRef <Account> accountRef, [Property(Name = PasswordPropertyName)] string password, NoContentResponse onUpdated, NotFoundResponse onNotFound) { return(accountRef.StorageUpdateAsync( async(account, saveAsync) => { account.password = Account.GeneratePasswordHash( account.userIdentification, password); await saveAsync(account); return onUpdated(); }, () => onNotFound())); }
public static Task <HttpResponseMessage> UpdateConnectorAsync( [Property] Guid id, [Property(Name = EastFive.Api.Resources.Connector.SourcePropertyName)] Guid source, [PropertyOptional(Name = EastFive.Api.Resources.Connector.DestinationPropertyName)] Guid?destination, [Property(Name = EastFive.Api.Resources.Connector.FlowPropertyName)] Connector.SynchronizationMethod Flow, Security security, Context context, HttpRequestMessage request, UrlHelper url, NoContentResponse onUpdated, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized, GeneralConflictResponse onFailure) { return(Connectors.UpdateConnectorAsync(id, Flow, security.performingAsActorId, security.claims, () => onUpdated(), () => onNotFound(), (why) => onFailure(why))); }
public static Task <HttpResponseMessage> UpdateGroupAsync( [Property] Guid id, [Property(Name = EastFive.Api.Resources.Connector.SourcePropertyName)] Guid source, [PropertyOptional(Name = EastFive.Api.Resources.Connector.DestinationPropertyName)] Guid?destination, [PropertyOptional(Name = EastFive.Api.Resources.Connector.DestinationIntegrationPropertyName)] Guid?destinationIntegration, EastFive.Api.Security security, HttpRequestMessage request, UrlHelper url, NoContentResponse onUpdated, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized, GeneralConflictResponse onFailure) { throw new NotImplementedException(); //return Connectors.UpdateConnectorAsync(id, // Flow, security.performingAsActorId, security.claims, // () => onUpdated(), // () => onNotFound(), // (why) => onFailure(why)); }
public static Task <HttpResponseMessage> UpdateConnectorAsync( [Property(Name = Resources.ProcessStage.IdPropertyName)] Guid processStageId, [PropertyOptional(Name = Resources.ProcessStage.TypePropertyName)] Guid?processStageTypeId, [PropertyOptional(Name = Resources.ProcessStage.TitlePropertyName)] string title, [PropertyOptional(Name = Resources.ProcessStage.ViewablePropertyName)] Guid [] viewableIds, [PropertyOptional(Name = Resources.ProcessStage.CompletablePropertyName)] Guid [] completableIds, [PropertyOptional(Name = Resources.ProcessStage.EditablePropertyName)] Guid [] editableIds, [PropertyOptional(Name = Resources.ProcessStage.ConfirmablePropertyName)] Resources.ProcessStage.ConfirmableResource [] confirmables, EastFive.Api.Security security, Context context, HttpRequestMessage request, UrlHelper url, NoContentResponse onUpdated, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized, GeneralConflictResponse onFailure) { return(EastFive.Azure.ProcessStages.UpdateAsync(processStageId, processStageTypeId, title, viewableIds, completableIds, editableIds, confirmables.IsDefaultOrNull() ? default(KeyValuePair <Guid[], Guid>[]) : confirmables .Select( confirmable => confirmable.ProcessStageNext.ToGuid() .PairWithValue(confirmable.Positions.Select(pos => pos.ToGuid()).ToArray())) .Where(kvp => kvp.Key.HasValue) .Select(kvp => kvp.Key.Value.PairWithKey( kvp.Value.Where(v => v.HasValue).Select(v => v.Value).ToArray())) .ToArray(), security, () => onUpdated(), () => onNotFound(), () => onUnauthorized(), (why) => onFailure(why))); }
public static async Task <HttpResponseMessage> DeleteByIdAsync( [Property(Name = IdPropertyName)] Guid passwordCredentialId, Context context, AzureApplication application, EastFive.Api.SessionToken security, UrlHelper urlHelper, NoContentResponse onDeleted, UnauthorizedResponse onUnauthorized, NotFoundResponse onNotFound, ServiceUnavailableResponse onServiceUnavailable) { return(await context.PasswordCredentials.DeletePasswordCredentialAsync(passwordCredentialId, security, application, () => { var response = onDeleted(); return response; }, () => onUnauthorized(), () => onNotFound(), (why) => onServiceUnavailable().AddReason(why))); }
public static Task <HttpResponseMessage> PutAsync( [Property(Name = IdPropertyName)] Guid credentialId, [PropertyOptional(Name = TokenPropertyName)] string token, [PropertyOptional(Name = ForceChangePropertyName)] bool forceChange, [PropertyOptional(Name = LastEmailSentPropertyName)] DateTime?lastEmailSent, Context context, AzureApplication application, EastFive.Api.SessionToken security, NoContentResponse onUpdated, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized, ServiceUnavailableResponse onServiceUnavailable, GeneralConflictResponse onFailure) { return(context.PasswordCredentials.UpdatePasswordCredentialAsync(credentialId, token, forceChange, lastEmailSent, security, application, () => onUpdated(), () => onNotFound(), () => onUnauthorized(), () => onServiceUnavailable(), (why) => onFailure($"Update failed:{why}"))); }
public static async Task <IHttpResponse> DeleteAsync( [UpdateId(Name = IntegrationIdPropertyName)] IRef <XIntegration> integrationRef, IAuthApplication application, EastFive.Api.SessionToken security, NoContentResponse onDeleted, NotFoundResponse onNotFound, ForbiddenResponse onForbidden) { var integrationMaybe = await integrationRef.StorageGetAsync(i => i, () => default(XIntegration?)); if (!integrationMaybe.HasValue) { return(onNotFound()); } var integration = integrationMaybe.Value; if (!await application.CanAdministerCredentialAsync(integration.accountId, security)) { return(onForbidden()); } return(await DeleteInternalAsync(integrationRef, () => onDeleted(), () => onNotFound())); }
public static async Task <IHttpResponse> QueueUpBackupPartitions( [Property(Name = IdPropertyName)] IRef <RepositoryBackup> repositoryBackupRef, [Property(Name = WhenPropertyName)] DateTime when, RequestMessage <TableBackup> requestQuery, IHttpRequest request, EastFive.Analytics.ILogger logger, MultipartAsyncResponse <InvocationMessage> onQueued, NoContentResponse onTooEarly, NotFoundResponse onNotFound) { return(await repositoryBackupRef.StorageUpdateAsync( async (repoBack, saveAsync) => { var needsToRun = NCrontab.CrontabSchedule.TryParse(repoBack.frequency, chronSchedule => { var next = chronSchedule.GetNextOccurrence(repoBack.when); if (when > next) { return true; } return false; }, ex => { return false; }); if (!needsToRun) { return onTooEarly(); } var includedTables = BackupFunction.DiscoverStorageResources() .Where(x => x.message.Any()) .Select(x => x.tableName) .ToArray(); CloudStorageAccount account = CloudStorageAccount .Parse(repoBack.storageSettingCopyFrom); CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint, account.Credentials); var tables = tableClient.GetTables(); var resourceInfoToProcess = tables .Where(table => includedTables.Contains(table.Name, StringComparer.OrdinalIgnoreCase)) .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; }) .Await(readAhead: 10); repoBack.when = when; await saveAsync(repoBack); return onQueued(resourceInfoToProcess); }, () => onNotFound())); }