Delete soft-deletes the entry
(ctx context.Context, orgID, workflowID string)
| 474 | |
| 475 | // Delete soft-deletes the entry |
| 476 | func (uc *WorkflowUseCase) Delete(ctx context.Context, orgID, workflowID string) error { |
| 477 | ctx, span := otelx.Start(ctx, workflowTracer, "WorkflowUseCase.Delete") |
| 478 | defer span.End() |
| 479 | |
| 480 | orgUUID, err := uuid.Parse(orgID) |
| 481 | if err != nil { |
| 482 | return NewErrInvalidUUID(err) |
| 483 | } |
| 484 | |
| 485 | workflowUUID, err := uuid.Parse(workflowID) |
| 486 | if err != nil { |
| 487 | return NewErrInvalidUUID(err) |
| 488 | } |
| 489 | |
| 490 | // Check that the workflow to delete belongs to the provided organization |
| 491 | wf, err := uc.wfRepo.GetOrgScoped(ctx, orgUUID, workflowUUID) |
| 492 | if err != nil { |
| 493 | return fmt.Errorf("failed to get workflow: %w", err) |
| 494 | } else if wf == nil { |
| 495 | return NewErrNotFound("organization") |
| 496 | } |
| 497 | |
| 498 | if err := uc.wfRepo.SoftDelete(ctx, workflowUUID); err != nil { |
| 499 | return fmt.Errorf("failed to soft delete workflow: %w", err) |
| 500 | } |
| 501 | |
| 502 | uc.auditorUC.Dispatch(ctx, &events.WorkflowDeleted{ |
| 503 | WorkflowBase: &events.WorkflowBase{ |
| 504 | WorkflowID: &workflowUUID, |
| 505 | WorkflowName: wf.Name, |
| 506 | ProjectName: wf.Project, |
| 507 | }, |
| 508 | }, &orgUUID) |
| 509 | |
| 510 | return nil |
| 511 | } |
nothing calls this directly
no test coverage detected