PauseTask pauses a task by stopping its workspace.
(ctx context.Context, user string, id uuid.UUID)
| 336 | |
| 337 | // PauseTask pauses a task by stopping its workspace. |
| 338 | func (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. |
| 357 | type ResumeTaskResponse struct { |