Skip to content

Commit

Permalink
service: Expose RespMetadata member on errors (#3217)
Browse files Browse the repository at this point in the history
  • Loading branch information
skmcgrail committed Mar 24, 2020
1 parent 2681c9b commit abca4e3
Show file tree
Hide file tree
Showing 211 changed files with 11,790 additions and 11,772 deletions.
20 changes: 10 additions & 10 deletions private/model/api/codegentest/service/restjsonservice/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions private/model/api/codegentest/service/restxmlservice/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions private/model/api/codegentest/service/rpcservice/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion private/model/api/eventstream_tmpl_readertests.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (c *loopReader) Read(p []byte) (int, error) {
{{ define "set event type" }}
&{{ $.ShapeName }}{
{{- if $.Exception }}
respMetadata: protocol.ResponseMetadata{
RespMetadata: protocol.ResponseMetadata{
StatusCode: 200,
},
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion private/model/api/eventstream_tmpl_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func valueForType(s *Shape, visited []string) string {
w := bytes.NewBuffer(nil)
fmt.Fprintf(w, "&%s{\n", s.ShapeName)
if s.Exception {
fmt.Fprintf(w, `respMetadata: protocol.ResponseMetadata{
fmt.Fprintf(w, `RespMetadata: protocol.ResponseMetadata{
StatusCode: 200,
},
`)
Expand Down
3 changes: 2 additions & 1 deletion private/model/api/passes.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ func exceptionCollides(name string) bool {
"String",
"GoString",
"RequestID",
"StatusCode":
"StatusCode",
"RespMetadata":
return true
}
return false
Expand Down
8 changes: 4 additions & 4 deletions private/model/api/shape.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ type {{ $.ShapeName }} struct {
{{- if $.Exception }}
{{- $_ := $.API.AddSDKImport "private/protocol" }}
respMetadata protocol.ResponseMetadata
RespMetadata protocol.ResponseMetadata` + "`json:\"-\" xml:\"-\"`" + `
{{- end }}
{{- if $.OutputEventStreamAPI }}
Expand Down Expand Up @@ -809,7 +809,7 @@ var exceptionShapeMethodTmpl = template.Must(
{{/* TODO allow service custom input to be used */}}
func newError{{ $.ShapeName }}(v protocol.ResponseMetadata) error {
return &{{ $.ShapeName }}{
respMetadata: v,
RespMetadata: v,
}
}
Expand Down Expand Up @@ -843,12 +843,12 @@ func (s {{ $.ShapeName }}) Error() string {
// Status code returns the HTTP status code for the request's response error.
func (s {{ $.ShapeName }}) StatusCode() int {
return s.respMetadata.StatusCode
return s.RespMetadata.StatusCode
}
// RequestID returns the service's response RequestID for request.
func (s {{ $.ShapeName }}) RequestID() string {
return s.respMetadata.RequestID
return s.RespMetadata.RequestID
}
`))

Expand Down
9 changes: 9 additions & 0 deletions private/protocol/xml/xmlutil/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"reflect"
"sort"
"strconv"
"strings"
"time"

"github.com/aws/aws-sdk-go/private/protocol"
Expand Down Expand Up @@ -60,6 +61,14 @@ func (b *xmlBuilder) buildValue(value reflect.Value, current *XMLNode, tag refle
return nil
}

xml := tag.Get("xml")
if len(xml) != 0 {
name := strings.SplitAfterN(xml, ",", 2)[0]
if name == "-" {
return nil
}
}

t := tag.Get("type")
if t == "" {
switch value.Kind() {
Expand Down
8 changes: 8 additions & 0 deletions private/protocol/xml/xmlutil/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ func UnmarshalXML(v interface{}, d *xml.Decoder, wrapper string) error {
// parse deserializes any value from the XMLNode. The type tag is used to infer the type, or reflect
// will be used to determine the type from r.
func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
xml := tag.Get("xml")
if len(xml) != 0 {
name := strings.SplitAfterN(xml, ",", 2)[0]
if name == "-" {
return nil
}
}

rtype := r.Type()
if rtype.Kind() == reflect.Ptr {
rtype = rtype.Elem() // check kind of actual element type
Expand Down
Loading

0 comments on commit abca4e3

Please sign in to comment.