| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Abstractions; |
| | | 3 | | using Elsa.Models; |
| | | 4 | | using Elsa.Workflows.CommitStates; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Api.Endpoints.CommitStrategies.Activities.List; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents an API endpoint that provides a list of registered workflow commit strategies. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <remarks> |
| | | 12 | | /// This class is an implementation of an endpoint that retrieves a collection of workflow commit strategy registrations |
| | | 13 | | /// from a provided registry and returns them in a unified response. |
| | | 14 | | /// </remarks> |
| | 3 | 15 | | internal class List(ICommitStrategyRegistry registry) : ElsaEndpointWithoutRequest<ListResponse<CommitStrategyDescriptor |
| | | 16 | | { |
| | | 17 | | public override void Configure() |
| | | 18 | | { |
| | 3 | 19 | | Get("/descriptors/commit-strategies/activities"); |
| | 3 | 20 | | RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.DescriptorsCommitStrategies, CoreVerbs.View |
| | 3 | 21 | | } |
| | | 22 | | |
| | | 23 | | public override Task<ListResponse<CommitStrategyDescriptor>> ExecuteAsync(CancellationToken cancellationToken) |
| | | 24 | | { |
| | 0 | 25 | | var registrations = registry.ListActivityStrategyRegistrations().ToList(); |
| | 0 | 26 | | var descriptors = CommitStrategyDescriptor.FromStrategyMetadata(registrations.Select(x => x.Metadata)).ToList(); |
| | 0 | 27 | | var response =new ListResponse<CommitStrategyDescriptor>(descriptors); |
| | 0 | 28 | | return Task.FromResult(response); |
| | | 29 | | } |
| | | 30 | | } |