diff --git a/databases.go b/databases.go index 8fe7523dd..83b4e7ab2 100644 --- a/databases.go +++ b/databases.go @@ -114,9 +114,9 @@ type DatabaseMaintenanceWindow struct { } type DatabaseMaintenanceWindowPending struct { - Deadline *time.Time `json:"deadline"` + Deadline *time.Time `json:"-"` Description string `json:"description"` - PlannedFor *time.Time `json:"planned_for"` + PlannedFor *time.Time `json:"-"` } // DatabaseType is information about the supported Database Types by Linode Managed Databases @@ -150,7 +150,7 @@ type ClusterPrice struct { // DatabaseFork describes the source and restore time for the fork for forked DBs type DatabaseFork struct { Source int `json:"source"` - RestoreTime *time.Time `json:"restore_time,omitempty"` + RestoreTime *time.Time `json:"-,omitempty"` } func (d *Database) UnmarshalJSON(b []byte) error { @@ -173,6 +173,44 @@ func (d *Database) UnmarshalJSON(b []byte) error { return nil } +func (d *DatabaseFork) UnmarshalJSON(b []byte) error { + type Mask DatabaseFork + + p := struct { + *Mask + RestoreTime *parseabletime.ParseableTime `json:"restore_time"` + }{ + Mask: (*Mask)(d), + } + + if err := json.Unmarshal(b, &p); err != nil { + return err + } + + d.RestoreTime = (*time.Time)(p.RestoreTime) + return nil +} + +func (d *DatabaseMaintenanceWindowPending) UnmarshalJSON(b []byte) error { + type Mask DatabaseMaintenanceWindowPending + + p := struct { + *Mask + Deadline *parseabletime.ParseableTime `json:"deadline"` + PlannedFor *parseabletime.ParseableTime `json:"planned_for"` + }{ + Mask: (*Mask)(d), + } + + if err := json.Unmarshal(b, &p); err != nil { + return err + } + + d.Deadline = (*time.Time)(p.Deadline) + d.PlannedFor = (*time.Time)(p.PlannedFor) + return nil +} + // ListDatabases lists all Database instances in Linode Managed Databases for the account func (c *Client) ListDatabases(ctx context.Context, opts *ListOptions) ([]Database, error) { response, err := getPaginatedResults[Database](ctx, c, "databases/instances", opts) diff --git a/mysql.go b/mysql.go index 6140c0ab2..66d09094d 100644 --- a/mysql.go +++ b/mysql.go @@ -91,6 +91,7 @@ type MySQLUpdateOptions struct { Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"` Type string `json:"type,omitempty"` ClusterSize int `json:"cluster_size,omitempty"` + Version string `json:"version,omitempty"` } // MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database diff --git a/postgres.go b/postgres.go index 5c1dca1f7..3e203033b 100644 --- a/postgres.go +++ b/postgres.go @@ -109,6 +109,7 @@ type PostgresUpdateOptions struct { Updates *DatabaseMaintenanceWindow `json:"updates,omitempty"` Type string `json:"type,omitempty"` ClusterSize int `json:"cluster_size,omitempty"` + Version string `json:"version,omitempty"` } // PostgresDatabaseSSL is the SSL Certificate to access the Linode Managed Postgres Database