Skip to content

Commit 8383850

Browse files
committed
feat: generic list tasks endpoint
Adds an endpoint to list tasks across all entities. PLAT-347
1 parent 74f4249 commit 8383850

File tree

25 files changed

+6444
-7312
lines changed

25 files changed

+6444
-7312
lines changed

api/apiv1/design/api.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,50 @@ var _ = g.Service("control-plane", func() {
633633
})
634634
})
635635

636+
g.Method("list-tasks", func() {
637+
g.Description("Lists tasks across all scopes with optional filtering by scope and entity ID.")
638+
g.Meta("openapi:summary", "List tasks")
639+
g.Payload(func() {
640+
g.Attribute("scope", g.String, func() {
641+
g.Enum("database", "host")
642+
g.Description("Optional scope to filter tasks (database or host).")
643+
g.Example("database")
644+
})
645+
g.Attribute("entity_id", Identifier, func() {
646+
g.Description("Optional entity ID to filter tasks. Requires scope to be set.")
647+
g.Example("my-app")
648+
})
649+
g.Attribute("after_task_id", g.String, func() {
650+
g.Description("ID of the task to start from.")
651+
g.Format(g.FormatUUID)
652+
g.Example("3c875a27-f6a6-4c1c-ba5f-6972fb1fc348")
653+
})
654+
g.Attribute("limit", g.Int, func() {
655+
g.Description("Maximum number of tasks to return.")
656+
g.Example(100)
657+
})
658+
g.Attribute("sort_order", g.String, func() {
659+
g.Enum("asc", "ascend", "ascending", "desc", "descend", "descending")
660+
g.Description("Sort order for the tasks.")
661+
g.Example("ascend")
662+
})
663+
})
664+
g.Result(ListTasksResponse)
665+
g.Error("cluster_not_initialized")
666+
g.Error("invalid_input")
667+
668+
g.HTTP(func() {
669+
g.GET("/v1/tasks")
670+
g.Param("scope")
671+
g.Param("entity_id")
672+
g.Param("after_task_id")
673+
g.Param("limit")
674+
g.Param("sort_order")
675+
676+
g.Meta("openapi:tag:System")
677+
})
678+
})
679+
636680
g.Method("restore-database", func() {
637681
g.Description("Perform an in-place restore of one or more nodes using the given restore configuration.")
638682
g.Meta("openapi:summary", "Restore database")

api/apiv1/design/task.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,33 @@ var ListHostTasksResponse = g.Type("ListHostTasksResponse", func() {
329329
},
330330
})
331331
})
332+
333+
var ListTasksResponse = g.Type("ListTasksResponse", func() {
334+
g.Attribute("tasks", g.ArrayOf(Task))
335+
336+
g.Example(map[string]any{
337+
"tasks": []map[string]any{
338+
{
339+
"completed_at": "2025-06-18T17:54:36Z",
340+
"created_at": "2025-06-18T17:54:28Z",
341+
"scope": "database",
342+
"entity_id": "storefront",
343+
"database_id": "storefront",
344+
"instance_id": "storefront-n1-689qacsi",
345+
"status": "completed",
346+
"task_id": "0197842d-9082-7496-b787-77bd2e11809f",
347+
"type": "node_backup",
348+
},
349+
{
350+
"completed_at": "2025-06-18T17:54:36Z",
351+
"created_at": "2025-06-18T17:54:28Z",
352+
"scope": "host",
353+
"entity_id": "host-1",
354+
"host_id": "host-1",
355+
"status": "completed",
356+
"task_id": "0197842d-9082-7496-b787-77bd2e11809f",
357+
"type": "remove_host",
358+
},
359+
},
360+
})
361+
})

api/apiv1/gen/control_plane/client.go

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/control_plane/endpoints.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/control_plane/service.go

Lines changed: 24 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/cli/control_plane/cli.go

Lines changed: 42 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/control_plane/client/cli.go

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)