rename snapshots.go; start rewrite of create snapshot
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
new file mode 100644
index 0000000..b13fa46
--- /dev/null
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -0,0 +1,56 @@
+package snapshots
+
+import (
+ "github.com/racker/perigee"
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/openstack/utils"
+)
+
+type CreateOpts struct {
+ Description string
+ Force bool
+ Metadata map[string]interface{}
+ Name string
+ VolumeID string
+}
+
+func Create(client *gophercloud.ServiceClient, opts CreateOpts) (*Snapshot, error) {
+ type snapshot struct {
+ Description *string `json:"display_description,omitempty"`
+ Force *bool `json:"force,omitempty"`
+ Metadata map[string]interface{} `json:"metadata,omitempty"`
+ Name *string `json:"display_name,omitempty"`
+ VolumeID *string `json:"volume_id,omitempty"`
+ }
+
+ type request struct {
+ Snapshot snapshot `json:"snapshot"`
+ }
+
+ reqBody := request{
+ Snapshot: snapshot{},
+ }
+
+ reqBody.Snapshot.Description = utils.MaybeString(opts.Description)
+ reqBody.Snapshot.Force = utils.MaybeString(opts.Force)
+ reqBody.Snapshot.Name = utils.MaybeString(opts.Name)
+ reqBody.Snapshot.VolumeID = utils.MaybeString(opts.VolumeID)
+
+ type response struct {
+ Snapshot Snapshot `json:"snapshot"`
+ }
+
+ var respBody response
+
+ _, err := perigee.Request("POST", snapshotsURL(client), perigee.Options{
+ MoreHeaders: client.Provider.AuthenticatedHeaders(),
+ OkCodes: []int{201},
+ ReqBody: &reqBody,
+ Results: &respBody,
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ return &respBody.Snapshot, nil
+}
diff --git a/openstack/blockstorage/v1/snapshots/requests.go.bak b/openstack/blockstorage/v1/snapshots/requests.go.bak
deleted file mode 100644
index 92008c5..0000000
--- a/openstack/blockstorage/v1/snapshots/requests.go.bak
+++ /dev/null
@@ -1,74 +0,0 @@
-package snapshots
-
-import (
- "github.com/racker/perigee"
- blockstorage "github.com/rackspace/gophercloud/openstack/blockstorage/v1"
-)
-
-func Create(c *blockstorage.Client, opts CreateOpts) (Snapshot, error) {
- var ss Snapshot
- h, err := c.GetHeaders()
- if err != nil {
- return ss, err
- }
- url := c.GetSnapshotsURL()
- _, err = perigee.Request("POST", url, perigee.Options{
- Results: &struct {
- Snapshot *Snapshot `json:"snapshot"`
- }{&ss},
- ReqBody: map[string]interface{}{
- "snapshot": opts,
- },
- MoreHeaders: h,
- })
- return ss, err
-}
-
-func List(c *blockstorage.Client, opts ListOpts) ([]Snapshot, error) {
- var ss []Snapshot
- var url string
- h, err := c.GetHeaders()
- if err != nil {
- return ss, err
- }
- if full := opts.Full; full {
- url = c.GetSnapshotsURL()
- } else {
- url = c.GetSnapshotURL("detail")
- }
- _, err = perigee.Request("GET", url, perigee.Options{
- Results: &struct {
- Snapshot *[]Snapshot `json:"snapshots"`
- }{&ss},
- MoreHeaders: h,
- })
- return ss, err
-}
-
-func Get(c *blockstorage.Client, opts GetOpts) (Snapshot, error) {
- var ss Snapshot
- h, err := c.GetHeaders()
- if err != nil {
- return ss, err
- }
- url := c.GetSnapshotURL(opts["id"])
- _, err = perigee.Request("GET", url, perigee.Options{
- Results: &struct {
- Snapshot *Snapshot `json:"snapshot"`
- }{&ss},
- MoreHeaders: h,
- })
- return ss, err
-}
-
-func Delete(c *blockstorage.Client, opts DeleteOpts) error {
- h, err := c.GetHeaders()
- if err != nil {
- return err
- }
- url := c.GetSnapshotURL(opts["id"])
- _, err = perigee.Request("DELETE", url, perigee.Options{
- MoreHeaders: h,
- })
- return err
-}
diff --git a/openstack/blockstorage/v1/snapshots/results.go b/openstack/blockstorage/v1/snapshots/results.go
new file mode 100644
index 0000000..db59b8e
--- /dev/null
+++ b/openstack/blockstorage/v1/snapshots/results.go
@@ -0,0 +1,12 @@
+package snapshots
+
+type Snapshot struct {
+ CreatedAt string
+ Description string
+ ID string
+ Metadata map[string]interface{}
+ Name string
+ Size int
+ Status string
+ VolumeID string
+}
diff --git a/openstack/blockstorage/v1/snapshots/snapshots.go b/openstack/blockstorage/v1/snapshots/snapshots.go
deleted file mode 100644
index 836ba82..0000000
--- a/openstack/blockstorage/v1/snapshots/snapshots.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package snapshots
-
-type Snapshot struct {
- Status string
- Display_name string
- Created_at string
- Display_description string
- Volume_id string
- Metadata map[string]string
- Id string
- Size int
-}
-
-type CreateOpts map[string]interface{}
-type ListOpts struct {
- Full bool
-}
-type GetOpts map[string]string
-type DeleteOpts map[string]string