aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil')
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go18
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go20
-rw-r--r--vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go1
3 files changed, 30 insertions, 9 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go
index 7091b45..07764c8 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/build.go
@@ -13,9 +13,13 @@ import (
13 "github.com/aws/aws-sdk-go/private/protocol" 13 "github.com/aws/aws-sdk-go/private/protocol"
14) 14)
15 15
16// BuildXML will serialize params into an xml.Encoder. 16// BuildXML will serialize params into an xml.Encoder. Error will be returned
17// Error will be returned if the serialization of any of the params or nested values fails. 17// if the serialization of any of the params or nested values fails.
18func BuildXML(params interface{}, e *xml.Encoder) error { 18func BuildXML(params interface{}, e *xml.Encoder) error {
19 return buildXML(params, e, false)
20}
21
22func buildXML(params interface{}, e *xml.Encoder, sorted bool) error {
19 b := xmlBuilder{encoder: e, namespaces: map[string]string{}} 23 b := xmlBuilder{encoder: e, namespaces: map[string]string{}}
20 root := NewXMLElement(xml.Name{}) 24 root := NewXMLElement(xml.Name{})
21 if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil { 25 if err := b.buildValue(reflect.ValueOf(params), root, ""); err != nil {
@@ -23,7 +27,7 @@ func BuildXML(params interface{}, e *xml.Encoder) error {
23 } 27 }
24 for _, c := range root.Children { 28 for _, c := range root.Children {
25 for _, v := range c { 29 for _, v := range c {
26 return StructToXML(e, v, false) 30 return StructToXML(e, v, sorted)
27 } 31 }
28 } 32 }
29 return nil 33 return nil
@@ -278,8 +282,12 @@ func (b *xmlBuilder) buildScalar(value reflect.Value, current *XMLNode, tag refl
278 case float32: 282 case float32:
279 str = strconv.FormatFloat(float64(converted), 'f', -1, 32) 283 str = strconv.FormatFloat(float64(converted), 'f', -1, 32)
280 case time.Time: 284 case time.Time:
281 const ISO8601UTC = "2006-01-02T15:04:05Z" 285 format := tag.Get("timestampFormat")
282 str = converted.UTC().Format(ISO8601UTC) 286 if len(format) == 0 {
287 format = protocol.ISO8601TimeFormatName
288 }
289
290 str = protocol.FormatTime(format, converted)
283 default: 291 default:
284 return fmt.Errorf("unsupported value for param %s: %v (%s)", 292 return fmt.Errorf("unsupported value for param %s: %v (%s)",
285 tag.Get("locationName"), value.Interface(), value.Type().Name()) 293 tag.Get("locationName"), value.Interface(), value.Type().Name())
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go
index 8758462..ff1ef68 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/unmarshal.go
@@ -9,6 +9,8 @@ import (
9 "strconv" 9 "strconv"
10 "strings" 10 "strings"
11 "time" 11 "time"
12
13 "github.com/aws/aws-sdk-go/private/protocol"
12) 14)
13 15
14// UnmarshalXML deserializes an xml.Decoder into the container v. V 16// UnmarshalXML deserializes an xml.Decoder into the container v. V
@@ -52,9 +54,15 @@ func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
52 if t == "" { 54 if t == "" {
53 switch rtype.Kind() { 55 switch rtype.Kind() {
54 case reflect.Struct: 56 case reflect.Struct:
55 t = "structure" 57 // also it can't be a time object
58 if _, ok := r.Interface().(*time.Time); !ok {
59 t = "structure"
60 }
56 case reflect.Slice: 61 case reflect.Slice:
57 t = "list" 62 // also it can't be a byte slice
63 if _, ok := r.Interface().([]byte); !ok {
64 t = "list"
65 }
58 case reflect.Map: 66 case reflect.Map:
59 t = "map" 67 t = "map"
60 } 68 }
@@ -247,8 +255,12 @@ func parseScalar(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
247 } 255 }
248 r.Set(reflect.ValueOf(&v)) 256 r.Set(reflect.ValueOf(&v))
249 case *time.Time: 257 case *time.Time:
250 const ISO8601UTC = "2006-01-02T15:04:05Z" 258 format := tag.Get("timestampFormat")
251 t, err := time.Parse(ISO8601UTC, node.Text) 259 if len(format) == 0 {
260 format = protocol.ISO8601TimeFormatName
261 }
262
263 t, err := protocol.ParseTime(format, node.Text)
252 if err != nil { 264 if err != nil {
253 return err 265 return err
254 } 266 }
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go
index 3e970b6..515ce15 100644
--- a/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil/xml_to_struct.go
@@ -29,6 +29,7 @@ func NewXMLElement(name xml.Name) *XMLNode {
29 29
30// AddChild adds child to the XMLNode. 30// AddChild adds child to the XMLNode.
31func (n *XMLNode) AddChild(child *XMLNode) { 31func (n *XMLNode) AddChild(child *XMLNode) {
32 child.parent = n
32 if _, ok := n.Children[child.Name.Local]; !ok { 33 if _, ok := n.Children[child.Name.Local]; !ok {
33 n.Children[child.Name.Local] = []*XMLNode{} 34 n.Children[child.Name.Local] = []*XMLNode{}
34 } 35 }