blob: a6d51fb195f32ec3eab032e8d5b69f47f3ffe5cd [file] [log] [blame]
Jon Perrittee6074f2014-04-30 18:42:32 -05001package volumes
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) (Volume, error) {
9 var v Volume
10 h, err := c.GetHeaders()
11 if err != nil {
12 return v, err
13 }
Jon Perritt3baca062014-04-30 23:33:04 -050014 url := c.GetVolumesURL()
Jon Perrittee6074f2014-04-30 18:42:32 -050015 _, err = perigee.Request("POST", url, perigee.Options{
Jon Perritte77b9b22014-05-01 13:11:12 -050016 Results: &struct {
17 Volume *Volume `json:"volume"`
18 }{&v},
Jon Perrittee6074f2014-04-30 18:42:32 -050019 ReqBody: map[string]interface{}{
20 "volume": opts,
21 },
22 MoreHeaders: h,
23 })
24 return v, err
25}
Jon Perritte77b9b22014-05-01 13:11:12 -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.GetVolumeURL(opts["id"])
33 _, err = perigee.Request("DELETE", url, perigee.Options{
34 MoreHeaders: h,
35 })
36 return err
37}