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
11 changes: 1 addition & 10 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,7 @@ type Database struct {
// Members has dynamic keys so it is a map
Members map[string]DatabaseMemberType `json:"members"`

// Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReplicationType string `json:"replication_type"`
// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
SSLConnection bool `json:"ssl_connection"`
// Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
Encrypted bool `json:"encrypted"`

Encrypted bool `json:"encrypted"`
AllowList []string `json:"allow_list"`
InstanceURI string `json:"instance_uri"`
Created *time.Time `json:"-"`
Expand Down Expand Up @@ -126,9 +120,6 @@ type DatabaseMaintenanceWindow struct {
HourOfDay int `json:"hour_of_day"`

Pending []DatabaseMaintenanceWindowPending `json:"pending,omitempty"`

// Deprecated: WeekOfMonth is a deprecated property, as it is no longer supported in DBaaS V2.
WeekOfMonth *int `json:"week_of_month,omitempty"`
}

type DatabaseMaintenanceWindowPending struct {
Expand Down
92 changes: 2 additions & 90 deletions mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@ type MySQLDatabase struct {
// Members has dynamic keys so it is a map
Members map[string]DatabaseMemberType `json:"members"`

// Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
ReplicationType string `json:"replication_type"`
// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
SSLConnection bool `json:"ssl_connection"`
// Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
Encrypted bool `json:"encrypted"`

SSLConnection bool `json:"ssl_connection"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So SSLConnection and Encrypted were deprecated properties and now they aren't? Only ReplicationType is gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those properties were initially marked as deprecated because they were mistakenly omitted from the API Spec during the migration from DBaaS V1 to V2, but this was a mistake. The API is still returning these fields now.

Encrypted bool `json:"encrypted"`
AllowList []string `json:"allow_list"`
InstanceURI string `json:"instance_uri"`
Created *time.Time `json:"-"`
Comment on lines 38 to 39
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The InstanceURI field was removed from the struct but is still present in the Database struct in databases.go (line 88). This creates inconsistency between the generic Database type and the MySQL-specific type, potentially causing issues if code relies on this field being present in MySQLDatabase.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is only meant to exist in the generic Managed Database endpoints. I think it never should have been included in the MySQL struct.

Updated *time.Time `json:"-"`
Updates DatabaseMaintenanceWindow `json:"updates"`
Expand Down Expand Up @@ -406,13 +400,6 @@ type MySQLCreateOptions struct {
AllowList []string `json:"allow_list,omitempty"`
ClusterSize int `json:"cluster_size,omitempty"`

// Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
ReplicationType string `json:"replication_type,omitempty"`
// Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
Encrypted bool `json:"encrypted,omitempty"`
// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
SSLConnection bool `json:"ssl_connection,omitempty"`

Fork *DatabaseFork `json:"fork,omitempty"`
EngineConfig *MySQLDatabaseEngineConfig `json:"engine_config,omitempty"`
PrivateNetwork *DatabasePrivateNetwork `json:"private_network,omitempty"`
Expand All @@ -430,46 +417,6 @@ type MySQLUpdateOptions struct {
PrivateNetwork **DatabasePrivateNetwork `json:"private_network,omitempty"`
}

// MySQLDatabaseBackup is information for interacting with a backup for the existing MySQL Database

// Deprecated: MySQLDatabaseBackup is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type MySQLDatabaseBackup struct {
ID int `json:"id"`
Label string `json:"label"`
Type string `json:"type"`
Created *time.Time `json:"-"`
}

// MySQLBackupCreateOptions are options used for CreateMySQLDatabaseBackup(...)
//
// Deprecated: MySQLBackupCreateOptions is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type MySQLBackupCreateOptions struct {
Label string `json:"label"`
Target MySQLDatabaseTarget `json:"target"`
}

func (d *MySQLDatabaseBackup) UnmarshalJSON(b []byte) error {
type Mask MySQLDatabaseBackup

p := struct {
*Mask

Created *parseabletime.ParseableTime `json:"created"`
}{
Mask: (*Mask)(d),
}

if err := json.Unmarshal(b, &p); err != nil {
return err
}

d.Created = (*time.Time)(p.Created)

return nil
}

// MySQLDatabaseCredential is the Root Credentials to access the Linode Managed Database
type MySQLDatabaseCredential struct {
Username string `json:"username"`
Expand All @@ -486,14 +433,6 @@ func (c *Client) ListMySQLDatabases(ctx context.Context, opts *ListOptions) ([]M
return getPaginatedResults[MySQLDatabase](ctx, c, "databases/mysql/instances", opts)
}

// ListMySQLDatabaseBackups lists all MySQL Database Backups associated with the given MySQL Database
//
// Deprecated: ListMySQLDatabaseBackups is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) ListMySQLDatabaseBackups(ctx context.Context, databaseID int, opts *ListOptions) ([]MySQLDatabaseBackup, error) {
return getPaginatedResults[MySQLDatabaseBackup](ctx, c, formatAPIPath("databases/mysql/instances/%d/backups", databaseID), opts)
}

// GetMySQLDatabase returns a single MySQL Database matching the id
func (c *Client) GetMySQLDatabase(ctx context.Context, databaseID int) (*MySQLDatabase, error) {
e := formatAPIPath("databases/mysql/instances/%d", databaseID)
Expand Down Expand Up @@ -535,33 +474,6 @@ func (c *Client) ResetMySQLDatabaseCredentials(ctx context.Context, databaseID i
return doPOSTRequestNoRequestResponseBody(ctx, c, e)
}

// GetMySQLDatabaseBackup returns a specific MySQL Database Backup with the given ids
//
// Deprecated: GetMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) GetMySQLDatabaseBackup(ctx context.Context, databaseID int, backupID int) (*MySQLDatabaseBackup, error) {
e := formatAPIPath("databases/mysql/instances/%d/backups/%d", databaseID, backupID)
return doGETRequest[MySQLDatabaseBackup](ctx, c, e)
}

// RestoreMySQLDatabaseBackup returns the given MySQL Database with the given Backup
//
// Deprecated: RestoreMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) RestoreMySQLDatabaseBackup(ctx context.Context, databaseID int, backupID int) error {
e := formatAPIPath("databases/mysql/instances/%d/backups/%d/restore", databaseID, backupID)
return doPOSTRequestNoRequestResponseBody(ctx, c, e)
}

// CreateMySQLDatabaseBackup creates a snapshot for the given MySQL database
//
// Deprecated: CreateMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) CreateMySQLDatabaseBackup(ctx context.Context, databaseID int, opts MySQLBackupCreateOptions) error {
e := formatAPIPath("databases/mysql/instances/%d/backups", databaseID)
return doPOSTRequestNoResponseBody(ctx, c, e, opts)
}

// PatchMySQLDatabase applies security patches and updates to the underlying operating system of the Managed MySQL Database
func (c *Client) PatchMySQLDatabase(ctx context.Context, databaseID int) error {
e := formatAPIPath("databases/mysql/instances/%d/patch", databaseID)
Expand Down
6 changes: 0 additions & 6 deletions paged_response_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ type LongviewSubscriptionsPagedResponse legacyPagedResponse[LongviewSubscription
// Deprecated: MySQLDatabasesPagedResponse exists for historical compatibility and should not be used.
type MySQLDatabasesPagedResponse legacyPagedResponse[MySQLDatabase]

// Deprecated: MySQLDatabaseBackupsPagedResponse exists for historical compatibility and should not be used.
type MySQLDatabaseBackupsPagedResponse legacyPagedResponse[MySQLDatabaseBackup]

// Deprecated: NodeBalancersPagedResponse exists for historical compatibility and should not be used.
type NodeBalancersPagedResponse legacyPagedResponse[NodeBalancer]

Expand Down Expand Up @@ -161,9 +158,6 @@ type TicketsPagedResponse legacyPagedResponse[Ticket]
// Deprecated: PostgresDatabasesPagedResponse exists for historical compatibility and should not be used.
type PostgresDatabasesPagedResponse legacyPagedResponse[PostgresDatabase]

// Deprecated: PostgresDatabaseBackupsPagedResponse exists for historical compatibility and should not be used.
type PostgresDatabaseBackupsPagedResponse legacyPagedResponse[PostgresDatabaseBackup]

// Deprecated: ProfileLoginsPagedResponse exists for historical compatibility and should not be used.
type ProfileLoginsPagedResponse legacyPagedResponse[ProfileLogin]

Expand Down
95 changes: 2 additions & 93 deletions postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,8 @@ type PostgresDatabase struct {
// Members has dynamic keys so it is a map
Members map[string]DatabaseMemberType `json:"members"`

// Deprecated: ReplicationCommitType is a deprecated property, as it is no longer supported in DBaaS V2.
ReplicationCommitType PostgresCommitType `json:"replication_commit_type"`
// Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
ReplicationType PostgresReplicationType `json:"replication_type"`
// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
SSLConnection bool `json:"ssl_connection"`
// Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
Encrypted bool `json:"encrypted"`

SSLConnection bool `json:"ssl_connection"`
Encrypted bool `json:"encrypted"`
Hosts DatabaseHost `json:"hosts"`
Updates DatabaseMaintenanceWindow `json:"updates"`
Created *time.Time `json:"-"`
Expand Down Expand Up @@ -604,15 +597,6 @@ type PostgresCreateOptions struct {
AllowList []string `json:"allow_list,omitempty"`
ClusterSize int `json:"cluster_size,omitempty"`

// Deprecated: Encrypted is a deprecated property, as it is no longer supported in DBaaS V2.
Encrypted bool `json:"encrypted,omitempty"`
// Deprecated: SSLConnection is a deprecated property, as it is no longer supported in DBaaS V2.
SSLConnection bool `json:"ssl_connection,omitempty"`
// Deprecated: ReplicationType is a deprecated property, as it is no longer supported in DBaaS V2.
ReplicationType PostgresReplicationType `json:"replication_type,omitempty"`
// Deprecated: ReplicationCommitType is a deprecated property, as it is no longer supported in DBaaS V2.
ReplicationCommitType PostgresCommitType `json:"replication_commit_type,omitempty"`

Fork *DatabaseFork `json:"fork,omitempty"`

EngineConfig *PostgresDatabaseEngineConfig `json:"engine_config,omitempty"`
Expand Down Expand Up @@ -647,54 +631,6 @@ func (c *Client) ListPostgresDatabases(ctx context.Context, opts *ListOptions) (
return getPaginatedResults[PostgresDatabase](ctx, c, "databases/postgresql/instances", opts)
}

// PostgresDatabaseBackup is information for interacting with a backup for the existing Postgres Database
//
// Deprecated: PostgresDatabaseBackup is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type PostgresDatabaseBackup struct {
ID int `json:"id"`
Label string `json:"label"`
Type string `json:"type"`
Created *time.Time `json:"-"`
}

func (d *PostgresDatabaseBackup) UnmarshalJSON(b []byte) error {
type Mask PostgresDatabaseBackup

p := struct {
*Mask

Created *parseabletime.ParseableTime `json:"created"`
}{
Mask: (*Mask)(d),
}

if err := json.Unmarshal(b, &p); err != nil {
return err
}

d.Created = (*time.Time)(p.Created)

return nil
}

// PostgresBackupCreateOptions are options used for CreatePostgresDatabaseBackup(...)
//
// Deprecated: PostgresBackupCreateOptions is a deprecated struct, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
type PostgresBackupCreateOptions struct {
Label string `json:"label"`
Target PostgresDatabaseTarget `json:"target"`
}

// ListPostgresDatabaseBackups lists all Postgres Database Backups associated with the given Postgres Database
//
// Deprecated: ListPostgresDatabaseBackups is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) ListPostgresDatabaseBackups(ctx context.Context, databaseID int, opts *ListOptions) ([]PostgresDatabaseBackup, error) {
return getPaginatedResults[PostgresDatabaseBackup](ctx, c, formatAPIPath("databases/postgresql/instances/%d/backups", databaseID), opts)
}

// GetPostgresDatabase returns a single Postgres Database matching the id
func (c *Client) GetPostgresDatabase(ctx context.Context, databaseID int) (*PostgresDatabase, error) {
e := formatAPIPath("databases/postgresql/instances/%d", databaseID)
Expand Down Expand Up @@ -742,33 +678,6 @@ func (c *Client) GetPostgresDatabaseSSL(ctx context.Context, databaseID int) (*P
return doGETRequest[PostgresDatabaseSSL](ctx, c, e)
}

// GetPostgresDatabaseBackup returns a specific Postgres Database Backup with the given ids
//
// Deprecated: GetPostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) GetPostgresDatabaseBackup(ctx context.Context, databaseID int, backupID int) (*PostgresDatabaseBackup, error) {
e := formatAPIPath("databases/postgresql/instances/%d/backups/%d", databaseID, backupID)
return doGETRequest[PostgresDatabaseBackup](ctx, c, e)
}

// RestorePostgresDatabaseBackup returns the given Postgres Database with the given Backup
//
// Deprecated: RestorePostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) RestorePostgresDatabaseBackup(ctx context.Context, databaseID int, backupID int) error {
e := formatAPIPath("databases/postgresql/instances/%d/backups/%d/restore", databaseID, backupID)
return doPOSTRequestNoRequestResponseBody(ctx, c, e)
}

// CreatePostgresDatabaseBackup creates a snapshot for the given Postgres database
//
// Deprecated: CreatePostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (c *Client) CreatePostgresDatabaseBackup(ctx context.Context, databaseID int, opts PostgresBackupCreateOptions) error {
e := formatAPIPath("databases/postgresql/instances/%d/backups", databaseID)
return doPOSTRequestNoResponseBody(ctx, c, e, opts)
}

// SuspendPostgresDatabase suspends a PostgreSQL Managed Database, releasing idle resources and keeping only necessary data.
// All service data is lost if there are no backups available.
func (c *Client) SuspendPostgresDatabase(ctx context.Context, databaseID int) error {
Expand Down
60 changes: 0 additions & 60 deletions waitfor.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,66 +489,6 @@ func (client Client) WaitForImageRegionStatus(ctx context.Context, imageID, regi
}
}

// WaitForMySQLDatabaseBackup waits for the backup with the given label to be available.
//
// Deprecated: WaitForMySQLDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (client Client) WaitForMySQLDatabaseBackup(ctx context.Context, dbID int, label string, timeoutSeconds int) (*MySQLDatabaseBackup, error) {
ctx, cancel := context.WithTimeout(ctx, time.Duration(timeoutSeconds)*time.Second)
defer cancel()

ticker := time.NewTicker(client.pollInterval)
defer ticker.Stop()

for {
select {
case <-ticker.C:
backups, err := client.ListMySQLDatabaseBackups(ctx, dbID, nil)
if err != nil {
return nil, err
}

for _, backup := range backups {
if backup.Label == label {
return &backup, nil
}
}
case <-ctx.Done():
return nil, fmt.Errorf("failed to wait for backup %s: %w", label, ctx.Err())
}
}
}

// WaitForPostgresDatabaseBackup waits for the backup with the given label to be available.
//
// Deprecated: WaitForPostgresDatabaseBackup is a deprecated method, as the backup endpoints are no longer supported in DBaaS V2.
// In DBaaS V2, databases can be backed up via database forking.
func (client Client) WaitForPostgresDatabaseBackup(ctx context.Context, dbID int, label string, timeoutSeconds int) (*PostgresDatabaseBackup, error) {
ctx, cancel := context.WithTimeout(ctx, time.Duration(timeoutSeconds)*time.Second)
defer cancel()

ticker := time.NewTicker(client.pollInterval)
defer ticker.Stop()

for {
select {
case <-ticker.C:
backups, err := client.ListPostgresDatabaseBackups(ctx, dbID, nil)
if err != nil {
return nil, err
}

for _, backup := range backups {
if backup.Label == label {
return &backup, nil
}
}
case <-ctx.Done():
return nil, fmt.Errorf("failed to wait for backup %s: %w", label, ctx.Err())
}
}
}

type databaseStatusFunc func(ctx context.Context, client Client, dbID int) (DatabaseStatus, error)

var databaseStatusHandlers = map[DatabaseEngineType]databaseStatusFunc{
Expand Down