Skip to content

Commit

Permalink
Merge pull request #165 from civo/feat/dbaas-restore
Browse files Browse the repository at this point in the history
Add support for restore postgres db
  • Loading branch information
vishalanarase authored Sep 1, 2023
2 parents 0e33442 + 87ac979 commit 49d3099
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ type SupportedSoftwareVersion struct {
Default bool `json:"default"`
}

// RestoreDatabaseRequest is the request body for restoring a database
type RestoreDatabaseRequest struct {
Software string `json:"software"`
NetworkID string `json:"network_id"`
Backup string `json:"backup"`
Region string `json:"region"`
}

// ListDatabases returns a list of all databases
func (c *Client) ListDatabases() (*PaginatedDatabases, error) {
resp, err := c.SendGetRequest("/v2/databases")
Expand Down Expand Up @@ -177,3 +185,13 @@ func (c *Client) ListDBVersions() (map[string][]SupportedSoftwareVersion, error)

return versions, nil
}

// RestoreDatabase restore a database
func (c *Client) RestoreDatabase(id string, v *RestoreDatabaseRequest) (*SimpleResponse, error) {
resp, err := c.SendPostRequest(fmt.Sprintf("/v2/databases/%s/restore", id), v)
if err != nil {
return nil, decodeError(err)
}

return c.DecodeSimpleResponse(resp)
}

0 comments on commit 49d3099

Please sign in to comment.