| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Workflows.Management; |
| | | 3 | | using Elsa.Workflows.Runtime; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Execute; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// An API endpoint that executes a given workflow definition through GET method. |
| | | 10 | | /// </summary> |
| | | 11 | | [PublicAPI] |
| | 3 | 12 | | internal class GetEndpoint( |
| | 3 | 13 | | IWorkflowDefinitionService workflowDefinitionService, |
| | 3 | 14 | | IWorkflowRuntime workflowRuntime, |
| | 3 | 15 | | IWorkflowStarter workflowStarter, |
| | 3 | 16 | | IApiSerializer apiSerializer) |
| | | 17 | | : ElsaEndpoint<GetRequest> |
| | | 18 | | { |
| | | 19 | | /// <inheritdoc /> |
| | | 20 | | public override void Configure() |
| | | 21 | | { |
| | 1 | 22 | | Routes("/workflow-definitions/{definitionId}/execute"); |
| | 1 | 23 | | ConfigurePermissions("exec:workflow-definitions"); |
| | 1 | 24 | | Verbs(FastEndpoints.Http.GET); |
| | 1 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <inheritdoc /> |
| | | 28 | | public override async Task HandleAsync(GetRequest request, CancellationToken cancellationToken) |
| | | 29 | | { |
| | 2 | 30 | | await WorkflowExecutionHelper.ExecuteWorkflowAsync( |
| | 2 | 31 | | request, |
| | 2 | 32 | | workflowDefinitionService, |
| | 2 | 33 | | workflowRuntime, |
| | 2 | 34 | | workflowStarter, |
| | 2 | 35 | | apiSerializer, |
| | 2 | 36 | | HttpContext, |
| | 2 | 37 | | cancellationToken); |
| | 2 | 38 | | } |
| | | 39 | | } |