| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Features.Contracts; |
| | | 3 | | using Elsa.Features.Models; |
| | | 4 | | using Elsa.Models; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.Endpoints.Features.List; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Returns a list of installed features. |
| | | 11 | | /// </summary> |
| | | 12 | | [PublicAPI] |
| | | 13 | | internal class List : ElsaEndpointWithoutRequest<ListResponse<FeatureDescriptor>> |
| | | 14 | | { |
| | | 15 | | private readonly IInstalledFeatureRegistry _installedFeatureRegistry; |
| | | 16 | | |
| | | 17 | | /// <inheritdoc /> |
| | 1 | 18 | | public List(IInstalledFeatureRegistry installedFeatureRegistry) |
| | | 19 | | { |
| | 1 | 20 | | _installedFeatureRegistry = installedFeatureRegistry; |
| | 1 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public override void Configure() |
| | | 25 | | { |
| | 1 | 26 | | Get("/features/installed"); |
| | 1 | 27 | | ConfigurePermissions("read:*", "read:installed-features"); |
| | 1 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <inheritdoc /> |
| | | 31 | | public override Task<ListResponse<FeatureDescriptor>> ExecuteAsync(CancellationToken cancellationToken) |
| | | 32 | | { |
| | 0 | 33 | | var descriptors = _installedFeatureRegistry.List().ToList(); |
| | 0 | 34 | | var response = new ListResponse<FeatureDescriptor>(descriptors); |
| | | 35 | | |
| | 0 | 36 | | return Task.FromResult(response); |
| | | 37 | | } |
| | | 38 | | } |