Skip to content

Commit 9d2aed8

Browse files
authored
fix: register task pause/resume routes under /api/v2 (coder#22544)
The pause/resume endpoints were only registered under /api/experimental but the frontend and Go SDK were calling /api/v2, resulting in 404s. Register the routes in the v2 group, update the SDK client paths, and fix swagger annotations (Accept → Produce) since these POST endpoints have no request body.
1 parent e2a3b99 commit 9d2aed8

6 files changed

Lines changed: 434 additions & 11 deletions

File tree

coderd/aitasks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ func (api *API) postWorkspaceAgentTaskLogSnapshot(rw http.ResponseWriter, r *htt
12491249
// @Summary Pause task
12501250
// @ID pause-task
12511251
// @Security CoderSessionToken
1252-
// @Accept json
1252+
// @Produce json
12531253
// @Tags Tasks
12541254
// @Param user path string true "Username, user ID, or 'me' for the authenticated user"
12551255
// @Param task path string true "Task ID" format(uuid)
@@ -1326,7 +1326,7 @@ func (api *API) pauseTask(rw http.ResponseWriter, r *http.Request) {
13261326
// @Summary Resume task
13271327
// @ID resume-task
13281328
// @Security CoderSessionToken
1329-
// @Accept json
1329+
// @Produce json
13301330
// @Tags Tasks
13311331
// @Param user path string true "Username, user ID, or 'me' for the authenticated user"
13321332
// @Param task path string true "Task ID" format(uuid)

coderd/apidoc/docs.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,8 @@ func New(options *Options) *API {
17941794
r.Patch("/input", api.taskUpdateInput)
17951795
r.Post("/send", api.taskSend)
17961796
r.Get("/logs", api.taskLogs)
1797+
r.Post("/pause", api.pauseTask)
1798+
r.Post("/resume", api.resumeTask)
17971799
})
17981800
})
17991801
})

codersdk/aitasks.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,8 @@ type PauseTaskResponse struct {
335335
}
336336

337337
// PauseTask pauses a task by stopping its workspace.
338-
// Experimental: uses the /api/experimental endpoint.
339338
func (c *Client) PauseTask(ctx context.Context, user string, id uuid.UUID) (PauseTaskResponse, error) {
340-
res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/experimental/tasks/%s/%s/pause", user, id.String()), nil)
339+
res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/tasks/%s/%s/pause", user, id.String()), nil)
341340
if err != nil {
342341
return PauseTaskResponse{}, err
343342
}
@@ -360,7 +359,7 @@ type ResumeTaskResponse struct {
360359
}
361360

362361
func (c *Client) ResumeTask(ctx context.Context, user string, id uuid.UUID) (ResumeTaskResponse, error) {
363-
res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/experimental/tasks/%s/%s/resume", user, id.String()), nil)
362+
res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/tasks/%s/%s/resume", user, id.String()), nil)
364363
if err != nil {
365364
return ResumeTaskResponse{}, err
366365
}

0 commit comments

Comments
 (0)