/
database_snapshot.go
51 lines (46 loc) · 1.54 KB
/
database_snapshot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package brightbox
import (
"time"
)
// DatabaseSnapshot represents a snapshot of a database server.
// https://api.gb1.brightbox.com/1.0/#database_snapshot
type DatabaseSnapshot struct {
Id string
Name string
Description string
Status string
Account Account
DatabaseEngine string `json:"database_engine"`
DatabaseVersion string `json:"database_version"`
Size int
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
Locked bool
}
// DatabaseSnapshots retrieves a list of all database snapshot
func (c *Client) DatabaseSnapshots() ([]DatabaseSnapshot, error) {
var database_snapshot []DatabaseSnapshot
_, err := c.MakeApiRequest("GET", "/1.0/database_snapshots", nil, &database_snapshot)
if err != nil {
return nil, err
}
return database_snapshot, err
}
// DatabaseSnapshot retrieves a detailed view of one database snapshot
func (c *Client) DatabaseSnapshot(identifier string) (*DatabaseSnapshot, error) {
database_snapshot := new(DatabaseSnapshot)
_, err := c.MakeApiRequest("GET", "/1.0/database_snapshots/"+identifier, nil, database_snapshot)
if err != nil {
return nil, err
}
return database_snapshot, err
}
// DestroyDatabaseSnapshot issues a request to destroy the database snapshot
func (c *Client) DestroyDatabaseSnapshot(identifier string) error {
_, err := c.MakeApiRequest("DELETE", "/1.0/database_snapshots/"+identifier, nil, nil)
if err != nil {
return err
}
return nil
}