blob: 94739308fa6c90aeed357b7d7956c346e60b8f04 [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
Jon Perritt9856a342014-10-27 13:44:06 -050011// ExtractHeader method on the GetResult.
Jon Perritt0e28b112014-10-14 20:49:31 -050012func 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
Jon Perritt9856a342014-10-27 13:44:06 -050036// Update will update an account's metadata with the Metadata in the UpdateOptsBuilder.
Jon Perritt0e28b112014-10-14 20:49:31 -050037func Update(c *gophercloud.ServiceClient, opts os.UpdateOptsBuilder) os.UpdateResult {
38 return os.Update(c, opts)
39}