Making account files more consistent
diff --git a/openstack/objectstorage/v1/accounts/accounts.go b/openstack/objectstorage/v1/accounts/accounts.go
deleted file mode 100644
index c460e45..0000000
--- a/openstack/objectstorage/v1/accounts/accounts.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package accounts
-
-import (
- "strings"
-)
-
-// UpdateOpts is a structure that contains parameters for updating, creating, or deleting an
-// account's metadata.
-type UpdateOpts struct {
- Metadata map[string]string
- Headers map[string]string
-}
-
-// GetOpts is a structure that contains parameters for getting an account's metadata.
-type GetOpts struct {
- Headers map[string]string
-}
-
-// ExtractMetadata is a function that takes a GetResult (of type *http.Response)
-// and returns the custom metatdata associated with the account.
-func ExtractMetadata(gr GetResult) map[string]string {
- metadata := make(map[string]string)
- for k, v := range gr.Header {
- if strings.HasPrefix(k, "X-Account-Meta-") {
- key := strings.TrimPrefix(k, "X-Account-Meta-")
- metadata[key] = v[0]
- }
- }
- return metadata
-}
diff --git a/openstack/objectstorage/v1/accounts/accounts_test.go b/openstack/objectstorage/v1/accounts/accounts_test.go
deleted file mode 100644
index 2c2a84a..0000000
--- a/openstack/objectstorage/v1/accounts/accounts_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package accounts
-
-import (
- "net/http"
- "reflect"
- "testing"
-)
-
-func TestExtractAccountMetadata(t *testing.T) {
- getResult := &http.Response{}
-
- expected := map[string]string{}
-
- actual := ExtractMetadata(getResult)
-
- if !reflect.DeepEqual(expected, actual) {
- t.Errorf("Expected: %+v\nActual:%+v", expected, actual)
- }
-}
diff --git a/openstack/objectstorage/v1/accounts/requests.go b/openstack/objectstorage/v1/accounts/requests.go
index c738573..2ba4744 100644
--- a/openstack/objectstorage/v1/accounts/requests.go
+++ b/openstack/objectstorage/v1/accounts/requests.go
@@ -1,14 +1,16 @@
package accounts
import (
- "net/http"
-
"github.com/racker/perigee"
"github.com/rackspace/gophercloud"
)
-// GetResult is a *http.Response that is returned from a call to the Get function.
-type GetResult *http.Response
+// UpdateOpts is a structure that contains parameters for updating, creating, or deleting an
+// account's metadata.
+type UpdateOpts struct {
+ Metadata map[string]string
+ Headers map[string]string
+}
// Update is a function that creates, updates, or deletes an account's metadata.
func Update(c *gophercloud.ServiceClient, opts UpdateOpts) error {
@@ -29,6 +31,11 @@
return err
}
+// GetOpts is a structure that contains parameters for getting an account's metadata.
+type GetOpts struct {
+ Headers map[string]string
+}
+
// Get is a function that retrieves an account's metadata. To extract just the custom
// metadata, pass the GetResult response to the ExtractMetadata function.
func Get(c *gophercloud.ServiceClient, opts GetOpts) (GetResult, error) {
diff --git a/openstack/objectstorage/v1/accounts/requests_test.go b/openstack/objectstorage/v1/accounts/requests_test.go
index 348f93e..ae9524f 100644
--- a/openstack/objectstorage/v1/accounts/requests_test.go
+++ b/openstack/objectstorage/v1/accounts/requests_test.go
@@ -2,6 +2,7 @@
import (
"net/http"
+ "reflect"
"testing"
"github.com/rackspace/gophercloud/testhelper"
@@ -42,3 +43,15 @@
t.Fatalf("Unable to get account metadata: %v", err)
}
}
+
+func TestExtractAccountMetadata(t *testing.T) {
+ getResult := &http.Response{}
+
+ expected := map[string]string{}
+
+ actual := ExtractMetadata(getResult)
+
+ if !reflect.DeepEqual(expected, actual) {
+ t.Errorf("Expected: %+v\nActual:%+v", expected, actual)
+ }
+}
diff --git a/openstack/objectstorage/v1/accounts/results.go b/openstack/objectstorage/v1/accounts/results.go
new file mode 100644
index 0000000..13a894b
--- /dev/null
+++ b/openstack/objectstorage/v1/accounts/results.go
@@ -0,0 +1,22 @@
+package accounts
+
+import (
+ "net/http"
+ "strings"
+)
+
+// GetResult is a *http.Response that is returned from a call to the Get function.
+type GetResult *http.Response
+
+// ExtractMetadata is a function that takes a GetResult (of type *http.Response)
+// and returns the custom metatdata associated with the account.
+func ExtractMetadata(gr GetResult) map[string]string {
+ metadata := make(map[string]string)
+ for k, v := range gr.Header {
+ if strings.HasPrefix(k, "X-Account-Meta-") {
+ key := strings.TrimPrefix(k, "X-Account-Meta-")
+ metadata[key] = v[0]
+ }
+ }
+ return metadata
+}