Skip to content

Commit 6413d13

Browse files
committed
feat: add available_upgrades opt-in to databases API
1 parent e6cf817 commit 6413d13

27 files changed

Lines changed: 6333 additions & 4914 deletions

File tree

api/apiv1/design/api.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,18 @@ var _ = g.Service("control-plane", func() {
209209
g.Method("list-databases", func() {
210210
g.Description("Lists all databases in the cluster.")
211211
g.Meta("openapi:summary", "List databases")
212+
g.Payload(func() {
213+
g.Attribute("include", g.ArrayOf(g.String), func() {
214+
g.Description("Optional fields to include in each database response. Supported values: available_upgrades.")
215+
g.Example([]string{"available_upgrades"})
216+
})
217+
})
212218
g.Result(ListDatabasesResponse)
213219
g.Error("cluster_not_initialized")
214220

215221
g.HTTP(func() {
216222
g.GET("/v1/databases")
223+
g.Param("include")
217224

218225
g.Meta("openapi:tag:Database")
219226
})
@@ -245,6 +252,10 @@ var _ = g.Service("control-plane", func() {
245252
g.Description("ID of the database to get.")
246253
g.Example("my-app")
247254
})
255+
g.Attribute("include", g.ArrayOf(g.String), func() {
256+
g.Description("Optional fields to include in the response. Supported values: available_upgrades.")
257+
g.Example([]string{"available_upgrades"})
258+
})
248259

249260
g.Required("database_id")
250261
})
@@ -255,6 +266,7 @@ var _ = g.Service("control-plane", func() {
255266

256267
g.HTTP(func() {
257268
g.GET("/v1/databases/{database_id}")
269+
g.Param("include")
258270

259271
g.Meta("openapi:tag:Database")
260272
})

api/apiv1/design/database.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,26 @@ var DatabaseSpec = g.Type("DatabaseSpec", func() {
702702
g.Required("database_name", "nodes")
703703
})
704704

705+
var AvailableUpgrade = g.Type("AvailableUpgrade", func() {
706+
g.Description("A newer stable image available for the database in the same Postgres major / Spock major bucket.")
707+
g.Attribute("postgres_version", g.String, func() {
708+
g.Description("Postgres version of the upgrade candidate.")
709+
g.Example("17.10")
710+
g.Meta("struct:tag:json", "postgres_version")
711+
})
712+
g.Attribute("spock_version", g.String, func() {
713+
g.Description("Spock major version of the upgrade candidate.")
714+
g.Example("5")
715+
g.Meta("struct:tag:json", "spock_version")
716+
})
717+
g.Attribute("image", g.String, func() {
718+
g.Description("Full container image reference for the upgrade candidate.")
719+
g.Example("ghcr.io/pgedge/pgedge-postgres:17.10-spock5.0.9-standard-1")
720+
g.Meta("struct:tag:json", "image")
721+
})
722+
g.Required("postgres_version", "spock_version", "image")
723+
})
724+
705725
var Database = g.Type("Database", func() {
706726
g.Attribute("id", Identifier, func() {
707727
g.Description("Unique identifier for the database.")
@@ -754,6 +774,10 @@ var Database = g.Type("Database", func() {
754774
g.Description("The user-provided specification for the database.")
755775
g.Meta("struct:tag:json", "spec,omitempty")
756776
})
777+
g.Attribute("available_upgrades", g.ArrayOf(AvailableUpgrade), func() {
778+
g.Description("Newer stable image versions available in the same Postgres major / Spock major bucket. Present only when ?include=available_upgrades is set.")
779+
g.Meta("struct:tag:json", "available_upgrades,omitempty")
780+
})
757781

758782
g.Example(exampleDatabase)
759783

@@ -805,6 +829,10 @@ var DatabaseSummary = g.Type("DatabaseSummary", func() {
805829
g.Description("All of the instances in the database.")
806830
g.Meta("struct:tag:json", "instances,omitempty")
807831
})
832+
g.Attribute("available_upgrades", g.ArrayOf(AvailableUpgrade), func() {
833+
g.Description("Newer stable image versions available in the same Postgres major / Spock major bucket. Present only when ?include=available_upgrades is set.")
834+
g.Meta("struct:tag:json", "available_upgrades,omitempty")
835+
})
808836

809837
g.Required("id", "created_at", "updated_at", "state")
810838
})

api/apiv1/gen/control_plane/client.go

Lines changed: 2 additions & 2 deletions
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: 2 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/service.go

Lines changed: 29 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: 12 additions & 5 deletions
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: 31 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)