Skip to content

Commit

Permalink
Update dbaas structs to support mysql backup and restore
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Anarse <[email protected]>
  • Loading branch information
Vishal Anarse committed Jan 31, 2024
1 parent 21e802a commit d730e0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
1 change: 1 addition & 0 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type SupportedSoftwareVersion struct {

// RestoreDatabaseRequest is the request body for restoring a database
type RestoreDatabaseRequest struct {
Name string `json:"name"`
Software string `json:"software"`
NetworkID string `json:"network_id"`
Backup string `json:"backup"`
Expand Down
39 changes: 19 additions & 20 deletions database_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@ import (
"fmt"
)

// Scheduled represents scheduled backups
type Scheduled struct {
Name string `json:"name,omitempty"`
Schedule string `json:"schedule,omitempty"`
Count int32 `json:"count,omitempty"`
Backups []string `json:"backups,omitempty"`
}

// Manual represents manual backups
type Manual struct {
Backup string `json:"backup,omitempty"`
}

// DatabaseBackup represents a backup
type DatabaseBackup struct {
DatabaseName string `json:"database_name"`
DatabaseID string `json:"database_id"`
Software string `json:"software"`
Scheduled *Scheduled `json:"scheduled,omitempty"`
Manual []Manual `json:"manual,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Software string `json:"software,omitempty"`
Status string `json:"status,omitempty"`
Schedule string `json:"schedule,omitempty"`
DatabaseName string `json:"database_name,omitempty"`
DatabaseID string `json:"database_id,omitempty"`
Backup string `json:"backup,omitempty"`
IsScheduled bool `json:"is_scheduled,omitempty"`
}

// PaginatedDatabases is the structure for list response from DB endpoint

Check failure on line 22 in database_backup.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, ubuntu-latest)

comment on exported type PaginatedDatabaseBackup should be of the form "PaginatedDatabaseBackup ..." (with optional leading article)

Check failure on line 22 in database_backup.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, ubuntu-latest)

comment on exported type PaginatedDatabaseBackup should be of the form "PaginatedDatabaseBackup ..." (with optional leading article)

Check failure on line 22 in database_backup.go

View workflow job for this annotation

GitHub Actions / test (1.18.x, ubuntu-latest)

comment on exported type PaginatedDatabaseBackup should be of the form "PaginatedDatabaseBackup ..." (with optional leading article)
type PaginatedDatabaseBackup struct {
Page int `json:"page"`
PerPage int `json:"per_page"`
Pages int `json:"pages"`
Items []DatabaseBackup `json:"items"`
}

// DatabaseBackupCreateRequest represents a backup create request
Expand All @@ -46,13 +45,13 @@ type DatabaseBackupUpdateRequest struct {
}

// ListDatabaseBackup lists backups for database
func (c *Client) ListDatabaseBackup(did string) (*DatabaseBackup, error) {
func (c *Client) ListDatabaseBackup(did string) (*PaginatedDatabaseBackup, error) {
resp, err := c.SendGetRequest(fmt.Sprintf("/v2/databases/%s/backups", did))
if err != nil {
return nil, decodeError(err)
}

back := &DatabaseBackup{}
back := &PaginatedDatabaseBackup{}
if err := json.NewDecoder(bytes.NewReader(resp)).Decode(&back); err != nil {
return nil, decodeError(err)
}
Expand Down

0 comments on commit d730e0f

Please sign in to comment.