Add API client for variable types and storage drivers
This commit is contained in:
parent
3e77eac149
commit
143fbefd55
|
|
@ -6,6 +6,8 @@ using Elsa.Api.Client.Converters;
|
|||
using Elsa.Api.Client.Options;
|
||||
using Elsa.Api.Client.Resources.ActivityDescriptors.Contracts;
|
||||
using Elsa.Api.Client.Resources.Identity.Contracts;
|
||||
using Elsa.Api.Client.Resources.StorageDrivers.Contracts;
|
||||
using Elsa.Api.Client.Resources.VariableTypes.Contracts;
|
||||
using Elsa.Api.Client.Resources.WorkflowDefinitions.Contracts;
|
||||
using Elsa.Api.Client.Services;
|
||||
using JetBrains.Annotations;
|
||||
|
|
@ -32,6 +34,8 @@ public static class DependencyInjectionExtensions
|
|||
|
||||
services.AddApi<IWorkflowDefinitionsApi>(CreateRefitSettings);
|
||||
services.AddApi<IActivityDescriptorsApi>(CreateRefitSettings);
|
||||
services.AddApi<IStorageDriversApi>(CreateRefitSettings);
|
||||
services.AddApi<IVariableTypesApi>(CreateRefitSettings);
|
||||
services.AddApi<ILoginApi>(CreateRefitSettings);
|
||||
return services;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
using Elsa.Api.Client.Resources.StorageDrivers.Models;
|
||||
using Refit;
|
||||
|
||||
namespace Elsa.Api.Client.Resources.StorageDrivers.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a client for the storage drivers API.
|
||||
/// </summary>
|
||||
public interface IStorageDriversApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists storage drivers.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The response containing the storage drivers.</returns>
|
||||
[Get("/descriptors/storage-drivers")]
|
||||
Task<ListStorageDriversResponse> ListAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
namespace Elsa.Api.Client.Resources.StorageDrivers.Models;
|
||||
|
||||
/// <summary>
|
||||
/// The response containing the storage drivers.
|
||||
/// </summary>
|
||||
/// <param name="Items">The storage drivers.</param>
|
||||
public record ListStorageDriversResponse(ICollection<StorageDriverDescriptor> Items);
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
namespace Elsa.Api.Client.Resources.StorageDrivers.Models;
|
||||
|
||||
public record StorageDriverDescriptor(string TypeName, string DisplayName);
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using Elsa.Api.Client.Resources.VariableTypes.Models;
|
||||
using Refit;
|
||||
|
||||
namespace Elsa.Api.Client.Resources.VariableTypes.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a client for the variable types API.
|
||||
/// </summary>
|
||||
public interface IVariableTypesApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists variable types.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>The response containing the variable types.</returns>
|
||||
[Get("/descriptors/variables")]
|
||||
Task<ListVariableTypesResponse> ListAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
namespace Elsa.Api.Client.Resources.VariableTypes.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A response containing a list of variable types.
|
||||
/// </summary>
|
||||
/// <param name="Items">A list of variable types.</param>
|
||||
public record ListVariableTypesResponse(ICollection<VariableTypeDescriptor> Items);
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
namespace Elsa.Api.Client.Resources.VariableTypes.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a variable type.
|
||||
/// </summary>
|
||||
/// <param name="TypeName">The .NET type name of the variable type.</param>
|
||||
/// <param name="DisplayName">The display name of the variable type.</param>
|
||||
/// <param name="Category">The category of the variable type.</param>
|
||||
/// <param name="Description">The description of the variable type.</param>
|
||||
public record VariableTypeDescriptor(string TypeName, string DisplayName, string Category, string? Description);
|
||||
|
|
@ -34,4 +34,9 @@ public class Variable
|
|||
/// The storage driver type to use for persistence.
|
||||
/// </summary>
|
||||
public string? StorageDriverTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type name of the variable, including the array indicator.
|
||||
/// </summary>
|
||||
public string GetTypeDisplayName() => IsArray ? $"{TypeName}[]" : TypeName;
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ internal class List : ElsaEndpointWithoutRequest<Response>
|
|||
return Task.FromResult(response);
|
||||
}
|
||||
|
||||
private VariableDescriptorModel Map(VariableDescriptor descriptor)
|
||||
private VariableTypeDescriptor Map(VariableDescriptor descriptor)
|
||||
{
|
||||
var type = descriptor.Type;
|
||||
var hasAlias = _wellKnownTypeRegistry.TryGetAlias(type, out var alias);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
namespace Elsa.Workflows.Api.Endpoints.VariableTypes.List;
|
||||
|
||||
public class Response
|
||||
internal class Response
|
||||
{
|
||||
public Response(ICollection<VariableDescriptorModel> items)
|
||||
public Response(ICollection<VariableTypeDescriptor> items)
|
||||
{
|
||||
Items = items;
|
||||
}
|
||||
|
||||
public ICollection<VariableDescriptorModel> Items { get; set; }
|
||||
public ICollection<VariableTypeDescriptor> Items { get; set; }
|
||||
}
|
||||
|
||||
public record VariableDescriptorModel(string TypeName, string DisplayName, string Category, string? Description);
|
||||
internal record VariableTypeDescriptor(string TypeName, string DisplayName, string Category, string? Description);
|
||||
Loading…
Reference in a new issue