MCPcopy Index your code
hub / github.com/coder/coder / PauseTask

Method PauseTask

codersdk/aitasks.go:338–354  ·  view source on GitHub ↗

PauseTask pauses a task by stopping its workspace.

(ctx context.Context, user string, id uuid.UUID)

Source from the content-addressed store, hash-verified

336
337// PauseTask pauses a task by stopping its workspace.
338func (c *Client) PauseTask(ctx context.Context, user string, id uuid.UUID) (PauseTaskResponse, error) {
339 res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/tasks/%s/%s/pause", user, id.String()), nil)
340 if err != nil {
341 return PauseTaskResponse{}, err
342 }
343 defer res.Body.Close()
344 if res.StatusCode != http.StatusAccepted {
345 return PauseTaskResponse{}, ReadBodyAsError(res)
346 }
347
348 var resp PauseTaskResponse
349 if err := json.NewDecoder(res.Body).Decode(&resp); err != nil {
350 return PauseTaskResponse{}, err
351 }
352
353 return resp, nil
354}
355
356// ResumeTaskResponse represents the response from resuming a task.
357type ResumeTaskResponse struct {

Callers 4

TestPauseTaskFunction · 0.80
TestResumeTaskFunction · 0.80
taskPauseMethod · 0.80
pauseTaskFunction · 0.80

Calls 4

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65
StringMethod · 0.45

Tested by 3

TestPauseTaskFunction · 0.64
TestResumeTaskFunction · 0.64
pauseTaskFunction · 0.64