| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Abstractions; |
| | | 3 | | using Elsa.Workflows.Runtime; |
| | | 4 | | using FastEndpoints; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.Endpoints.RuntimeAdmin.Pause; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// <c>POST /admin/workflow-runtime/pause</c> — places the runtime into <see cref="QuiescenceReason.AdministrativePause" |
| | | 11 | | /// Idempotent: subsequent calls return the current state without producing additional audit events (SC-007). |
| | | 12 | | /// </summary> |
| | | 13 | | [PublicAPI] |
| | 4 | 14 | | internal sealed class PauseEndpoint(IWorkflowRuntimeAdminService admin) : ElsaEndpoint<PauseRequest, StatusResponse> |
| | | 15 | | { |
| | | 16 | | public override void Configure() |
| | | 17 | | { |
| | 4 | 18 | | Post("/admin/workflow-runtime/pause"); |
| | 4 | 19 | | RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.Runtime, "control"); |
| | 4 | 20 | | } |
| | | 21 | | |
| | | 22 | | public override async Task HandleAsync(PauseRequest req, CancellationToken ct) |
| | | 23 | | { |
| | 0 | 24 | | await admin.PauseAsync(req.Reason, HttpContext.User.Identity?.Name, ct); |
| | 0 | 25 | | await Send.OkAsync(StatusResponseFactory.Build(admin.GetStatus()), ct); |
| | 0 | 26 | | } |
| | | 27 | | } |