public static async Task <HttpResponseMessage> FindByResourceAsync( [QueryParameter] Guid resourceId, EastFive.Api.Security security, UrlHelper url, MultipartAcceptArrayResponseAsync onMultipart, ReferencedDocumentNotFoundResponse onResourceNotFound, UnauthorizedResponse onUnauthorized) { return(await await EastFive.Azure.ProcessStages.FindByResourceAsync(resourceId, security, (processStages) => onMultipart(processStages.Select(ps => GetResource(ps, url))), () => onResourceNotFound().ToTask(), () => onUnauthorized().ToTask())); }
public static async Task <IHttpResponse> QueueUpBackupPartitions( [Property(Name = IdPropertyName)] IRef <RepositoryBackup> repositoryBackupRef, [Property(Name = StorageSettingCopyFromPropertyName)] string storageSettingCopyFrom, [Property(Name = StorageSettingCopyToPropertyName)] string storageSettingCopyTo, [Resource] RepositoryBackup repositoryBackup, AzureApplication application, EastFive.Api.Security security, RequestMessage <TableBackup> requestQuery, IHttpRequest request, EastFive.Analytics.ILogger logger, MultipartAsyncResponse <InvocationMessage> onQueued, AlreadyExistsResponse onAlreadyExists) { CloudStorageAccount account = CloudStorageAccount .Parse(storageSettingCopyFrom); CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint, account.Credentials); return(await repositoryBackup.StorageCreateAsync( (discard) => { var includedTables = BackupFunction.DiscoverStorageResources() .Where(x => x.message.Any()) .Select(x => x.tableName) .ToArray(); var resourceInfoToProcess = tableClient.GetTables() .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); return onQueued(resourceInfoToProcess); }, () => onAlreadyExists())); }
public static Task <HttpResponseMessage> FindByIdAsync( [QueryParameter(CheckFileName = true)] Guid id, EastFive.Api.Security security, UrlHelper url, ContentResponse onFound, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized) { return(EastFive.Azure.ProcessStages.FindByIdAsync(id, security, (processStage) => onFound(GetResource(processStage, url)), () => onNotFound(), () => onUnauthorized())); }
public static async Task <HttpResponseMessage> FindByFirstStepByActorAndTypeAsync( [QueryParameter(Name = Resources.ProcessStage.OwnerPropertyName)] Guid ownerId, [QueryParameter(Name = Resources.ProcessStage.TypePropertyName)] Type resourceType, [QueryParameter(Name = "processstage." + Resources.ProcessStage.ConfirmablePropertyName + "." + Resources.ProcessStage.ConfirmableResource.ProcessStageNextPropertyName)] EastFive.Api.Controllers.WebIdNone nextStage, AzureApplication application, EastFive.Api.Security security, UrlHelper url, MultipartAcceptArrayResponseAsync onMultipart, ReferencedDocumentNotFoundResponse onResourceNotFound, UnauthorizedResponse onUnauthorized) { return(await await EastFive.Azure.ProcessStages.FindStartByActorAndResourceTypeAsync(ownerId, resourceType, security, (processStages) => onMultipart(processStages.Select(ps => GetResource(ps, url))), () => onResourceNotFound().ToTask(), () => onUnauthorized().ToTask())); }
public static Task <IHttpResponse> FindByFirstStepByActorAndTypeAsync( [QueryParameter(Name = Resources.ProcessStage.OwnerPropertyName)] Guid ownerId, [QueryParameter(Name = Resources.ProcessStage.TypePropertyName)] Type resourceType, [QueryParameter(Name = "processstage." + Resources.ProcessStage.ConfirmablePropertyName + "." + Resources.ProcessStage.ConfirmableResource.ProcessStageNextPropertyName)] IRefOptional <IReferenceable> nextStage, EastFive.Api.Security security, IProvideUrl url, MultipartAcceptArrayResponse onMultipart, ReferencedDocumentNotFoundResponse onResourceNotFound, UnauthorizedResponse onUnauthorized) { return(EastFive.Azure.ProcessStages.FindStartByActorAndResourceTypeAsync(ownerId, resourceType, security, (processStages) => onMultipart(processStages.Select(ps => GetResource(ps, url))), () => onResourceNotFound(), () => onUnauthorized())); }
public static Task <HttpResponseMessage> CreateAsync( [Property(Name = Resources.ProcessStage.IdPropertyName)] Guid processStageId, [Property(Name = Resources.ProcessStage.OwnerPropertyName)] Guid ownerId, [Property(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, EastFive.Api.Azure.AzureApplication application, CreatedResponse onCreated, AlreadyExistsResponse onAlreadyExists, ReferencedDocumentDoesNotExistsResponse <Resources.ProcessStageType> onTypeDoesNotExist, ReferencedDocumentDoesNotExistsResponse <Resources.ProcessStage> onConfirmationStageDoesNotExist, ReferencedDocumentDoesNotExistsResponse <BlackBarLabs.Api.ResourceBase> onActorDoesNotExists, UnauthorizedResponse onUnauthorized, GeneralConflictResponse onFailure) { return(EastFive.Azure.ProcessStages.CreateAsync(processStageId, ownerId, processStageTypeId, title, viewableIds, editableIds, completableIds, confirmables .Select( confirmable => confirmable.ProcessStageNext.ToGuid().Value .PairWithKey( confirmable.Positions .Select(position => position.ToGuid().Value) .ToArray())) .ToArray(), security, () => onCreated(), () => onAlreadyExists(), () => onTypeDoesNotExist(), (missingStageId) => onConfirmationStageDoesNotExist(), () => onActorDoesNotExists(), (why) => onFailure(why))); }
public static IHttpResponse ClearAsync( [WorkflowParameter(Value = "true")] [QueryParameter(Name = "clear")] bool clear, RequestMessage <TeamsNotification> teamsNotifications, EastFive.Api.Security security, MultipartAsyncResponse <TeamsNotification> onDeleted) { return(teamsNotifications .StorageGet() .StorageDeleteBatch( tr => { return (tr.Result as IWrapTableEntity <TeamsNotification>).Entity; }) .HttpResponse(onDeleted)); }
public static Task <HttpResponseMessage> Get(EastFive.Api.Security security, HttpRequestMessage request) { return(EastFive.Web.Configuration.Settings.GetGuid( EastFive.Api.AppSettings.ActorIdSuperAdmin, (actorIdSuperAdmin) => { if (actorIdSuperAdmin == security.performingAsActorId) { var settings = ConfigurationManager.AppSettings.AllKeys .Select(x => new AppSetting { Name = x, Value = ConfigurationManager.AppSettings[x] }).OrderBy(x => x.Name).ToArray(); return request.CreateResponse(System.Net.HttpStatusCode.OK, settings, "application/json").ToTask(); } return request.CreateResponse(System.Net.HttpStatusCode.NotFound).ToTask(); }, (why) => request.CreateResponse(System.Net.HttpStatusCode.InternalServerError, why).ToTask())); }
public static Task <IHttpResponse> FindByResourceTypeAsync( [EastFive.Api.QueryParameter(Name = ActorPropertyName)] Guid actorId, [EastFive.Api.QueryParameter(Name = Resources.ProcessStageType.ResourceTypePropertyName)] Type resourceType, EastFive.Api.Security security, AzureApplication application, IProvideUrl url, [Display(Name = "Found")] MultipartAcceptArrayResponse onMultipart, ReferencedDocumentNotFoundResponse onResourceNotFound, UnauthorizedResponse onUnauthorized) { return(EastFive.Azure.ProcessResourceViews.FindByResourceAsync(actorId, resourceType, security, (views) => { var viewResources = views.Select(ps => GetResource(ps, application, url)).ToArray(); return onMultipart(viewResources); }, () => onResourceNotFound(), () => onUnauthorized())); }
public static async Task <IHttpResponse> CreateAsync( [Property(Name = IdPropertyName)] IRef <TableBackupOperation> tableBackupOperationRef, [Property(Name = WhenPropertyName)] DateTime when, [Property(Name = TableBackupPropertyName)] IRef <TableBackup> tableBackupRef, [Property(Name = OperationSetPropertyName)] string operationSet, [Resource] TableBackupOperation tableBackup, RequestMessage <TableBackupOperation> requestQuery, IHttpRequest request, EastFive.Api.Security security, EastFive.Analytics.ILogger logger, CreatedBodyResponse <InvocationMessage> onCreated, AlreadyExistsResponse onAlreadyExists) { return(await await tableBackup.StorageCreateAsync( async (discard) => { var invocationMessage = await requestQuery .ById(tableBackupOperationRef) .HttpPatch(default)
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 IHttpResponse WhoAmI( EastFive.Api.Security security, ContentTypeResponse <Guid> onFound) { return(onFound(security.performingAsActorId)); }
public async static Task <IHttpResponse> GetAllSecureAsync( [Api.Meta.Flows.WorkflowParameter(Value = "{{AuthenticationMethod}}")] [QueryParameter(Name = "method")] IRef <Method> methodRef, [OptionalQueryParameter(Name = "successOnly")] bool successOnly, [Api.Meta.Flows.WorkflowParameter(Description = "ACP,Dash,TCM,HUDDLE", Value = "")] [OptionalQueryParameter(Name = "search")] string search, [OptionalQueryParameter(Name = "months")] int?monthsMaybe, AzureApplication application, EastFive.Api.Security security, IHttpRequest request, [Api.Meta.Flows.WorkflowVariable(AuthorizationPropertyName, "authorization{0}")] ContentTypeResponse <RedirectionManager[]> onContent, UnauthorizedResponse onUnauthorized, ConfigurationFailureResponse onConfigFailure, BadRequestResponse onBadRequest) { // this query is faster than the version commented out below var methodMaybe = await Method.ById(methodRef, application, (m) => m, () => default(Method?)); if (methodMaybe.IsDefault()) { return(onBadRequest().AddReason("Method no longer supported")); } var method = methodMaybe.Value; var months = monthsMaybe.HasValue ? Math.Abs(monthsMaybe.Value) : 1; var since = DateTime.UtcNow.Date.AddMonths(-months); var query = new TableQuery <GenericTableEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterConditionForGuid("method", QueryComparisons.Equal, method.id), TableOperators.And, TableQuery.CombineFilters( TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThanOrEqual, since), TableOperators.And, TableQuery.GenerateFilterConditionForBool("authorized", QueryComparisons.Equal, true) ) ) ); var table = EastFive.Azure.Persistence.AppSettings.Storage.ConfigurationString( (conn) => { var account = CloudStorageAccount.Parse(conn); var client = account.CreateCloudTableClient(); return(client.GetTableReference("authorization")); }, (why) => throw new Exception(why)); var segment = default(TableQuerySegment <GenericTableEntity>); var token = default(TableContinuationToken); var redirections = new RedirectionManager[] { }; do { segment = await table.ExecuteQuerySegmentedAsync(query, token); token = segment.ContinuationToken; var result = await segment.Results .Select( async (entity) => { var id = Guid.Parse(entity.RowKey); var when = entity.Timestamp.DateTime; var props = entity.WriteEntity(default);