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

Method CreateTask

codersdk/aitasks.go:25–42  ·  view source on GitHub ↗

CreateTask creates a new task.

(ctx context.Context, user string, request CreateTaskRequest)

Source from the content-addressed store, hash-verified

23
24// CreateTask creates a new task.
25func (c *Client) CreateTask(ctx context.Context, user string, request CreateTaskRequest) (Task, error) {
26 res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/tasks/%s", user), request)
27 if err != nil {
28 return Task{}, err
29 }
30 defer res.Body.Close()
31
32 if res.StatusCode != http.StatusCreated {
33 return Task{}, ReadBodyAsError(res)
34 }
35
36 var task Task
37 if err := json.NewDecoder(res.Body).Decode(&task); err != nil {
38 return Task{}, err
39 }
40
41 return task, nil
42}
43
44// TaskStatus represents the status of a task.
45type TaskStatus string

Callers 12

TestWorkspaceListTasksFunction · 0.80
TestTasksFunction · 0.80
TestTasksCreateFunction · 0.80
TestPauseTaskFunction · 0.80
TestResumeTaskFunction · 0.80
TestToolsFunction · 0.80
toolsdk.goFile · 0.80
setupCLITaskTestFunction · 0.80
taskCreateMethod · 0.80
TestManagedAgentLimitFunction · 0.80
TestWorkspaceAITaskFunction · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 10

TestWorkspaceListTasksFunction · 0.64
TestTasksFunction · 0.64
TestTasksCreateFunction · 0.64
TestPauseTaskFunction · 0.64
TestResumeTaskFunction · 0.64
TestToolsFunction · 0.64
setupCLITaskTestFunction · 0.64
TestManagedAgentLimitFunction · 0.64
TestWorkspaceAITaskFunction · 0.64