diff --git a/CHANGELOG.md b/CHANGELOG.md index 88e88bb5..73be90cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ See updating [Changelog example here](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] +### Added +- Managed Database sub-properties support. E.g., PostgreSQL property `timescaledb` is of type `object` and has `max_background_workers` sub-property. + ## [6.10.0] ### Added diff --git a/upcloud/managed_database.go b/upcloud/managed_database.go index c83dac9f..06532204 100644 --- a/upcloud/managed_database.go +++ b/upcloud/managed_database.go @@ -817,17 +817,20 @@ func (s *ManagedDatabaseServicePlanZones) UnmarshalJSON(b []byte) error { // ManagedDatabaseServiceProperty contains help for database property usage and validation type ManagedDatabaseServiceProperty struct { - CreateOnly bool `json:"createOnly,omitempty"` - Default interface{} `json:"default,omitempty"` - Example interface{} `json:"example,omitempty"` - MaxLength int `json:"maxLength,omitempty"` - MinLength int `json:"minLength,omitempty"` - Pattern string `json:"pattern,omitempty"` - Type interface{} `json:"type"` - Title string `json:"title"` - Description string `json:"description,omitempty"` - Enum interface{} `json:"enum,omitempty"` - UserError string `json:"user_error,omitempty"` + CreateOnly bool `json:"createOnly,omitempty"` + Default interface{} `json:"default,omitempty"` + Example interface{} `json:"example,omitempty"` + MaxLength int `json:"maxLength,omitempty"` + Maximum float64 `json:"maximum,omitempty"` + MinLength int `json:"minLength,omitempty"` + Minimum float64 `json:"minimum,omitempty"` + Pattern string `json:"pattern,omitempty"` + Type interface{} `json:"type"` + Title string `json:"title"` + Description string `json:"description,omitempty"` + Enum interface{} `json:"enum,omitempty"` + UserError string `json:"user_error,omitempty"` + Properties map[string]ManagedDatabaseServiceProperty `json:"properties,omitempty"` } // ManagedDatabaseMetadata contains additional read-only informational data about the managed database diff --git a/upcloud/managed_database_test.go b/upcloud/managed_database_test.go index 20a87ab8..40522a53 100644 --- a/upcloud/managed_database_test.go +++ b/upcloud/managed_database_test.go @@ -349,6 +349,22 @@ func TestManagedDatabaseType_UnmarshalJSON(t *testing.T) { "title": "Public Access", "type": "boolean", "description": "Allow access to the service from the public Internet" + }, + "timescaledb": { + "title": "TimescaleDB extension configuration values", + "type": "object", + "properties": { + "max_background_workers": { + "default": 16, + "example": 8, + "title": "timescaledb.max_background_workers", + "type": "integer", + "description": "The number of background workers for timescaledb operations. You should configure this setting to the sum of your number of databases and the total number of concurrent background workers you want running at any given point in time.", + "minimum": 1, + "maximum": 4096 + } + }, + "description": "System-wide settings for the timescaledb extension" } } }` @@ -376,6 +392,23 @@ func TestManagedDatabaseType_UnmarshalJSON(t *testing.T) { Type: "boolean", Description: "Allow access to the service from the public Internet", }, + // `timescaledb` is a PostgreSQL property (not MySQL), but that shouldn't make difference from marshaling point-of-view. + "timescaledb": { + Title: "TimescaleDB extension configuration values", + Description: "System-wide settings for the timescaledb extension", + Type: "object", + Properties: map[string]ManagedDatabaseServiceProperty{ + "max_background_workers": { + Default: 16.0, + Example: 8.0, + Title: "timescaledb.max_background_workers", + Type: "integer", + Description: "The number of background workers for timescaledb operations. You should configure this setting to the sum of your number of databases and the total number of concurrent background workers you want running at any given point in time.", + Minimum: 1, + Maximum: 4096, + }, + }, + }, }, }