| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Alterations.Core.Contracts; |
| | | 3 | | using Elsa.Alterations.Core.Models; |
| | | 4 | | using Elsa.Common; |
| | | 5 | | using Elsa.Workflows; |
| | | 6 | | using JetBrains.Annotations; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Alterations.Endpoints.Alterations.Submit; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Submits an alteration plan to be executed targeting workflow instances by a filter. |
| | | 12 | | /// </summary> |
| | | 13 | | [PublicAPI] |
| | | 14 | | public class Submit : ElsaEndpoint<AlterationPlanParams, Response> |
| | | 15 | | { |
| | | 16 | | private readonly IAlterationPlanScheduler _alterationPlanScheduler; |
| | | 17 | | private readonly IIdentityGenerator _identityGenerator; |
| | | 18 | | private readonly ISystemClock _systemClock; |
| | | 19 | | |
| | | 20 | | /// <inheritdoc /> |
| | 1 | 21 | | public Submit(IAlterationPlanScheduler alterationPlanScheduler, IIdentityGenerator identityGenerator, ISystemClock s |
| | | 22 | | { |
| | 1 | 23 | | _alterationPlanScheduler = alterationPlanScheduler; |
| | 1 | 24 | | _identityGenerator = identityGenerator; |
| | 1 | 25 | | _systemClock = systemClock; |
| | 1 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <inheritdoc /> |
| | | 29 | | public override void Configure() |
| | | 30 | | { |
| | 1 | 31 | | Post("/alterations/submit"); |
| | 1 | 32 | | ConfigurePermissions("run:alterations"); |
| | 1 | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <inheritdoc /> |
| | | 36 | | public override async Task HandleAsync(AlterationPlanParams planParams, CancellationToken cancellationToken) |
| | | 37 | | { |
| | | 38 | | // Submit the plan. |
| | 0 | 39 | | var planId = await _alterationPlanScheduler.SubmitAsync(planParams, cancellationToken); |
| | | 40 | | |
| | | 41 | | // Write response. |
| | 0 | 42 | | var response = new Response(planId); |
| | 0 | 43 | | await Send.OkAsync(response, cancellationToken); |
| | 0 | 44 | | } |
| | | 45 | | } |