Jon Perritt | 687c7d0 | 2014-05-05 18:44:54 -0500 | [diff] [blame] | 1 | package snapshots |
| 2 | |
| 3 | import ( |
| 4 | "github.com/racker/perigee" |
| 5 | blockstorage "github.com/rackspace/gophercloud/openstack/blockstorage/v1" |
| 6 | ) |
| 7 | |
| 8 | func 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 Perritt | 982c86d | 2014-05-05 21:13:54 -0500 | [diff] [blame^] | 26 | |
| 27 | func 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 | } |