< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowInstances.Variables.List.List
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/List/Endpoint.cs
Line coverage
28%
Covered lines: 4
Uncovered lines: 10
Coverable lines: 14
Total lines: 37
Line coverage: 28.5%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
HandleAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/List/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Models;
 3using Elsa.Workflows.Management;
 4using JetBrains.Annotations;
 5using Microsoft.AspNetCore.Http;
 6using Open.Linq.AsyncExtensions;
 7
 8namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Variables.List;
 9
 10[UsedImplicitly]
 111internal class List(IWorkflowInstanceVariableManager workflowInstanceVariableManager) : ElsaEndpointWithoutRequest<ListR
 12{
 13    public override void Configure()
 14    {
 115        Get("/workflow-instances/{id}/variables");
 116        ConfigurePermissions("read:workflow-instances");
 117    }
 18
 19    public override async Task HandleAsync(CancellationToken cancellationToken)
 20    {
 021        var workflowInstanceId = Route<string>("id");
 22
 023        if (string.IsNullOrWhiteSpace(workflowInstanceId))
 24        {
 025            AddError("The workflow instance ID is required.");
 026            await Send.ErrorsAsync(StatusCodes.Status400BadRequest, cancellationToken);
 027            return;
 28        }
 29
 030        var variables = await workflowInstanceVariableManager.GetVariablesAsync(workflowInstanceId, ["LargeData"],cancel
 031        var variableModels = variables.Select(x => new ResolvedVariableModel(x.Variable.Id, x.Variable.Name, x.Value)).T
 032        var response = new ListResponse<ResolvedVariableModel>(variableModels);
 033        await Send.OkAsync(response, cancellationToken);
 034    }
 35}
 36
 37internal record ResolvedVariableModel(string Id, string Name, object? Value);