| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Features.Contracts; |
| | | 3 | | using Elsa.Features.Models; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Api.Endpoints.Features.Get; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Returns the specified installed feature. |
| | | 10 | | /// </summary> |
| | | 11 | | [PublicAPI] |
| | | 12 | | internal class Get : ElsaEndpointWithoutRequest<FeatureDescriptor> |
| | | 13 | | { |
| | | 14 | | private readonly IInstalledFeatureRegistry _installedFeatureRegistry; |
| | | 15 | | |
| | | 16 | | /// <inheritdoc /> |
| | 1 | 17 | | public Get(IInstalledFeatureRegistry installedFeatureRegistry) |
| | | 18 | | { |
| | 1 | 19 | | _installedFeatureRegistry = installedFeatureRegistry; |
| | 1 | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | public override void Configure() |
| | | 24 | | { |
| | 1 | 25 | | Get("/features/installed/{fullName}"); |
| | 1 | 26 | | ConfigurePermissions("read:*", "read:installed-features"); |
| | 1 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | public override async Task HandleAsync( CancellationToken cancellationToken) |
| | | 31 | | { |
| | 0 | 32 | | var fullName = Route<string>("fullName")!; |
| | 0 | 33 | | var descriptor = _installedFeatureRegistry.Find(fullName); |
| | | 34 | | |
| | 0 | 35 | | if (descriptor == null) |
| | | 36 | | { |
| | 0 | 37 | | await Send.NotFoundAsync(cancellationToken); |
| | 0 | 38 | | return; |
| | | 39 | | } |
| | | 40 | | |
| | 0 | 41 | | await Send.OkAsync(descriptor, cancellationToken); |
| | 0 | 42 | | } |
| | | 43 | | } |