< Summary

Information
Class: Elsa.Shells.Api.Endpoints.Shells.ReloadAll.ReloadAll
Assembly: Elsa.Shells.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Shells.Api/Endpoints/Shells/ReloadAll/Endpoint.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 53
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
HandleAsync()100%11100%
SendResponseAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Shells.Api/Endpoints/Shells/ReloadAll/Endpoint.cs

#LineLine coverage
 1using CShells.Management;
 2using Elsa.Abstractions;
 3using Elsa.Shells.Api.Endpoints.Shells;
 4using Elsa.Workflows;
 5using JetBrains.Annotations;
 6using Microsoft.AspNetCore.Http;
 7using Microsoft.Extensions.Logging;
 8
 9namespace Elsa.Shells.Api.Endpoints.Shells.ReloadAll;
 10
 11[PublicAPI]
 612internal class ReloadAll(IShellManager shellManager, IApiSerializer apiSerializer, ILogger<ReloadAll> logger) : ElsaEndp
 13{
 14    public override void Configure()
 15    {
 416        Post("/shells/reload");
 417        ConfigurePermissions("actions:shells:reload");
 418    }
 19
 20    public override async Task HandleAsync(CancellationToken cancellationToken)
 21    {
 22        try
 23        {
 224            await shellManager.ReloadAllShellsAsync(cancellationToken);
 125        }
 126        catch (InvalidOperationException ex)
 27        {
 128            logger.LogError(ex, "Failed to reload all shells");
 129            var failedResponse = new ShellReloadResponse
 130            {
 131                Status = ShellReloadStatus.Failed,
 132                Timestamp = DateTimeOffset.UtcNow,
 133                Message = ex.Message
 134            };
 135            await SendResponseAsync(failedResponse, StatusCodes.Status503ServiceUnavailable, cancellationToken);
 136            return;
 37        }
 38
 139        var response = new ShellReloadResponse
 140        {
 141            Status = ShellReloadStatus.Completed,
 142            Timestamp = DateTimeOffset.UtcNow
 143        };
 144        await SendResponseAsync(response, StatusCodes.Status200OK, cancellationToken);
 245    }
 46
 47    private async Task SendResponseAsync(ShellReloadResponse response, int statusCode, CancellationToken cancellationTok
 48    {
 249        var serializerOptions = apiSerializer.GetOptions();
 250        HttpContext.Response.StatusCode = statusCode;
 251        await HttpContext.Response.WriteAsJsonAsync(response, serializerOptions, cancellationToken);
 252    }
 53}