consistency updates; struct opts -> interface opts (networking, compute)
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
index f54432f..1bc0a14 100644
--- a/openstack/blockstorage/v1/snapshots/requests.go
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -72,7 +72,7 @@
_, res.Err = perigee.Request("POST", createURL(client), perigee.Options{
MoreHeaders: client.Provider.AuthenticatedHeaders(),
OkCodes: []int{200, 201},
- ReqBody: reqBody,
+ ReqBody: &reqBody,
Results: &res.Resp,
})
return res
@@ -102,7 +102,7 @@
// ListOptsBuilder allows extensions to add additional parameters to the List
// request.
type ListOptsBuilder interface {
- ToVolumeListParams() (string, error)
+ ToSnapshotListString() (string, error)
}
// ListOpts hold options for listing Snapshots. It is passed to the
@@ -113,8 +113,8 @@
VolumeID string `q:"volume_id"`
}
-// ToVolumeListParams formats a ListOpts into a query string.
-func (opts ListOpts) ToVolumeListParams() (string, error) {
+// ToSnapshotListString formats a ListOpts into a query string.
+func (opts ListOpts) ToSnapshotListString() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
@@ -127,7 +127,7 @@
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
url := listURL(client)
if opts != nil {
- query, err := opts.ToVolumeListParams()
+ query, err := opts.ToSnapshotListString()
if err != nil {
return pagination.Pager{Err: err}
}
@@ -180,7 +180,7 @@
_, res.Err = perigee.Request("PUT", updateMetadataURL(client, id), perigee.Options{
MoreHeaders: client.Provider.AuthenticatedHeaders(),
OkCodes: []int{200},
- ReqBody: reqBody,
+ ReqBody: &reqBody,
Results: &res.Resp,
})
return res
diff --git a/openstack/blockstorage/v1/volumes/requests.go b/openstack/blockstorage/v1/volumes/requests.go
index dc04732..f46b2b6 100644
--- a/openstack/blockstorage/v1/volumes/requests.go
+++ b/openstack/blockstorage/v1/volumes/requests.go
@@ -87,7 +87,7 @@
_, res.Err = perigee.Request("POST", createURL(client), perigee.Options{
MoreHeaders: client.Provider.AuthenticatedHeaders(),
- ReqBody: reqBody,
+ ReqBody: &reqBody,
Results: &res.Resp,
OkCodes: []int{200, 201},
})
@@ -118,7 +118,7 @@
// ListOptsBuilder allows extensions to add additional parameters to the List
// request.
type ListOptsBuilder interface {
- ToVolumeListParams() (string, error)
+ ToVolumeListString() (string, error)
}
// ListOpts holds options for listing Volumes. It is passed to the volumes.List
@@ -134,8 +134,8 @@
Status string `q:"status"`
}
-// ToVolumeListParams formats a ListOpts into a query string.
-func (opts ListOpts) ToVolumeListParams() (string, error) {
+// ToVolumeListString formats a ListOpts into a query string.
+func (opts ListOpts) ToVolumeListString() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
if err != nil {
return "", err
@@ -147,7 +147,7 @@
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
url := listURL(client)
if opts != nil {
- query, err := opts.ToVolumeListParams()
+ query, err := opts.ToVolumeListString()
if err != nil {
return pagination.Pager{Err: err}
}
@@ -197,7 +197,7 @@
// Update will update the Volume with provided information. To extract the updated
// Volume from the response, call the Extract method on the UpdateResult.
-func Update(client *gophercloud.ServiceClient, id string, opts *UpdateOpts) UpdateResult {
+func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult {
var res UpdateResult
reqBody, err := opts.ToVolumeUpdateMap()
@@ -209,7 +209,7 @@
_, res.Err = perigee.Request("PUT", updateURL(client, id), perigee.Options{
MoreHeaders: client.Provider.AuthenticatedHeaders(),
OkCodes: []int{200},
- ReqBody: reqBody,
+ ReqBody: &reqBody,
Results: &res.Resp,
})
return res
diff --git a/openstack/blockstorage/v1/volumetypes/requests.go b/openstack/blockstorage/v1/volumetypes/requests.go
index ff71de1..d4f880f 100644
--- a/openstack/blockstorage/v1/volumetypes/requests.go
+++ b/openstack/blockstorage/v1/volumetypes/requests.go
@@ -9,7 +9,7 @@
// CreateOptsBuilder allows extensions to add additional parameters to the
// Create request.
type CreateOptsBuilder interface {
- ToVolumeTypeCreateMap() map[string]interface{}
+ ToVolumeTypeCreateMap() (map[string]interface{}, error)
}
// CreateOpts are options for creating a volume type.
@@ -21,7 +21,7 @@
}
// ToVolumeTypeCreateMap casts a CreateOpts struct to a map.
-func (opts CreateOpts) ToVolumeTypeCreateMap() map[string]interface{} {
+func (opts CreateOpts) ToVolumeTypeCreateMap() (map[string]interface{}, error) {
vt := make(map[string]interface{})
if opts.ExtraSpecs != nil {
@@ -31,17 +31,24 @@
vt["name"] = opts.Name
}
- return map[string]interface{}{"volume_type": vt}
+ return map[string]interface{}{"volume_type": vt}, nil
}
// Create will create a new volume. To extract the created volume type object,
// call the Extract method on the CreateResult.
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
var res CreateResult
+
+ reqBody, err := opts.ToVolumeTypeCreateMap()
+ if err != nil {
+ res.Err = err
+ return res
+ }
+
_, res.Err = perigee.Request("POST", createURL(client), perigee.Options{
MoreHeaders: client.Provider.AuthenticatedHeaders(),
OkCodes: []int{200, 201},
- ReqBody: opts.ToVolumeTypeCreateMap(),
+ ReqBody: &reqBody,
Results: &res.Resp,
})
return res