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

Method TaskByIdentifier

codersdk/aitasks.go:266–281  ·  view source on GitHub ↗

TaskByIdentifier fetches and returns a task by an identifier, which may be either a UUID, a name (for a task owned by the current user), or a "user/task" combination, where user is either a username or UUID. Since there is no TaskByOwnerAndName endpoint yet, this function uses the list endpoint wit

(ctx context.Context, identifier string)

Source from the content-addressed store, hash-verified

264// Since there is no TaskByOwnerAndName endpoint yet, this function uses the
265// list endpoint with filtering when a name is provided.
266func (c *Client) TaskByIdentifier(ctx context.Context, identifier string) (Task, error) {
267 identifier = strings.TrimSpace(identifier)
268
269 // Try parsing as UUID first.
270 if taskID, err := uuid.Parse(identifier); err == nil {
271 return c.TaskByID(ctx, taskID)
272 }
273
274 // Not a UUID, treat as identifier.
275 owner, taskName, err := splitTaskIdentifier(identifier)
276 if err != nil {
277 return Task{}, err
278 }
279
280 return c.TaskByOwnerAndName(ctx, owner, taskName)
281}
282
283// DeleteTask deletes a task by its ID.
284func (c *Client) DeleteTask(ctx context.Context, user string, id uuid.UUID) error {

Callers 11

TestTasksFunction · 0.80
toolsdk.goFile · 0.80
TestExpTaskResumeFunction · 0.80
taskSendMethod · 0.80
taskPauseMethod · 0.80
taskStatusMethod · 0.80
taskLogsMethod · 0.80
taskResumeMethod · 0.80
taskDeleteMethod · 0.80
Test_TaskSendFunction · 0.80
TestExpTaskPauseFunction · 0.80

Calls 4

TaskByIDMethod · 0.95
TaskByOwnerAndNameMethod · 0.95
splitTaskIdentifierFunction · 0.85
ParseMethod · 0.65

Tested by 4

TestTasksFunction · 0.64
TestExpTaskResumeFunction · 0.64
Test_TaskSendFunction · 0.64
TestExpTaskPauseFunction · 0.64