| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Models; |
| | | 3 | | using Elsa.Workflows.Management; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | using Microsoft.AspNetCore.Http; |
| | | 6 | | using Open.Linq.AsyncExtensions; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Variables.List; |
| | | 9 | | |
| | | 10 | | [UsedImplicitly] |
| | 1 | 11 | | internal class List(IWorkflowInstanceVariableManager workflowInstanceVariableManager) : ElsaEndpointWithoutRequest<ListR |
| | | 12 | | { |
| | | 13 | | public override void Configure() |
| | | 14 | | { |
| | 1 | 15 | | Get("/workflow-instances/{id}/variables"); |
| | 1 | 16 | | ConfigurePermissions("read:workflow-instances"); |
| | 1 | 17 | | } |
| | | 18 | | |
| | | 19 | | public override async Task HandleAsync(CancellationToken cancellationToken) |
| | | 20 | | { |
| | 0 | 21 | | var workflowInstanceId = Route<string>("id"); |
| | | 22 | | |
| | 0 | 23 | | if (string.IsNullOrWhiteSpace(workflowInstanceId)) |
| | | 24 | | { |
| | 0 | 25 | | AddError("The workflow instance ID is required."); |
| | 0 | 26 | | await Send.ErrorsAsync(StatusCodes.Status400BadRequest, cancellationToken); |
| | 0 | 27 | | return; |
| | | 28 | | } |
| | | 29 | | |
| | 0 | 30 | | var variables = await workflowInstanceVariableManager.GetVariablesAsync(workflowInstanceId, ["LargeData"],cancel |
| | 0 | 31 | | var variableModels = variables.Select(x => new ResolvedVariableModel(x.Variable.Id, x.Variable.Name, x.Value)).T |
| | 0 | 32 | | var response = new ListResponse<ResolvedVariableModel>(variableModels); |
| | 0 | 33 | | await Send.OkAsync(response, cancellationToken); |
| | 0 | 34 | | } |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | internal record ResolvedVariableModel(string Id, string Name, object? Value); |