Update bulk publish APIs and clients

This commit is contained in:
Sipke Schoorstra 2023-07-03 22:55:21 +02:00
parent 924f74e84b
commit 9971f94fb8
9 changed files with 49 additions and 11 deletions

View file

@ -68,7 +68,15 @@ public interface IWorkflowDefinitionsApi
/// <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);
Task<BulkDeleteWorkflowDefinitionsResponse> BulkDeleteAsync(BulkDeleteWorkflowDefinitionsRequest request, CancellationToken cancellationToken = default);
/// <summary>
/// Publishes many workflow definitions.
/// </summary>
/// <param name="request">The request containing the IDs of the workflow definitions to publish.</param>
/// <param name="cancellationToken">The cancellation token.</param>
[Post("/bulk-actions/publish/workflow-definitions/by-definition-ids")]
Task<BulkPublishWorkflowDefinitionsResponse> BulkPublishAsync(BulkPublishWorkflowDefinitionsRequest request, CancellationToken cancellationToken = default);
/// <summary>
/// Exports a workflow definition.

View file

@ -3,13 +3,13 @@ namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
/// <summary>
/// A request to delete many workflow definitions.
/// </summary>
public class DeleteManyWorkflowDefinitionsRequest
public class BulkDeleteWorkflowDefinitionsRequest
{
/// <summary>
/// Initializes a new instance of the <see cref="DeleteManyWorkflowDefinitionsRequest"/> class.
/// Initializes a new instance of the <see cref="BulkDeleteWorkflowDefinitionsRequest"/> class.
/// </summary>
/// <param name="definitionIds">The IDs of the workflow definitions to delete.</param>
public DeleteManyWorkflowDefinitionsRequest(IEnumerable<string> definitionIds)
public BulkDeleteWorkflowDefinitionsRequest(IEnumerable<string> definitionIds)
{
DefinitionIds = definitionIds.ToArray();
}

View file

@ -4,4 +4,4 @@ namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
/// 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);
public record BulkDeleteWorkflowDefinitionsResponse(long Deleted);

View file

@ -0,0 +1,21 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
/// <summary>
/// A request to publish many workflow definitions.
/// </summary>
public class BulkPublishWorkflowDefinitionsRequest
{
/// <summary>
/// Initializes a new instance of the <see cref="BulkDeleteWorkflowDefinitionsRequest"/> class.
/// </summary>
/// <param name="definitionIds">The IDs of the workflow definitions to delete.</param>
public BulkPublishWorkflowDefinitionsRequest(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,9 @@
namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Models;
/// <summary>
/// The response from a request to publish workflow definitions.
/// </summary>
public record BulkPublishWorkflowDefinitionsResponse(
ICollection<string> Published,
ICollection<string> AlreadyPublished,
ICollection<string> NotFound);

View file

@ -162,7 +162,7 @@ export class WorkflowDefinitionsApi {
async publishMany(request: PublishManyWorkflowDefinitionRequest): Promise<PublishManyWorkflowDefinitionResponse> {
const httpClient = await this.getHttpClient();
const response = await httpClient.post<PublishManyWorkflowDefinitionResponse>(`/bulk-actions/publish/workflow-definitions/by-definition-id`, {
const response = await httpClient.post<PublishManyWorkflowDefinitionResponse>(`/bulk-actions/publish/workflow-definitions/by-definition-ids`, {
definitionIds: request.definitionIds,
});
return response.data;
@ -170,7 +170,7 @@ export class WorkflowDefinitionsApi {
async unpublishMany(request: UnpublishManyWorkflowDefinitionRequest): Promise<UnpublishManyWorkflowDefinitionResponse> {
const httpClient = await this.getHttpClient();
const response = await httpClient.post<UnpublishManyWorkflowDefinitionResponse>(`/bulk-actions/retract/workflow-definitions/by-definition-id`, {
const response = await httpClient.post<UnpublishManyWorkflowDefinitionResponse>(`/bulk-actions/retract/workflow-definitions/by-definition-ids`, {
definitionIds: request.definitionIds,
});
return response.data;

View file

@ -20,7 +20,7 @@ internal class BulkPublish : ElsaEndpoint<Request, Response>
public override void Configure()
{
Post("/bulk-actions/publish/workflow-definitions/by-definition-id");
Post("/bulk-actions/publish/workflow-definitions/by-definition-ids");
ConfigurePermissions("publish:workflow-definitions");
}

View file

@ -1,11 +1,11 @@
namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.BulkPublish;
public class Request
internal class Request
{
public ICollection<string> DefinitionIds { get; set; } = default!;
}
public class Response
internal class Response
{
public Response(ICollection<string> published, ICollection<string> alreadyPublished, ICollection<string> notFound)
{

View file

@ -20,7 +20,7 @@ internal class BulkRetract : ElsaEndpoint<Request, Response>
public override void Configure()
{
Post("/bulk-actions/retract/workflow-definitions/by-definition-id");
Post("/bulk-actions/retract/workflow-definitions/by-definition-ids");
ConfigurePermissions("retract:workflow-definitions");
}