blob: c460e455d96bdfdb6cb629469db4be55c00f4c82 [file] [log] [blame]
Jon Perritt816d2a02014-03-11 20:49:46 -05001package accounts
2
3import (
4 "strings"
5)
6
Jon Perrittbef727e2014-05-12 22:41:55 -05007// UpdateOpts is a structure that contains parameters for updating, creating, or deleting an
8// account's metadata.
Jon Perritt816d2a02014-03-11 20:49:46 -05009type UpdateOpts struct {
10 Metadata map[string]string
11 Headers map[string]string
12}
13
Jon Perrittbef727e2014-05-12 22:41:55 -050014// GetOpts is a structure that contains parameters for getting an account's metadata.
Jon Perritt816d2a02014-03-11 20:49:46 -050015type GetOpts struct {
16 Headers map[string]string
17}
18
Jon Perritteb575642014-04-24 15:16:31 -050019// ExtractMetadata is a function that takes a GetResult (of type *http.Response)
Jon Perritt816d2a02014-03-11 20:49:46 -050020// and returns the custom metatdata associated with the account.
Jon Perritteb575642014-04-24 15:16:31 -050021func ExtractMetadata(gr GetResult) map[string]string {
Jon Perritt816d2a02014-03-11 20:49:46 -050022 metadata := make(map[string]string)
Jon Perritteb575642014-04-24 15:16:31 -050023 for k, v := range gr.Header {
Jon Perritt816d2a02014-03-11 20:49:46 -050024 if strings.HasPrefix(k, "X-Account-Meta-") {
25 key := strings.TrimPrefix(k, "X-Account-Meta-")
26 metadata[key] = v[0]
27 }
28 }
29 return metadata
30}