| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Workflows.Runtime; |
| | | 3 | | using Elsa.Workflows.Runtime.Entities; |
| | | 4 | | using Elsa.Workflows.Runtime.Filters; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.Endpoints.ActivityExecutions.Get; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Gets an individual execution for a given activity. |
| | | 11 | | /// </summary> |
| | | 12 | | [PublicAPI] |
| | 1 | 13 | | internal class Endpoint(IActivityExecutionStore store) : ElsaEndpointWithoutRequest<ActivityExecutionRecord> |
| | | 14 | | { |
| | | 15 | | /// <inheritdoc /> |
| | | 16 | | public override void Configure() |
| | | 17 | | { |
| | 1 | 18 | | Get("/activity-executions/{id}"); |
| | 1 | 19 | | ConfigurePermissions("read:activity-execution"); |
| | 1 | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | public override async Task HandleAsync(CancellationToken cancellationToken) |
| | | 24 | | { |
| | 0 | 25 | | var id = Route<string>("id"); |
| | 0 | 26 | | var filter = new ActivityExecutionRecordFilter |
| | 0 | 27 | | { |
| | 0 | 28 | | Id = id |
| | 0 | 29 | | }; |
| | | 30 | | |
| | 0 | 31 | | var record = await store.FindAsync(filter, cancellationToken); |
| | | 32 | | |
| | 0 | 33 | | if (record == null) |
| | | 34 | | { |
| | 0 | 35 | | await Send.NotFoundAsync(cancellationToken); |
| | 0 | 36 | | return; |
| | | 37 | | } |
| | | 38 | | |
| | 0 | 39 | | await Send.OkAsync(record, cancellationToken); |
| | 0 | 40 | | } |
| | | 41 | | } |