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

Method TaskByID

codersdk/aitasks.go:204–220  ·  view source on GitHub ↗

TaskByID fetches a single task by its ID. Only tasks owned by codersdk.Me are supported.

(ctx context.Context, id uuid.UUID)

Source from the content-addressed store, hash-verified

202// TaskByID fetches a single task by its ID.
203// Only tasks owned by codersdk.Me are supported.
204func (c *Client) TaskByID(ctx context.Context, id uuid.UUID) (Task, error) {
205 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/tasks/%s/%s", "me", id.String()), nil)
206 if err != nil {
207 return Task{}, err
208 }
209 defer res.Body.Close()
210 if res.StatusCode != http.StatusOK {
211 return Task{}, ReadBodyAsError(res)
212 }
213
214 var task Task
215 if err := json.NewDecoder(res.Body).Decode(&task); err != nil {
216 return Task{}, err
217 }
218
219 return task, nil
220}
221
222// TaskByOwnerAndName fetches a single task by its owner and name.
223func (c *Client) TaskByOwnerAndName(ctx context.Context, owner, ident string) (Task, error) {

Callers 4

TaskByIdentifierMethod · 0.95
TestTasksFunction · 0.80
waitForTaskIdleFunction · 0.80
taskStatusMethod · 0.80

Calls 4

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

Tested by 1

TestTasksFunction · 0.64