StartTask explicitly enqueues one executable run for an existing task.
(c *gin.Context)
| 748 | |
| 749 | // StartTask explicitly enqueues one executable run for an existing task. |
| 750 | func (h *BaseHandlers) StartTask(c *gin.Context) { |
| 751 | manager, ok := h.requireTaskManager(c) |
| 752 | if !ok { |
| 753 | return |
| 754 | } |
| 755 | |
| 756 | taskID, err := requiredPathID(c.Param("id"), "task id") |
| 757 | if err != nil { |
| 758 | h.respondError(c, StatusForTaskError(err), err) |
| 759 | return |
| 760 | } |
| 761 | |
| 762 | var req contract.TaskExecutionRequest |
| 763 | if err := decodeOptionalJSON(c, &req); err != nil { |
| 764 | h.respondError( |
| 765 | c, |
| 766 | http.StatusBadRequest, |
| 767 | NewTaskValidationError(fmt.Errorf("%s: decode start task request: %w", h.transportName(), err)), |
| 768 | ) |
| 769 | return |
| 770 | } |
| 771 | |
| 772 | actor, err := h.taskActorContext(c, taskActionStart) |
| 773 | if err != nil { |
| 774 | h.respondError(c, StatusForTaskError(err), err) |
| 775 | return |
| 776 | } |
| 777 | |
| 778 | executionReq, err := taskExecutionRequestFromRequest(req) |
| 779 | if err != nil { |
| 780 | h.respondError(c, StatusForTaskError(err), err) |
| 781 | return |
| 782 | } |
| 783 | |
| 784 | execution, err := manager.StartTask(c.Request.Context(), taskID, executionReq, actor) |
| 785 | if err != nil { |
| 786 | h.respondError(c, StatusForTaskError(err), err) |
| 787 | return |
| 788 | } |
| 789 | |
| 790 | c.JSON(http.StatusCreated, TaskExecutionResponseFromExecution(execution)) |
| 791 | } |
| 792 | |
| 793 | // CancelTask requests cancellation for one task tree. |
| 794 | func (h *BaseHandlers) CancelTask(c *gin.Context) { |
nothing calls this directly
no test coverage detected