Skip to content

Commit 49d3099

Browse files
Merge pull request #165 from civo/feat/dbaas-restore
Add support for restore postgres db
2 parents 0e33442 + 87ac979 commit 49d3099

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

database.go

+18
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ type SupportedSoftwareVersion struct {
5959
Default bool `json:"default"`
6060
}
6161

62+
// RestoreDatabaseRequest is the request body for restoring a database
63+
type RestoreDatabaseRequest struct {
64+
Software string `json:"software"`
65+
NetworkID string `json:"network_id"`
66+
Backup string `json:"backup"`
67+
Region string `json:"region"`
68+
}
69+
6270
// ListDatabases returns a list of all databases
6371
func (c *Client) ListDatabases() (*PaginatedDatabases, error) {
6472
resp, err := c.SendGetRequest("/v2/databases")
@@ -177,3 +185,13 @@ func (c *Client) ListDBVersions() (map[string][]SupportedSoftwareVersion, error)
177185

178186
return versions, nil
179187
}
188+
189+
// RestoreDatabase restore a database
190+
func (c *Client) RestoreDatabase(id string, v *RestoreDatabaseRequest) (*SimpleResponse, error) {
191+
resp, err := c.SendPostRequest(fmt.Sprintf("/v2/databases/%s/restore", id), v)
192+
if err != nil {
193+
return nil, decodeError(err)
194+
}
195+
196+
return c.DecodeSimpleResponse(resp)
197+
}

0 commit comments

Comments
 (0)