Suspend suspends a workflow
(c *gin.Context)
| 484 | |
| 485 | // Suspend suspends a workflow |
| 486 | func (h *WorkflowHandler) Suspend(c *gin.Context) { |
| 487 | ctx := c.Request.Context() |
| 488 | id := c.Param("id") |
| 489 | |
| 490 | var workflow WorkflowRecord |
| 491 | if err := (*h.store).Get(ctx, "workflows", id, &workflow); err != nil { |
| 492 | if errors.Is(err, store.ErrNotFound) { |
| 493 | c.JSON(http.StatusNotFound, gin.H{ |
| 494 | "success": false, |
| 495 | "error": gin.H{ |
| 496 | "code": "not_found", |
| 497 | "message": "Workflow not found", |
| 498 | }, |
| 499 | }) |
| 500 | return |
| 501 | } |
| 502 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 503 | "success": false, |
| 504 | "error": gin.H{ |
| 505 | "code": "internal_error", |
| 506 | "message": "Failed to get workflow: " + err.Error(), |
| 507 | }, |
| 508 | }) |
| 509 | return |
| 510 | } |
| 511 | |
| 512 | workflow.Status = "inactive" |
| 513 | workflow.UpdatedAt = time.Now() |
| 514 | |
| 515 | if err := (*h.store).Set(ctx, "workflows", id, &workflow); err != nil { |
| 516 | c.JSON(http.StatusInternalServerError, gin.H{ |
| 517 | "success": false, |
| 518 | "error": gin.H{ |
| 519 | "code": "internal_error", |
| 520 | "message": "Failed to suspend workflow: " + err.Error(), |
| 521 | }, |
| 522 | }) |
| 523 | return |
| 524 | } |
| 525 | |
| 526 | c.JSON(http.StatusOK, gin.H{ |
| 527 | "success": true, |
| 528 | "data": &workflow, |
| 529 | }) |
| 530 | } |
| 531 | |
| 532 | // Resume resumes a workflow |
| 533 | func (h *WorkflowHandler) Resume(c *gin.Context) { |