Add bulk delete client API

This commit is contained in:
Sipke Schoorstra 2023-06-30 11:23:28 +02:00
parent 299f9248f0
commit 925946d404
3 changed files with 36 additions and 5 deletions

View file

@ -17,7 +17,6 @@ public interface IWorkflowDefinitionsApi
/// <param name="request">The request containing options for listing workflow definitions.</param>
/// <param name="versionOptions">The version options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The response containing the workflow definitions.</returns>
[Get("/workflow-definitions?versionOptions={versionOptions}")]
Task<ListWorkflowDefinitionsResponse> ListAsync([Query]ListWorkflowDefinitionsRequest request, [Query]VersionOptions? versionOptions = default, CancellationToken cancellationToken = default);
@ -28,7 +27,6 @@ public interface IWorkflowDefinitionsApi
/// <param name="versionOptions">The version options.</param>
/// <param name="includeCompositeRoot">Whether to include the root activity of composite activities.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The workflow definition.</returns>
[Get("/workflow-definitions/{definitionId}?versionOptions={versionOptions}&includeCompositeRoot={includeCompositeRoot}")]
Task<WorkflowDefinition?> GetAsync(string definitionId, VersionOptions? versionOptions = default, bool includeCompositeRoot = false, CancellationToken cancellationToken = default);
@ -44,7 +42,6 @@ public interface IWorkflowDefinitionsApi
/// </summary>
/// <param name="name">The name to check.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A response containing a value indicating whether the name is unique.</returns>
[Get("/workflow-definitions/validation/is-name-unique?name={name}")]
Task<GetIsNameUniqueResponse> GetIsNameUniqueAsync(string name, CancellationToken cancellationToken = default);
@ -53,7 +50,6 @@ public interface IWorkflowDefinitionsApi
/// </summary>
/// <param name="request">The request containing the workflow definition to save.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The workflow definition.</returns>
[Post("/workflow-definitions")]
Task<WorkflowDefinition> SaveAsync(SaveWorkflowDefinitionRequest request, CancellationToken cancellationToken = default);
@ -62,7 +58,14 @@ public interface IWorkflowDefinitionsApi
/// </summary>
/// <param name="definitionId">The ID of the workflow definition to delete.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The response.</returns>
[Delete("/workflow-definitions/{definitionId}")]
Task<DeleteWorkflowDefinitionResponse> DeleteAsync(string definitionId, CancellationToken cancellationToken = default);
/// <summary>
/// Deletes many workflow definitions.
/// </summary>
/// <param name="request">The request containing the IDs of the workflow definitions to delete.</param>
/// <param name="cancellationToken">The cancellation token.</param>
[Post("/bulk-actions/delete/workflow-definitions/by-definition-id")]
Task<DeleteManyWorkflowDefinitionsResponse> DeleteManyAsync(DeleteManyWorkflowDefinitionsRequest request, CancellationToken cancellationToken = default);
}

View file

@ -0,0 +1,21 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
/// <summary>
/// A request to delete many workflow definitions.
/// </summary>
public class DeleteManyWorkflowDefinitionsRequest
{
/// <summary>
/// Initializes a new instance of the <see cref="DeleteManyWorkflowDefinitionsRequest"/> class.
/// </summary>
/// <param name="definitionIds">The IDs of the workflow definitions to delete.</param>
public DeleteManyWorkflowDefinitionsRequest(IEnumerable<string> definitionIds)
{
DefinitionIds = definitionIds.ToArray();
}
/// <summary>
/// Gets or sets the IDs of the workflow definitions to delete.
/// </summary>
public string[] DefinitionIds { get; set; }
}

View file

@ -0,0 +1,7 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
/// <summary>
/// The response from a request to delete workflow definitions.
/// </summary>
/// <param name="Deleted">The number of workflow definitions deleted.</param>
public record DeleteManyWorkflowDefinitionsResponse(long Deleted);