func (opts UpdateOpts) ToVolumeUpdateMap() (map[string]interface{}, error) {
	v := make(map[string]interface{})
	if opts.Description != "" {
		v["display_description"] = opts.Description
	}
	if opts.Metadata != nil {
		v["metadata"] = opts.Metadata
	}
	if opts.Name != "" {
		v["display_name"] = opts.Name
	}
	return map[string]interface{}{"volume": v}, nil
}
ToVolumeUpdateMap assembles a request body based on the contents of an
UpdateOpts.
package volumes
import (
	"fmt"
	"github.com/rackspace/gophercloud"
	"github.com/rackspace/gophercloud/pagination"
)
type CreateOptsBuilder interface {
	ToVolumeCreateMap() (map[string]interface{}, error)
}
type CreateOpts struct {
	Availability string
	Description string
	Metadata map[string]string
	Name string
	Size int
	SnapshotID, SourceVolID, ImageID string
	VolumeType string
}
func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error) {
	v := make(map[string]interface{})
	if opts.Size == 0 {
		return nil, fmt.Errorf("Required CreateOpts field 'Size' not set.")
	}
	v["size"] = opts.Size
	if opts.Availability != "" {
		v["availability_zone"] = opts.Availability
	}
	if opts.Description != "" {
		v["display_description"] = opts.Description
	}
	if opts.ImageID != "" {
		v["imageRef"] = opts.ImageID
	}
	if opts.Metadata != nil {
		v["metadata"] = opts.Metadata
	}
	if opts.Name != "" {
		v["display_name"] = opts.Name
	}
	if opts.SourceVolID != "" {
		v["source_volid"] = opts.SourceVolID
	}
	if opts.SnapshotID != "" {
		v["snapshot_id"] = opts.SnapshotID
	}
	if opts.VolumeType != "" {
		v["volume_type"] = opts.VolumeType
	}
	return map[string]interface{}{"volume": v}, nil
}
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
	var res CreateResult
	reqBody, err := opts.ToVolumeCreateMap()
	if err != nil {
		res.Err = err
		return res
	}
	_, res.Err = client.Request("POST", createURL(client), gophercloud.RequestOpts{
		OkCodes:      []int{200, 201},
		JSONBody:     &reqBody,
		JSONResponse: &res.Body,
	})
	return res
}
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
	var res DeleteResult
	_, res.Err = client.Request("DELETE", deleteURL(client, id), gophercloud.RequestOpts{
		OkCodes: []int{202, 204},
	})
	return res
}
func Get(client *gophercloud.ServiceClient, id string) GetResult {
	var res GetResult
	_, res.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
		JSONResponse: &res.Body,
		OkCodes:      []int{200},
	})
	return res
}
type ListOptsBuilder interface {
	ToVolumeListQuery() (string, error)
}
type ListOpts struct {
	AllTenants bool `q:"all_tenants"`
	Metadata map[string]string `q:"metadata"`
	Name string `q:"name"`
	Status string `q:"status"`
}
func (opts ListOpts) ToVolumeListQuery() (string, error) {
	q, err := gophercloud.BuildQueryString(opts)
	if err != nil {
		return "", err
	}
	return q.String(), nil
}
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
	url := listURL(client)
	if opts != nil {
		query, err := opts.ToVolumeListQuery()
		if err != nil {
			return pagination.Pager{Err: err}
		}
		url += query
	}
	createPage := func(r pagination.PageResult) pagination.Page {
		return ListResult{pagination.SinglePageBase(r)}
	}
	return pagination.NewPager(client, url, createPage)
}
type UpdateOptsBuilder interface {
	ToVolumeUpdateMap() (map[string]interface{}, error)
}
type UpdateOpts struct {
	Name string
	Description string
	Metadata map[string]string
}