Jon Perritt | ee6074f | 2014-04-30 18:42:32 -0500 | [diff] [blame] | 1 | package volumes |
| 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) (Volume, error) { |
| 9 | var v Volume |
| 10 | h, err := c.GetHeaders() |
| 11 | if err != nil { |
| 12 | return v, err |
| 13 | } |
Jon Perritt | 3baca06 | 2014-04-30 23:33:04 -0500 | [diff] [blame] | 14 | url := c.GetVolumesURL() |
Jon Perritt | ee6074f | 2014-04-30 18:42:32 -0500 | [diff] [blame] | 15 | _, err = perigee.Request("POST", url, perigee.Options{ |
Jon Perritt | e77b9b2 | 2014-05-01 13:11:12 -0500 | [diff] [blame^] | 16 | Results: &struct { |
| 17 | Volume *Volume `json:"volume"` |
| 18 | }{&v}, |
Jon Perritt | ee6074f | 2014-04-30 18:42:32 -0500 | [diff] [blame] | 19 | ReqBody: map[string]interface{}{ |
| 20 | "volume": opts, |
| 21 | }, |
| 22 | MoreHeaders: h, |
| 23 | }) |
| 24 | return v, err |
| 25 | } |
Jon Perritt | e77b9b2 | 2014-05-01 13:11:12 -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.GetVolumeURL(opts["id"]) |
| 33 | _, err = perigee.Request("DELETE", url, perigee.Options{ |
| 34 | MoreHeaders: h, |
| 35 | }) |
| 36 | return err |
| 37 | } |