| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Abstractions; |
| | | 3 | | using Elsa.Workflows.Models; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Api.Endpoints.ActivityDescriptors.Get; |
| | | 7 | | |
| | | 8 | | [PublicAPI] |
| | | 9 | | internal class Get : ElsaEndpoint<Request, ActivityDescriptor> |
| | | 10 | | { |
| | | 11 | | private readonly IActivityRegistryLookupService _registryLookup; |
| | | 12 | | |
| | | 13 | | /// <inheritdoc /> |
| | 3 | 14 | | public Get(IActivityRegistryLookupService registryLookup) |
| | | 15 | | { |
| | 3 | 16 | | _registryLookup = registryLookup; |
| | 3 | 17 | | } |
| | | 18 | | |
| | | 19 | | /// <inheritdoc /> |
| | | 20 | | public override void Configure() |
| | | 21 | | { |
| | 3 | 22 | | Get("/descriptors/activities/{typeName}"); |
| | 3 | 23 | | RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.DescriptorsActivities, CoreVerbs.View); |
| | 3 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <inheritdoc /> |
| | | 27 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 28 | | { |
| | 0 | 29 | | var descriptor = request.Version == null ? await _registryLookup.FindAsync(request.TypeName) : await _registryLo |
| | | 30 | | |
| | 0 | 31 | | if (descriptor == null) |
| | 0 | 32 | | await Send.NotFoundAsync(cancellationToken); |
| | | 33 | | else |
| | 0 | 34 | | await Send.OkAsync(descriptor, cancellationToken); |
| | 0 | 35 | | } |
| | | 36 | | } |