blob: ae3de267daa999a7e7873dc2f0f06810e9fc10f7 [file] [log] [blame]
Jon Perritt0e28b112014-10-14 20:49:31 -05001package accounts
2
3import (
4 "github.com/rackspace/gophercloud"
5 os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts"
6)
7
8// Get is a function that retrieves an account's metadata. To extract just the
9// custom metadata, call the ExtractMetadata method on the GetResult. To extract
10// all the headers that are returned (including the metadata), call the
11// ExtractHeaders method on the GetResult.
12func Get(c *gophercloud.ServiceClient) os.GetResult {
13 return os.Get(c, nil)
14}
15
16// UpdateOpts is a structure that contains parameters for updating, creating, or
17// deleting an account's metadata.
18type UpdateOpts struct {
19 Metadata map[string]string
20 TempURLKey string `h:"X-Account-Meta-Temp-URL-Key"`
21 TempURLKey2 string `h:"X-Account-Meta-Temp-URL-Key-2"`
22}
23
24// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers.
25func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) {
26 headers, err := gophercloud.BuildHeaders(opts)
27 if err != nil {
28 return nil, err
29 }
30 for k, v := range opts.Metadata {
31 headers["X-Account-Meta-"+k] = v
32 }
33 return headers, err
34}
35
36func Update(c *gophercloud.ServiceClient, opts os.UpdateOptsBuilder) os.UpdateResult {
37 return os.Update(c, opts)
38}