Skip to content

Commit

Permalink
More PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ezilber-akamai committed Dec 2, 2024
1 parent ffd5f5c commit 8acd7eb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
44 changes: 41 additions & 3 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8acd7eb

Please sign in to comment.