struct opts -> interface opts (object storage)
diff --git a/openstack/objectstorage/v1/accounts/requests.go b/openstack/objectstorage/v1/accounts/requests.go
index b30439c..55fcb05 100644
--- a/openstack/objectstorage/v1/accounts/requests.go
+++ b/openstack/objectstorage/v1/accounts/requests.go
@@ -5,20 +5,33 @@
"github.com/rackspace/gophercloud"
)
-// GetOpts is a structure that contains parameters for getting an account's metadata.
+// GetOptsBuilder allows extensions to add additional headers to the Get
+// request.
+type GetOptsBuilder interface {
+ ToAccountGetMap() (map[string]string, error)
+}
+
+// GetOpts is a structure that contains parameters for getting an account's
+// metadata.
type GetOpts struct {
Newest bool `h:"X-Newest"`
}
-// Get is a function that retrieves an account's metadata. To extract just the custom
-// metadata, call the ExtractMetadata method on the GetResult. To extract all the headers that are
-// returned (including the metadata), call the ExtractHeaders method on the GetResult.
-func Get(c *gophercloud.ServiceClient, opts *GetOpts) GetResult {
+// ToAccountGetMap formats a GetOpts into a map[string]string of headers.
+func (opts GetOpts) ToAccountGetMap() (map[string]string, error) {
+ return gophercloud.BuildHeaders(opts)
+}
+
+// Get is a function that retrieves an account's metadata. To extract just the
+// custom metadata, call the ExtractMetadata method on the GetResult. To extract
+// all the headers that are returned (including the metadata), call the
+// ExtractHeaders method on the GetResult.
+func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) GetResult {
var res GetResult
h := c.Provider.AuthenticatedHeaders()
if opts != nil {
- headers, err := gophercloud.BuildHeaders(opts)
+ headers, err := opts.ToAccountGetMap()
if err != nil {
res.Err = err
return res
@@ -38,8 +51,14 @@
return res
}
-// UpdateOpts is a structure that contains parameters for updating, creating, or deleting an
-// account's metadata.
+// UpdateOptsBuilder allows extensions to add additional headers to the Update
+// request.
+type UpdateOptsBuilder interface {
+ ToAccountUpdateMap() (map[string]string, error)
+}
+
+// UpdateOpts is a structure that contains parameters for updating, creating, or
+// deleting an account's metadata.
type UpdateOpts struct {
Metadata map[string]string
ContentType string `h:"Content-Type"`
@@ -48,14 +67,27 @@
TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"`
}
-// Update is a function that creates, updates, or deletes an account's metadata. To extract the
-// headers returned, call the ExtractHeaders method on the UpdateResult.
-func Update(c *gophercloud.ServiceClient, opts *UpdateOpts) UpdateResult {
+// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers.
+func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) {
+ headers, err := gophercloud.BuildHeaders(opts)
+ if err != nil {
+ return nil, err
+ }
+ for k, v := range opts.Metadata {
+ headers["X-Account-Meta-"+k] = v
+ }
+ return headers, err
+}
+
+// Update is a function that creates, updates, or deletes an account's metadata.
+// To extract the headers returned, call the ExtractHeaders method on the
+// UpdateResult.
+func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) UpdateResult {
var res UpdateResult
h := c.Provider.AuthenticatedHeaders()
if opts != nil {
- headers, err := gophercloud.BuildHeaders(opts)
+ headers, err := opts.ToAccountUpdateMap()
if err != nil {
res.Err = err
return res
@@ -63,10 +95,6 @@
for k, v := range headers {
h[k] = v
}
-
- for k, v := range opts.Metadata {
- h["X-Account-Meta-"+k] = v
- }
}
resp, err := perigee.Request("POST", updateURL(c), perigee.Options{