Jon Perritt | 0e28b11 | 2014-10-14 20:49:31 -0500 | [diff] [blame] | 1 | package accounts |
| 2 | |
| 3 | import ( |
| 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 Perritt | 9856a34 | 2014-10-27 13:44:06 -0500 | [diff] [blame] | 11 | // ExtractHeader method on the GetResult. |
Jon Perritt | 0e28b11 | 2014-10-14 20:49:31 -0500 | [diff] [blame] | 12 | func 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. |
| 18 | type 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. |
| 25 | func (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 Perritt | 9856a34 | 2014-10-27 13:44:06 -0500 | [diff] [blame] | 36 | // Update will update an account's metadata with the Metadata in the UpdateOptsBuilder. |
Jon Perritt | 0e28b11 | 2014-10-14 20:49:31 -0500 | [diff] [blame] | 37 | func Update(c *gophercloud.ServiceClient, opts os.UpdateOptsBuilder) os.UpdateResult { |
| 38 | return os.Update(c, opts) |
| 39 | } |