Rename environment model
This commit is contained in:
parent
9f9f35edb4
commit
ad44becbda
|
|
@ -12,5 +12,12 @@ public interface IEnvironmentsManager
|
|||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>All environments.</returns>
|
||||
Task<IEnumerable<WorkflowsEnvironment>> ListEnvironmentsAsync(CancellationToken cancellationToken = default);
|
||||
ValueTask<IEnumerable<ServerEnvironment>> ListEnvironmentsAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the name of the default environment.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The name of the default environment.</returns>
|
||||
ValueTask<string?> GetDefaultEnvironmentNameAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
@ -12,5 +12,5 @@ public interface IEnvironmentsProvider
|
|||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A list of workflow environments.</returns>
|
||||
ValueTask<IEnumerable<WorkflowsEnvironment>> GetEnvironmentsAsync(CancellationToken cancellationToken = default);
|
||||
ValueTask<IEnumerable<ServerEnvironment>> GetEnvironmentsAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\Elsa.Api.Common\Elsa.Api.Common.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Identity\Elsa.Identity.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Elsa.Abstractions;
|
||||
using Elsa.Environments.Contracts;
|
||||
using Elsa.Environments.Models;
|
||||
using Elsa.Identity;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Environments.Endpoints.Environments.List;
|
||||
|
|
@ -19,14 +20,16 @@ internal class Endpoint : ElsaEndpointWithoutRequest<Response>
|
|||
{
|
||||
Get("/environments");
|
||||
ConfigurePermissions("read:environments");
|
||||
Policies(IdentityPolicyNames.SecurityRoot);
|
||||
}
|
||||
|
||||
public override async Task<Response> ExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var environments = await _environmentsManager.ListEnvironmentsAsync(cancellationToken);
|
||||
return new(environments.ToList());
|
||||
var defaultEnvironmentName = await _environmentsManager.GetDefaultEnvironmentNameAsync(cancellationToken);
|
||||
return new(environments.ToList(), defaultEnvironmentName);
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
internal record Response(ICollection<WorkflowsEnvironment> Environments);
|
||||
internal record Response(ICollection<ServerEnvironment> Environments, string? DefaultEnvironmentName = default);
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/// <summary>
|
||||
/// Represents the environment in which the workflow engine is running.
|
||||
/// </summary>
|
||||
public class WorkflowsEnvironment
|
||||
public class ServerEnvironment
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the environment.
|
||||
|
|
@ -1,14 +1,21 @@
|
|||
using Elsa.Environments.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Environments.Options;
|
||||
|
||||
/// <summary>
|
||||
/// EnvironmentsOptions for providing environments.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public class EnvironmentsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a list of environments.
|
||||
/// </summary>
|
||||
public ICollection<WorkflowsEnvironment> Environments { get; set; } = new List<WorkflowsEnvironment>();
|
||||
public ICollection<ServerEnvironment> Environments { get; set; } = new List<ServerEnvironment>();
|
||||
|
||||
/// <summary>
|
||||
/// The name of the default environment.
|
||||
/// </summary>
|
||||
public string? DefaultEnvironmentName { get; set; }
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ public class ConfigurationEnvironmentsProvider : IEnvironmentsProvider
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask<IEnumerable<WorkflowsEnvironment>> GetEnvironmentsAsync(CancellationToken cancellationToken = default)
|
||||
public ValueTask<IEnumerable<ServerEnvironment>> GetEnvironmentsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return new (_options.Value.Environments);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using Elsa.Environments.Contracts;
|
||||
using Elsa.Environments.Models;
|
||||
using Elsa.Environments.Options;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Elsa.Environments.Services;
|
||||
|
||||
|
|
@ -7,19 +9,21 @@ namespace Elsa.Environments.Services;
|
|||
public class DefaultEnvironmentsManager : IEnvironmentsManager
|
||||
{
|
||||
private readonly IEnumerable<IEnvironmentsProvider> _providers;
|
||||
private readonly IOptions<EnvironmentsOptions> _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="DefaultEnvironmentsManager"/>.
|
||||
/// </summary>
|
||||
public DefaultEnvironmentsManager(IEnumerable<IEnvironmentsProvider> providers)
|
||||
public DefaultEnvironmentsManager(IEnumerable<IEnvironmentsProvider> providers, IOptions<EnvironmentsOptions> options)
|
||||
{
|
||||
_providers = providers;
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<WorkflowsEnvironment>> ListEnvironmentsAsync(CancellationToken cancellationToken = default)
|
||||
public async ValueTask<IEnumerable<ServerEnvironment>> ListEnvironmentsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var allEnvironments = new List<WorkflowsEnvironment>();
|
||||
var allEnvironments = new List<ServerEnvironment>();
|
||||
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
|
|
@ -29,4 +33,10 @@ public class DefaultEnvironmentsManager : IEnvironmentsManager
|
|||
|
||||
return allEnvironments;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ValueTask<string?> GetDefaultEnvironmentNameAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return new(_options.Value.DefaultEnvironmentName);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
using Elsa.Extensions;
|
||||
using Elsa.Workflows.Core.Activities;
|
||||
using Elsa.Workflows.Core.Models;
|
||||
using Elsa.Workflows.Management.Activities.SetOutput;
|
||||
|
||||
public class AskDetails : Composite<Person>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue