blob: 90c2ec3975be6143f6e4602629ac5a0d48ed04fa [file] [log] [blame]
Jon Perritt687c7d02014-05-05 18:44:54 -05001package snapshots
2
3import (
4 "github.com/racker/perigee"
5 blockstorage "github.com/rackspace/gophercloud/openstack/blockstorage/v1"
6)
7
8func Create(c *blockstorage.Client, opts CreateOpts) (Snapshot, error) {
9 var ss Snapshot
10 h, err := c.GetHeaders()
11 if err != nil {
12 return ss, err
13 }
14 url := c.GetSnapshotsURL()
15 _, err = perigee.Request("POST", url, perigee.Options{
16 Results: &struct {
17 Snapshot *Snapshot `json:"snapshot"`
18 }{&ss},
19 ReqBody: map[string]interface{}{
20 "snapshot": opts,
21 },
22 MoreHeaders: h,
23 })
24 return ss, err
25}
Jon Perritt982c86d2014-05-05 21:13:54 -050026
27func Delete(c *blockstorage.Client, opts DeleteOpts) error {
28 h, err := c.GetHeaders()
29 if err != nil {
30 return err
31 }
32 url := c.GetSnapshotURL(opts["id"])
33 _, err = perigee.Request("DELETE", url, perigee.Options{
34 MoreHeaders: h,
35 })
36 return err
37}