Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions api/design/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ var _ = g.Service("control-plane", func() {
g.Method("create-database", func() {
g.Description("Creates a new database in the cluster.")
g.Payload(CreateDatabaseRequest)
g.Result(Database, func() {
g.View("default")
})
g.Result(CreateDatabaseResponse)
g.Error("cluster_not_initialized")
g.Error("invalid_input")
g.Error("database_already_exists")
Expand Down Expand Up @@ -196,9 +194,7 @@ var _ = g.Service("control-plane", func() {
})
g.Attribute("request", UpdateDatabaseRequest)
})
g.Result(Database, func() {
g.View("default")
})
g.Result(UpdateDatabaseResponse)
g.Error("cluster_not_initialized")
g.Error("not_found")
g.Error("database_not_modifiable")
Expand All @@ -221,6 +217,7 @@ var _ = g.Service("control-plane", func() {

g.Required("database_id")
})
g.Result(DeleteDatabaseResponse)
g.Error("cluster_not_initialized")
g.Error("not_found")
g.Error("database_not_modifiable")
Expand All @@ -230,8 +227,8 @@ var _ = g.Service("control-plane", func() {
})
})

g.Method("initiate-database-backup", func() {
g.Description("Initiates a backup for a database.")
g.Method("backup-database-node", func() {
g.Description("Initiates a backup for a database node.")
g.Payload(func() {
g.Attribute("database_id", g.String, func() {
g.Format(g.FormatUUID)
Expand All @@ -246,7 +243,7 @@ var _ = g.Service("control-plane", func() {

g.Required("database_id", "node_name", "options")
})
g.Result(Task)
g.Result(BackupDatabaseNodeResponse)
g.Error("cluster_not_initialized")
g.Error("not_found")
g.Error("database_not_modifiable")
Expand Down Expand Up @@ -334,13 +331,13 @@ var _ = g.Service("control-plane", func() {
g.Description("ID of the task to get log for.")
g.Example("3c875a27-f6a6-4c1c-ba5f-6972fb1fc348")
})
g.Attribute("after_line_id", g.String, func() {
g.Attribute("after_entry_id", g.String, func() {
g.Format(g.FormatUUID)
g.Description("ID of the line to start from.")
g.Description("ID of the entry to start from.")
g.Example("3c875a27-f6a6-4c1c-ba5f-6972fb1fc348")
})
g.Attribute("limit", g.Int, func() {
g.Description("Maximum number of lines to return.")
g.Description("Maximum number of entries to return.")
g.Example(100)
})

Expand All @@ -352,7 +349,7 @@ var _ = g.Service("control-plane", func() {

g.HTTP(func() {
g.GET("/databases/{database_id}/tasks/{task_id}/log")
g.Param("after_line_id")
g.Param("after_entry_id")
g.Param("limit")
})
})
Expand Down
39 changes: 36 additions & 3 deletions api/design/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,15 @@ var CreateDatabaseRequest = g.Type("CreateDatabaseRequest", func() {
})
})

var CreateDatabaseResponse = g.Type("CreateDatabaseResponse", func() {
g.Attribute("task", Task, func() {
g.Description("The task that will create this database.")
})
g.Attribute("database", Database, func() {
g.Description("The database being created.")
})
})

var UpdateDatabaseRequest = g.Type("UpdateDatabaseRequest", func() {
g.Attribute("tenant_id", g.String, func() {
g.Format(g.FormatUUID)
Expand All @@ -491,6 +500,27 @@ var UpdateDatabaseRequest = g.Type("UpdateDatabaseRequest", func() {
})
})

var UpdateDatabaseResponse = g.Type("UpdateDatabaseResponse", func() {
g.Attribute("task", Task, func() {
g.Description("The task that will update this database.")
})
g.Attribute("database", Database, func() {
g.Description("The database being updated.")
})
})

var DeleteDatabaseResponse = g.Type("DeleteDatabaseResponse", func() {
g.Attribute("task", Task, func() {
g.Description("The task that will delete this database.")
})
})

var BackupDatabaseNodeResponse = g.Type("BackupDatabaseNodeResponse", func() {
g.Attribute("task", Task, func() {
g.Description("The task that will backup this database node.")
})
})

var RestoreDatabaseRequest = g.Type("RestoreDatabaseRequest", func() {
g.Attribute("restore_config", RestoreConfigSpec, func() {
g.Description("Configuration for the restore process.")
Expand All @@ -505,12 +535,15 @@ var RestoreDatabaseRequest = g.Type("RestoreDatabaseRequest", func() {
})

var RestoreDatabaseResponse = g.Type("RestoreDatabaseResponse", func() {
g.Attribute("task", Task, func() {
g.Description("The task that will restore this database.")
})
g.Attribute("node_tasks", g.ArrayOf(Task), func() {
g.Description("The tasks that will restore each database node.")
})
g.Attribute("database", Database, func() {
g.Description("The database being restored.")
})
g.Attribute("tasks", g.ArrayOf(Task), func() {
g.Description("The restore tasks that were created to restore this database.")
})
})

var ExtraVolumesSpec = g.Type("ExtraVolumesSpec", func() {
Expand Down
36 changes: 30 additions & 6 deletions api/design/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
)

var Task = g.Type("Task", func() {
g.Attribute("parent_id", g.String, func() {
g.Format(g.FormatUUID)
g.Description("The parent task ID of the task.")
g.Example("439eb515-e700-4740-b508-4a3f12ec4f83")
})
g.Attribute("database_id", g.String, func() {
g.Format(g.FormatUUID)
g.Description("The database ID of the task.")
Expand Down Expand Up @@ -56,6 +61,26 @@ var Task = g.Type("Task", func() {
g.Required("database_id", "task_id", "created_at", "type", "status")
})

var TaskLogEntry = g.Type("TaskLogEntry", func() {
g.Attribute("timestamp", g.String, func() {
g.Format(g.FormatDateTime)
g.Description("The timestamp of the log entry.")
g.Example("2025-05-29T15:43:13Z")
})
g.Attribute("message", g.String, func() {
g.Description("The log message.")
g.Example("task started")
})
g.Attribute("fields", g.MapOf(g.String, g.Any), func() {
g.Description("Additional fields for the log entry.")
g.Example(map[string]any{
"status": "creating",
"option.enabled": true,
})
})
g.Required("timestamp", "message")
})

var TaskLog = g.Type("TaskLog", func() {
g.Attribute("database_id", g.String, func() {
g.Format(g.FormatUUID)
Expand All @@ -72,15 +97,14 @@ var TaskLog = g.Type("TaskLog", func() {
g.Description("The status of the task.")
g.Example("pending")
})
g.Attribute("last_line_id", g.String, func() {
g.Attribute("last_entry_id", g.String, func() {
g.Format(g.FormatUUID)
g.Description("The ID of the last line in the task log.")
g.Description("The ID of the last entry in the task log.")
g.Example("3c875a27-f6a6-4c1c-ba5f-6972fb1fc348")
})
g.Attribute("lines", g.ArrayOf(g.String), func() {
g.Description("The lines of the task log.")
g.Example([]string{"Task started", "Task completed"})
g.Attribute("entries", g.ArrayOf(TaskLogEntry), func() {
g.Description("Entries in the task log.")
})

g.Required("database_id", "task_id", "task_status", "lines")
g.Required("database_id", "task_id", "task_status", "entries")
})
106 changes: 55 additions & 51 deletions api/gen/control_plane/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading