diff --git a/internal/protocoltest/awsrestjson/api_op_HttpPrefixHeadersResponse.go b/internal/protocoltest/awsrestjson/api_op_HttpPrefixHeadersResponse.go new file mode 100644 index 00000000000..64e65f1750e --- /dev/null +++ b/internal/protocoltest/awsrestjson/api_op_HttpPrefixHeadersResponse.go @@ -0,0 +1,73 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awsrestjson + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// Clients that perform this test extract all headers from the response. +func (c *Client) HttpPrefixHeadersResponse(ctx context.Context, params *HttpPrefixHeadersResponseInput, optFns ...func(*Options)) (*HttpPrefixHeadersResponseOutput, error) { + stack := middleware.NewStack("HttpPrefixHeadersResponse", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsRestjson1_serdeOpHttpPrefixHeadersResponseMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + retry.AddRetryMiddlewares(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opHttpPrefixHeadersResponse(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "HttpPrefixHeadersResponse", + Err: err, + } + } + out := result.(*HttpPrefixHeadersResponseOutput) + out.ResultMetadata = metadata + return out, nil +} + +type HttpPrefixHeadersResponseInput struct { +} + +type HttpPrefixHeadersResponseOutput struct { + PrefixHeaders map[string]*string + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsRestjson1_serdeOpHttpPrefixHeadersResponseMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsRestjson1_serializeOpHttpPrefixHeadersResponse{}, middleware.After) + stack.Deserialize.Add(&awsRestjson1_deserializeOpHttpPrefixHeadersResponse{}, middleware.After) +} + +func newServiceMetadataMiddleware_opHttpPrefixHeadersResponse(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "Rest Json Protocol", + ServiceID: "restjsonprotocol", + EndpointPrefix: "restjsonprotocol", + OperationName: "HttpPrefixHeadersResponse", + } +} diff --git a/internal/protocoltest/awsrestjson/api_op_HttpPrefixHeadersResponse_test.go b/internal/protocoltest/awsrestjson/api_op_HttpPrefixHeadersResponse_test.go new file mode 100644 index 00000000000..931ae9c8e7e --- /dev/null +++ b/internal/protocoltest/awsrestjson/api_op_HttpPrefixHeadersResponse_test.go @@ -0,0 +1,96 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awsrestjson + +import ( + "bytes" + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithyrand "github.com/awslabs/smithy-go/rand" + smithytesting "github.com/awslabs/smithy-go/testing" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_HttpPrefixHeadersResponse_awsRestjson1Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectResult *HttpPrefixHeadersResponseOutput + }{ + // (de)serializes all response headers + "HttpPrefixHeadersResponse": { + StatusCode: 200, + Header: http.Header{ + "Hello": []string{"Hello"}, + "X-Foo": []string{"Foo"}, + }, + Body: []byte(``), + ExpectResult: &HttpPrefixHeadersResponseOutput{ + PrefixHeaders: map[string]*string{ + "X-Foo": ptr.String("Foo"), + "Hello": ptr.String("Hello"), + }, + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + IdempotencyTokenProvider: smithyrand.NewUUIDIdempotencyToken(&smithytesting.ByteLoop{}), + Region: "us-west-2", + }) + var params HttpPrefixHeadersResponseInput + result, err := client.HttpPrefixHeadersResponse(context.Background(), ¶ms) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if err := smithytesting.CompareValues(c.ExpectResult, result, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectResult value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/awsrestjson/api_op_JsonUnions.go b/internal/protocoltest/awsrestjson/api_op_JsonUnions.go new file mode 100644 index 00000000000..65cf05bb82b --- /dev/null +++ b/internal/protocoltest/awsrestjson/api_op_JsonUnions.go @@ -0,0 +1,79 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awsrestjson + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/awsrestjson/types" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// This operation uses unions for inputs and outputs. +func (c *Client) JsonUnions(ctx context.Context, params *JsonUnionsInput, optFns ...func(*Options)) (*JsonUnionsOutput, error) { + stack := middleware.NewStack("JsonUnions", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsRestjson1_serdeOpJsonUnionsMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + retry.AddRetryMiddlewares(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opJsonUnions(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "JsonUnions", + Err: err, + } + } + out := result.(*JsonUnionsOutput) + out.ResultMetadata = metadata + return out, nil +} + +// A shared structure that contains a single union member. +type JsonUnionsInput struct { + // A union with a representative set of types for members. + Contents types.MyUnion +} + +// A shared structure that contains a single union member. +type JsonUnionsOutput struct { + // A union with a representative set of types for members. + Contents types.MyUnion + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsRestjson1_serdeOpJsonUnionsMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsRestjson1_serializeOpJsonUnions{}, middleware.After) + stack.Deserialize.Add(&awsRestjson1_deserializeOpJsonUnions{}, middleware.After) +} + +func newServiceMetadataMiddleware_opJsonUnions(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "Rest Json Protocol", + ServiceID: "restjsonprotocol", + EndpointPrefix: "restjsonprotocol", + OperationName: "JsonUnions", + } +} diff --git a/internal/protocoltest/awsrestjson/api_op_JsonUnions_test.go b/internal/protocoltest/awsrestjson/api_op_JsonUnions_test.go new file mode 100644 index 00000000000..ea4e0de72d4 --- /dev/null +++ b/internal/protocoltest/awsrestjson/api_op_JsonUnions_test.go @@ -0,0 +1,514 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package awsrestjson + +import ( + "bytes" + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/awsrestjson/types" + "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithyrand "github.com/awslabs/smithy-go/rand" + smithytesting "github.com/awslabs/smithy-go/testing" + smithytime "github.com/awslabs/smithy-go/time" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_JsonUnions_awsRestjson1Serialize(t *testing.T) { + cases := map[string]struct { + Params *JsonUnionsInput + ExpectMethod string + ExpectURIPath string + ExpectQuery []smithytesting.QueryItem + RequireQuery []string + ForbidQuery []string + ExpectHeader http.Header + RequireHeader []string + ForbidHeader []string + BodyMediaType string + BodyAssert func(io.Reader) error + }{ + // Serializes a string union value + "RestJsonSerializeStringUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberStringValue{Value: "foo"}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "stringValue": "foo" + } + }`)) + }, + }, + // Serializes a boolean union value + "RestJsonSerializeBooleanUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberBooleanValue{Value: true}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "booleanValue": true + } + }`)) + }, + }, + // Serializes a number union value + "RestJsonSerializeNumberUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberNumberValue{Value: 1}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "numberValue": 1 + } + }`)) + }, + }, + // Serializes a blob union value + "RestJsonSerializeBlobUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberBlobValue{Value: []byte("foo")}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "blobValue": "Zm9v" + } + }`)) + }, + }, + // Serializes a timestamp union value + "RestJsonSerializeTimestampUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberTimestampValue{Value: smithytime.ParseEpochSeconds(1398796238)}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "timestampValue": 1398796238 + } + }`)) + }, + }, + // Serializes an enum union value + "RestJsonSerializeEnumUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberEnumValue{Value: types.FooEnum("Foo")}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "enumValue": "Foo" + } + }`)) + }, + }, + // Serializes a list union value + "RestJsonSerializeListUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberListValue{Value: []*string{ + ptr.String("foo"), + ptr.String("bar"), + }}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "listValue": ["foo", "bar"] + } + }`)) + }, + }, + // Serializes a map union value + "RestJsonSerializeMapUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberMapValue{Value: map[string]*string{ + "foo": ptr.String("bar"), + "spam": ptr.String("eggs"), + }}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "mapValue": { + "foo": "bar", + "spam": "eggs" + } + } + }`)) + }, + }, + // Serializes a structure union value + "RestJsonSerializeStructureUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberStructureValue{Value: &types.GreetingStruct{ + Hi: ptr.String("hello"), + }}, + }, + ExpectMethod: "PUT", + ExpectURIPath: "/JsonUnions", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "structureValue": { + "hi": "hello" + } + } + }`)) + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + var actualReq *http.Request + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + actualReq = r.Clone(r.Context()) + if len(actualReq.URL.RawPath) == 0 { + actualReq.URL.RawPath = actualReq.URL.Path + } + if v := actualReq.ContentLength; v != 0 { + actualReq.Header.Set("Content-Length", strconv.FormatInt(v, 10)) + } + var buf bytes.Buffer + if _, err := io.Copy(&buf, r.Body); err != nil { + t.Errorf("failed to read request body, %v", err) + } + actualReq.Body = ioutil.NopCloser(&buf) + + w.WriteHeader(200) + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + IdempotencyTokenProvider: smithyrand.NewUUIDIdempotencyToken(&smithytesting.ByteLoop{}), + Region: "us-west-2", + }) + result, err := client.JsonUnions(context.Background(), c.Params) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if e, a := c.ExpectMethod, actualReq.Method; e != a { + t.Errorf("expect %v method, got %v", e, a) + } + if e, a := c.ExpectURIPath, actualReq.URL.RawPath; e != a { + t.Errorf("expect %v path, got %v", e, a) + } + queryItems := smithytesting.ParseRawQuery(actualReq.URL.RawQuery) + smithytesting.AssertHasQuery(t, c.ExpectQuery, queryItems) + smithytesting.AssertHasQueryKeys(t, c.RequireQuery, queryItems) + smithytesting.AssertNotHaveQueryKeys(t, c.ForbidQuery, queryItems) + smithytesting.AssertHasHeader(t, c.ExpectHeader, actualReq.Header) + smithytesting.AssertHasHeaderKeys(t, c.RequireHeader, actualReq.Header) + smithytesting.AssertNotHaveHeaderKeys(t, c.ForbidHeader, actualReq.Header) + if c.BodyAssert != nil { + if err := c.BodyAssert(actualReq.Body); err != nil { + t.Errorf("expect body equal, got %v", err) + } + } + }) + } +} + +func TestClient_JsonUnions_awsRestjson1Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectResult *JsonUnionsOutput + }{ + // Deserializes a string union value + "RestJsonDeserializeStringUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "stringValue": "foo" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberStringValue{Value: "foo"}, + }, + }, + // Deserializes a boolean union value + "RestJsonDeserializeBooleanUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "booleanValue": true + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberBooleanValue{Value: true}, + }, + }, + // Deserializes a number union value + "RestJsonDeserializeNumberUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "numberValue": 1 + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberNumberValue{Value: 1}, + }, + }, + // Deserializes a blob union value + "RestJsonDeserializeBlobUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "blobValue": "Zm9v" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberBlobValue{Value: []byte("foo")}, + }, + }, + // Deserializes a timestamp union value + "RestJsonDeserializeTimestampUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "timestampValue": 1398796238 + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberTimestampValue{Value: smithytime.ParseEpochSeconds(1398796238)}, + }, + }, + // Deserializes an enum union value + "RestJsonDeserializeEnumUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "enumValue": "Foo" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberEnumValue{Value: types.FooEnum("Foo")}, + }, + }, + // Deserializes a list union value + "RestJsonDeserializeListUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "listValue": ["foo", "bar"] + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberListValue{Value: []*string{ + ptr.String("foo"), + ptr.String("bar"), + }}, + }, + }, + // Deserializes a map union value + "RestJsonDeserializeMapUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "mapValue": { + "foo": "bar", + "spam": "eggs" + } + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberMapValue{Value: map[string]*string{ + "foo": ptr.String("bar"), + "spam": ptr.String("eggs"), + }}, + }, + }, + // Deserializes a structure union value + "RestJsonDeserializeStructureUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "structureValue": { + "hi": "hello" + } + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberStructureValue{Value: &types.GreetingStruct{ + Hi: ptr.String("hello"), + }}, + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + IdempotencyTokenProvider: smithyrand.NewUUIDIdempotencyToken(&smithytesting.ByteLoop{}), + Region: "us-west-2", + }) + var params JsonUnionsInput + result, err := client.JsonUnions(context.Background(), ¶ms) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if err := smithytesting.CompareValues(c.ExpectResult, result, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectResult value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/awsrestjson/deserializers.go b/internal/protocoltest/awsrestjson/deserializers.go index 4b3c831d734..3cfc2c54cd8 100644 --- a/internal/protocoltest/awsrestjson/deserializers.go +++ b/internal/protocoltest/awsrestjson/deserializers.go @@ -5,12 +5,14 @@ package awsrestjson import ( "bytes" "context" + "encoding/base64" "encoding/json" "fmt" "github.com/aws/aws-sdk-go-v2/aws/protocol/restjson" "github.com/aws/aws-sdk-go-v2/internal/protocoltest/awsrestjson/types" smithy "github.com/awslabs/smithy-go" smithyio "github.com/awslabs/smithy-go/io" + smithyjson "github.com/awslabs/smithy-go/json" "github.com/awslabs/smithy-go/middleware" "github.com/awslabs/smithy-go/ptr" smithytime "github.com/awslabs/smithy-go/time" @@ -818,7 +820,7 @@ func awsRestjson1_deserializeDocumentHttpPayloadWithStructureOutput(v **HttpPayl } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -945,6 +947,109 @@ func awsRestjson1_deserializeHttpBindingsHttpPrefixHeadersOutput(v *HttpPrefixHe return nil } +type awsRestjson1_deserializeOpHttpPrefixHeadersResponse struct { +} + +func (*awsRestjson1_deserializeOpHttpPrefixHeadersResponse) ID() string { + return "OperationDeserializer" +} + +func (m *awsRestjson1_deserializeOpHttpPrefixHeadersResponse) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsRestjson1_deserializeOpErrorHttpPrefixHeadersResponse(response) + } + output := &HttpPrefixHeadersResponseOutput{} + out.Result = output + + err = awsRestjson1_deserializeHttpBindingsHttpPrefixHeadersResponseOutput(output, response) + if err != nil { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("failed to decode response with invalid Http bindings, %w", err)} + } + + return out, metadata, err +} + +func awsRestjson1_deserializeOpErrorHttpPrefixHeadersResponse(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +func awsRestjson1_deserializeHttpBindingsHttpPrefixHeadersResponseOutput(v *HttpPrefixHeadersResponseOutput, response *smithyhttp.Response) error { + if v == nil { + return fmt.Errorf("unsupported deserialization for nil %T", v) + } + + for headerKey, headerValues := range response.Header { + if lenPrefix := len(""); len(headerKey) >= lenPrefix && strings.EqualFold(headerKey[:lenPrefix], "") { + if v.PrefixHeaders == nil { + v.PrefixHeaders = map[string]*string{} + } + headerValues[0] = strings.TrimSpace(headerValues[0]) + v.PrefixHeaders[headerKey[lenPrefix:]] = ptr.String(headerValues[0]) + } + } + + return nil +} + type awsRestjson1_deserializeOpHttpRequestWithGreedyLabelInPath struct { } @@ -1328,7 +1433,7 @@ func awsRestjson1_deserializeDocumentIgnoreQueryParamsInResponseOutput(v **Ignor } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1495,7 +1600,7 @@ func awsRestjson1_deserializeDocumentInlineDocumentOutput(v **InlineDocumentOutp } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1649,7 +1754,7 @@ func awsRestjson1_deserializeDocumentInlineDocumentAsPayloadOutput(v **InlineDoc } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2087,7 +2192,7 @@ func awsRestjson1_deserializeDocumentJsonBlobsOutput(v **JsonBlobsOutput, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2290,7 +2395,7 @@ func awsRestjson1_deserializeDocumentJsonEnumsOutput(v **JsonEnumsOutput, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2479,7 +2584,7 @@ func awsRestjson1_deserializeDocumentJsonListsOutput(v **JsonListsOutput, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2633,7 +2738,7 @@ func awsRestjson1_deserializeDocumentJsonMapsOutput(v **JsonMapsOutput, decoder } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2850,7 +2955,161 @@ func awsRestjson1_deserializeDocumentJsonTimestampsOutput(v **JsonTimestampsOutp } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +type awsRestjson1_deserializeOpJsonUnions struct { +} + +func (*awsRestjson1_deserializeOpJsonUnions) ID() string { + return "OperationDeserializer" +} + +func (m *awsRestjson1_deserializeOpJsonUnions) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsRestjson1_deserializeOpErrorJsonUnions(response) + } + output := &JsonUnionsOutput{} + out.Result = output + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(response.Body, ringBuffer) + + decoder := json.NewDecoder(body) + decoder.UseNumber() + + err = awsRestjson1_deserializeDocumentJsonUnionsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsRestjson1_deserializeOpErrorJsonUnions(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +func awsRestjson1_deserializeDocumentJsonUnionsOutput(v **JsonUnionsOutput, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *JsonUnionsOutput + if *v == nil { + sv = &JsonUnionsOutput{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "contents": + if err := awsRestjson1_deserializeDocumentMyUnion(&sv.Contents, decoder); err != nil { + return err + } + + default: + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2961,7 +3220,11 @@ func awsRestjson1_deserializeHttpBindingsMediaTypeHeaderOutput(v *MediaTypeHeade if headerValues := response.Header.Values("X-Json"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) - v.Json = ptr.String(headerValues[0]) + b, err := base64.StdEncoding.DecodeString(headerValues[0]) + if err != nil { + return err + } + v.Json = ptr.String(string(b)) } return nil @@ -3660,7 +3923,7 @@ func awsRestjson1_deserializeDocumentRecursiveShapesOutput(v **RecursiveShapesOu } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -3967,7 +4230,7 @@ func awsRestjson1_deserializeDocumentSimpleScalarPropertiesOutput(v **SimpleScal } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -4610,7 +4873,7 @@ func awsRestjson1_deserializeDocumentComplexError(v **types.ComplexError, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -4674,7 +4937,7 @@ func awsRestjson1_deserializeDocumentComplexNestedErrorData(v **types.ComplexNes } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -4733,7 +4996,7 @@ func awsRestjson1_deserializeDocumentFooError(v **types.FooError, decoder *json. } switch t { default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -4797,7 +5060,7 @@ func awsRestjson1_deserializeDocumentInvalidGreeting(v **types.InvalidGreeting, } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -4871,6 +5134,166 @@ func awsRestjson1_deserializeDocumentJsonMapsInputOutputMap(v *map[string]*types return nil } +func awsRestjson1_deserializeDocumentMyUnion(v *types.MyUnion, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var uv types.MyUnion + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "blobValue": + var mv []byte + err := decoder.Decode(&mv) + if err != nil { + return err + } + uv = &types.MyUnionMemberBlobValue{Value: mv} + + case "booleanValue": + var mv *bool + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(bool) + if !ok { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) + } + mv = &jtv + } + uv = &types.MyUnionMemberBooleanValue{Value: *mv} + + case "enumValue": + var mv types.FooEnum + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected FooEnum to be of type string, got %T instead", val) + } + mv = types.FooEnum(jtv) + } + uv = &types.MyUnionMemberEnumValue{Value: mv} + + case "listValue": + var mv []*string + if err := awsRestjson1_deserializeDocumentStringList(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberListValue{Value: mv} + + case "mapValue": + var mv map[string]*string + if err := awsRestjson1_deserializeDocumentStringMap(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberMapValue{Value: mv} + + case "numberValue": + var mv *int32 + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(json.Number) + if !ok { + return fmt.Errorf("expected Integer to be json.Number, got %T instead", val) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + mv = ptr.Int32(int32(i64)) + } + uv = &types.MyUnionMemberNumberValue{Value: *mv} + + case "stringValue": + var mv *string + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + mv = &jtv + } + uv = &types.MyUnionMemberStringValue{Value: *mv} + + case "structureValue": + var mv *types.GreetingStruct + if err := awsRestjson1_deserializeDocumentGreetingStruct(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberStructureValue{Value: mv} + + case "timestampValue": + var mv *time.Time + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(json.Number) + if !ok { + return fmt.Errorf("expected Timestamp to be json.Number, got %T instead", val) + } + f64, err := jtv.Float64() + if err != nil { + return err + } + mv = ptr.Time(smithytime.ParseEpochSeconds(f64)) + } + uv = &types.MyUnionMemberTimestampValue{Value: *mv} + + default: + tagString, ok := t.(string) + if !ok { + return fmt.Errorf("expected string key, found %T", t) + } + value, err := smithyjson.CollectUnknownField(decoder) + if err != nil { + return err + } + uv = &types.UnknownUnionMember{Tag: tagString, Value: value} + + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = uv + return nil +} + func awsRestjson1_deserializeDocumentNestedPayload(v **types.NestedPayload, decoder *json.Decoder) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) @@ -4929,7 +5352,7 @@ func awsRestjson1_deserializeDocumentNestedPayload(v **types.NestedPayload, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -4998,7 +5421,7 @@ func awsRestjson1_deserializeDocumentRecursiveShapesInputOutputNested1(v **types } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5067,7 +5490,7 @@ func awsRestjson1_deserializeDocumentRecursiveShapesInputOutputNested2(v **types } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5189,7 +5612,7 @@ func awsRestjson1_deserializeDocumentStructureListMember(v **types.StructureList } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5475,7 +5898,7 @@ func awsRestjson1_deserializeDocumentGreetingStruct(v **types.GreetingStruct, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5649,6 +6072,69 @@ func awsRestjson1_deserializeDocumentStringList(v *[]*string, decoder *json.Deco return nil } +func awsRestjson1_deserializeDocumentStringMap(v *map[string]*string, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var mv map[string]*string + if *v == nil { + mv = map[string]*string{} + } else { + mv = *v + } + + for decoder.More() { + token, err := decoder.Token() + if err != nil { + return err + } + + key, ok := token.(string) + if !ok { + return fmt.Errorf("expected map-key of type string, found type %T", token) + } + + var parsedVal *string + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + parsedVal = &jtv + } + mv[key] = parsedVal + + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = mv + return nil +} + func awsRestjson1_deserializeDocumentStringSet(v *[]*string, decoder *json.Decoder) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) diff --git a/internal/protocoltest/awsrestjson/go.mod b/internal/protocoltest/awsrestjson/go.mod index c8a4719003c..82f8f68dc23 100644 --- a/internal/protocoltest/awsrestjson/go.mod +++ b/internal/protocoltest/awsrestjson/go.mod @@ -3,7 +3,7 @@ module github.com/aws/aws-sdk-go-v2/internal/protocoltest/awsrestjson go 1.15 require ( - github.com/aws/aws-sdk-go-v2 v0.24.1-0.20200821181726-bc564654ccac - github.com/awslabs/smithy-go v0.0.0-20200820215706-7b32252c1389 + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 github.com/google/go-cmp v0.4.1 ) diff --git a/internal/protocoltest/awsrestjson/go.sum b/internal/protocoltest/awsrestjson/go.sum index b52e4b21198..33226d2fa0c 100644 --- a/internal/protocoltest/awsrestjson/go.sum +++ b/internal/protocoltest/awsrestjson/go.sum @@ -3,6 +3,9 @@ github.com/aws/aws-sdk-go-v2 v0.21.1-0.20200820194649-74a617e66b47/go.mod h1:chh github.com/awslabs/smithy-go v0.0.0-20200820191216-588c85568291/go.mod h1:hPOQwnmBLHsUphH13tVSjQhTAFma0/0XoZGbBcOuABI= github.com/awslabs/smithy-go v0.0.0-20200820192257-b29a2bc72e74 h1:G/RQUW+EoxUd5xXPMBWyzPPxArT9XRFSpwXBnJCMq9o= github.com/awslabs/smithy-go v0.0.0-20200820192257-b29a2bc72e74/go.mod h1:hPOQwnmBLHsUphH13tVSjQhTAFma0/0XoZGbBcOuABI= +github.com/awslabs/smithy-go v0.0.0-20200825193951-1f2465f8442d/go.mod h1:hPOQwnmBLHsUphH13tVSjQhTAFma0/0XoZGbBcOuABI= +github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 h1:aOVIC7mMrGscwocQEPMhsW31+nXUQj9ckxRY+syJQOk= +github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931/go.mod h1:hPOQwnmBLHsUphH13tVSjQhTAFma0/0XoZGbBcOuABI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0= diff --git a/internal/protocoltest/awsrestjson/serializers.go b/internal/protocoltest/awsrestjson/serializers.go index 9a85b56d3a7..7486bd6e116 100644 --- a/internal/protocoltest/awsrestjson/serializers.go +++ b/internal/protocoltest/awsrestjson/serializers.go @@ -5,12 +5,14 @@ package awsrestjson import ( "bytes" "context" + "encoding/base64" "fmt" "github.com/aws/aws-sdk-go-v2/internal/protocoltest/awsrestjson/types" smithy "github.com/awslabs/smithy-go" "github.com/awslabs/smithy-go/httpbinding" smithyjson "github.com/awslabs/smithy-go/json" "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" smithytime "github.com/awslabs/smithy-go/time" smithyhttp "github.com/awslabs/smithy-go/transport/http" "time" @@ -464,8 +466,9 @@ func awsRestjson1_serializeHttpBindingsHttpPayloadTraitsInput(v *HttpPayloadTrai } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -535,8 +538,9 @@ func awsRestjson1_serializeHttpBindingsHttpPayloadTraitsWithMediaTypeInput(v *Ht } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -660,16 +664,17 @@ func awsRestjson1_serializeHttpBindingsHttpPrefixHeadersInput(v *HttpPrefixHeade } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } if v.FooMap != nil { hv := encoder.Headers("X-Foo-") for mapKey, mapVal := range v.FooMap { - if mapVal != nil && len(*mapVal) > 0 { - hv.AddHeader(mapKey).String(*mapVal) + if len(*mapVal) > 0 { + hv.SetHeader(mapKey).String(*mapVal) } } } @@ -677,6 +682,56 @@ func awsRestjson1_serializeHttpBindingsHttpPrefixHeadersInput(v *HttpPrefixHeade return nil } +type awsRestjson1_serializeOpHttpPrefixHeadersResponse struct { +} + +func (*awsRestjson1_serializeOpHttpPrefixHeadersResponse) ID() string { + return "OperationSerializer" +} + +func (m *awsRestjson1_serializeOpHttpPrefixHeadersResponse) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*HttpPrefixHeadersResponseInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + opPath, opQuery := httpbinding.SplitURI("/HttpPrefixHeadersResponse") + request.URL.Path = opPath + if len(request.URL.RawQuery) > 0 { + request.URL.RawQuery = "&" + opQuery + } else { + request.URL.RawQuery = opQuery + } + + request.Method = "GET" + restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = restEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} +func awsRestjson1_serializeHttpBindingsHttpPrefixHeadersResponseInput(v *HttpPrefixHeadersResponseInput, encoder *httpbinding.Encoder) error { + if v == nil { + return fmt.Errorf("unsupported serialization of nil %T", v) + } + + return nil +} + type awsRestjson1_serializeOpHttpRequestWithGreedyLabelInPath struct { } @@ -1188,93 +1243,109 @@ func awsRestjson1_serializeHttpBindingsInputAndOutputWithHeadersInput(v *InputAn } if v.HeaderBooleanList != nil { + locationName := "X-BooleanList" for i := range v.HeaderBooleanList { if v.HeaderBooleanList[i] != nil { - encoder.AddHeader("X-BooleanList").Boolean(*v.HeaderBooleanList[i]) + encoder.AddHeader(locationName).Boolean(*v.HeaderBooleanList[i]) } } } if v.HeaderByte != nil { - encoder.SetHeader("X-Byte").Byte(*v.HeaderByte) + locationName := "X-Byte" + encoder.SetHeader(locationName).Byte(*v.HeaderByte) } if v.HeaderDouble != nil { - encoder.SetHeader("X-Double").Double(*v.HeaderDouble) + locationName := "X-Double" + encoder.SetHeader(locationName).Double(*v.HeaderDouble) } if len(v.HeaderEnum) > 0 { - encoder.SetHeader("X-Enum").String(string(v.HeaderEnum)) + locationName := "X-Enum" + encoder.SetHeader(locationName).String(string(v.HeaderEnum)) } if v.HeaderEnumList != nil { + locationName := "X-EnumList" for i := range v.HeaderEnumList { if len(v.HeaderEnumList[i]) > 0 { - encoder.AddHeader("X-EnumList").String(string(v.HeaderEnumList[i])) + encoder.AddHeader(locationName).String(string(v.HeaderEnumList[i])) } } } if v.HeaderFalseBool != nil { - encoder.SetHeader("X-Boolean2").Boolean(*v.HeaderFalseBool) + locationName := "X-Boolean2" + encoder.SetHeader(locationName).Boolean(*v.HeaderFalseBool) } if v.HeaderFloat != nil { - encoder.SetHeader("X-Float").Float(*v.HeaderFloat) + locationName := "X-Float" + encoder.SetHeader(locationName).Float(*v.HeaderFloat) } if v.HeaderInteger != nil { - encoder.SetHeader("X-Integer").Integer(*v.HeaderInteger) + locationName := "X-Integer" + encoder.SetHeader(locationName).Integer(*v.HeaderInteger) } if v.HeaderIntegerList != nil { + locationName := "X-IntegerList" for i := range v.HeaderIntegerList { if v.HeaderIntegerList[i] != nil { - encoder.AddHeader("X-IntegerList").Integer(*v.HeaderIntegerList[i]) + encoder.AddHeader(locationName).Integer(*v.HeaderIntegerList[i]) } } } if v.HeaderLong != nil { - encoder.SetHeader("X-Long").Long(*v.HeaderLong) + locationName := "X-Long" + encoder.SetHeader(locationName).Long(*v.HeaderLong) } if v.HeaderShort != nil { - encoder.SetHeader("X-Short").Short(*v.HeaderShort) + locationName := "X-Short" + encoder.SetHeader(locationName).Short(*v.HeaderShort) } if v.HeaderString != nil { + locationName := "X-String" if len(*v.HeaderString) > 0 { - encoder.SetHeader("X-String").String(*v.HeaderString) + encoder.SetHeader(locationName).String(*v.HeaderString) } } if v.HeaderStringList != nil { + locationName := "X-StringList" for i := range v.HeaderStringList { if v.HeaderStringList[i] != nil && len(*v.HeaderStringList[i]) > 0 { - encoder.AddHeader("X-StringList").String(*v.HeaderStringList[i]) + encoder.AddHeader(locationName).String(*v.HeaderStringList[i]) } } } if v.HeaderStringSet != nil { + locationName := "X-StringSet" for i := range v.HeaderStringSet { if v.HeaderStringSet[i] != nil && len(*v.HeaderStringSet[i]) > 0 { - encoder.AddHeader("X-StringSet").String(*v.HeaderStringSet[i]) + encoder.AddHeader(locationName).String(*v.HeaderStringSet[i]) } } } if v.HeaderTimestampList != nil { + locationName := "X-TimestampList" for i := range v.HeaderTimestampList { if v.HeaderTimestampList[i] != nil { - encoder.AddHeader("X-TimestampList").String(smithytime.FormatHTTPDate(*v.HeaderTimestampList[i])) + encoder.AddHeader(locationName).String(smithytime.FormatHTTPDate(*v.HeaderTimestampList[i])) } } } if v.HeaderTrueBool != nil { - encoder.SetHeader("X-Boolean1").Boolean(*v.HeaderTrueBool) + locationName := "X-Boolean1" + encoder.SetHeader(locationName).Boolean(*v.HeaderTrueBool) } return nil @@ -1744,6 +1815,81 @@ func awsRestjson1_serializeDocumentJsonTimestampsInput(v *JsonTimestampsInput, v return nil } +type awsRestjson1_serializeOpJsonUnions struct { +} + +func (*awsRestjson1_serializeOpJsonUnions) ID() string { + return "OperationSerializer" +} + +func (m *awsRestjson1_serializeOpJsonUnions) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*JsonUnionsInput) + _ = input + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + opPath, opQuery := httpbinding.SplitURI("/JsonUnions") + request.URL.Path = opPath + if len(request.URL.RawQuery) > 0 { + request.URL.RawQuery = "&" + opQuery + } else { + request.URL.RawQuery = opQuery + } + + request.Method = "PUT" + restEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + restEncoder.SetHeader("Content-Type").String("application/json") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsRestjson1_serializeDocumentJsonUnionsInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = restEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} +func awsRestjson1_serializeHttpBindingsJsonUnionsInput(v *JsonUnionsInput, encoder *httpbinding.Encoder) error { + if v == nil { + return fmt.Errorf("unsupported serialization of nil %T", v) + } + + return nil +} + +func awsRestjson1_serializeDocumentJsonUnionsInput(v *JsonUnionsInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Contents != nil { + ok := object.Key("contents") + if err := awsRestjson1_serializeDocumentMyUnion(v.Contents, ok); err != nil { + return err + } + } + + return nil +} + type awsRestjson1_serializeOpMediaTypeHeader struct { } @@ -1796,8 +1942,10 @@ func awsRestjson1_serializeHttpBindingsMediaTypeHeaderInput(v *MediaTypeHeaderIn } if v.Json != nil { + locationName := "X-Json" if len(*v.Json) > 0 { - encoder.SetHeader("X-Json").String(*v.Json) + encoded := ptr.String(base64.StdEncoding.EncodeToString([]byte(*v.Json))) + encoder.SetHeader(locationName).String(*encoded) } } @@ -1956,21 +2104,24 @@ func awsRestjson1_serializeHttpBindingsNullAndEmptyHeadersClientInput(v *NullAnd } if v.A != nil { + locationName := "X-A" if len(*v.A) > 0 { - encoder.SetHeader("X-A").String(*v.A) + encoder.SetHeader(locationName).String(*v.A) } } if v.B != nil { + locationName := "X-B" if len(*v.B) > 0 { - encoder.SetHeader("X-B").String(*v.B) + encoder.SetHeader(locationName).String(*v.B) } } if v.C != nil { + locationName := "X-C" for i := range v.C { if v.C[i] != nil && len(*v.C[i]) > 0 { - encoder.AddHeader("X-C").String(*v.C[i]) + encoder.AddHeader(locationName).String(*v.C[i]) } } } @@ -2030,21 +2181,24 @@ func awsRestjson1_serializeHttpBindingsNullAndEmptyHeadersServerInput(v *NullAnd } if v.A != nil { + locationName := "X-A" if len(*v.A) > 0 { - encoder.SetHeader("X-A").String(*v.A) + encoder.SetHeader(locationName).String(*v.A) } } if v.B != nil { + locationName := "X-B" if len(*v.B) > 0 { - encoder.SetHeader("X-B").String(*v.B) + encoder.SetHeader(locationName).String(*v.B) } } if v.C != nil { + locationName := "X-C" for i := range v.C { if v.C[i] != nil && len(*v.C[i]) > 0 { - encoder.AddHeader("X-C").String(*v.C[i]) + encoder.AddHeader(locationName).String(*v.C[i]) } } } @@ -2310,8 +2464,9 @@ func awsRestjson1_serializeHttpBindingsSimpleScalarPropertiesInput(v *SimpleScal } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -2433,8 +2588,9 @@ func awsRestjson1_serializeHttpBindingsStreamingTraitsInput(v *StreamingTraitsIn } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -2504,8 +2660,9 @@ func awsRestjson1_serializeHttpBindingsStreamingTraitsRequireLengthInput(v *Stre } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -2575,8 +2732,9 @@ func awsRestjson1_serializeHttpBindingsStreamingTraitsWithMediaTypeInput(v *Stre } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -2635,31 +2793,38 @@ func awsRestjson1_serializeHttpBindingsTimestampFormatHeadersInput(v *TimestampF } if v.DefaultFormat != nil { - encoder.SetHeader("X-defaultFormat").String(smithytime.FormatHTTPDate(*v.DefaultFormat)) + locationName := "X-defaultFormat" + encoder.SetHeader(locationName).String(smithytime.FormatHTTPDate(*v.DefaultFormat)) } if v.MemberDateTime != nil { - encoder.SetHeader("X-memberDateTime").String(smithytime.FormatDateTime(*v.MemberDateTime)) + locationName := "X-memberDateTime" + encoder.SetHeader(locationName).String(smithytime.FormatDateTime(*v.MemberDateTime)) } if v.MemberEpochSeconds != nil { - encoder.SetHeader("X-memberEpochSeconds").Double(smithytime.FormatEpochSeconds(*v.MemberEpochSeconds)) + locationName := "X-memberEpochSeconds" + encoder.SetHeader(locationName).Double(smithytime.FormatEpochSeconds(*v.MemberEpochSeconds)) } if v.MemberHttpDate != nil { - encoder.SetHeader("X-memberHttpDate").String(smithytime.FormatHTTPDate(*v.MemberHttpDate)) + locationName := "X-memberHttpDate" + encoder.SetHeader(locationName).String(smithytime.FormatHTTPDate(*v.MemberHttpDate)) } if v.TargetDateTime != nil { - encoder.SetHeader("X-targetDateTime").String(smithytime.FormatDateTime(*v.TargetDateTime)) + locationName := "X-targetDateTime" + encoder.SetHeader(locationName).String(smithytime.FormatDateTime(*v.TargetDateTime)) } if v.TargetEpochSeconds != nil { - encoder.SetHeader("X-targetEpochSeconds").Double(smithytime.FormatEpochSeconds(*v.TargetEpochSeconds)) + locationName := "X-targetEpochSeconds" + encoder.SetHeader(locationName).Double(smithytime.FormatEpochSeconds(*v.TargetEpochSeconds)) } if v.TargetHttpDate != nil { - encoder.SetHeader("X-targetHttpDate").String(smithytime.FormatHTTPDate(*v.TargetHttpDate)) + locationName := "X-targetHttpDate" + encoder.SetHeader(locationName).String(smithytime.FormatHTTPDate(*v.TargetHttpDate)) } return nil @@ -2687,6 +2852,60 @@ func awsRestjson1_serializeDocumentJsonMapsInputOutputMap(v map[string]*types.Gr return nil } +func awsRestjson1_serializeDocumentMyUnion(v types.MyUnion, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + switch uv := v.(type) { + case *types.MyUnionMemberBlobValue: + av := object.Key("blobValue") + av.Base64EncodeBytes(uv.Value) + + case *types.MyUnionMemberBooleanValue: + av := object.Key("booleanValue") + av.Boolean(uv.Value) + + case *types.MyUnionMemberEnumValue: + av := object.Key("enumValue") + av.String(string(uv.Value)) + + case *types.MyUnionMemberListValue: + av := object.Key("listValue") + if err := awsRestjson1_serializeDocumentStringList(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberMapValue: + av := object.Key("mapValue") + if err := awsRestjson1_serializeDocumentStringMap(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberNumberValue: + av := object.Key("numberValue") + av.Integer(uv.Value) + + case *types.MyUnionMemberStringValue: + av := object.Key("stringValue") + av.String(uv.Value) + + case *types.MyUnionMemberStructureValue: + av := object.Key("structureValue") + if err := awsRestjson1_serializeDocumentGreetingStruct(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberTimestampValue: + av := object.Key("timestampValue") + av.Double(smithytime.FormatEpochSeconds(uv.Value)) + + default: + return fmt.Errorf("attempted to serialize unknown member type %T for union %T", uv, v) + + } + return nil +} + func awsRestjson1_serializeDocumentNestedPayload(v *types.NestedPayload, value smithyjson.Value) error { object := value.Object() defer object.Close() @@ -2883,6 +3102,21 @@ func awsRestjson1_serializeDocumentStringList(v []*string, value smithyjson.Valu return nil } +func awsRestjson1_serializeDocumentStringMap(v map[string]*string, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + for key := range v { + om := object.Key(key) + if vv := v[key]; vv == nil { + om.Null() + continue + } + om.String(*v[key]) + } + return nil +} + func awsRestjson1_serializeDocumentStringSet(v []*string, value smithyjson.Value) error { array := value.Array() defer array.Close() diff --git a/internal/protocoltest/awsrestjson/types/types.go b/internal/protocoltest/awsrestjson/types/types.go index e9183d12201..5ea77086130 100644 --- a/internal/protocoltest/awsrestjson/types/types.go +++ b/internal/protocoltest/awsrestjson/types/types.go @@ -2,10 +2,73 @@ package types +import ( + "time" +) + type ComplexNestedErrorData struct { Foo *string } +// A union with a representative set of types for members. +type MyUnion interface { + isMyUnion() +} + +type MyUnionMemberStringValue struct { + Value string +} + +func (*MyUnionMemberStringValue) isMyUnion() {} + +type MyUnionMemberBooleanValue struct { + Value bool +} + +func (*MyUnionMemberBooleanValue) isMyUnion() {} + +type MyUnionMemberNumberValue struct { + Value int32 +} + +func (*MyUnionMemberNumberValue) isMyUnion() {} + +type MyUnionMemberBlobValue struct { + Value []byte +} + +func (*MyUnionMemberBlobValue) isMyUnion() {} + +type MyUnionMemberTimestampValue struct { + Value time.Time +} + +func (*MyUnionMemberTimestampValue) isMyUnion() {} + +type MyUnionMemberEnumValue struct { + Value FooEnum +} + +func (*MyUnionMemberEnumValue) isMyUnion() {} + +type MyUnionMemberListValue struct { + Value []*string +} + +func (*MyUnionMemberListValue) isMyUnion() {} + +type MyUnionMemberMapValue struct { + Value map[string]*string +} + +func (*MyUnionMemberMapValue) isMyUnion() {} + +type MyUnionMemberStructureValue struct { + Value *GreetingStruct +} + +func (*MyUnionMemberStructureValue) isMyUnion() {} + type NestedPayload struct { Greeting *string Name *string @@ -29,3 +92,12 @@ type StructureListMember struct { type GreetingStruct struct { Hi *string } + +// UnknownUnionMember is returned when a union member is returned over the wire, +// but has an unknown tag. +type UnknownUnionMember struct { + Tag string + Value []byte +} + +func (*UnknownUnionMember) isMyUnion() {} diff --git a/internal/protocoltest/ec2query/deserializers.go b/internal/protocoltest/ec2query/deserializers.go index eadf64797c3..5027d0a17bf 100644 --- a/internal/protocoltest/ec2query/deserializers.go +++ b/internal/protocoltest/ec2query/deserializers.go @@ -5,12 +5,22 @@ package ec2query import ( "bytes" "context" + "encoding/base64" + "encoding/xml" "fmt" + "github.com/aws/aws-sdk-go-v2/aws/protocol/ec2query" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/ec2query/types" smithy "github.com/awslabs/smithy-go" + smithyio "github.com/awslabs/smithy-go/io" "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithytime "github.com/awslabs/smithy-go/time" smithyhttp "github.com/awslabs/smithy-go/transport/http" + smithyxml "github.com/awslabs/smithy-go/xml" "io" + "strconv" "strings" + "time" ) type awsEc2query_deserializeOpEmptyInputAndEmptyOutput struct { @@ -39,6 +49,34 @@ func (m *awsEc2query_deserializeOpEmptyInputAndEmptyOutput) HandleDeserialize(ct output := &EmptyInputAndEmptyOutputOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentEmptyInputAndEmptyOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -52,7 +90,11 @@ func awsEc2query_deserializeOpErrorEmptyInputAndEmptyOutput(response *smithyhttp errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -90,6 +132,34 @@ func (m *awsEc2query_deserializeOpGreetingWithErrors) HandleDeserialize(ctx cont output := &GreetingWithErrorsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentGreetingWithErrorsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -103,7 +173,11 @@ func awsEc2query_deserializeOpErrorGreetingWithErrors(response *smithyhttp.Respo errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { case strings.EqualFold("ComplexError", errorCode): return awsEc2query_deserializeErrorComplexError(response, errorBody) @@ -147,6 +221,34 @@ func (m *awsEc2query_deserializeOpIgnoresWrappingXmlName) HandleDeserialize(ctx output := &IgnoresWrappingXmlNameOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentIgnoresWrappingXmlNameOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -160,7 +262,11 @@ func awsEc2query_deserializeOpErrorIgnoresWrappingXmlName(response *smithyhttp.R errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -198,6 +304,34 @@ func (m *awsEc2query_deserializeOpNestedStructures) HandleDeserialize(ctx contex output := &NestedStructuresOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentNestedStructuresOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -211,7 +345,11 @@ func awsEc2query_deserializeOpErrorNestedStructures(response *smithyhttp.Respons errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -249,6 +387,34 @@ func (m *awsEc2query_deserializeOpNoInputAndOutput) HandleDeserialize(ctx contex output := &NoInputAndOutputOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentNoInputAndOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -262,7 +428,11 @@ func awsEc2query_deserializeOpErrorNoInputAndOutput(response *smithyhttp.Respons errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -300,6 +470,34 @@ func (m *awsEc2query_deserializeOpQueryIdempotencyTokenAutoFill) HandleDeseriali output := &QueryIdempotencyTokenAutoFillOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentQueryIdempotencyTokenAutoFillOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -313,7 +511,11 @@ func awsEc2query_deserializeOpErrorQueryIdempotencyTokenAutoFill(response *smith errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -351,6 +553,34 @@ func (m *awsEc2query_deserializeOpQueryLists) HandleDeserialize(ctx context.Cont output := &QueryListsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentQueryListsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -364,7 +594,11 @@ func awsEc2query_deserializeOpErrorQueryLists(response *smithyhttp.Response) err errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -402,6 +636,34 @@ func (m *awsEc2query_deserializeOpQueryTimestamps) HandleDeserialize(ctx context output := &QueryTimestampsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentQueryTimestampsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -415,7 +677,11 @@ func awsEc2query_deserializeOpErrorQueryTimestamps(response *smithyhttp.Response errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -453,6 +719,34 @@ func (m *awsEc2query_deserializeOpRecursiveXmlShapes) HandleDeserialize(ctx cont output := &RecursiveXmlShapesOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentRecursiveXmlShapesOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -466,7 +760,11 @@ func awsEc2query_deserializeOpErrorRecursiveXmlShapes(response *smithyhttp.Respo errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -504,6 +802,34 @@ func (m *awsEc2query_deserializeOpSimpleInputParams) HandleDeserialize(ctx conte output := &SimpleInputParamsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentSimpleInputParamsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -517,7 +843,11 @@ func awsEc2query_deserializeOpErrorSimpleInputParams(response *smithyhttp.Respon errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -555,6 +885,34 @@ func (m *awsEc2query_deserializeOpSimpleScalarXmlProperties) HandleDeserialize(c output := &SimpleScalarXmlPropertiesOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentSimpleScalarXmlPropertiesOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -568,7 +926,11 @@ func awsEc2query_deserializeOpErrorSimpleScalarXmlProperties(response *smithyhtt errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -606,6 +968,34 @@ func (m *awsEc2query_deserializeOpXmlBlobs) HandleDeserialize(ctx context.Contex output := &XmlBlobsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentXmlBlobsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -619,7 +1009,11 @@ func awsEc2query_deserializeOpErrorXmlBlobs(response *smithyhttp.Response) error errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -657,6 +1051,34 @@ func (m *awsEc2query_deserializeOpXmlEnums) HandleDeserialize(ctx context.Contex output := &XmlEnumsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentXmlEnumsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -670,7 +1092,11 @@ func awsEc2query_deserializeOpErrorXmlEnums(response *smithyhttp.Response) error errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -708,6 +1134,34 @@ func (m *awsEc2query_deserializeOpXmlLists) HandleDeserialize(ctx context.Contex output := &XmlListsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentXmlListsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -721,7 +1175,11 @@ func awsEc2query_deserializeOpErrorXmlLists(response *smithyhttp.Response) error errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -759,6 +1217,34 @@ func (m *awsEc2query_deserializeOpXmlNamespaces) HandleDeserialize(ctx context.C output := &XmlNamespacesOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentXmlNamespacesOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -772,7 +1258,11 @@ func awsEc2query_deserializeOpErrorXmlNamespaces(response *smithyhttp.Response) errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -810,6 +1300,34 @@ func (m *awsEc2query_deserializeOpXmlTimestamps) HandleDeserialize(ctx context.C output := &XmlTimestampsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentXmlTimestampsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -823,7 +1341,11 @@ func awsEc2query_deserializeOpErrorXmlTimestamps(response *smithyhttp.Response) errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, errorMessage, err := ec2query.GetResponseErrorCode(errorBody) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -836,11 +1358,2164 @@ func awsEc2query_deserializeOpErrorXmlTimestamps(response *smithyhttp.Response) } func awsEc2query_deserializeErrorComplexError(response *smithyhttp.Response, errorBody *bytes.Reader) error { - // TODO: support query error deser - return &smithy.DeserializationError{Err: fmt.Errorf("TODO: support query error deser")} + output := &types.ComplexError{} + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(errorBody, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return output + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentComplexError(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return output } func awsEc2query_deserializeErrorInvalidGreeting(response *smithyhttp.Response, errorBody *bytes.Reader) error { - // TODO: support query error deser - return &smithy.DeserializationError{Err: fmt.Errorf("TODO: support query error deser")} + output := &types.InvalidGreeting{} + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(errorBody, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return output + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsEc2query_deserializeDocumentInvalidGreeting(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return output +} + +func awsEc2query_deserializeDocumentComplexError(v **types.ComplexError, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.ComplexError + if *v == nil { + sv = &types.ComplexError{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("Nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentComplexNestedErrorData(&sv.Nested, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("TopLevel", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.TopLevel = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentComplexNestedErrorData(v **types.ComplexNestedErrorData, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.ComplexNestedErrorData + if *v == nil { + sv = &types.ComplexNestedErrorData{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("Foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentInvalidGreeting(v **types.InvalidGreeting, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.InvalidGreeting + if *v == nil { + sv = &types.InvalidGreeting{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("Message", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Message = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentRecursiveXmlShapesOutputNested1(v **types.RecursiveXmlShapesOutputNested1, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.RecursiveXmlShapesOutputNested1 + if *v == nil { + sv = &types.RecursiveXmlShapesOutputNested1{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + case strings.EqualFold("nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentRecursiveXmlShapesOutputNested2(&sv.Nested, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentRecursiveXmlShapesOutputNested2(v **types.RecursiveXmlShapesOutputNested2, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.RecursiveXmlShapesOutputNested2 + if *v == nil { + sv = &types.RecursiveXmlShapesOutputNested2{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("bar", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Bar = &xtv + } + + case strings.EqualFold("recursiveMember", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentRecursiveXmlShapesOutputNested1(&sv.RecursiveMember, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentRenamedListMembers(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("item", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentRenamedListMembersUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentStructureList(v *[]*types.StructureListMember, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*types.StructureListMember + if *v == nil { + sv = make([]*types.StructureListMember, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + for { + if strings.EqualFold("item", t.Name.Local) { + var col *types.StructureListMember + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentStructureListMember(&col, nodeDecoder); err != nil { + return err + } + sv = append(sv, col) + break + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentStructureListUnwrapped(v *[]*types.StructureListMember, decoder smithyxml.NodeDecoder) error { + var sv []*types.StructureListMember + if *v == nil { + sv = make([]*types.StructureListMember, 0) + } else { + sv = *v + } + + for { + var mv *types.StructureListMember + t := decoder.StartEl + _ = t + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentStructureListMember(&mv, nodeDecoder); err != nil { + return err + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentStructureListMember(v **types.StructureListMember, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.StructureListMember + if *v == nil { + sv = &types.StructureListMember{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("value", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.A = &xtv + } + + case strings.EqualFold("other", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.B = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentXmlNamespacedList(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentXmlNamespacedListUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentXmlNamespaceNested(v **types.XmlNamespaceNested, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.XmlNamespaceNested + if *v == nil { + sv = &types.XmlNamespaceNested{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + case strings.EqualFold("values", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentXmlNamespacedList(&sv.Values, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentBooleanList(v *[]*bool, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*bool + if *v == nil { + sv = make([]*bool, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *bool + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected PrimitiveBoolean to be of type *bool, got %T instead", val) + } + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentBooleanListUnwrapped(v *[]*bool, decoder smithyxml.NodeDecoder) error { + var sv []*bool + if *v == nil { + sv = make([]*bool, 0) + } else { + sv = *v + } + + for { + var mv *bool + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected PrimitiveBoolean to be of type *bool, got %T instead", val) + } + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentFooEnumList(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col types.FooEnum + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = types.FooEnum(xtv) + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentFooEnumListUnwrapped(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + for { + var mv types.FooEnum + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = types.FooEnum(xtv) + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentFooEnumMap(v *map[string]types.FooEnum, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv map[string]types.FooEnum + if *v == nil { + sv = make(map[string]types.FooEnum, 0) + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + if strings.EqualFold("entry", t.Name.Local) { + entryDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentFooEnumMapUnwrapped(&sv, entryDecoder); err != nil { + return err + } + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentFooEnumMapUnwrapped(v *map[string]types.FooEnum, decoder smithyxml.NodeDecoder) error { + var sv map[string]types.FooEnum + if *v == nil { + sv = make(map[string]types.FooEnum, 0) + } else { + sv = *v + } + + var ek *string + var ev types.FooEnum + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + sv[*ek] = ev + break + } + switch { + case strings.EqualFold("key", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ek = &xtv + } + + case strings.EqualFold("value", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ev = types.FooEnum(xtv) + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentFooEnumSet(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col types.FooEnum + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = types.FooEnum(xtv) + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentFooEnumSetUnwrapped(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + for { + var mv types.FooEnum + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = types.FooEnum(xtv) + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentIntegerList(v *[]*int32, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*int32 + if *v == nil { + sv = make([]*int32, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *int32 + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + col = ptr.Int32(int32(i64)) + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentIntegerListUnwrapped(v *[]*int32, decoder smithyxml.NodeDecoder) error { + var sv []*int32 + if *v == nil { + sv = make([]*int32, 0) + } else { + sv = *v + } + + for { + var mv *int32 + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + mv = ptr.Int32(int32(i64)) + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentNestedStringList(v *[][]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv [][]*string + if *v == nil { + sv = make([][]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + for { + if strings.EqualFold("member", t.Name.Local) { + var col []*string + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentStringList(&col, nodeDecoder); err != nil { + return err + } + sv = append(sv, col) + break + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentNestedStringListUnwrapped(v *[][]*string, decoder smithyxml.NodeDecoder) error { + var sv [][]*string + if *v == nil { + sv = make([][]*string, 0) + } else { + sv = *v + } + + for { + var mv []*string + t := decoder.StartEl + _ = t + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentStringList(&mv, nodeDecoder); err != nil { + return err + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentStringList(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentStringListUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentStringSet(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentStringSetUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentTimestampList(v *[]*time.Time, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*time.Time + if *v == nil { + sv = make([]*time.Time, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *time.Time + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + col = &t + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentTimestampListUnwrapped(v *[]*time.Time, decoder smithyxml.NodeDecoder) error { + var sv []*time.Time + if *v == nil { + sv = make([]*time.Time, 0) + } else { + sv = *v + } + + for { + var mv *time.Time + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + mv = &t + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsEc2query_deserializeDocumentEmptyInputAndEmptyOutputOutput(v **EmptyInputAndEmptyOutputOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *EmptyInputAndEmptyOutputOutput + if *v == nil { + sv = &EmptyInputAndEmptyOutputOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentGreetingWithErrorsOutput(v **GreetingWithErrorsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *GreetingWithErrorsOutput + if *v == nil { + sv = &GreetingWithErrorsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("greeting", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Greeting = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentIgnoresWrappingXmlNameOutput(v **IgnoresWrappingXmlNameOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *IgnoresWrappingXmlNameOutput + if *v == nil { + sv = &IgnoresWrappingXmlNameOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentNestedStructuresOutput(v **NestedStructuresOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *NestedStructuresOutput + if *v == nil { + sv = &NestedStructuresOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentNoInputAndOutputOutput(v **NoInputAndOutputOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *NoInputAndOutputOutput + if *v == nil { + sv = &NoInputAndOutputOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentQueryIdempotencyTokenAutoFillOutput(v **QueryIdempotencyTokenAutoFillOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *QueryIdempotencyTokenAutoFillOutput + if *v == nil { + sv = &QueryIdempotencyTokenAutoFillOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentQueryListsOutput(v **QueryListsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *QueryListsOutput + if *v == nil { + sv = &QueryListsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentQueryTimestampsOutput(v **QueryTimestampsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *QueryTimestampsOutput + if *v == nil { + sv = &QueryTimestampsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentRecursiveXmlShapesOutput(v **RecursiveXmlShapesOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *RecursiveXmlShapesOutput + if *v == nil { + sv = &RecursiveXmlShapesOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentRecursiveXmlShapesOutputNested1(&sv.Nested, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentSimpleInputParamsOutput(v **SimpleInputParamsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *SimpleInputParamsOutput + if *v == nil { + sv = &SimpleInputParamsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentSimpleScalarXmlPropertiesOutput(v **SimpleScalarXmlPropertiesOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *SimpleScalarXmlPropertiesOutput + if *v == nil { + sv = &SimpleScalarXmlPropertiesOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("byteValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.ByteValue = ptr.Int8(int8(i64)) + } + + case strings.EqualFold("DoubleDribble", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + f64, err := strconv.ParseFloat(xtv, 64) + if err != nil { + return err + } + sv.DoubleValue = &f64 + } + + case strings.EqualFold("emptyStringValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.EmptyStringValue = &xtv + } + + case strings.EqualFold("falseBooleanValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) + } + sv.FalseBooleanValue = &xtv + } + + case strings.EqualFold("floatValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + f64, err := strconv.ParseFloat(xtv, 64) + if err != nil { + return err + } + sv.FloatValue = ptr.Float32(float32(f64)) + } + + case strings.EqualFold("integerValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.IntegerValue = ptr.Int32(int32(i64)) + } + + case strings.EqualFold("longValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.LongValue = &i64 + } + + case strings.EqualFold("shortValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.ShortValue = ptr.Int16(int16(i64)) + } + + case strings.EqualFold("stringValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.StringValue = &xtv + } + + case strings.EqualFold("trueBooleanValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) + } + sv.TrueBooleanValue = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentXmlBlobsOutput(v **XmlBlobsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlBlobsOutput + if *v == nil { + sv = &XmlBlobsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("data", t.Name.Local): + var data string + err := decoder.Decoder.DecodeElement(&data, &t) + if err != nil { + return err + } + sv.Data, err = base64.StdEncoding.DecodeString(data) + if err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentXmlEnumsOutput(v **XmlEnumsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlEnumsOutput + if *v == nil { + sv = &XmlEnumsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("fooEnum1", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.FooEnum1 = types.FooEnum(xtv) + } + + case strings.EqualFold("fooEnum2", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.FooEnum2 = types.FooEnum(xtv) + } + + case strings.EqualFold("fooEnum3", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.FooEnum3 = types.FooEnum(xtv) + } + + case strings.EqualFold("fooEnumList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentFooEnumList(&sv.FooEnumList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("fooEnumMap", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentFooEnumMap(&sv.FooEnumMap, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("fooEnumSet", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentFooEnumSet(&sv.FooEnumSet, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentXmlListsOutput(v **XmlListsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlListsOutput + if *v == nil { + sv = &XmlListsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("booleanList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentBooleanList(&sv.BooleanList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("enumList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentFooEnumList(&sv.EnumList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("flattenedList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentRenamedListMembersUnwrapped(&sv.FlattenedList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("customName", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentRenamedListMembersUnwrapped(&sv.FlattenedList2, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("integerList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentIntegerList(&sv.IntegerList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("nestedStringList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentNestedStringList(&sv.NestedStringList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("renamed", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentRenamedListMembers(&sv.RenamedListMembers, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("stringList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentStringList(&sv.StringList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("stringSet", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentStringSet(&sv.StringSet, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("myStructureList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentStructureList(&sv.StructureList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("timestampList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentTimestampList(&sv.TimestampList, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentXmlNamespacesOutput(v **XmlNamespacesOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlNamespacesOutput + if *v == nil { + sv = &XmlNamespacesOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsEc2query_deserializeDocumentXmlNamespaceNested(&sv.Nested, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsEc2query_deserializeDocumentXmlTimestampsOutput(v **XmlTimestampsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlTimestampsOutput + if *v == nil { + sv = &XmlTimestampsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("dateTime", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + sv.DateTime = &t + } + + case strings.EqualFold("epochSeconds", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + f64, err := strconv.ParseFloat(xtv, 64) + if err != nil { + return err + } + sv.EpochSeconds = ptr.Time(smithytime.ParseEpochSeconds(f64)) + } + + case strings.EqualFold("httpDate", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseHTTPDate(xtv) + if err != nil { + return err + } + sv.HttpDate = &t + } + + case strings.EqualFold("normal", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + sv.Normal = &t + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil } diff --git a/internal/protocoltest/ec2query/go.mod b/internal/protocoltest/ec2query/go.mod index 4eb7e796d9c..1c5e90058f6 100644 --- a/internal/protocoltest/ec2query/go.mod +++ b/internal/protocoltest/ec2query/go.mod @@ -3,7 +3,7 @@ module github.com/aws/aws-sdk-go-v2/internal/protocoltest/ec2query go 1.15 require ( - github.com/aws/aws-sdk-go-v2 v0.24.1-0.20200821181726-bc564654ccac - github.com/awslabs/smithy-go v0.0.0-20200820215706-7b32252c1389 + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 github.com/google/go-cmp v0.4.1 ) diff --git a/internal/protocoltest/jsonrpc/api_op_JsonUnions.go b/internal/protocoltest/jsonrpc/api_op_JsonUnions.go new file mode 100644 index 00000000000..d78920b87b7 --- /dev/null +++ b/internal/protocoltest/jsonrpc/api_op_JsonUnions.go @@ -0,0 +1,83 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc/types" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// This operation uses unions for inputs and outputs. +func (c *Client) JsonUnions(ctx context.Context, params *JsonUnionsInput, optFns ...func(*Options)) (*JsonUnionsOutput, error) { + stack := middleware.NewStack("JsonUnions", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsAwsjson11_serdeOpJsonUnionsMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + v4.AddComputePayloadSHA256Middleware(stack) + retry.AddRetryMiddlewares(stack, options) + v4.AddHTTPSignerMiddleware(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opJsonUnions(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "JsonUnions", + Err: err, + } + } + out := result.(*JsonUnionsOutput) + out.ResultMetadata = metadata + return out, nil +} + +// A shared structure that contains a single union member. +type JsonUnionsInput struct { + // A union with a representative set of types for members. + Contents types.MyUnion +} + +// A shared structure that contains a single union member. +type JsonUnionsOutput struct { + // A union with a representative set of types for members. + Contents types.MyUnion + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsAwsjson11_serdeOpJsonUnionsMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsAwsjson11_serializeOpJsonUnions{}, middleware.After) + stack.Deserialize.Add(&awsAwsjson11_deserializeOpJsonUnions{}, middleware.After) +} + +func newServiceMetadataMiddleware_opJsonUnions(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "Json Protocol", + ServiceID: "jsonprotocol", + EndpointPrefix: "jsonprotocol", + SigningName: "foo", + OperationName: "JsonUnions", + } +} diff --git a/internal/protocoltest/jsonrpc/api_op_JsonUnions_test.go b/internal/protocoltest/jsonrpc/api_op_JsonUnions_test.go new file mode 100644 index 00000000000..16cf4c59cef --- /dev/null +++ b/internal/protocoltest/jsonrpc/api_op_JsonUnions_test.go @@ -0,0 +1,520 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc + +import ( + "bytes" + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc/types" + "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithytesting "github.com/awslabs/smithy-go/testing" + smithytime "github.com/awslabs/smithy-go/time" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_JsonUnions_awsAwsjson11Serialize(t *testing.T) { + cases := map[string]struct { + Params *JsonUnionsInput + ExpectMethod string + ExpectURIPath string + ExpectQuery []smithytesting.QueryItem + RequireQuery []string + ForbidQuery []string + ExpectHeader http.Header + RequireHeader []string + ForbidHeader []string + BodyMediaType string + BodyAssert func(io.Reader) error + }{ + // Serializes a string union value + "AwsJson11SerializeStringUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberStringValue{Value: "foo"}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "stringValue": "foo" + } + }`)) + }, + }, + // Serializes a boolean union value + "AwsJson11SerializeBooleanUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberBooleanValue{Value: true}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "booleanValue": true + } + }`)) + }, + }, + // Serializes a number union value + "AwsJson11SerializeNumberUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberNumberValue{Value: 1}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "numberValue": 1 + } + }`)) + }, + }, + // Serializes a blob union value + "AwsJson11SerializeBlobUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberBlobValue{Value: []byte("foo")}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "blobValue": "Zm9v" + } + }`)) + }, + }, + // Serializes a timestamp union value + "AwsJson11SerializeTimestampUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberTimestampValue{Value: smithytime.ParseEpochSeconds(1398796238)}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "timestampValue": 1398796238 + } + }`)) + }, + }, + // Serializes an enum union value + "AwsJson11SerializeEnumUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberEnumValue{Value: types.FooEnum("Foo")}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "enumValue": "Foo" + } + }`)) + }, + }, + // Serializes a list union value + "AwsJson11SerializeListUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberListValue{Value: []*string{ + ptr.String("foo"), + ptr.String("bar"), + }}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "listValue": ["foo", "bar"] + } + }`)) + }, + }, + // Serializes a map union value + "AwsJson11SerializeMapUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberMapValue{Value: map[string]*string{ + "foo": ptr.String("bar"), + "spam": ptr.String("eggs"), + }}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "mapValue": { + "foo": "bar", + "spam": "eggs" + } + } + }`)) + }, + }, + // Serializes a structure union value + "AwsJson11SerializeStructureUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberStructureValue{Value: &types.GreetingStruct{ + Hi: ptr.String("hello"), + }}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + "X-Amz-Target": []string{"JsonProtocol.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "structureValue": { + "hi": "hello" + } + } + }`)) + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + var actualReq *http.Request + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + actualReq = r.Clone(r.Context()) + if len(actualReq.URL.RawPath) == 0 { + actualReq.URL.RawPath = actualReq.URL.Path + } + if v := actualReq.ContentLength; v != 0 { + actualReq.Header.Set("Content-Length", strconv.FormatInt(v, 10)) + } + var buf bytes.Buffer + if _, err := io.Copy(&buf, r.Body); err != nil { + t.Errorf("failed to read request body, %v", err) + } + actualReq.Body = ioutil.NopCloser(&buf) + + w.WriteHeader(200) + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + result, err := client.JsonUnions(context.Background(), c.Params) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if e, a := c.ExpectMethod, actualReq.Method; e != a { + t.Errorf("expect %v method, got %v", e, a) + } + if e, a := c.ExpectURIPath, actualReq.URL.RawPath; e != a { + t.Errorf("expect %v path, got %v", e, a) + } + queryItems := smithytesting.ParseRawQuery(actualReq.URL.RawQuery) + smithytesting.AssertHasQuery(t, c.ExpectQuery, queryItems) + smithytesting.AssertHasQueryKeys(t, c.RequireQuery, queryItems) + smithytesting.AssertNotHaveQueryKeys(t, c.ForbidQuery, queryItems) + smithytesting.AssertHasHeader(t, c.ExpectHeader, actualReq.Header) + smithytesting.AssertHasHeaderKeys(t, c.RequireHeader, actualReq.Header) + smithytesting.AssertNotHaveHeaderKeys(t, c.ForbidHeader, actualReq.Header) + if c.BodyAssert != nil { + if err := c.BodyAssert(actualReq.Body); err != nil { + t.Errorf("expect body equal, got %v", err) + } + } + }) + } +} + +func TestClient_JsonUnions_awsAwsjson11Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectResult *JsonUnionsOutput + }{ + // Deserializes a string union value + "AwsJson11DeserializeStringUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "stringValue": "foo" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberStringValue{Value: "foo"}, + }, + }, + // Deserializes a boolean union value + "AwsJson11DeserializeBooleanUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "booleanValue": true + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberBooleanValue{Value: true}, + }, + }, + // Deserializes a number union value + "AwsJson11DeserializeNumberUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "numberValue": 1 + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberNumberValue{Value: 1}, + }, + }, + // Deserializes a blob union value + "AwsJson11DeserializeBlobUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "blobValue": "Zm9v" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberBlobValue{Value: []byte("foo")}, + }, + }, + // Deserializes a timestamp union value + "AwsJson11DeserializeTimestampUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "timestampValue": 1398796238 + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberTimestampValue{Value: smithytime.ParseEpochSeconds(1398796238)}, + }, + }, + // Deserializes an enum union value + "AwsJson11DeserializeEnumUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "enumValue": "Foo" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberEnumValue{Value: types.FooEnum("Foo")}, + }, + }, + // Deserializes a list union value + "AwsJson11DeserializeListUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "listValue": ["foo", "bar"] + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberListValue{Value: []*string{ + ptr.String("foo"), + ptr.String("bar"), + }}, + }, + }, + // Deserializes a map union value + "AwsJson11DeserializeMapUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "mapValue": { + "foo": "bar", + "spam": "eggs" + } + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberMapValue{Value: map[string]*string{ + "foo": ptr.String("bar"), + "spam": ptr.String("eggs"), + }}, + }, + }, + // Deserializes a structure union value + "AwsJson11DeserializeStructureUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.1"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "structureValue": { + "hi": "hello" + } + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberStructureValue{Value: &types.GreetingStruct{ + Hi: ptr.String("hello"), + }}, + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params JsonUnionsInput + result, err := client.JsonUnions(context.Background(), ¶ms) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if err := smithytesting.CompareValues(c.ExpectResult, result, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectResult value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/jsonrpc/deserializers.go b/internal/protocoltest/jsonrpc/deserializers.go index 8d7dea80cf0..20e39d9f3fd 100644 --- a/internal/protocoltest/jsonrpc/deserializers.go +++ b/internal/protocoltest/jsonrpc/deserializers.go @@ -11,12 +11,14 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc/types" smithy "github.com/awslabs/smithy-go" smithyio "github.com/awslabs/smithy-go/io" + smithyjson "github.com/awslabs/smithy-go/json" "github.com/awslabs/smithy-go/middleware" "github.com/awslabs/smithy-go/ptr" smithytime "github.com/awslabs/smithy-go/time" smithyhttp "github.com/awslabs/smithy-go/transport/http" "io" "strings" + "time" ) type awsAwsjson11_deserializeOpEmptyOperation struct { @@ -319,6 +321,103 @@ func awsAwsjson11_deserializeOpErrorJsonEnums(response *smithyhttp.Response) err } } +type awsAwsjson11_deserializeOpJsonUnions struct { +} + +func (*awsAwsjson11_deserializeOpJsonUnions) ID() string { + return "OperationDeserializer" +} + +func (m *awsAwsjson11_deserializeOpJsonUnions) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson11_deserializeOpErrorJsonUnions(response) + } + output := &JsonUnionsOutput{} + out.Result = output + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(response.Body, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + err = awsAwsjson11_deserializeDocumentJsonUnionsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsAwsjson11_deserializeOpErrorJsonUnions(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + type awsAwsjson11_deserializeOpKitchenSinkOperation struct { } @@ -883,7 +982,7 @@ func awsAwsjson11_deserializeDocumentComplexError(v **types.ComplexError, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -947,7 +1046,7 @@ func awsAwsjson11_deserializeDocumentComplexNestedErrorData(v **types.ComplexNes } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1006,7 +1105,7 @@ func awsAwsjson11_deserializeDocumentEmptyStruct(v **types.EmptyStruct, decoder } switch t { default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1128,7 +1227,7 @@ func awsAwsjson11_deserializeDocumentErrorWithMembers(v **types.ErrorWithMembers } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1179,7 +1278,7 @@ func awsAwsjson11_deserializeDocumentErrorWithoutMembers(v **types.ErrorWithoutM } switch t { default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1230,7 +1329,7 @@ func awsAwsjson11_deserializeDocumentFooError(v **types.FooError, decoder *json. } switch t { default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1294,7 +1393,7 @@ func awsAwsjson11_deserializeDocumentInvalidGreeting(v **types.InvalidGreeting, } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1596,7 +1695,7 @@ func awsAwsjson11_deserializeDocumentKitchenSink(v **types.KitchenSink, decoder } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2131,6 +2230,166 @@ func awsAwsjson11_deserializeDocumentMapOfStructs(v *map[string]*types.SimpleStr return nil } +func awsAwsjson11_deserializeDocumentMyUnion(v *types.MyUnion, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var uv types.MyUnion + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "blobValue": + var mv []byte + err := decoder.Decode(&mv) + if err != nil { + return err + } + uv = &types.MyUnionMemberBlobValue{Value: mv} + + case "booleanValue": + var mv *bool + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(bool) + if !ok { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) + } + mv = &jtv + } + uv = &types.MyUnionMemberBooleanValue{Value: *mv} + + case "enumValue": + var mv types.FooEnum + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected FooEnum to be of type string, got %T instead", val) + } + mv = types.FooEnum(jtv) + } + uv = &types.MyUnionMemberEnumValue{Value: mv} + + case "listValue": + var mv []*string + if err := awsAwsjson11_deserializeDocumentStringList(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberListValue{Value: mv} + + case "mapValue": + var mv map[string]*string + if err := awsAwsjson11_deserializeDocumentStringMap(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberMapValue{Value: mv} + + case "numberValue": + var mv *int32 + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(json.Number) + if !ok { + return fmt.Errorf("expected Integer to be json.Number, got %T instead", val) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + mv = ptr.Int32(int32(i64)) + } + uv = &types.MyUnionMemberNumberValue{Value: *mv} + + case "stringValue": + var mv *string + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + mv = &jtv + } + uv = &types.MyUnionMemberStringValue{Value: *mv} + + case "structureValue": + var mv *types.GreetingStruct + if err := awsAwsjson11_deserializeDocumentGreetingStruct(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberStructureValue{Value: mv} + + case "timestampValue": + var mv *time.Time + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(json.Number) + if !ok { + return fmt.Errorf("expected Timestamp to be json.Number, got %T instead", val) + } + f64, err := jtv.Float64() + if err != nil { + return err + } + mv = ptr.Time(smithytime.ParseEpochSeconds(f64)) + } + uv = &types.MyUnionMemberTimestampValue{Value: *mv} + + default: + tagString, ok := t.(string) + if !ok { + return fmt.Errorf("expected string key, found %T", t) + } + value, err := smithyjson.CollectUnknownField(decoder) + if err != nil { + return err + } + uv = &types.UnknownUnionMember{Tag: tagString, Value: value} + + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = uv + return nil +} + func awsAwsjson11_deserializeDocumentSimpleStruct(v **types.SimpleStruct, decoder *json.Decoder) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) @@ -2176,7 +2435,7 @@ func awsAwsjson11_deserializeDocumentSimpleStruct(v **types.SimpleStruct, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2240,7 +2499,7 @@ func awsAwsjson11_deserializeDocumentStructWithLocationName(v **types.StructWith } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2428,6 +2687,70 @@ func awsAwsjson11_deserializeDocumentFooEnumSet(v *[]types.FooEnum, decoder *jso return nil } +func awsAwsjson11_deserializeDocumentGreetingStruct(v **types.GreetingStruct, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *types.GreetingStruct + if *v == nil { + sv = &types.GreetingStruct{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "hi": + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + sv.Hi = &jtv + } + + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + func awsAwsjson11_deserializeDocumentStringList(v *[]*string, decoder *json.Decoder) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) @@ -2576,7 +2899,7 @@ func awsAwsjson11_deserializeDocumentEmptyOperationOutput(v **EmptyOperationOutp } switch t { default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2640,7 +2963,7 @@ func awsAwsjson11_deserializeDocumentGreetingWithErrorsOutput(v **GreetingWithEr } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2745,7 +3068,63 @@ func awsAwsjson11_deserializeDocumentJsonEnumsOutput(v **JsonEnumsOutput, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson11_deserializeDocumentJsonUnionsOutput(v **JsonUnionsOutput, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *JsonUnionsOutput + if *v == nil { + sv = &JsonUnionsOutput{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "contents": + if err := awsAwsjson11_deserializeDocumentMyUnion(&sv.Contents, decoder); err != nil { + return err + } + + default: + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -3047,7 +3426,7 @@ func awsAwsjson11_deserializeDocumentKitchenSinkOperationOutput(v **KitchenSinkO } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -3121,7 +3500,7 @@ func awsAwsjson11_deserializeDocumentNullOperationOutput(v **NullOperationOutput } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -3185,7 +3564,7 @@ func awsAwsjson11_deserializeDocumentOperationWithOptionalInputOutputOutput(v ** } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -3241,7 +3620,7 @@ func awsAwsjson11_deserializeDocumentPutAndGetInlineDocumentsOutput(v **PutAndGe } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } diff --git a/internal/protocoltest/jsonrpc/go.mod b/internal/protocoltest/jsonrpc/go.mod index c3dc5fa5381..a09ca986237 100644 --- a/internal/protocoltest/jsonrpc/go.mod +++ b/internal/protocoltest/jsonrpc/go.mod @@ -3,7 +3,7 @@ module github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc go 1.15 require ( - github.com/aws/aws-sdk-go-v2 v0.24.1-0.20200821181726-bc564654ccac - github.com/awslabs/smithy-go v0.0.0-20200820215706-7b32252c1389 + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 github.com/google/go-cmp v0.4.1 ) diff --git a/internal/protocoltest/jsonrpc/serializers.go b/internal/protocoltest/jsonrpc/serializers.go index fa65cedd9fa..13e278a6e3a 100644 --- a/internal/protocoltest/jsonrpc/serializers.go +++ b/internal/protocoltest/jsonrpc/serializers.go @@ -139,6 +139,52 @@ func (m *awsAwsjson11_serializeOpJsonEnums) HandleSerialize(ctx context.Context, return next.HandleSerialize(ctx, in) } +type awsAwsjson11_serializeOpJsonUnions struct { +} + +func (*awsAwsjson11_serializeOpJsonUnions) ID() string { + return "OperationSerializer" +} + +func (m *awsAwsjson11_serializeOpJsonUnions) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*JsonUnionsInput) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + request.Request.URL.Path = "/" + request.Request.Method = "POST" + httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.1") + httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonProtocol.JsonUnions") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsAwsjson11_serializeDocumentJsonUnionsInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} + type awsAwsjson11_serializeOpKitchenSinkOperation struct { } @@ -665,6 +711,60 @@ func awsAwsjson11_serializeDocumentMapOfStructs(v map[string]*types.SimpleStruct return nil } +func awsAwsjson11_serializeDocumentMyUnion(v types.MyUnion, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + switch uv := v.(type) { + case *types.MyUnionMemberBlobValue: + av := object.Key("blobValue") + av.Base64EncodeBytes(uv.Value) + + case *types.MyUnionMemberBooleanValue: + av := object.Key("booleanValue") + av.Boolean(uv.Value) + + case *types.MyUnionMemberEnumValue: + av := object.Key("enumValue") + av.String(string(uv.Value)) + + case *types.MyUnionMemberListValue: + av := object.Key("listValue") + if err := awsAwsjson11_serializeDocumentStringList(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberMapValue: + av := object.Key("mapValue") + if err := awsAwsjson11_serializeDocumentStringMap(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberNumberValue: + av := object.Key("numberValue") + av.Integer(uv.Value) + + case *types.MyUnionMemberStringValue: + av := object.Key("stringValue") + av.String(uv.Value) + + case *types.MyUnionMemberStructureValue: + av := object.Key("structureValue") + if err := awsAwsjson11_serializeDocumentGreetingStruct(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberTimestampValue: + av := object.Key("timestampValue") + av.Double(smithytime.FormatEpochSeconds(uv.Value)) + + default: + return fmt.Errorf("attempted to serialize unknown member type %T for union %T", uv, v) + + } + return nil +} + func awsAwsjson11_serializeDocumentSimpleStruct(v *types.SimpleStruct, value smithyjson.Value) error { object := value.Object() defer object.Close() @@ -722,6 +822,18 @@ func awsAwsjson11_serializeDocumentFooEnumSet(v []types.FooEnum, value smithyjso return nil } +func awsAwsjson11_serializeDocumentGreetingStruct(v *types.GreetingStruct, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Hi != nil { + ok := object.Key("hi") + ok.String(*v.Hi) + } + + return nil +} + func awsAwsjson11_serializeDocumentStringList(v []*string, value smithyjson.Value) error { array := value.Array() defer array.Close() @@ -809,6 +921,20 @@ func awsAwsjson11_serializeDocumentJsonEnumsInput(v *JsonEnumsInput, value smith return nil } +func awsAwsjson11_serializeDocumentJsonUnionsInput(v *JsonUnionsInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Contents != nil { + ok := object.Key("contents") + if err := awsAwsjson11_serializeDocumentMyUnion(v.Contents, ok); err != nil { + return err + } + } + + return nil +} + func awsAwsjson11_serializeDocumentKitchenSinkOperationInput(v *KitchenSinkOperationInput, value smithyjson.Value) error { object := value.Object() defer object.Close() diff --git a/internal/protocoltest/jsonrpc/types/types.go b/internal/protocoltest/jsonrpc/types/types.go index 2b71823d57d..54dd50a7a80 100644 --- a/internal/protocoltest/jsonrpc/types/types.go +++ b/internal/protocoltest/jsonrpc/types/types.go @@ -42,6 +42,65 @@ type KitchenSink struct { UnixTimestamp *time.Time } +// A union with a representative set of types for members. +type MyUnion interface { + isMyUnion() +} + +type MyUnionMemberStringValue struct { + Value string +} + +func (*MyUnionMemberStringValue) isMyUnion() {} + +type MyUnionMemberBooleanValue struct { + Value bool +} + +func (*MyUnionMemberBooleanValue) isMyUnion() {} + +type MyUnionMemberNumberValue struct { + Value int32 +} + +func (*MyUnionMemberNumberValue) isMyUnion() {} + +type MyUnionMemberBlobValue struct { + Value []byte +} + +func (*MyUnionMemberBlobValue) isMyUnion() {} + +type MyUnionMemberTimestampValue struct { + Value time.Time +} + +func (*MyUnionMemberTimestampValue) isMyUnion() {} + +type MyUnionMemberEnumValue struct { + Value FooEnum +} + +func (*MyUnionMemberEnumValue) isMyUnion() {} + +type MyUnionMemberListValue struct { + Value []*string +} + +func (*MyUnionMemberListValue) isMyUnion() {} + +type MyUnionMemberMapValue struct { + Value map[string]*string +} + +func (*MyUnionMemberMapValue) isMyUnion() {} + +type MyUnionMemberStructureValue struct { + Value *GreetingStruct +} + +func (*MyUnionMemberStructureValue) isMyUnion() {} + type SimpleStruct struct { Value *string } @@ -49,3 +108,16 @@ type SimpleStruct struct { type StructWithLocationName struct { Value *string } + +type GreetingStruct struct { + Hi *string +} + +// UnknownUnionMember is returned when a union member is returned over the wire, +// but has an unknown tag. +type UnknownUnionMember struct { + Tag string + Value []byte +} + +func (*UnknownUnionMember) isMyUnion() {} diff --git a/internal/protocoltest/jsonrpc10/api_client.go b/internal/protocoltest/jsonrpc10/api_client.go new file mode 100644 index 00000000000..9930ce47368 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_client.go @@ -0,0 +1,128 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/retry" + "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + "github.com/awslabs/smithy-go/middleware" + "net/http" +) + +type Client struct { + options Options +} + +// New returns an initialized Client based on the functional options. Provide +// additional functional options to further configure the behavior of the client, +// such as changing the client's endpoint or adding custom middleware behavior. +func New(options Options, optFns ...func(*Options)) *Client { + options = options.Copy() + + resolveDefaultEndpointConfiguration(&options) + + for _, fn := range optFns { + fn(&options) + } + + client := &Client{ + options: options, + } + + return client +} + +// ServiceID returns the name of the identifier for the service API. +func (c *Client) ServiceID() string { return "jsonrpc10" } + +// ServiceName returns the full service title. +func (c *Client) ServiceName() string { return "jsonrpc10" } + +type Options struct { + // Set of options to modify how an operation is invoked. These apply to all + // operations invoked for this client. Use functional options on operation call to + // modify this list for per operation behavior. + APIOptions []APIOptionFunc + + // The endpoint options to be used when attempting to resolve an endpoint. + EndpointOptions ResolverOptions + + // The service endpoint resolver. + EndpointResolver EndpointResolver + + // HTTPSigner provides AWS request signing for HTTP requests made from the client. + // When nil the API client will use a default signer. + HTTPSigner v4.HTTPSigner + + // An integer value representing the logging level. + LogLevel aws.LogLevel + + // The logger writer interface to write logging messages to. + Logger aws.Logger + + // The region to send requests to. (Required) + Region string + + // Retryer guides how HTTP requests should be retried in case of recoverable + // failures. When nil the API client will use a default retryer. + Retryer retry.Retryer + + // The HTTP client to invoke API calls with. Defaults to client's default HTTP + // implementation if nil. + HTTPClient HTTPClient +} + +func (o Options) GetEndpointOptions() ResolverOptions { + return o.EndpointOptions +} + +func (o Options) GetEndpointResolver() EndpointResolver { + return o.EndpointResolver +} + +func (o Options) GetHTTPSigner() v4.HTTPSigner { + return o.HTTPSigner +} + +func (o Options) GetLogLevel() aws.LogLevel { + return o.LogLevel +} + +func (o Options) GetLogger() aws.Logger { + return o.Logger +} + +func (o Options) GetRegion() string { + return o.Region +} + +func (o Options) GetRetryer() retry.Retryer { + return o.Retryer +} + +type HTTPClient interface { + Do(*http.Request) (*http.Response, error) +} + +// Copy creates a clone where the APIOptions list is deep copied. +func (o Options) Copy() Options { + to := o + to.APIOptions = make([]APIOptionFunc, len(o.APIOptions)) + copy(to.APIOptions, o.APIOptions) + return to +} + +type APIOptionFunc func(*middleware.Stack) error + +// NewFromConfig returns a new client from the provided config. +func NewFromConfig(cfg aws.Config, optFns ...func(*Options)) *Client { + opts := Options{ + Region: cfg.Region, + Retryer: cfg.Retryer, + LogLevel: cfg.LogLevel, + Logger: cfg.Logger, + HTTPClient: cfg.HTTPClient, + } + return New(opts, optFns...) +} diff --git a/internal/protocoltest/jsonrpc10/api_op_EmptyInputAndEmptyOutput.go b/internal/protocoltest/jsonrpc10/api_op_EmptyInputAndEmptyOutput.go new file mode 100644 index 00000000000..05a126f9ddf --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_EmptyInputAndEmptyOutput.go @@ -0,0 +1,74 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// The example tests how requests and responses are serialized when there's no +// request or response payload because the operation has an empty input and empty +// output structure that reuses the same shape. While this should be rare, code +// generators must support this. +func (c *Client) EmptyInputAndEmptyOutput(ctx context.Context, params *EmptyInputAndEmptyOutputInput, optFns ...func(*Options)) (*EmptyInputAndEmptyOutputOutput, error) { + stack := middleware.NewStack("EmptyInputAndEmptyOutput", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsAwsjson10_serdeOpEmptyInputAndEmptyOutputMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + retry.AddRetryMiddlewares(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opEmptyInputAndEmptyOutput(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "EmptyInputAndEmptyOutput", + Err: err, + } + } + out := result.(*EmptyInputAndEmptyOutputOutput) + out.ResultMetadata = metadata + return out, nil +} + +type EmptyInputAndEmptyOutputInput struct { +} + +type EmptyInputAndEmptyOutputOutput struct { + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsAwsjson10_serdeOpEmptyInputAndEmptyOutputMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsAwsjson10_serializeOpEmptyInputAndEmptyOutput{}, middleware.After) + stack.Deserialize.Add(&awsAwsjson10_deserializeOpEmptyInputAndEmptyOutput{}, middleware.After) +} + +func newServiceMetadataMiddleware_opEmptyInputAndEmptyOutput(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "JSON RPC 10", + ServiceID: "jsonrpc10", + EndpointPrefix: "jsonrpc10", + OperationName: "EmptyInputAndEmptyOutput", + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_EmptyInputAndEmptyOutput_test.go b/internal/protocoltest/jsonrpc10/api_op_EmptyInputAndEmptyOutput_test.go new file mode 100644 index 00000000000..165cb4a041a --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_EmptyInputAndEmptyOutput_test.go @@ -0,0 +1,193 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "bytes" + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/awslabs/smithy-go/middleware" + smithytesting "github.com/awslabs/smithy-go/testing" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_EmptyInputAndEmptyOutput_awsAwsjson10Serialize(t *testing.T) { + cases := map[string]struct { + Params *EmptyInputAndEmptyOutputInput + ExpectMethod string + ExpectURIPath string + ExpectQuery []smithytesting.QueryItem + RequireQuery []string + ForbidQuery []string + ExpectHeader http.Header + RequireHeader []string + ForbidHeader []string + BodyMediaType string + BodyAssert func(io.Reader) error + }{ + // Empty input serializes no payload + "AwsJson10EmptyInputAndEmptyOutput": { + Params: &EmptyInputAndEmptyOutputInput{}, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.EmptyInputAndEmptyOutput"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareReaderEmpty(actual) + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + var actualReq *http.Request + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + actualReq = r.Clone(r.Context()) + if len(actualReq.URL.RawPath) == 0 { + actualReq.URL.RawPath = actualReq.URL.Path + } + if v := actualReq.ContentLength; v != 0 { + actualReq.Header.Set("Content-Length", strconv.FormatInt(v, 10)) + } + var buf bytes.Buffer + if _, err := io.Copy(&buf, r.Body); err != nil { + t.Errorf("failed to read request body, %v", err) + } + actualReq.Body = ioutil.NopCloser(&buf) + + w.WriteHeader(200) + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + result, err := client.EmptyInputAndEmptyOutput(context.Background(), c.Params) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if e, a := c.ExpectMethod, actualReq.Method; e != a { + t.Errorf("expect %v method, got %v", e, a) + } + if e, a := c.ExpectURIPath, actualReq.URL.RawPath; e != a { + t.Errorf("expect %v path, got %v", e, a) + } + queryItems := smithytesting.ParseRawQuery(actualReq.URL.RawQuery) + smithytesting.AssertHasQuery(t, c.ExpectQuery, queryItems) + smithytesting.AssertHasQueryKeys(t, c.RequireQuery, queryItems) + smithytesting.AssertNotHaveQueryKeys(t, c.ForbidQuery, queryItems) + smithytesting.AssertHasHeader(t, c.ExpectHeader, actualReq.Header) + smithytesting.AssertHasHeaderKeys(t, c.RequireHeader, actualReq.Header) + smithytesting.AssertNotHaveHeaderKeys(t, c.ForbidHeader, actualReq.Header) + if c.BodyAssert != nil { + if err := c.BodyAssert(actualReq.Body); err != nil { + t.Errorf("expect body equal, got %v", err) + } + } + }) + } +} + +func TestClient_EmptyInputAndEmptyOutput_awsAwsjson10Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectResult *EmptyInputAndEmptyOutputOutput + }{ + // Empty output serializes no payload + "AwsJson10EmptyInputAndEmptyOutput": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(``), + ExpectResult: &EmptyInputAndEmptyOutputOutput{}, + }, + // Empty output serializes no payload + "AwsJson10EmptyInputAndEmptyJsonObjectOutput": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{}`), + ExpectResult: &EmptyInputAndEmptyOutputOutput{}, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params EmptyInputAndEmptyOutputInput + result, err := client.EmptyInputAndEmptyOutput(context.Background(), ¶ms) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if err := smithytesting.CompareValues(c.ExpectResult, result, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectResult value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_GreetingWithErrors.go b/internal/protocoltest/jsonrpc10/api_op_GreetingWithErrors.go new file mode 100644 index 00000000000..79e701eab99 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_GreetingWithErrors.go @@ -0,0 +1,84 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// This operation has three possible return values: +// +// * A successful response in +// the form of GreetingWithErrorsOutput +// +// * An InvalidGreeting error. +// +// * A +// ComplexError error. +// +// Implementations must be able to successfully take a +// response and properly deserialize successful and error responses. +func (c *Client) GreetingWithErrors(ctx context.Context, params *GreetingWithErrorsInput, optFns ...func(*Options)) (*GreetingWithErrorsOutput, error) { + stack := middleware.NewStack("GreetingWithErrors", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsAwsjson10_serdeOpGreetingWithErrorsMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + retry.AddRetryMiddlewares(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opGreetingWithErrors(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "GreetingWithErrors", + Err: err, + } + } + out := result.(*GreetingWithErrorsOutput) + out.ResultMetadata = metadata + return out, nil +} + +type GreetingWithErrorsInput struct { +} + +type GreetingWithErrorsOutput struct { + Greeting *string + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsAwsjson10_serdeOpGreetingWithErrorsMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsAwsjson10_serializeOpGreetingWithErrors{}, middleware.After) + stack.Deserialize.Add(&awsAwsjson10_deserializeOpGreetingWithErrors{}, middleware.After) +} + +func newServiceMetadataMiddleware_opGreetingWithErrors(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "JSON RPC 10", + ServiceID: "jsonrpc10", + EndpointPrefix: "jsonrpc10", + OperationName: "GreetingWithErrors", + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_GreetingWithErrors_test.go b/internal/protocoltest/jsonrpc10/api_op_GreetingWithErrors_test.go new file mode 100644 index 00000000000..80854a63c78 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_GreetingWithErrors_test.go @@ -0,0 +1,416 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "bytes" + "context" + "errors" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/types" + "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithytesting "github.com/awslabs/smithy-go/testing" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_GreetingWithErrors_InvalidGreeting_awsAwsjson10Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectError *types.InvalidGreeting + }{ + // Parses simple JSON errors + "AwsJson10InvalidGreetingError": { + StatusCode: 400, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "__type": "aws.protocoltests.json10#InvalidGreeting", + "Message": "Hi" + }`), + ExpectError: &types.InvalidGreeting{ + Message: ptr.String("Hi"), + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params GreetingWithErrorsInput + result, err := client.GreetingWithErrors(context.Background(), ¶ms) + if err == nil { + t.Fatalf("expect not nil err") + } + if result != nil { + t.Fatalf("expect nil result, got %v", result) + } + var opErr interface { + Service() string + Operation() string + } + if !errors.As(err, &opErr) { + t.Fatalf("expect *types.InvalidGreeting operation error, got %T", err) + } + if e, a := client.ServiceID(), opErr.Service(); e != a { + t.Errorf("expect %v operation service name, got %v", e, a) + } + if e, a := "GreetingWithErrors", opErr.Operation(); e != a { + t.Errorf("expect %v operation service name, got %v", e, a) + } + var actualErr *types.InvalidGreeting + if !errors.As(err, &actualErr) { + t.Fatalf("expect *types.InvalidGreeting result error, got %T", err) + } + if err := smithytesting.CompareValues(c.ExpectError, actualErr, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectError value match:\n%v", err) + } + }) + } +} + +func TestClient_GreetingWithErrors_FooError_awsAwsjson10Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectError *types.FooError + }{ + // Serializes the X-Amzn-ErrorType header. For an example service, see Amazon EKS. + "AwsJson10FooErrorUsingXAmznErrorType": { + StatusCode: 500, + Header: http.Header{ + "X-Amzn-Errortype": []string{"FooError"}, + }, + ExpectError: &types.FooError{}, + }, + // Some X-Amzn-Errortype headers contain URLs. Clients need to split the URL on ':' + // and take only the first half of the string. For example, + // 'ValidationException:http://internal.amazon.com/coral/com.amazon.coral.validate/' + // is to be interpreted as 'ValidationException'. For an example service see Amazon + // Polly. + "AwsJson10FooErrorUsingXAmznErrorTypeWithUri": { + StatusCode: 500, + Header: http.Header{ + "X-Amzn-Errortype": []string{"FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/"}, + }, + ExpectError: &types.FooError{}, + }, + // X-Amzn-Errortype might contain a URL and a namespace. Client should extract only + // the shape name. This is a pathalogical case that might not actually happen in + // any deployed AWS service. + "AwsJson10FooErrorUsingXAmznErrorTypeWithUriAndNamespace": { + StatusCode: 500, + Header: http.Header{ + "X-Amzn-Errortype": []string{"aws.protocoltests.json10#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/"}, + }, + ExpectError: &types.FooError{}, + }, + // This example uses the 'code' property in the output rather than + // X-Amzn-Errortype. Some services do this though it's preferable to send the + // X-Amzn-Errortype. Client implementations must first check for the + // X-Amzn-Errortype and then check for a top-level 'code' property. For example + // service see Amazon S3 Glacier. + "AwsJson10FooErrorUsingCode": { + StatusCode: 500, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "code": "FooError" + }`), + ExpectError: &types.FooError{}, + }, + // Some services serialize errors using code, and it might contain a namespace. + // Clients should just take the last part of the string after '#'. + "AwsJson10FooErrorUsingCodeAndNamespace": { + StatusCode: 500, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "code": "aws.protocoltests.json10#FooError" + }`), + ExpectError: &types.FooError{}, + }, + // Some services serialize errors using code, and it might contain a namespace. It + // also might contain a URI. Clients should just take the last part of the string + // after '#' and before ":". This is a pathalogical case that might not occur in + // any deployed AWS service. + "AwsJson10FooErrorUsingCodeUriAndNamespace": { + StatusCode: 500, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "code": "aws.protocoltests.json10#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/" + }`), + ExpectError: &types.FooError{}, + }, + // Some services serialize errors using __type. + "AwsJson10FooErrorWithDunderType": { + StatusCode: 500, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "__type": "FooError" + }`), + ExpectError: &types.FooError{}, + }, + // Some services serialize errors using __type, and it might contain a namespace. + // Clients should just take the last part of the string after '#'. + "AwsJson10FooErrorWithDunderTypeAndNamespace": { + StatusCode: 500, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "__type": "aws.protocoltests.json10#FooError" + }`), + ExpectError: &types.FooError{}, + }, + // Some services serialize errors using __type, and it might contain a namespace. + // It also might contain a URI. Clients should just take the last part of the + // string after '#' and before ":". This is a pathalogical case that might not + // occur in any deployed AWS service. + "AwsJson10FooErrorWithDunderTypeUriAndNamespace": { + StatusCode: 500, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "__type": "aws.protocoltests.json10#FooError:http://internal.amazon.com/coral/com.amazon.coral.validate/" + }`), + ExpectError: &types.FooError{}, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params GreetingWithErrorsInput + result, err := client.GreetingWithErrors(context.Background(), ¶ms) + if err == nil { + t.Fatalf("expect not nil err") + } + if result != nil { + t.Fatalf("expect nil result, got %v", result) + } + var opErr interface { + Service() string + Operation() string + } + if !errors.As(err, &opErr) { + t.Fatalf("expect *types.FooError operation error, got %T", err) + } + if e, a := client.ServiceID(), opErr.Service(); e != a { + t.Errorf("expect %v operation service name, got %v", e, a) + } + if e, a := "GreetingWithErrors", opErr.Operation(); e != a { + t.Errorf("expect %v operation service name, got %v", e, a) + } + var actualErr *types.FooError + if !errors.As(err, &actualErr) { + t.Fatalf("expect *types.FooError result error, got %T", err) + } + if err := smithytesting.CompareValues(c.ExpectError, actualErr, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectError value match:\n%v", err) + } + }) + } +} + +func TestClient_GreetingWithErrors_ComplexError_awsAwsjson10Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectError *types.ComplexError + }{ + // Parses a complex error with no message member + "AwsJson10ComplexError": { + StatusCode: 400, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "__type": "aws.protocoltests.json10#ComplexError", + "TopLevel": "Top level", + "Nested": { + "Fooooo": "bar" + } + }`), + ExpectError: &types.ComplexError{ + TopLevel: ptr.String("Top level"), + Nested: &types.ComplexNestedErrorData{ + Foo: ptr.String("bar"), + }, + }, + }, + // Parses a complex error with an empty body + "AwsJson10EmptyComplexError": { + StatusCode: 400, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "__type": "aws.protocoltests.json10#ComplexError" + }`), + ExpectError: &types.ComplexError{}, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params GreetingWithErrorsInput + result, err := client.GreetingWithErrors(context.Background(), ¶ms) + if err == nil { + t.Fatalf("expect not nil err") + } + if result != nil { + t.Fatalf("expect nil result, got %v", result) + } + var opErr interface { + Service() string + Operation() string + } + if !errors.As(err, &opErr) { + t.Fatalf("expect *types.ComplexError operation error, got %T", err) + } + if e, a := client.ServiceID(), opErr.Service(); e != a { + t.Errorf("expect %v operation service name, got %v", e, a) + } + if e, a := "GreetingWithErrors", opErr.Operation(); e != a { + t.Errorf("expect %v operation service name, got %v", e, a) + } + var actualErr *types.ComplexError + if !errors.As(err, &actualErr) { + t.Fatalf("expect *types.ComplexError result error, got %T", err) + } + if err := smithytesting.CompareValues(c.ExpectError, actualErr, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectError value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_JsonUnions.go b/internal/protocoltest/jsonrpc10/api_op_JsonUnions.go new file mode 100644 index 00000000000..671386159c6 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_JsonUnions.go @@ -0,0 +1,79 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/types" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// This operation uses unions for inputs and outputs. +func (c *Client) JsonUnions(ctx context.Context, params *JsonUnionsInput, optFns ...func(*Options)) (*JsonUnionsOutput, error) { + stack := middleware.NewStack("JsonUnions", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsAwsjson10_serdeOpJsonUnionsMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + retry.AddRetryMiddlewares(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opJsonUnions(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "JsonUnions", + Err: err, + } + } + out := result.(*JsonUnionsOutput) + out.ResultMetadata = metadata + return out, nil +} + +// A shared structure that contains a single union member. +type JsonUnionsInput struct { + // A union with a representative set of types for members. + Contents types.MyUnion +} + +// A shared structure that contains a single union member. +type JsonUnionsOutput struct { + // A union with a representative set of types for members. + Contents types.MyUnion + + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsAwsjson10_serdeOpJsonUnionsMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsAwsjson10_serializeOpJsonUnions{}, middleware.After) + stack.Deserialize.Add(&awsAwsjson10_deserializeOpJsonUnions{}, middleware.After) +} + +func newServiceMetadataMiddleware_opJsonUnions(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "JSON RPC 10", + ServiceID: "jsonrpc10", + EndpointPrefix: "jsonrpc10", + OperationName: "JsonUnions", + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_JsonUnions_test.go b/internal/protocoltest/jsonrpc10/api_op_JsonUnions_test.go new file mode 100644 index 00000000000..12908981569 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_JsonUnions_test.go @@ -0,0 +1,520 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "bytes" + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/types" + "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithytesting "github.com/awslabs/smithy-go/testing" + smithytime "github.com/awslabs/smithy-go/time" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_JsonUnions_awsAwsjson10Serialize(t *testing.T) { + cases := map[string]struct { + Params *JsonUnionsInput + ExpectMethod string + ExpectURIPath string + ExpectQuery []smithytesting.QueryItem + RequireQuery []string + ForbidQuery []string + ExpectHeader http.Header + RequireHeader []string + ForbidHeader []string + BodyMediaType string + BodyAssert func(io.Reader) error + }{ + // Serializes a string union value + "AwsJson10SerializeStringUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberStringValue{Value: "foo"}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "stringValue": "foo" + } + }`)) + }, + }, + // Serializes a boolean union value + "AwsJson10SerializeBooleanUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberBooleanValue{Value: true}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "booleanValue": true + } + }`)) + }, + }, + // Serializes a number union value + "AwsJson10SerializeNumberUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberNumberValue{Value: 1}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "numberValue": 1 + } + }`)) + }, + }, + // Serializes a blob union value + "AwsJson10SerializeBlobUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberBlobValue{Value: []byte("foo")}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "blobValue": "Zm9v" + } + }`)) + }, + }, + // Serializes a timestamp union value + "AwsJson10SerializeTimestampUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberTimestampValue{Value: smithytime.ParseEpochSeconds(1398796238)}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "timestampValue": 1398796238 + } + }`)) + }, + }, + // Serializes an enum union value + "AwsJson10SerializeEnumUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberEnumValue{Value: types.FooEnum("Foo")}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "enumValue": "Foo" + } + }`)) + }, + }, + // Serializes a list union value + "AwsJson10SerializeListUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberListValue{Value: []*string{ + ptr.String("foo"), + ptr.String("bar"), + }}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "listValue": ["foo", "bar"] + } + }`)) + }, + }, + // Serializes a map union value + "AwsJson10SerializeMapUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberMapValue{Value: map[string]*string{ + "foo": ptr.String("bar"), + "spam": ptr.String("eggs"), + }}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "mapValue": { + "foo": "bar", + "spam": "eggs" + } + } + }`)) + }, + }, + // Serializes a structure union value + "AwsJson10SerializeStructureUnionValue": { + Params: &JsonUnionsInput{ + Contents: &types.MyUnionMemberStructureValue{Value: &types.GreetingStruct{ + Hi: ptr.String("hello"), + }}, + }, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.JsonUnions"}, + }, + BodyMediaType: "application/json", + BodyAssert: func(actual io.Reader) error { + return smithytesting.CompareJSONReaderBytes(actual, []byte(`{ + "contents": { + "structureValue": { + "hi": "hello" + } + } + }`)) + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + var actualReq *http.Request + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + actualReq = r.Clone(r.Context()) + if len(actualReq.URL.RawPath) == 0 { + actualReq.URL.RawPath = actualReq.URL.Path + } + if v := actualReq.ContentLength; v != 0 { + actualReq.Header.Set("Content-Length", strconv.FormatInt(v, 10)) + } + var buf bytes.Buffer + if _, err := io.Copy(&buf, r.Body); err != nil { + t.Errorf("failed to read request body, %v", err) + } + actualReq.Body = ioutil.NopCloser(&buf) + + w.WriteHeader(200) + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + result, err := client.JsonUnions(context.Background(), c.Params) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if e, a := c.ExpectMethod, actualReq.Method; e != a { + t.Errorf("expect %v method, got %v", e, a) + } + if e, a := c.ExpectURIPath, actualReq.URL.RawPath; e != a { + t.Errorf("expect %v path, got %v", e, a) + } + queryItems := smithytesting.ParseRawQuery(actualReq.URL.RawQuery) + smithytesting.AssertHasQuery(t, c.ExpectQuery, queryItems) + smithytesting.AssertHasQueryKeys(t, c.RequireQuery, queryItems) + smithytesting.AssertNotHaveQueryKeys(t, c.ForbidQuery, queryItems) + smithytesting.AssertHasHeader(t, c.ExpectHeader, actualReq.Header) + smithytesting.AssertHasHeaderKeys(t, c.RequireHeader, actualReq.Header) + smithytesting.AssertNotHaveHeaderKeys(t, c.ForbidHeader, actualReq.Header) + if c.BodyAssert != nil { + if err := c.BodyAssert(actualReq.Body); err != nil { + t.Errorf("expect body equal, got %v", err) + } + } + }) + } +} + +func TestClient_JsonUnions_awsAwsjson10Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectResult *JsonUnionsOutput + }{ + // Deserializes a string union value + "AwsJson10DeserializeStringUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "stringValue": "foo" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberStringValue{Value: "foo"}, + }, + }, + // Deserializes a boolean union value + "AwsJson10DeserializeBooleanUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "booleanValue": true + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberBooleanValue{Value: true}, + }, + }, + // Deserializes a number union value + "AwsJson10DeserializeNumberUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "numberValue": 1 + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberNumberValue{Value: 1}, + }, + }, + // Deserializes a blob union value + "AwsJson10DeserializeBlobUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "blobValue": "Zm9v" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberBlobValue{Value: []byte("foo")}, + }, + }, + // Deserializes a timestamp union value + "AwsJson10DeserializeTimestampUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "timestampValue": 1398796238 + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberTimestampValue{Value: smithytime.ParseEpochSeconds(1398796238)}, + }, + }, + // Deserializes an enum union value + "AwsJson10DeserializeEnumUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "enumValue": "Foo" + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberEnumValue{Value: types.FooEnum("Foo")}, + }, + }, + // Deserializes a list union value + "AwsJson10DeserializeListUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "listValue": ["foo", "bar"] + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberListValue{Value: []*string{ + ptr.String("foo"), + ptr.String("bar"), + }}, + }, + }, + // Deserializes a map union value + "AwsJson10DeserializeMapUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "mapValue": { + "foo": "bar", + "spam": "eggs" + } + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberMapValue{Value: map[string]*string{ + "foo": ptr.String("bar"), + "spam": ptr.String("eggs"), + }}, + }, + }, + // Deserializes a structure union value + "AwsJson10DeserializeStructureUnionValue": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + BodyMediaType: "application/json", + Body: []byte(`{ + "contents": { + "structureValue": { + "hi": "hello" + } + } + }`), + ExpectResult: &JsonUnionsOutput{ + Contents: &types.MyUnionMemberStructureValue{Value: &types.GreetingStruct{ + Hi: ptr.String("hello"), + }}, + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params JsonUnionsInput + result, err := client.JsonUnions(context.Background(), ¶ms) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if err := smithytesting.CompareValues(c.ExpectResult, result, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectResult value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_NoInputAndNoOutput.go b/internal/protocoltest/jsonrpc10/api_op_NoInputAndNoOutput.go new file mode 100644 index 00000000000..c1d7cb75a9c --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_NoInputAndNoOutput.go @@ -0,0 +1,73 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// The example tests how requests and responses are serialized when there's no +// request or response payload because the operation has no input or output. While +// this should be rare, code generators must support this. +func (c *Client) NoInputAndNoOutput(ctx context.Context, params *NoInputAndNoOutputInput, optFns ...func(*Options)) (*NoInputAndNoOutputOutput, error) { + stack := middleware.NewStack("NoInputAndNoOutput", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsAwsjson10_serdeOpNoInputAndNoOutputMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + retry.AddRetryMiddlewares(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opNoInputAndNoOutput(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "NoInputAndNoOutput", + Err: err, + } + } + out := result.(*NoInputAndNoOutputOutput) + out.ResultMetadata = metadata + return out, nil +} + +type NoInputAndNoOutputInput struct { +} + +type NoInputAndNoOutputOutput struct { + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsAwsjson10_serdeOpNoInputAndNoOutputMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsAwsjson10_serializeOpNoInputAndNoOutput{}, middleware.After) + stack.Deserialize.Add(&awsAwsjson10_deserializeOpNoInputAndNoOutput{}, middleware.After) +} + +func newServiceMetadataMiddleware_opNoInputAndNoOutput(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "JSON RPC 10", + ServiceID: "jsonrpc10", + EndpointPrefix: "jsonrpc10", + OperationName: "NoInputAndNoOutput", + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_NoInputAndNoOutput_test.go b/internal/protocoltest/jsonrpc10/api_op_NoInputAndNoOutput_test.go new file mode 100644 index 00000000000..bf5dfeee25e --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_NoInputAndNoOutput_test.go @@ -0,0 +1,177 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "bytes" + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/awslabs/smithy-go/middleware" + smithytesting "github.com/awslabs/smithy-go/testing" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_NoInputAndNoOutput_awsAwsjson10Serialize(t *testing.T) { + cases := map[string]struct { + Params *NoInputAndNoOutputInput + ExpectMethod string + ExpectURIPath string + ExpectQuery []smithytesting.QueryItem + RequireQuery []string + ForbidQuery []string + ExpectHeader http.Header + RequireHeader []string + ForbidHeader []string + BodyMediaType string + BodyAssert func(io.Reader) error + }{ + // No input serializes no payload + "AwsJson10NoInputAndNoOutput": { + Params: &NoInputAndNoOutputInput{}, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.NoInputAndNoOutput"}, + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + var actualReq *http.Request + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + actualReq = r.Clone(r.Context()) + if len(actualReq.URL.RawPath) == 0 { + actualReq.URL.RawPath = actualReq.URL.Path + } + if v := actualReq.ContentLength; v != 0 { + actualReq.Header.Set("Content-Length", strconv.FormatInt(v, 10)) + } + var buf bytes.Buffer + if _, err := io.Copy(&buf, r.Body); err != nil { + t.Errorf("failed to read request body, %v", err) + } + actualReq.Body = ioutil.NopCloser(&buf) + + w.WriteHeader(200) + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + result, err := client.NoInputAndNoOutput(context.Background(), c.Params) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if e, a := c.ExpectMethod, actualReq.Method; e != a { + t.Errorf("expect %v method, got %v", e, a) + } + if e, a := c.ExpectURIPath, actualReq.URL.RawPath; e != a { + t.Errorf("expect %v path, got %v", e, a) + } + queryItems := smithytesting.ParseRawQuery(actualReq.URL.RawQuery) + smithytesting.AssertHasQuery(t, c.ExpectQuery, queryItems) + smithytesting.AssertHasQueryKeys(t, c.RequireQuery, queryItems) + smithytesting.AssertNotHaveQueryKeys(t, c.ForbidQuery, queryItems) + smithytesting.AssertHasHeader(t, c.ExpectHeader, actualReq.Header) + smithytesting.AssertHasHeaderKeys(t, c.RequireHeader, actualReq.Header) + smithytesting.AssertNotHaveHeaderKeys(t, c.ForbidHeader, actualReq.Header) + if c.BodyAssert != nil { + if err := c.BodyAssert(actualReq.Body); err != nil { + t.Errorf("expect body equal, got %v", err) + } + } + }) + } +} + +func TestClient_NoInputAndNoOutput_awsAwsjson10Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectResult *NoInputAndNoOutputOutput + }{ + // No output serializes no payload + "AwsJson10NoInputAndNoOutput": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + ExpectResult: &NoInputAndNoOutputOutput{}, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params NoInputAndNoOutputInput + result, err := client.NoInputAndNoOutput(context.Background(), ¶ms) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if err := smithytesting.CompareValues(c.ExpectResult, result, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectResult value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_NoInputAndOutput.go b/internal/protocoltest/jsonrpc10/api_op_NoInputAndOutput.go new file mode 100644 index 00000000000..80199263f46 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_NoInputAndOutput.go @@ -0,0 +1,73 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "context" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + "github.com/aws/aws-sdk-go-v2/aws/retry" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +// The example tests how requests and responses are serialized when there's no +// request or response payload because the operation has no input and the output is +// empty. While this should be rare, code generators must support this. +func (c *Client) NoInputAndOutput(ctx context.Context, params *NoInputAndOutputInput, optFns ...func(*Options)) (*NoInputAndOutputOutput, error) { + stack := middleware.NewStack("NoInputAndOutput", smithyhttp.NewStackRequest) + options := c.options.Copy() + for _, fn := range optFns { + fn(&options) + } + addawsAwsjson10_serdeOpNoInputAndOutputMiddlewares(stack) + awsmiddleware.AddRequestInvocationIDMiddleware(stack) + smithyhttp.AddContentLengthMiddleware(stack) + AddResolveEndpointMiddleware(stack, options) + retry.AddRetryMiddlewares(stack, options) + awsmiddleware.AddAttemptClockSkewMiddleware(stack) + smithyhttp.AddErrorCloseResponseBodyMiddleware(stack) + smithyhttp.AddCloseResponseBodyMiddleware(stack) + stack.Initialize.Add(newServiceMetadataMiddleware_opNoInputAndOutput(options.Region), middleware.Before) + + for _, fn := range options.APIOptions { + if err := fn(stack); err != nil { + return nil, err + } + } + handler := middleware.DecorateHandler(smithyhttp.NewClientHandler(options.HTTPClient), stack) + result, metadata, err := handler.Handle(ctx, params) + if err != nil { + return nil, &smithy.OperationError{ + ServiceID: c.ServiceID(), + OperationName: "NoInputAndOutput", + Err: err, + } + } + out := result.(*NoInputAndOutputOutput) + out.ResultMetadata = metadata + return out, nil +} + +type NoInputAndOutputInput struct { +} + +type NoInputAndOutputOutput struct { + // Metadata pertaining to the operation's result. + ResultMetadata middleware.Metadata +} + +func addawsAwsjson10_serdeOpNoInputAndOutputMiddlewares(stack *middleware.Stack) { + stack.Serialize.Add(&awsAwsjson10_serializeOpNoInputAndOutput{}, middleware.After) + stack.Deserialize.Add(&awsAwsjson10_deserializeOpNoInputAndOutput{}, middleware.After) +} + +func newServiceMetadataMiddleware_opNoInputAndOutput(region string) awsmiddleware.RegisterServiceMetadata { + return awsmiddleware.RegisterServiceMetadata{ + Region: region, + ServiceName: "JSON RPC 10", + ServiceID: "jsonrpc10", + EndpointPrefix: "jsonrpc10", + OperationName: "NoInputAndOutput", + } +} diff --git a/internal/protocoltest/jsonrpc10/api_op_NoInputAndOutput_test.go b/internal/protocoltest/jsonrpc10/api_op_NoInputAndOutput_test.go new file mode 100644 index 00000000000..ee2b60a320a --- /dev/null +++ b/internal/protocoltest/jsonrpc10/api_op_NoInputAndOutput_test.go @@ -0,0 +1,177 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "bytes" + "context" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/awslabs/smithy-go/middleware" + smithytesting "github.com/awslabs/smithy-go/testing" + "github.com/google/go-cmp/cmp/cmpopts" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" +) + +func TestClient_NoInputAndOutput_awsAwsjson10Serialize(t *testing.T) { + cases := map[string]struct { + Params *NoInputAndOutputInput + ExpectMethod string + ExpectURIPath string + ExpectQuery []smithytesting.QueryItem + RequireQuery []string + ForbidQuery []string + ExpectHeader http.Header + RequireHeader []string + ForbidHeader []string + BodyMediaType string + BodyAssert func(io.Reader) error + }{ + // No input serializes no payload + "AwsJson10NoInputAndOutput": { + Params: &NoInputAndOutputInput{}, + ExpectMethod: "POST", + ExpectURIPath: "/", + ExpectQuery: []smithytesting.QueryItem{}, + ExpectHeader: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + "X-Amz-Target": []string{"JsonRpc10.NoInputAndOutput"}, + }, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + var actualReq *http.Request + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + actualReq = r.Clone(r.Context()) + if len(actualReq.URL.RawPath) == 0 { + actualReq.URL.RawPath = actualReq.URL.Path + } + if v := actualReq.ContentLength; v != 0 { + actualReq.Header.Set("Content-Length", strconv.FormatInt(v, 10)) + } + var buf bytes.Buffer + if _, err := io.Copy(&buf, r.Body); err != nil { + t.Errorf("failed to read request body, %v", err) + } + actualReq.Body = ioutil.NopCloser(&buf) + + w.WriteHeader(200) + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + result, err := client.NoInputAndOutput(context.Background(), c.Params) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if e, a := c.ExpectMethod, actualReq.Method; e != a { + t.Errorf("expect %v method, got %v", e, a) + } + if e, a := c.ExpectURIPath, actualReq.URL.RawPath; e != a { + t.Errorf("expect %v path, got %v", e, a) + } + queryItems := smithytesting.ParseRawQuery(actualReq.URL.RawQuery) + smithytesting.AssertHasQuery(t, c.ExpectQuery, queryItems) + smithytesting.AssertHasQueryKeys(t, c.RequireQuery, queryItems) + smithytesting.AssertNotHaveQueryKeys(t, c.ForbidQuery, queryItems) + smithytesting.AssertHasHeader(t, c.ExpectHeader, actualReq.Header) + smithytesting.AssertHasHeaderKeys(t, c.RequireHeader, actualReq.Header) + smithytesting.AssertNotHaveHeaderKeys(t, c.ForbidHeader, actualReq.Header) + if c.BodyAssert != nil { + if err := c.BodyAssert(actualReq.Body); err != nil { + t.Errorf("expect body equal, got %v", err) + } + } + }) + } +} + +func TestClient_NoInputAndOutput_awsAwsjson10Deserialize(t *testing.T) { + cases := map[string]struct { + StatusCode int + Header http.Header + BodyMediaType string + Body []byte + ExpectResult *NoInputAndOutputOutput + }{ + // Empty output serializes no payload + "AwsJson10NoInputAndOutput": { + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/x-amz-json-1.0"}, + }, + ExpectResult: &NoInputAndOutputOutput{}, + }, + } + for name, c := range cases { + t.Run(name, func(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + for k, vs := range c.Header { + for _, v := range vs { + w.Header().Add(k, v) + } + } + if len(c.BodyMediaType) != 0 && len(w.Header().Values("Content-Type")) == 0 { + w.Header().Set("Content-Type", c.BodyMediaType) + } + if len(c.Body) != 0 { + w.Header().Set("Content-Length", strconv.Itoa(len(c.Body))) + } + w.WriteHeader(c.StatusCode) + if len(c.Body) != 0 { + if _, err := io.Copy(w, bytes.NewReader(c.Body)); err != nil { + t.Errorf("failed to write response body, %v", err) + } + } + })) + defer server.Close() + client := New(Options{ + APIOptions: []APIOptionFunc{ + func(s *middleware.Stack) error { + s.Finalize.Clear() + return nil + }, + }, + EndpointResolver: EndpointResolverFunc(func(region string, options ResolverOptions) (e aws.Endpoint, err error) { + e.URL = server.URL + e.SigningRegion = "us-west-2" + return e, err + }), + HTTPClient: aws.NewBuildableHTTPClient(), + Region: "us-west-2", + }) + var params NoInputAndOutputInput + result, err := client.NoInputAndOutput(context.Background(), ¶ms) + if err != nil { + t.Fatalf("expect nil err, got %v", err) + } + if result == nil { + t.Fatalf("expect not nil result") + } + if err := smithytesting.CompareValues(c.ExpectResult, result, cmpopts.IgnoreUnexported(middleware.Metadata{})); err != nil { + t.Errorf("expect c.ExpectResult value match:\n%v", err) + } + }) + } +} diff --git a/internal/protocoltest/jsonrpc10/deserializers.go b/internal/protocoltest/jsonrpc10/deserializers.go new file mode 100644 index 00000000000..4bccb1c7a9b --- /dev/null +++ b/internal/protocoltest/jsonrpc10/deserializers.go @@ -0,0 +1,1449 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "github.com/aws/aws-sdk-go-v2/aws/protocol/restjson" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/types" + smithy "github.com/awslabs/smithy-go" + smithyio "github.com/awslabs/smithy-go/io" + smithyjson "github.com/awslabs/smithy-go/json" + "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithytime "github.com/awslabs/smithy-go/time" + smithyhttp "github.com/awslabs/smithy-go/transport/http" + "io" + "strings" + "time" +) + +type awsAwsjson10_deserializeOpEmptyInputAndEmptyOutput struct { +} + +func (*awsAwsjson10_deserializeOpEmptyInputAndEmptyOutput) ID() string { + return "OperationDeserializer" +} + +func (m *awsAwsjson10_deserializeOpEmptyInputAndEmptyOutput) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorEmptyInputAndEmptyOutput(response) + } + output := &EmptyInputAndEmptyOutputOutput{} + out.Result = output + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(response.Body, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + err = awsAwsjson10_deserializeDocumentEmptyInputAndEmptyOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsAwsjson10_deserializeOpErrorEmptyInputAndEmptyOutput(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +type awsAwsjson10_deserializeOpGreetingWithErrors struct { +} + +func (*awsAwsjson10_deserializeOpGreetingWithErrors) ID() string { + return "OperationDeserializer" +} + +func (m *awsAwsjson10_deserializeOpGreetingWithErrors) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorGreetingWithErrors(response) + } + output := &GreetingWithErrorsOutput{} + out.Result = output + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(response.Body, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + err = awsAwsjson10_deserializeDocumentGreetingWithErrorsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsAwsjson10_deserializeOpErrorGreetingWithErrors(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + case strings.EqualFold("ComplexError", errorCode): + return awsAwsjson10_deserializeErrorComplexError(response, errorBody) + + case strings.EqualFold("FooError", errorCode): + return awsAwsjson10_deserializeErrorFooError(response, errorBody) + + case strings.EqualFold("InvalidGreeting", errorCode): + return awsAwsjson10_deserializeErrorInvalidGreeting(response, errorBody) + + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +type awsAwsjson10_deserializeOpJsonUnions struct { +} + +func (*awsAwsjson10_deserializeOpJsonUnions) ID() string { + return "OperationDeserializer" +} + +func (m *awsAwsjson10_deserializeOpJsonUnions) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorJsonUnions(response) + } + output := &JsonUnionsOutput{} + out.Result = output + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(response.Body, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + err = awsAwsjson10_deserializeDocumentJsonUnionsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsAwsjson10_deserializeOpErrorJsonUnions(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +type awsAwsjson10_deserializeOpNoInputAndNoOutput struct { +} + +func (*awsAwsjson10_deserializeOpNoInputAndNoOutput) ID() string { + return "OperationDeserializer" +} + +func (m *awsAwsjson10_deserializeOpNoInputAndNoOutput) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorNoInputAndNoOutput(response) + } + output := &NoInputAndNoOutputOutput{} + out.Result = output + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(response.Body, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + err = awsAwsjson10_deserializeDocumentNoInputAndNoOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsAwsjson10_deserializeOpErrorNoInputAndNoOutput(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +type awsAwsjson10_deserializeOpNoInputAndOutput struct { +} + +func (*awsAwsjson10_deserializeOpNoInputAndOutput) ID() string { + return "OperationDeserializer" +} + +func (m *awsAwsjson10_deserializeOpNoInputAndOutput) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( + out middleware.DeserializeOutput, metadata middleware.Metadata, err error, +) { + out, metadata, err = next.HandleDeserialize(ctx, in) + if err != nil { + return out, metadata, err + } + + response, ok := out.RawResponse.(*smithyhttp.Response) + if !ok { + return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} + } + + if response.StatusCode < 200 || response.StatusCode >= 300 { + return out, metadata, awsAwsjson10_deserializeOpErrorNoInputAndOutput(response) + } + output := &NoInputAndOutputOutput{} + out.Result = output + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(response.Body, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + err = awsAwsjson10_deserializeDocumentNoInputAndOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return out, metadata, err +} + +func awsAwsjson10_deserializeOpErrorNoInputAndOutput(response *smithyhttp.Response) error { + var errorBuffer bytes.Buffer + if _, err := io.Copy(&errorBuffer, response.Body); err != nil { + return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} + } + errorBody := bytes.NewReader(errorBuffer.Bytes()) + + errorCode := "UnknownError" + errorMessage := errorCode + + code := response.Header.Get("X-Amzn-ErrorType") + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + code, message, err := restjson.GetErrorInfo(decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + if len(code) != 0 { + errorCode = restjson.SanitizeErrorCode(code) + } + if len(message) != 0 { + errorMessage = message + } + + switch { + default: + genericError := &smithy.GenericAPIError{ + Code: errorCode, + Message: errorMessage, + } + return genericError + + } +} + +func awsAwsjson10_deserializeErrorComplexError(response *smithyhttp.Response, errorBody *bytes.Reader) error { + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + output := &types.ComplexError{} + err := awsAwsjson10_deserializeDocumentComplexError(&output, decoder) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + return output +} + +func awsAwsjson10_deserializeErrorFooError(response *smithyhttp.Response, errorBody *bytes.Reader) error { + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + output := &types.FooError{} + err := awsAwsjson10_deserializeDocumentFooError(&output, decoder) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + return output +} + +func awsAwsjson10_deserializeErrorInvalidGreeting(response *smithyhttp.Response, errorBody *bytes.Reader) error { + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + + body := io.TeeReader(errorBody, ringBuffer) + decoder := json.NewDecoder(body) + decoder.UseNumber() + + output := &types.InvalidGreeting{} + err := awsAwsjson10_deserializeDocumentInvalidGreeting(&output, decoder) + + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + errorBody.Seek(0, io.SeekStart) + return output +} + +func awsAwsjson10_deserializeDocumentComplexError(v **types.ComplexError, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *types.ComplexError + if *v == nil { + sv = &types.ComplexError{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "Nested": + if err := awsAwsjson10_deserializeDocumentComplexNestedErrorData(&sv.Nested, decoder); err != nil { + return err + } + + case "TopLevel": + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + sv.TopLevel = &jtv + } + + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentComplexNestedErrorData(v **types.ComplexNestedErrorData, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *types.ComplexNestedErrorData + if *v == nil { + sv = &types.ComplexNestedErrorData{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "Fooooo": + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + sv.Foo = &jtv + } + + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentFooError(v **types.FooError, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *types.FooError + if *v == nil { + sv = &types.FooError{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentInvalidGreeting(v **types.InvalidGreeting, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *types.InvalidGreeting + if *v == nil { + sv = &types.InvalidGreeting{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "Message": + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + sv.Message = &jtv + } + + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentMyUnion(v *types.MyUnion, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var uv types.MyUnion + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "blobValue": + var mv []byte + err := decoder.Decode(&mv) + if err != nil { + return err + } + uv = &types.MyUnionMemberBlobValue{Value: mv} + + case "booleanValue": + var mv *bool + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(bool) + if !ok { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) + } + mv = &jtv + } + uv = &types.MyUnionMemberBooleanValue{Value: *mv} + + case "enumValue": + var mv types.FooEnum + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected FooEnum to be of type string, got %T instead", val) + } + mv = types.FooEnum(jtv) + } + uv = &types.MyUnionMemberEnumValue{Value: mv} + + case "listValue": + var mv []*string + if err := awsAwsjson10_deserializeDocumentStringList(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberListValue{Value: mv} + + case "mapValue": + var mv map[string]*string + if err := awsAwsjson10_deserializeDocumentStringMap(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberMapValue{Value: mv} + + case "numberValue": + var mv *int32 + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(json.Number) + if !ok { + return fmt.Errorf("expected Integer to be json.Number, got %T instead", val) + } + i64, err := jtv.Int64() + if err != nil { + return err + } + mv = ptr.Int32(int32(i64)) + } + uv = &types.MyUnionMemberNumberValue{Value: *mv} + + case "stringValue": + var mv *string + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + mv = &jtv + } + uv = &types.MyUnionMemberStringValue{Value: *mv} + + case "structureValue": + var mv *types.GreetingStruct + if err := awsAwsjson10_deserializeDocumentGreetingStruct(&mv, decoder); err != nil { + return err + } + uv = &types.MyUnionMemberStructureValue{Value: mv} + + case "timestampValue": + var mv *time.Time + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(json.Number) + if !ok { + return fmt.Errorf("expected Timestamp to be json.Number, got %T instead", val) + } + f64, err := jtv.Float64() + if err != nil { + return err + } + mv = ptr.Time(smithytime.ParseEpochSeconds(f64)) + } + uv = &types.MyUnionMemberTimestampValue{Value: *mv} + + default: + tagString, ok := t.(string) + if !ok { + return fmt.Errorf("expected string key, found %T", t) + } + value, err := smithyjson.CollectUnknownField(decoder) + if err != nil { + return err + } + uv = &types.UnknownUnionMember{Tag: tagString, Value: value} + + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = uv + return nil +} + +func awsAwsjson10_deserializeDocumentGreetingStruct(v **types.GreetingStruct, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *types.GreetingStruct + if *v == nil { + sv = &types.GreetingStruct{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "hi": + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + sv.Hi = &jtv + } + + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentStringList(v *[]*string, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '[' { + return fmt.Errorf("expect `[` as start token") + } + + var cv []*string + if *v == nil { + cv = []*string{} + } else { + cv = *v + } + + for decoder.More() { + var col *string + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + col = &jtv + } + cv = append(cv, col) + + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != ']' { + return fmt.Errorf("expect `]` as end token") + } + + *v = cv + return nil +} + +func awsAwsjson10_deserializeDocumentStringMap(v *map[string]*string, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var mv map[string]*string + if *v == nil { + mv = map[string]*string{} + } else { + mv = *v + } + + for decoder.More() { + token, err := decoder.Token() + if err != nil { + return err + } + + key, ok := token.(string) + if !ok { + return fmt.Errorf("expected map-key of type string, found type %T", token) + } + + var parsedVal *string + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + parsedVal = &jtv + } + mv[key] = parsedVal + + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = mv + return nil +} + +func awsAwsjson10_deserializeDocumentEmptyInputAndEmptyOutputOutput(v **EmptyInputAndEmptyOutputOutput, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *EmptyInputAndEmptyOutputOutput + if *v == nil { + sv = &EmptyInputAndEmptyOutputOutput{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentGreetingWithErrorsOutput(v **GreetingWithErrorsOutput, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *GreetingWithErrorsOutput + if *v == nil { + sv = &GreetingWithErrorsOutput{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "greeting": + val, err := decoder.Token() + if err != nil { + return err + } + if val != nil { + jtv, ok := val.(string) + if !ok { + return fmt.Errorf("expected String to be of type string, got %T instead", val) + } + sv.Greeting = &jtv + } + + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentJsonUnionsOutput(v **JsonUnionsOutput, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *JsonUnionsOutput + if *v == nil { + sv = &JsonUnionsOutput{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + case "contents": + if err := awsAwsjson10_deserializeDocumentMyUnion(&sv.Contents, decoder); err != nil { + return err + } + + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentNoInputAndNoOutputOutput(v **NoInputAndNoOutputOutput, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *NoInputAndNoOutputOutput + if *v == nil { + sv = &NoInputAndNoOutputOutput{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} + +func awsAwsjson10_deserializeDocumentNoInputAndOutputOutput(v **NoInputAndOutputOutput, decoder *json.Decoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + startToken, err := decoder.Token() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + if startToken == nil { + return nil + } + if t, ok := startToken.(json.Delim); !ok || t != '{' { + return fmt.Errorf("expect `{` as start token") + } + + var sv *NoInputAndOutputOutput + if *v == nil { + sv = &NoInputAndOutputOutput{} + } else { + sv = *v + } + + for decoder.More() { + t, err := decoder.Token() + if err != nil { + return err + } + switch t { + default: + err := smithyjson.DiscardUnknownField(decoder) + if err != nil { + return err + } + + } + } + endToken, err := decoder.Token() + if err != nil { + return err + } + if t, ok := endToken.(json.Delim); !ok || t != '}' { + return fmt.Errorf("expect `}` as end token") + } + + *v = sv + return nil +} diff --git a/internal/protocoltest/jsonrpc10/endpoints.go b/internal/protocoltest/jsonrpc10/endpoints.go new file mode 100644 index 00000000000..99e47ebe870 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/endpoints.go @@ -0,0 +1,105 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "context" + "fmt" + "github.com/aws/aws-sdk-go-v2/aws" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + internalendpoints "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/internal/endpoints" + "github.com/awslabs/smithy-go/middleware" + smithyhttp "github.com/awslabs/smithy-go/transport/http" + "net/url" +) + +// ResolverOptions is the service endpoint resolver options +type ResolverOptions = internalendpoints.Options + +// EndpointResolver interface for resolving service endpoints. +type EndpointResolver interface { + ResolveEndpoint(region string, options ResolverOptions) (aws.Endpoint, error) +} + +var _ EndpointResolver = &internalendpoints.Resolver{} + +// NewDefaultEndpointResolver constructs a new service endpoint resolver +func NewDefaultEndpointResolver() *internalendpoints.Resolver { + return internalendpoints.New() +} + +// EndpointResolverFunc is a helper utility that wraps a function so it satisfies +// the EndpointResolver interface. This is useful when you want to add additional +// endpoint resolving logic, or stub out specific endpoints with custom values. +type EndpointResolverFunc func(region string, options ResolverOptions) (aws.Endpoint, error) + +func (fn EndpointResolverFunc) ResolveEndpoint(region string, options ResolverOptions) (aws.Endpoint, error) { + return fn(region, options) +} + +func resolveDefaultEndpointConfiguration(o *Options) { + if o.EndpointResolver != nil { + return + } + o.EndpointResolver = NewDefaultEndpointResolver() +} + +type ResolveEndpoint struct { + Resolver EndpointResolver + Options ResolverOptions +} + +func (*ResolveEndpoint) ID() string { + return "ResolveEndpoint" +} + +func (m *ResolveEndpoint) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + req, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) + } + + if m.Resolver == nil { + return out, metadata, fmt.Errorf("expected endpoint resolver to not be nil") + } + + var endpoint aws.Endpoint + endpoint, err = m.Resolver.ResolveEndpoint(awsmiddleware.GetRegion(ctx), m.Options) + if err != nil { + return out, metadata, fmt.Errorf("failed to resolve service endpoint") + } + + req.URL, err = url.Parse(endpoint.URL) + if err != nil { + return out, metadata, fmt.Errorf("failed to parse endpoint URL: %w", err) + } + + if len(awsmiddleware.GetSigningName(ctx)) == 0 { + signingName := endpoint.SigningName + if len(signingName) == 0 { + signingName = "jsonrpc10" + } + ctx = awsmiddleware.SetSigningName(ctx, signingName) + } + ctx = awsmiddleware.SetSigningRegion(ctx, endpoint.SigningRegion) + + return next.HandleSerialize(ctx, in) +} + +type ResolveEndpointMiddlewareOptions interface { + GetEndpointResolver() EndpointResolver + GetEndpointOptions() ResolverOptions +} + +func AddResolveEndpointMiddleware(stack *middleware.Stack, options ResolveEndpointMiddlewareOptions) { + stack.Serialize.Insert(&ResolveEndpoint{ + Resolver: options.GetEndpointResolver(), + Options: options.GetEndpointOptions(), + }, "OperationSerializer", middleware.Before) +} + +func RemoveResolveEndpointMiddleware(stack *middleware.Stack) error { + return stack.Serialize.Remove((&ResolveEndpoint{}).ID()) +} diff --git a/internal/protocoltest/jsonrpc10/go.mod b/internal/protocoltest/jsonrpc10/go.mod new file mode 100644 index 00000000000..e6f06c977cd --- /dev/null +++ b/internal/protocoltest/jsonrpc10/go.mod @@ -0,0 +1,9 @@ +module github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10 + +go 1.15 + +require ( + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 + github.com/google/go-cmp v0.4.1 +) diff --git a/internal/protocoltest/jsonrpc10/internal/endpoints/endpoints.go b/internal/protocoltest/jsonrpc10/internal/endpoints/endpoints.go new file mode 100644 index 00000000000..9c97ffa5832 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/internal/endpoints/endpoints.go @@ -0,0 +1,87 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package endpoints + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + endpoints "github.com/aws/aws-sdk-go-v2/aws/endpoints/v2" + "regexp" +) + +// Options is the endpoint resolver configuration options +type Options struct { + DisableHTTPS bool +} + +// Resolver JSON RPC 10 endpoint resolver +type Resolver struct { + partitions endpoints.Partitions +} + +// ResolveEndpoint resolves the service endpoint for the given region and options +func (r *Resolver) ResolveEndpoint(region string, options Options) (aws.Endpoint, error) { + opt := endpoints.Options{ + DisableHTTPS: options.DisableHTTPS, + } + return r.partitions.ResolveEndpoint(region, opt) +} + +// New returns a new Resolver +func New() *Resolver { + return &Resolver{ + partitions: defaultPartitions, + } +} + +var defaultPartitions = endpoints.Partitions{ + { + ID: "aws", + Defaults: endpoints.Endpoint{ + Hostname: "jsonrpc10.{region}.amazonaws.com", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + RegionRegex: regexp.MustCompile("^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$"), + IsRegionalized: true, + }, + { + ID: "aws-cn", + Defaults: endpoints.Endpoint{ + Hostname: "jsonrpc10.{region}.amazonaws.com.cn", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + RegionRegex: regexp.MustCompile("^cn\\-\\w+\\-\\d+$"), + IsRegionalized: true, + }, + { + ID: "aws-iso", + Defaults: endpoints.Endpoint{ + Hostname: "jsonrpc10.{region}.c2s.ic.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + RegionRegex: regexp.MustCompile("^us\\-iso\\-\\w+\\-\\d+$"), + IsRegionalized: true, + }, + { + ID: "aws-iso-b", + Defaults: endpoints.Endpoint{ + Hostname: "jsonrpc10.{region}.sc2s.sgov.gov", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + RegionRegex: regexp.MustCompile("^us\\-isob\\-\\w+\\-\\d+$"), + IsRegionalized: true, + }, + { + ID: "aws-us-gov", + Defaults: endpoints.Endpoint{ + Hostname: "jsonrpc10.{region}.amazonaws.com", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + RegionRegex: regexp.MustCompile("^us\\-gov\\-\\w+\\-\\d+$"), + IsRegionalized: true, + }, +} diff --git a/internal/protocoltest/jsonrpc10/internal/endpoints/endpoints_test.go b/internal/protocoltest/jsonrpc10/internal/endpoints/endpoints_test.go new file mode 100644 index 00000000000..08e5da2d833 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/internal/endpoints/endpoints_test.go @@ -0,0 +1,11 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package endpoints + +import ( + "testing" +) + +func TestRegexCompile(t *testing.T) { + _ = defaultPartitions +} diff --git a/internal/protocoltest/jsonrpc10/protocol_test.go b/internal/protocoltest/jsonrpc10/protocol_test.go new file mode 100644 index 00000000000..a2014efaade --- /dev/null +++ b/internal/protocoltest/jsonrpc10/protocol_test.go @@ -0,0 +1,3 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 diff --git a/internal/protocoltest/jsonrpc10/serializers.go b/internal/protocoltest/jsonrpc10/serializers.go new file mode 100644 index 00000000000..bd3ef07f2c3 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/serializers.go @@ -0,0 +1,355 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 + +import ( + "bytes" + "context" + "fmt" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/types" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/httpbinding" + smithyjson "github.com/awslabs/smithy-go/json" + "github.com/awslabs/smithy-go/middleware" + smithytime "github.com/awslabs/smithy-go/time" + smithyhttp "github.com/awslabs/smithy-go/transport/http" +) + +type awsAwsjson10_serializeOpEmptyInputAndEmptyOutput struct { +} + +func (*awsAwsjson10_serializeOpEmptyInputAndEmptyOutput) ID() string { + return "OperationSerializer" +} + +func (m *awsAwsjson10_serializeOpEmptyInputAndEmptyOutput) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*EmptyInputAndEmptyOutputInput) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + request.Request.URL.Path = "/" + request.Request.Method = "POST" + httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") + httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.EmptyInputAndEmptyOutput") + + _ = input + + if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} + +type awsAwsjson10_serializeOpGreetingWithErrors struct { +} + +func (*awsAwsjson10_serializeOpGreetingWithErrors) ID() string { + return "OperationSerializer" +} + +func (m *awsAwsjson10_serializeOpGreetingWithErrors) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*GreetingWithErrorsInput) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + request.Request.URL.Path = "/" + request.Request.Method = "POST" + httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") + httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.GreetingWithErrors") + + _ = input + + if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} + +type awsAwsjson10_serializeOpJsonUnions struct { +} + +func (*awsAwsjson10_serializeOpJsonUnions) ID() string { + return "OperationSerializer" +} + +func (m *awsAwsjson10_serializeOpJsonUnions) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*JsonUnionsInput) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + request.Request.URL.Path = "/" + request.Request.Method = "POST" + httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") + httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.JsonUnions") + + jsonEncoder := smithyjson.NewEncoder() + if err := awsAwsjson10_serializeDocumentJsonUnionsInput(input, jsonEncoder.Value); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request, err = request.SetStream(bytes.NewReader(jsonEncoder.Bytes())); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + + if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} + +type awsAwsjson10_serializeOpNoInputAndNoOutput struct { +} + +func (*awsAwsjson10_serializeOpNoInputAndNoOutput) ID() string { + return "OperationSerializer" +} + +func (m *awsAwsjson10_serializeOpNoInputAndNoOutput) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*NoInputAndNoOutputInput) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + request.Request.URL.Path = "/" + request.Request.Method = "POST" + httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") + httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.NoInputAndNoOutput") + + _ = input + + if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} + +type awsAwsjson10_serializeOpNoInputAndOutput struct { +} + +func (*awsAwsjson10_serializeOpNoInputAndOutput) ID() string { + return "OperationSerializer" +} + +func (m *awsAwsjson10_serializeOpNoInputAndOutput) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( + out middleware.SerializeOutput, metadata middleware.Metadata, err error, +) { + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown transport type %T", in.Request)} + } + + input, ok := in.Parameters.(*NoInputAndOutputInput) + if !ok { + return out, metadata, &smithy.SerializationError{Err: fmt.Errorf("unknown input parameters type %T", in.Parameters)} + } + + request.Request.URL.Path = "/" + request.Request.Method = "POST" + httpBindingEncoder, err := httpbinding.NewEncoder(request.URL.Path, request.URL.RawQuery, request.Header) + if err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + httpBindingEncoder.SetHeader("Content-Type").String("application/x-amz-json-1.0") + httpBindingEncoder.SetHeader("X-Amz-Target").String("JsonRpc10.NoInputAndOutput") + + _ = input + + if request.Request, err = httpBindingEncoder.Encode(request.Request); err != nil { + return out, metadata, &smithy.SerializationError{Err: err} + } + in.Request = request + + return next.HandleSerialize(ctx, in) +} +func awsAwsjson10_serializeDocumentMyUnion(v types.MyUnion, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + switch uv := v.(type) { + case *types.MyUnionMemberBlobValue: + av := object.Key("blobValue") + av.Base64EncodeBytes(uv.Value) + + case *types.MyUnionMemberBooleanValue: + av := object.Key("booleanValue") + av.Boolean(uv.Value) + + case *types.MyUnionMemberEnumValue: + av := object.Key("enumValue") + av.String(string(uv.Value)) + + case *types.MyUnionMemberListValue: + av := object.Key("listValue") + if err := awsAwsjson10_serializeDocumentStringList(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberMapValue: + av := object.Key("mapValue") + if err := awsAwsjson10_serializeDocumentStringMap(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberNumberValue: + av := object.Key("numberValue") + av.Integer(uv.Value) + + case *types.MyUnionMemberStringValue: + av := object.Key("stringValue") + av.String(uv.Value) + + case *types.MyUnionMemberStructureValue: + av := object.Key("structureValue") + if err := awsAwsjson10_serializeDocumentGreetingStruct(uv.Value, av); err != nil { + return err + } + + case *types.MyUnionMemberTimestampValue: + av := object.Key("timestampValue") + av.Double(smithytime.FormatEpochSeconds(uv.Value)) + + default: + return fmt.Errorf("attempted to serialize unknown member type %T for union %T", uv, v) + + } + return nil +} + +func awsAwsjson10_serializeDocumentGreetingStruct(v *types.GreetingStruct, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Hi != nil { + ok := object.Key("hi") + ok.String(*v.Hi) + } + + return nil +} + +func awsAwsjson10_serializeDocumentStringList(v []*string, value smithyjson.Value) error { + array := value.Array() + defer array.Close() + + for i := range v { + av := array.Value() + if vv := v[i]; vv == nil { + av.Null() + continue + } + av.String(*v[i]) + } + return nil +} + +func awsAwsjson10_serializeDocumentStringMap(v map[string]*string, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + for key := range v { + om := object.Key(key) + if vv := v[key]; vv == nil { + om.Null() + continue + } + om.String(*v[key]) + } + return nil +} + +func awsAwsjson10_serializeDocumentEmptyInputAndEmptyOutputInput(v *EmptyInputAndEmptyOutputInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + return nil +} + +func awsAwsjson10_serializeDocumentGreetingWithErrorsInput(v *GreetingWithErrorsInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + return nil +} + +func awsAwsjson10_serializeDocumentJsonUnionsInput(v *JsonUnionsInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + if v.Contents != nil { + ok := object.Key("contents") + if err := awsAwsjson10_serializeDocumentMyUnion(v.Contents, ok); err != nil { + return err + } + } + + return nil +} + +func awsAwsjson10_serializeDocumentNoInputAndNoOutputInput(v *NoInputAndNoOutputInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + return nil +} + +func awsAwsjson10_serializeDocumentNoInputAndOutputInput(v *NoInputAndOutputInput, value smithyjson.Value) error { + object := value.Object() + defer object.Close() + + return nil +} diff --git a/internal/protocoltest/jsonrpc10/types/enums.go b/internal/protocoltest/jsonrpc10/types/enums.go new file mode 100644 index 00000000000..e287393662a --- /dev/null +++ b/internal/protocoltest/jsonrpc10/types/enums.go @@ -0,0 +1,14 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package types + +type FooEnum string + +// Enum values for FooEnum +const ( + FooEnumFoo FooEnum = "Foo" + FooEnumBaz FooEnum = "Baz" + FooEnumBar FooEnum = "Bar" + FooEnum1 FooEnum = "1" + FooEnum0 FooEnum = "0" +) diff --git a/internal/protocoltest/jsonrpc10/types/errors.go b/internal/protocoltest/jsonrpc10/types/errors.go new file mode 100644 index 00000000000..fbcb59a7de8 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/types/errors.go @@ -0,0 +1,82 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package types + +import ( + "fmt" + smithy "github.com/awslabs/smithy-go" + "github.com/awslabs/smithy-go/ptr" +) + +// This error is thrown when a request is invalid. +type ComplexError struct { + Message *string + + TopLevel *string + Nested *ComplexNestedErrorData +} + +func (e *ComplexError) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *ComplexError) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *ComplexError) ErrorCode() string { return "ComplexError" } +func (e *ComplexError) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } +func (e *ComplexError) GetTopLevel() string { + return ptr.ToString(e.TopLevel) +} +func (e *ComplexError) HasTopLevel() bool { + return e.TopLevel != nil +} +func (e *ComplexError) GetNested() *ComplexNestedErrorData { + return e.Nested +} +func (e *ComplexError) HasNested() bool { + return e.Nested != nil +} + +// This error has test cases that test some of the dark corners of Amazon service +// framework history. It should only be implemented by clients. +type FooError struct { + Message *string +} + +func (e *FooError) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *FooError) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *FooError) ErrorCode() string { return "FooError" } +func (e *FooError) ErrorFault() smithy.ErrorFault { return smithy.FaultServer } + +// This error is thrown when an invalid greeting value is provided. +type InvalidGreeting struct { + Message *string +} + +func (e *InvalidGreeting) Error() string { + return fmt.Sprintf("%s: %s", e.ErrorCode(), e.ErrorMessage()) +} +func (e *InvalidGreeting) ErrorMessage() string { + if e.Message == nil { + return "" + } + return *e.Message +} +func (e *InvalidGreeting) ErrorCode() string { return "InvalidGreeting" } +func (e *InvalidGreeting) ErrorFault() smithy.ErrorFault { return smithy.FaultClient } +func (e *InvalidGreeting) GetMessage() string { + return ptr.ToString(e.Message) +} +func (e *InvalidGreeting) HasMessage() bool { + return e.Message != nil +} diff --git a/internal/protocoltest/jsonrpc10/types/types.go b/internal/protocoltest/jsonrpc10/types/types.go new file mode 100644 index 00000000000..c8d0ae65b55 --- /dev/null +++ b/internal/protocoltest/jsonrpc10/types/types.go @@ -0,0 +1,83 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package types + +import ( + "time" +) + +type ComplexNestedErrorData struct { + Foo *string +} + +// A union with a representative set of types for members. +type MyUnion interface { + isMyUnion() +} + +type MyUnionMemberStringValue struct { + Value string +} + +func (*MyUnionMemberStringValue) isMyUnion() {} + +type MyUnionMemberBooleanValue struct { + Value bool +} + +func (*MyUnionMemberBooleanValue) isMyUnion() {} + +type MyUnionMemberNumberValue struct { + Value int32 +} + +func (*MyUnionMemberNumberValue) isMyUnion() {} + +type MyUnionMemberBlobValue struct { + Value []byte +} + +func (*MyUnionMemberBlobValue) isMyUnion() {} + +type MyUnionMemberTimestampValue struct { + Value time.Time +} + +func (*MyUnionMemberTimestampValue) isMyUnion() {} + +type MyUnionMemberEnumValue struct { + Value FooEnum +} + +func (*MyUnionMemberEnumValue) isMyUnion() {} + +type MyUnionMemberListValue struct { + Value []*string +} + +func (*MyUnionMemberListValue) isMyUnion() {} + +type MyUnionMemberMapValue struct { + Value map[string]*string +} + +func (*MyUnionMemberMapValue) isMyUnion() {} + +type MyUnionMemberStructureValue struct { + Value *GreetingStruct +} + +func (*MyUnionMemberStructureValue) isMyUnion() {} + +type GreetingStruct struct { + Hi *string +} + +// UnknownUnionMember is returned when a union member is returned over the wire, +// but has an unknown tag. +type UnknownUnionMember struct { + Tag string + Value []byte +} + +func (*UnknownUnionMember) isMyUnion() {} diff --git a/internal/protocoltest/jsonrpc10/validators.go b/internal/protocoltest/jsonrpc10/validators.go new file mode 100644 index 00000000000..a2014efaade --- /dev/null +++ b/internal/protocoltest/jsonrpc10/validators.go @@ -0,0 +1,3 @@ +// Code generated by smithy-go-codegen DO NOT EDIT. + +package jsonrpc10 diff --git a/internal/protocoltest/query/deserializers.go b/internal/protocoltest/query/deserializers.go index a29bdd38e9b..416ffcc3e9f 100644 --- a/internal/protocoltest/query/deserializers.go +++ b/internal/protocoltest/query/deserializers.go @@ -5,12 +5,21 @@ package query import ( "bytes" "context" + "encoding/base64" + "encoding/xml" "fmt" + "github.com/aws/aws-sdk-go-v2/internal/protocoltest/query/types" smithy "github.com/awslabs/smithy-go" + smithyio "github.com/awslabs/smithy-go/io" "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" + smithytime "github.com/awslabs/smithy-go/time" smithyhttp "github.com/awslabs/smithy-go/transport/http" + smithyxml "github.com/awslabs/smithy-go/xml" "io" + "strconv" "strings" + "time" ) type awsAwsquery_deserializeOpEmptyInputAndEmptyOutput struct { @@ -39,6 +48,34 @@ func (m *awsAwsquery_deserializeOpEmptyInputAndEmptyOutput) HandleDeserialize(ct output := &EmptyInputAndEmptyOutputOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentEmptyInputAndEmptyOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -52,7 +89,11 @@ func awsAwsquery_deserializeOpErrorEmptyInputAndEmptyOutput(response *smithyhttp errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -90,6 +131,34 @@ func (m *awsAwsquery_deserializeOpFlattenedXmlMap) HandleDeserialize(ctx context output := &FlattenedXmlMapOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentFlattenedXmlMapOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -103,7 +172,11 @@ func awsAwsquery_deserializeOpErrorFlattenedXmlMap(response *smithyhttp.Response errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -141,6 +214,34 @@ func (m *awsAwsquery_deserializeOpFlattenedXmlMapWithXmlName) HandleDeserialize( output := &FlattenedXmlMapWithXmlNameOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentFlattenedXmlMapWithXmlNameOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -154,7 +255,11 @@ func awsAwsquery_deserializeOpErrorFlattenedXmlMapWithXmlName(response *smithyht errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -192,6 +297,34 @@ func (m *awsAwsquery_deserializeOpGreetingWithErrors) HandleDeserialize(ctx cont output := &GreetingWithErrorsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentGreetingWithErrorsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -205,7 +338,11 @@ func awsAwsquery_deserializeOpErrorGreetingWithErrors(response *smithyhttp.Respo errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { case strings.EqualFold("ComplexError", errorCode): return awsAwsquery_deserializeErrorComplexError(response, errorBody) @@ -249,6 +386,34 @@ func (m *awsAwsquery_deserializeOpIgnoresWrappingXmlName) HandleDeserialize(ctx output := &IgnoresWrappingXmlNameOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentIgnoresWrappingXmlNameOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -262,7 +427,11 @@ func awsAwsquery_deserializeOpErrorIgnoresWrappingXmlName(response *smithyhttp.R errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -300,6 +469,34 @@ func (m *awsAwsquery_deserializeOpNestedStructures) HandleDeserialize(ctx contex output := &NestedStructuresOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentNestedStructuresOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -313,7 +510,11 @@ func awsAwsquery_deserializeOpErrorNestedStructures(response *smithyhttp.Respons errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -351,6 +552,34 @@ func (m *awsAwsquery_deserializeOpNoInputAndNoOutput) HandleDeserialize(ctx cont output := &NoInputAndNoOutputOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentNoInputAndNoOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -364,7 +593,11 @@ func awsAwsquery_deserializeOpErrorNoInputAndNoOutput(response *smithyhttp.Respo errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -402,6 +635,34 @@ func (m *awsAwsquery_deserializeOpNoInputAndOutput) HandleDeserialize(ctx contex output := &NoInputAndOutputOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentNoInputAndOutputOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -415,7 +676,11 @@ func awsAwsquery_deserializeOpErrorNoInputAndOutput(response *smithyhttp.Respons errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -453,6 +718,34 @@ func (m *awsAwsquery_deserializeOpQueryIdempotencyTokenAutoFill) HandleDeseriali output := &QueryIdempotencyTokenAutoFillOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentQueryIdempotencyTokenAutoFillOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -466,7 +759,11 @@ func awsAwsquery_deserializeOpErrorQueryIdempotencyTokenAutoFill(response *smith errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -504,6 +801,34 @@ func (m *awsAwsquery_deserializeOpQueryLists) HandleDeserialize(ctx context.Cont output := &QueryListsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentQueryListsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -517,7 +842,11 @@ func awsAwsquery_deserializeOpErrorQueryLists(response *smithyhttp.Response) err errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -555,6 +884,34 @@ func (m *awsAwsquery_deserializeOpQueryMaps) HandleDeserialize(ctx context.Conte output := &QueryMapsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentQueryMapsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -568,7 +925,11 @@ func awsAwsquery_deserializeOpErrorQueryMaps(response *smithyhttp.Response) erro errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -606,6 +967,34 @@ func (m *awsAwsquery_deserializeOpQueryTimestamps) HandleDeserialize(ctx context output := &QueryTimestampsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentQueryTimestampsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -619,7 +1008,11 @@ func awsAwsquery_deserializeOpErrorQueryTimestamps(response *smithyhttp.Response errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -657,6 +1050,34 @@ func (m *awsAwsquery_deserializeOpRecursiveXmlShapes) HandleDeserialize(ctx cont output := &RecursiveXmlShapesOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentRecursiveXmlShapesOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -670,7 +1091,11 @@ func awsAwsquery_deserializeOpErrorRecursiveXmlShapes(response *smithyhttp.Respo errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -708,6 +1133,34 @@ func (m *awsAwsquery_deserializeOpSimpleInputParams) HandleDeserialize(ctx conte output := &SimpleInputParamsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentSimpleInputParamsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -721,7 +1174,11 @@ func awsAwsquery_deserializeOpErrorSimpleInputParams(response *smithyhttp.Respon errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -759,6 +1216,34 @@ func (m *awsAwsquery_deserializeOpSimpleScalarXmlProperties) HandleDeserialize(c output := &SimpleScalarXmlPropertiesOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentSimpleScalarXmlPropertiesOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -772,7 +1257,11 @@ func awsAwsquery_deserializeOpErrorSimpleScalarXmlProperties(response *smithyhtt errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -810,6 +1299,34 @@ func (m *awsAwsquery_deserializeOpXmlBlobs) HandleDeserialize(ctx context.Contex output := &XmlBlobsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentXmlBlobsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -823,7 +1340,11 @@ func awsAwsquery_deserializeOpErrorXmlBlobs(response *smithyhttp.Response) error errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -861,6 +1382,34 @@ func (m *awsAwsquery_deserializeOpXmlEnums) HandleDeserialize(ctx context.Contex output := &XmlEnumsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentXmlEnumsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -874,7 +1423,11 @@ func awsAwsquery_deserializeOpErrorXmlEnums(response *smithyhttp.Response) error errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -912,6 +1465,34 @@ func (m *awsAwsquery_deserializeOpXmlLists) HandleDeserialize(ctx context.Contex output := &XmlListsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentXmlListsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -925,7 +1506,11 @@ func awsAwsquery_deserializeOpErrorXmlLists(response *smithyhttp.Response) error errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -963,6 +1548,34 @@ func (m *awsAwsquery_deserializeOpXmlMaps) HandleDeserialize(ctx context.Context output := &XmlMapsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentXmlMapsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -976,7 +1589,11 @@ func awsAwsquery_deserializeOpErrorXmlMaps(response *smithyhttp.Response) error errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -1014,6 +1631,34 @@ func (m *awsAwsquery_deserializeOpXmlMapsXmlName) HandleDeserialize(ctx context. output := &XmlMapsXmlNameOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentXmlMapsXmlNameOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -1027,7 +1672,11 @@ func awsAwsquery_deserializeOpErrorXmlMapsXmlName(response *smithyhttp.Response) errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -1065,6 +1714,34 @@ func (m *awsAwsquery_deserializeOpXmlNamespaces) HandleDeserialize(ctx context.C output := &XmlNamespacesOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentXmlNamespacesOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -1078,7 +1755,11 @@ func awsAwsquery_deserializeOpErrorXmlNamespaces(response *smithyhttp.Response) errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -1116,6 +1797,34 @@ func (m *awsAwsquery_deserializeOpXmlTimestamps) HandleDeserialize(ctx context.C output := &XmlTimestampsOutput{} out.Result = output + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(response.Body, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return out, metadata, nil + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentXmlTimestampsOutput(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + return out, metadata, err } @@ -1129,7 +1838,11 @@ func awsAwsquery_deserializeOpErrorXmlTimestamps(response *smithyhttp.Response) errorCode := "UnknownError" errorMessage := errorCode - _ = errorBody + errorCode, err := smithyxml.GetResponseErrorCode(errorBody, false) + if err != nil { + return err + } + errorBody.Seek(0, io.SeekStart) switch { default: genericError := &smithy.GenericAPIError{ @@ -1142,11 +1855,2649 @@ func awsAwsquery_deserializeOpErrorXmlTimestamps(response *smithyhttp.Response) } func awsAwsquery_deserializeErrorComplexError(response *smithyhttp.Response, errorBody *bytes.Reader) error { - // TODO: support query error deser - return &smithy.DeserializationError{Err: fmt.Errorf("TODO: support query error deser")} + output := &types.ComplexError{} + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(errorBody, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return output + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentComplexError(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return output } func awsAwsquery_deserializeErrorInvalidGreeting(response *smithyhttp.Response, errorBody *bytes.Reader) error { - // TODO: support query error deser - return &smithy.DeserializationError{Err: fmt.Errorf("TODO: support query error deser")} + output := &types.InvalidGreeting{} + buff := make([]byte, 1024) + ringBuffer := smithyio.NewRingBuffer(buff) + body := io.TeeReader(errorBody, ringBuffer) + rootDecoder := xml.NewDecoder(body) + t, err := smithyxml.FetchRootElement(rootDecoder) + if err == io.EOF { + return output + } + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + decoder := smithyxml.WrapNodeDecoder(rootDecoder, t) + err = awsAwsquery_deserializeDocumentInvalidGreeting(&output, decoder) + if err != nil { + var snapshot bytes.Buffer + io.Copy(&snapshot, ringBuffer) + return &smithy.DeserializationError{ + Err: fmt.Errorf("failed to decode response body, %w", err), + Snapshot: snapshot.Bytes(), + } + } + + return output +} + +func awsAwsquery_deserializeDocumentComplexError(v **types.ComplexError, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.ComplexError + if *v == nil { + sv = &types.ComplexError{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("Nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentComplexNestedErrorData(&sv.Nested, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("TopLevel", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.TopLevel = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentComplexNestedErrorData(v **types.ComplexNestedErrorData, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.ComplexNestedErrorData + if *v == nil { + sv = &types.ComplexNestedErrorData{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("Foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentFlattenedXmlMapWithXmlNameOutputMap(v *map[string]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv map[string]*string + if *v == nil { + sv = make(map[string]*string, 0) + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + if strings.EqualFold("entry", t.Name.Local) { + entryDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFlattenedXmlMapWithXmlNameOutputMapUnwrapped(&sv, entryDecoder); err != nil { + return err + } + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentFlattenedXmlMapWithXmlNameOutputMapUnwrapped(v *map[string]*string, decoder smithyxml.NodeDecoder) error { + var sv map[string]*string + if *v == nil { + sv = make(map[string]*string, 0) + } else { + sv = *v + } + + var ek *string + var ev *string + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + sv[*ek] = ev + break + } + switch { + case strings.EqualFold("K", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ek = &xtv + } + + case strings.EqualFold("V", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ev = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentInvalidGreeting(v **types.InvalidGreeting, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.InvalidGreeting + if *v == nil { + sv = &types.InvalidGreeting{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("Message", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Message = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentRecursiveXmlShapesOutputNested1(v **types.RecursiveXmlShapesOutputNested1, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.RecursiveXmlShapesOutputNested1 + if *v == nil { + sv = &types.RecursiveXmlShapesOutputNested1{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + case strings.EqualFold("nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentRecursiveXmlShapesOutputNested2(&sv.Nested, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentRecursiveXmlShapesOutputNested2(v **types.RecursiveXmlShapesOutputNested2, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.RecursiveXmlShapesOutputNested2 + if *v == nil { + sv = &types.RecursiveXmlShapesOutputNested2{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("bar", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Bar = &xtv + } + + case strings.EqualFold("recursiveMember", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentRecursiveXmlShapesOutputNested1(&sv.RecursiveMember, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentRenamedListMembers(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("item", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentRenamedListMembersUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentStructureList(v *[]*types.StructureListMember, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*types.StructureListMember + if *v == nil { + sv = make([]*types.StructureListMember, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + for { + if strings.EqualFold("item", t.Name.Local) { + var col *types.StructureListMember + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentStructureListMember(&col, nodeDecoder); err != nil { + return err + } + sv = append(sv, col) + break + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentStructureListUnwrapped(v *[]*types.StructureListMember, decoder smithyxml.NodeDecoder) error { + var sv []*types.StructureListMember + if *v == nil { + sv = make([]*types.StructureListMember, 0) + } else { + sv = *v + } + + for { + var mv *types.StructureListMember + t := decoder.StartEl + _ = t + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentStructureListMember(&mv, nodeDecoder); err != nil { + return err + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentStructureListMember(v **types.StructureListMember, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.StructureListMember + if *v == nil { + sv = &types.StructureListMember{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("value", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.A = &xtv + } + + case strings.EqualFold("other", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.B = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlMapsOutputMap(v *map[string]*types.GreetingStruct, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv map[string]*types.GreetingStruct + if *v == nil { + sv = make(map[string]*types.GreetingStruct, 0) + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + if strings.EqualFold("entry", t.Name.Local) { + entryDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentXmlMapsOutputMapUnwrapped(&sv, entryDecoder); err != nil { + return err + } + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlMapsOutputMapUnwrapped(v *map[string]*types.GreetingStruct, decoder smithyxml.NodeDecoder) error { + var sv map[string]*types.GreetingStruct + if *v == nil { + sv = make(map[string]*types.GreetingStruct, 0) + } else { + sv = *v + } + + var ek *string + var ev *types.GreetingStruct + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + sv[*ek] = ev + break + } + switch { + case strings.EqualFold("key", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ek = &xtv + } + + case strings.EqualFold("value", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentGreetingStruct(&ev, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentXmlMapsXmlNameOutputMap(v *map[string]*types.GreetingStruct, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv map[string]*types.GreetingStruct + if *v == nil { + sv = make(map[string]*types.GreetingStruct, 0) + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + if strings.EqualFold("entry", t.Name.Local) { + entryDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentXmlMapsXmlNameOutputMapUnwrapped(&sv, entryDecoder); err != nil { + return err + } + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlMapsXmlNameOutputMapUnwrapped(v *map[string]*types.GreetingStruct, decoder smithyxml.NodeDecoder) error { + var sv map[string]*types.GreetingStruct + if *v == nil { + sv = make(map[string]*types.GreetingStruct, 0) + } else { + sv = *v + } + + var ek *string + var ev *types.GreetingStruct + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + sv[*ek] = ev + break + } + switch { + case strings.EqualFold("Attribute", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ek = &xtv + } + + case strings.EqualFold("Setting", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentGreetingStruct(&ev, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentXmlNamespacedList(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlNamespacedListUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentXmlNamespaceNested(v **types.XmlNamespaceNested, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.XmlNamespaceNested + if *v == nil { + sv = &types.XmlNamespaceNested{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + case strings.EqualFold("values", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentXmlNamespacedList(&sv.Values, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentBooleanList(v *[]*bool, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*bool + if *v == nil { + sv = make([]*bool, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *bool + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected PrimitiveBoolean to be of type *bool, got %T instead", val) + } + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentBooleanListUnwrapped(v *[]*bool, decoder smithyxml.NodeDecoder) error { + var sv []*bool + if *v == nil { + sv = make([]*bool, 0) + } else { + sv = *v + } + + for { + var mv *bool + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected PrimitiveBoolean to be of type *bool, got %T instead", val) + } + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentFooEnumList(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col types.FooEnum + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = types.FooEnum(xtv) + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentFooEnumListUnwrapped(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + for { + var mv types.FooEnum + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = types.FooEnum(xtv) + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentFooEnumMap(v *map[string]types.FooEnum, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv map[string]types.FooEnum + if *v == nil { + sv = make(map[string]types.FooEnum, 0) + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + if strings.EqualFold("entry", t.Name.Local) { + entryDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFooEnumMapUnwrapped(&sv, entryDecoder); err != nil { + return err + } + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentFooEnumMapUnwrapped(v *map[string]types.FooEnum, decoder smithyxml.NodeDecoder) error { + var sv map[string]types.FooEnum + if *v == nil { + sv = make(map[string]types.FooEnum, 0) + } else { + sv = *v + } + + var ek *string + var ev types.FooEnum + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + sv[*ek] = ev + break + } + switch { + case strings.EqualFold("key", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ek = &xtv + } + + case strings.EqualFold("value", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + ev = types.FooEnum(xtv) + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentFooEnumSet(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col types.FooEnum + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = types.FooEnum(xtv) + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentFooEnumSetUnwrapped(v *[]types.FooEnum, decoder smithyxml.NodeDecoder) error { + var sv []types.FooEnum + if *v == nil { + sv = make([]types.FooEnum, 0) + } else { + sv = *v + } + + for { + var mv types.FooEnum + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = types.FooEnum(xtv) + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentGreetingStruct(v **types.GreetingStruct, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *types.GreetingStruct + if *v == nil { + sv = &types.GreetingStruct{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("hi", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Hi = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentIntegerList(v *[]*int32, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*int32 + if *v == nil { + sv = make([]*int32, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *int32 + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + col = ptr.Int32(int32(i64)) + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentIntegerListUnwrapped(v *[]*int32, decoder smithyxml.NodeDecoder) error { + var sv []*int32 + if *v == nil { + sv = make([]*int32, 0) + } else { + sv = *v + } + + for { + var mv *int32 + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + mv = ptr.Int32(int32(i64)) + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentNestedStringList(v *[][]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv [][]*string + if *v == nil { + sv = make([][]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + for { + if strings.EqualFold("member", t.Name.Local) { + var col []*string + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentStringList(&col, nodeDecoder); err != nil { + return err + } + sv = append(sv, col) + break + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentNestedStringListUnwrapped(v *[][]*string, decoder smithyxml.NodeDecoder) error { + var sv [][]*string + if *v == nil { + sv = make([][]*string, 0) + } else { + sv = *v + } + + for { + var mv []*string + t := decoder.StartEl + _ = t + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentStringList(&mv, nodeDecoder); err != nil { + return err + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentStringList(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentStringListUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentStringSet(v *[]*string, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *string + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + col = &xtv + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentStringSetUnwrapped(v *[]*string, decoder smithyxml.NodeDecoder) error { + var sv []*string + if *v == nil { + sv = make([]*string, 0) + } else { + sv = *v + } + + for { + var mv *string + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + mv = &xtv + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentTimestampList(v *[]*time.Time, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv []*time.Time + if *v == nil { + sv = make([]*time.Time, 0) + } else { + sv = *v + } + + originalDecoder := decoder + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + memberDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + decoder = memberDecoder + for { + if strings.EqualFold("member", t.Name.Local) { + var col *time.Time + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + col = &t + } + sv = append(sv, col) + } + } + decoder = originalDecoder + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentTimestampListUnwrapped(v *[]*time.Time, decoder smithyxml.NodeDecoder) error { + var sv []*time.Time + if *v == nil { + sv = make([]*time.Time, 0) + } else { + sv = *v + } + + for { + var mv *time.Time + t := decoder.StartEl + _ = t + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + mv = &t + } + sv = append(sv, mv) + } + *v = sv + return nil +} +func awsAwsquery_deserializeDocumentEmptyInputAndEmptyOutputOutput(v **EmptyInputAndEmptyOutputOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *EmptyInputAndEmptyOutputOutput + if *v == nil { + sv = &EmptyInputAndEmptyOutputOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentFlattenedXmlMapOutput(v **FlattenedXmlMapOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *FlattenedXmlMapOutput + if *v == nil { + sv = &FlattenedXmlMapOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("myMap", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFooEnumMapUnwrapped(&sv.MyMap, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentFlattenedXmlMapWithXmlNameOutput(v **FlattenedXmlMapWithXmlNameOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *FlattenedXmlMapWithXmlNameOutput + if *v == nil { + sv = &FlattenedXmlMapWithXmlNameOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("KVP", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFlattenedXmlMapWithXmlNameOutputMapUnwrapped(&sv.MyMap, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentGreetingWithErrorsOutput(v **GreetingWithErrorsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *GreetingWithErrorsOutput + if *v == nil { + sv = &GreetingWithErrorsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("greeting", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Greeting = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentIgnoresWrappingXmlNameOutput(v **IgnoresWrappingXmlNameOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *IgnoresWrappingXmlNameOutput + if *v == nil { + sv = &IgnoresWrappingXmlNameOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("foo", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.Foo = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentNestedStructuresOutput(v **NestedStructuresOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *NestedStructuresOutput + if *v == nil { + sv = &NestedStructuresOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentNoInputAndNoOutputOutput(v **NoInputAndNoOutputOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *NoInputAndNoOutputOutput + if *v == nil { + sv = &NoInputAndNoOutputOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentNoInputAndOutputOutput(v **NoInputAndOutputOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *NoInputAndOutputOutput + if *v == nil { + sv = &NoInputAndOutputOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentQueryIdempotencyTokenAutoFillOutput(v **QueryIdempotencyTokenAutoFillOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *QueryIdempotencyTokenAutoFillOutput + if *v == nil { + sv = &QueryIdempotencyTokenAutoFillOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentQueryListsOutput(v **QueryListsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *QueryListsOutput + if *v == nil { + sv = &QueryListsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentQueryMapsOutput(v **QueryMapsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *QueryMapsOutput + if *v == nil { + sv = &QueryMapsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentQueryTimestampsOutput(v **QueryTimestampsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *QueryTimestampsOutput + if *v == nil { + sv = &QueryTimestampsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentRecursiveXmlShapesOutput(v **RecursiveXmlShapesOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *RecursiveXmlShapesOutput + if *v == nil { + sv = &RecursiveXmlShapesOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentRecursiveXmlShapesOutputNested1(&sv.Nested, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentSimpleInputParamsOutput(v **SimpleInputParamsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *SimpleInputParamsOutput + if *v == nil { + sv = &SimpleInputParamsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentSimpleScalarXmlPropertiesOutput(v **SimpleScalarXmlPropertiesOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *SimpleScalarXmlPropertiesOutput + if *v == nil { + sv = &SimpleScalarXmlPropertiesOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("byteValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.ByteValue = ptr.Int8(int8(i64)) + } + + case strings.EqualFold("DoubleDribble", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + f64, err := strconv.ParseFloat(xtv, 64) + if err != nil { + return err + } + sv.DoubleValue = &f64 + } + + case strings.EqualFold("emptyStringValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.EmptyStringValue = &xtv + } + + case strings.EqualFold("falseBooleanValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) + } + sv.FalseBooleanValue = &xtv + } + + case strings.EqualFold("floatValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + f64, err := strconv.ParseFloat(xtv, 64) + if err != nil { + return err + } + sv.FloatValue = ptr.Float32(float32(f64)) + } + + case strings.EqualFold("integerValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.IntegerValue = ptr.Int32(int32(i64)) + } + + case strings.EqualFold("longValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.LongValue = &i64 + } + + case strings.EqualFold("shortValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + i64, err := strconv.ParseInt(xtv, 10, 64) + if err != nil { + return err + } + sv.ShortValue = ptr.Int16(int16(i64)) + } + + case strings.EqualFold("stringValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.StringValue = &xtv + } + + case strings.EqualFold("trueBooleanValue", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv, err := strconv.ParseBool(string(val)) + if err != nil { + return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", val) + } + sv.TrueBooleanValue = &xtv + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlBlobsOutput(v **XmlBlobsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlBlobsOutput + if *v == nil { + sv = &XmlBlobsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("data", t.Name.Local): + var data string + err := decoder.Decoder.DecodeElement(&data, &t) + if err != nil { + return err + } + sv.Data, err = base64.StdEncoding.DecodeString(data) + if err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlEnumsOutput(v **XmlEnumsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlEnumsOutput + if *v == nil { + sv = &XmlEnumsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("fooEnum1", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.FooEnum1 = types.FooEnum(xtv) + } + + case strings.EqualFold("fooEnum2", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.FooEnum2 = types.FooEnum(xtv) + } + + case strings.EqualFold("fooEnum3", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + sv.FooEnum3 = types.FooEnum(xtv) + } + + case strings.EqualFold("fooEnumList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFooEnumList(&sv.FooEnumList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("fooEnumMap", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFooEnumMap(&sv.FooEnumMap, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("fooEnumSet", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFooEnumSet(&sv.FooEnumSet, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlListsOutput(v **XmlListsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlListsOutput + if *v == nil { + sv = &XmlListsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("booleanList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentBooleanList(&sv.BooleanList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("enumList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentFooEnumList(&sv.EnumList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("flattenedList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentRenamedListMembersUnwrapped(&sv.FlattenedList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("customName", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentRenamedListMembersUnwrapped(&sv.FlattenedList2, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("integerList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentIntegerList(&sv.IntegerList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("nestedStringList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentNestedStringList(&sv.NestedStringList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("renamed", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentRenamedListMembers(&sv.RenamedListMembers, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("stringList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentStringList(&sv.StringList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("stringSet", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentStringSet(&sv.StringSet, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("myStructureList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentStructureList(&sv.StructureList, nodeDecoder); err != nil { + return err + } + + case strings.EqualFold("timestampList", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentTimestampList(&sv.TimestampList, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlMapsOutput(v **XmlMapsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlMapsOutput + if *v == nil { + sv = &XmlMapsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("myMap", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentXmlMapsOutputMap(&sv.MyMap, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlMapsXmlNameOutput(v **XmlMapsXmlNameOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlMapsXmlNameOutput + if *v == nil { + sv = &XmlMapsXmlNameOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("myMap", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentXmlMapsXmlNameOutputMap(&sv.MyMap, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlNamespacesOutput(v **XmlNamespacesOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlNamespacesOutput + if *v == nil { + sv = &XmlNamespacesOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("nested", t.Name.Local): + nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) + if err := awsAwsquery_deserializeDocumentXmlNamespaceNested(&sv.Nested, nodeDecoder); err != nil { + return err + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil +} + +func awsAwsquery_deserializeDocumentXmlTimestampsOutput(v **XmlTimestampsOutput, decoder smithyxml.NodeDecoder) error { + if v == nil { + return fmt.Errorf("unexpected nil of type %T", v) + } + var sv *XmlTimestampsOutput + if *v == nil { + sv = &XmlTimestampsOutput{} + } else { + sv = *v + } + + for { + t, done, err := decoder.Token() + if err != nil { + return err + } + if done { + break + } + _ = t + switch { + case strings.EqualFold("dateTime", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + sv.DateTime = &t + } + + case strings.EqualFold("epochSeconds", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + f64, err := strconv.ParseFloat(xtv, 64) + if err != nil { + return err + } + sv.EpochSeconds = ptr.Time(smithytime.ParseEpochSeconds(f64)) + } + + case strings.EqualFold("httpDate", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseHTTPDate(xtv) + if err != nil { + return err + } + sv.HttpDate = &t + } + + case strings.EqualFold("normal", t.Name.Local): + val, done, err := decoder.Value() + if err != nil { + return err + } + if done { + break + } + if val != nil { + xtv := string(val) + t, err := smithytime.ParseDateTime(xtv) + if err != nil { + return err + } + sv.Normal = &t + } + + default: + // Do nothing and ignore the unexpected tag element + + } + } + *v = sv + return nil } diff --git a/internal/protocoltest/query/go.mod b/internal/protocoltest/query/go.mod index a6fef3b20c1..cea0ec9bf48 100644 --- a/internal/protocoltest/query/go.mod +++ b/internal/protocoltest/query/go.mod @@ -3,7 +3,7 @@ module github.com/aws/aws-sdk-go-v2/internal/protocoltest/query go 1.15 require ( - github.com/aws/aws-sdk-go-v2 v0.24.1-0.20200821181726-bc564654ccac - github.com/awslabs/smithy-go v0.0.0-20200820215706-7b32252c1389 + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 github.com/google/go-cmp v0.4.1 ) diff --git a/internal/protocoltest/restxml/deserializers.go b/internal/protocoltest/restxml/deserializers.go index 4bb6be7eb8e..a06c5432563 100644 --- a/internal/protocoltest/restxml/deserializers.go +++ b/internal/protocoltest/restxml/deserializers.go @@ -345,6 +345,7 @@ func awsRestxml_deserializeDocumentFlattenedXmlMapOutput(v **FlattenedXmlMapOutp if done { break } + _ = t switch { case strings.EqualFold("myMap", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -463,6 +464,7 @@ func awsRestxml_deserializeDocumentFlattenedXmlMapWithXmlNameOutput(v **Flattene if done { break } + _ = t switch { case strings.EqualFold("KVP", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -842,6 +844,7 @@ func awsRestxml_deserializeDocumentHttpPayloadWithStructureOutput(v **HttpPayloa if done { break } + _ = t switch { case strings.EqualFold("nested", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -960,6 +963,7 @@ func awsRestxml_deserializeDocumentHttpPayloadWithXmlNameOutput(v **HttpPayloadW if done { break } + _ = t switch { case strings.EqualFold("nested", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -1078,6 +1082,7 @@ func awsRestxml_deserializeDocumentHttpPayloadWithXmlNamespaceOutput(v **HttpPay if done { break } + _ = t switch { case strings.EqualFold("nested", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -1196,6 +1201,7 @@ func awsRestxml_deserializeDocumentHttpPayloadWithXmlNamespaceAndPrefixOutput(v if done { break } + _ = t switch { case strings.EqualFold("nested", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -1562,6 +1568,7 @@ func awsRestxml_deserializeDocumentIgnoreQueryParamsInResponseOutput(v **IgnoreQ if done { break } + _ = t switch { case strings.EqualFold("baz", t.Name.Local): val, done, err := decoder.Value() @@ -2353,6 +2360,7 @@ func awsRestxml_deserializeDocumentRecursiveShapesOutput(v **RecursiveShapesOutp if done { break } + _ = t switch { case strings.EqualFold("nested", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -2488,6 +2496,7 @@ func awsRestxml_deserializeDocumentSimpleScalarPropertiesOutput(v **SimpleScalar if done { break } + _ = t switch { case strings.EqualFold("byteValue", t.Name.Local): val, done, err := decoder.Value() @@ -2891,6 +2900,7 @@ func awsRestxml_deserializeDocumentXmlAttributesOutput(v **XmlAttributesOutput, if done { break } + _ = t switch { case strings.EqualFold("foo", t.Name.Local): val, done, err := decoder.Value() @@ -3016,6 +3026,7 @@ func awsRestxml_deserializeDocumentXmlAttributesOnPayloadOutput(v **XmlAttribute if done { break } + _ = t switch { case strings.EqualFold("payload", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -3134,6 +3145,7 @@ func awsRestxml_deserializeDocumentXmlBlobsOutput(v **XmlBlobsOutput, decoder sm if done { break } + _ = t switch { case strings.EqualFold("data", t.Name.Local): var data string @@ -3257,6 +3269,7 @@ func awsRestxml_deserializeDocumentXmlEnumsOutput(v **XmlEnumsOutput, decoder sm if done { break } + _ = t switch { case strings.EqualFold("fooEnum1", t.Name.Local): val, done, err := decoder.Value() @@ -3426,6 +3439,7 @@ func awsRestxml_deserializeDocumentXmlListsOutput(v **XmlListsOutput, decoder sm if done { break } + _ = t switch { case strings.EqualFold("booleanList", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -3604,6 +3618,7 @@ func awsRestxml_deserializeDocumentXmlMapsOutput(v **XmlMapsOutput, decoder smit if done { break } + _ = t switch { case strings.EqualFold("myMap", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -3722,6 +3737,7 @@ func awsRestxml_deserializeDocumentXmlMapsXmlNameOutput(v **XmlMapsXmlNameOutput if done { break } + _ = t switch { case strings.EqualFold("myMap", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -3840,6 +3856,7 @@ func awsRestxml_deserializeDocumentXmlNamespacesOutput(v **XmlNamespacesOutput, if done { break } + _ = t switch { case strings.EqualFold("nested", t.Name.Local): nodeDecoder := smithyxml.WrapNodeDecoder(decoder.Decoder, t) @@ -3958,6 +3975,7 @@ func awsRestxml_deserializeDocumentXmlTimestampsOutput(v **XmlTimestampsOutput, if done { break } + _ = t switch { case strings.EqualFold("dateTime", t.Name.Local): val, done, err := decoder.Value() @@ -4136,6 +4154,7 @@ func awsRestxml_deserializeDocumentComplexError(v **types.ComplexError, decoder if done { break } + _ = t switch { case strings.EqualFold("Header", t.Name.Local): val, done, err := decoder.Value() @@ -4197,6 +4216,7 @@ func awsRestxml_deserializeDocumentComplexNestedErrorData(v **types.ComplexNeste if done { break } + _ = t switch { case strings.EqualFold("Foo", t.Name.Local): val, done, err := decoder.Value() @@ -4323,6 +4343,7 @@ func awsRestxml_deserializeDocumentInvalidGreeting(v **types.InvalidGreeting, de if done { break } + _ = t switch { case strings.EqualFold("Message", t.Name.Local): val, done, err := decoder.Value() @@ -4365,6 +4386,7 @@ func awsRestxml_deserializeDocumentNestedPayload(v **types.NestedPayload, decode if done { break } + _ = t switch { case strings.EqualFold("greeting", t.Name.Local): val, done, err := decoder.Value() @@ -4420,6 +4442,7 @@ func awsRestxml_deserializeDocumentPayloadWithXmlName(v **types.PayloadWithXmlNa if done { break } + _ = t switch { case strings.EqualFold("name", t.Name.Local): val, done, err := decoder.Value() @@ -4462,6 +4485,7 @@ func awsRestxml_deserializeDocumentPayloadWithXmlNamespace(v **types.PayloadWith if done { break } + _ = t switch { case strings.EqualFold("name", t.Name.Local): val, done, err := decoder.Value() @@ -4504,6 +4528,7 @@ func awsRestxml_deserializeDocumentPayloadWithXmlNamespaceAndPrefix(v **types.Pa if done { break } + _ = t switch { case strings.EqualFold("name", t.Name.Local): val, done, err := decoder.Value() @@ -4546,6 +4571,7 @@ func awsRestxml_deserializeDocumentRecursiveShapesInputOutputNested1(v **types.R if done { break } + _ = t switch { case strings.EqualFold("foo", t.Name.Local): val, done, err := decoder.Value() @@ -4594,6 +4620,7 @@ func awsRestxml_deserializeDocumentRecursiveShapesInputOutputNested2(v **types.R if done { break } + _ = t switch { case strings.EqualFold("bar", t.Name.Local): val, done, err := decoder.Value() @@ -4773,6 +4800,7 @@ func awsRestxml_deserializeDocumentStructureListMember(v **types.StructureListMe if done { break } + _ = t switch { case strings.EqualFold("value", t.Name.Local): val, done, err := decoder.Value() @@ -4839,6 +4867,7 @@ func awsRestxml_deserializeDocumentXmlAttributesInputOutput(v **types.XmlAttribu if done { break } + _ = t switch { case strings.EqualFold("foo", t.Name.Local): val, done, err := decoder.Value() @@ -5108,6 +5137,7 @@ func awsRestxml_deserializeDocumentXmlNamespaceNested(v **types.XmlNamespaceNest if done { break } + _ = t switch { case strings.EqualFold("foo", t.Name.Local): val, done, err := decoder.Value() @@ -5465,6 +5495,7 @@ func awsRestxml_deserializeDocumentGreetingStruct(v **types.GreetingStruct, deco if done { break } + _ = t switch { case strings.EqualFold("hi", t.Name.Local): val, done, err := decoder.Value() diff --git a/internal/protocoltest/restxml/go.mod b/internal/protocoltest/restxml/go.mod index c5cc42ba676..07297194d46 100644 --- a/internal/protocoltest/restxml/go.mod +++ b/internal/protocoltest/restxml/go.mod @@ -3,7 +3,7 @@ module github.com/aws/aws-sdk-go-v2/internal/protocoltest/restxml go 1.15 require ( - github.com/aws/aws-sdk-go-v2 v0.24.1-0.20200821181726-bc564654ccac - github.com/awslabs/smithy-go v0.0.0-20200820215706-7b32252c1389 + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 github.com/google/go-cmp v0.4.1 ) diff --git a/internal/protocoltest/restxml/serializers.go b/internal/protocoltest/restxml/serializers.go index a5a536e6a06..3b8103a20ed 100644 --- a/internal/protocoltest/restxml/serializers.go +++ b/internal/protocoltest/restxml/serializers.go @@ -634,8 +634,9 @@ func awsRestxml_serializeHttpBindingsHttpPayloadTraitsInput(v *HttpPayloadTraits } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -705,8 +706,9 @@ func awsRestxml_serializeHttpBindingsHttpPayloadTraitsWithMediaTypeInput(v *Http } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -1055,16 +1057,17 @@ func awsRestxml_serializeHttpBindingsHttpPrefixHeadersInput(v *HttpPrefixHeaders } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } if v.FooMap != nil { hv := encoder.Headers("X-Foo-") for mapKey, mapVal := range v.FooMap { - if mapVal != nil && len(*mapVal) > 0 { - hv.AddHeader(mapKey).String(*mapVal) + if len(*mapVal) > 0 { + hv.SetHeader(mapKey).String(*mapVal) } } } @@ -1438,93 +1441,109 @@ func awsRestxml_serializeHttpBindingsInputAndOutputWithHeadersInput(v *InputAndO } if v.HeaderBooleanList != nil { + locationName := "X-BooleanList" for i := range v.HeaderBooleanList { if v.HeaderBooleanList[i] != nil { - encoder.AddHeader("X-BooleanList").Boolean(*v.HeaderBooleanList[i]) + encoder.AddHeader(locationName).Boolean(*v.HeaderBooleanList[i]) } } } if v.HeaderByte != nil { - encoder.SetHeader("X-Byte").Byte(*v.HeaderByte) + locationName := "X-Byte" + encoder.SetHeader(locationName).Byte(*v.HeaderByte) } if v.HeaderDouble != nil { - encoder.SetHeader("X-Double").Double(*v.HeaderDouble) + locationName := "X-Double" + encoder.SetHeader(locationName).Double(*v.HeaderDouble) } if len(v.HeaderEnum) > 0 { - encoder.SetHeader("X-Enum").String(string(v.HeaderEnum)) + locationName := "X-Enum" + encoder.SetHeader(locationName).String(string(v.HeaderEnum)) } if v.HeaderEnumList != nil { + locationName := "X-EnumList" for i := range v.HeaderEnumList { if len(v.HeaderEnumList[i]) > 0 { - encoder.AddHeader("X-EnumList").String(string(v.HeaderEnumList[i])) + encoder.AddHeader(locationName).String(string(v.HeaderEnumList[i])) } } } if v.HeaderFalseBool != nil { - encoder.SetHeader("X-Boolean2").Boolean(*v.HeaderFalseBool) + locationName := "X-Boolean2" + encoder.SetHeader(locationName).Boolean(*v.HeaderFalseBool) } if v.HeaderFloat != nil { - encoder.SetHeader("X-Float").Float(*v.HeaderFloat) + locationName := "X-Float" + encoder.SetHeader(locationName).Float(*v.HeaderFloat) } if v.HeaderInteger != nil { - encoder.SetHeader("X-Integer").Integer(*v.HeaderInteger) + locationName := "X-Integer" + encoder.SetHeader(locationName).Integer(*v.HeaderInteger) } if v.HeaderIntegerList != nil { + locationName := "X-IntegerList" for i := range v.HeaderIntegerList { if v.HeaderIntegerList[i] != nil { - encoder.AddHeader("X-IntegerList").Integer(*v.HeaderIntegerList[i]) + encoder.AddHeader(locationName).Integer(*v.HeaderIntegerList[i]) } } } if v.HeaderLong != nil { - encoder.SetHeader("X-Long").Long(*v.HeaderLong) + locationName := "X-Long" + encoder.SetHeader(locationName).Long(*v.HeaderLong) } if v.HeaderShort != nil { - encoder.SetHeader("X-Short").Short(*v.HeaderShort) + locationName := "X-Short" + encoder.SetHeader(locationName).Short(*v.HeaderShort) } if v.HeaderString != nil { + locationName := "X-String" if len(*v.HeaderString) > 0 { - encoder.SetHeader("X-String").String(*v.HeaderString) + encoder.SetHeader(locationName).String(*v.HeaderString) } } if v.HeaderStringList != nil { + locationName := "X-StringList" for i := range v.HeaderStringList { if v.HeaderStringList[i] != nil && len(*v.HeaderStringList[i]) > 0 { - encoder.AddHeader("X-StringList").String(*v.HeaderStringList[i]) + encoder.AddHeader(locationName).String(*v.HeaderStringList[i]) } } } if v.HeaderStringSet != nil { + locationName := "X-StringSet" for i := range v.HeaderStringSet { if v.HeaderStringSet[i] != nil && len(*v.HeaderStringSet[i]) > 0 { - encoder.AddHeader("X-StringSet").String(*v.HeaderStringSet[i]) + encoder.AddHeader(locationName).String(*v.HeaderStringSet[i]) } } } if v.HeaderTimestampList != nil { + locationName := "X-TimestampList" for i := range v.HeaderTimestampList { if v.HeaderTimestampList[i] != nil { - encoder.AddHeader("X-TimestampList").String(smithytime.FormatHTTPDate(*v.HeaderTimestampList[i])) + encoder.AddHeader(locationName).String(smithytime.FormatHTTPDate(*v.HeaderTimestampList[i])) } } } if v.HeaderTrueBool != nil { - encoder.SetHeader("X-Boolean1").Boolean(*v.HeaderTrueBool) + locationName := "X-Boolean1" + encoder.SetHeader(locationName).Boolean(*v.HeaderTrueBool) } return nil @@ -1682,21 +1701,24 @@ func awsRestxml_serializeHttpBindingsNullAndEmptyHeadersClientInput(v *NullAndEm } if v.A != nil { + locationName := "X-A" if len(*v.A) > 0 { - encoder.SetHeader("X-A").String(*v.A) + encoder.SetHeader(locationName).String(*v.A) } } if v.B != nil { + locationName := "X-B" if len(*v.B) > 0 { - encoder.SetHeader("X-B").String(*v.B) + encoder.SetHeader(locationName).String(*v.B) } } if v.C != nil { + locationName := "X-C" for i := range v.C { if v.C[i] != nil && len(*v.C[i]) > 0 { - encoder.AddHeader("X-C").String(*v.C[i]) + encoder.AddHeader(locationName).String(*v.C[i]) } } } @@ -1756,21 +1778,24 @@ func awsRestxml_serializeHttpBindingsNullAndEmptyHeadersServerInput(v *NullAndEm } if v.A != nil { + locationName := "X-A" if len(*v.A) > 0 { - encoder.SetHeader("X-A").String(*v.A) + encoder.SetHeader(locationName).String(*v.A) } } if v.B != nil { + locationName := "X-B" if len(*v.B) > 0 { - encoder.SetHeader("X-B").String(*v.B) + encoder.SetHeader(locationName).String(*v.B) } } if v.C != nil { + locationName := "X-C" for i := range v.C { if v.C[i] != nil && len(*v.C[i]) > 0 { - encoder.AddHeader("X-C").String(*v.C[i]) + encoder.AddHeader(locationName).String(*v.C[i]) } } } @@ -2052,8 +2077,9 @@ func awsRestxml_serializeHttpBindingsSimpleScalarPropertiesInput(v *SimpleScalar } if v.Foo != nil { + locationName := "X-Foo" if len(*v.Foo) > 0 { - encoder.SetHeader("X-Foo").String(*v.Foo) + encoder.SetHeader(locationName).String(*v.Foo) } } @@ -2216,31 +2242,38 @@ func awsRestxml_serializeHttpBindingsTimestampFormatHeadersInput(v *TimestampFor } if v.DefaultFormat != nil { - encoder.SetHeader("X-defaultFormat").String(smithytime.FormatHTTPDate(*v.DefaultFormat)) + locationName := "X-defaultFormat" + encoder.SetHeader(locationName).String(smithytime.FormatHTTPDate(*v.DefaultFormat)) } if v.MemberDateTime != nil { - encoder.SetHeader("X-memberDateTime").String(smithytime.FormatDateTime(*v.MemberDateTime)) + locationName := "X-memberDateTime" + encoder.SetHeader(locationName).String(smithytime.FormatDateTime(*v.MemberDateTime)) } if v.MemberEpochSeconds != nil { - encoder.SetHeader("X-memberEpochSeconds").Double(smithytime.FormatEpochSeconds(*v.MemberEpochSeconds)) + locationName := "X-memberEpochSeconds" + encoder.SetHeader(locationName).Double(smithytime.FormatEpochSeconds(*v.MemberEpochSeconds)) } if v.MemberHttpDate != nil { - encoder.SetHeader("X-memberHttpDate").String(smithytime.FormatHTTPDate(*v.MemberHttpDate)) + locationName := "X-memberHttpDate" + encoder.SetHeader(locationName).String(smithytime.FormatHTTPDate(*v.MemberHttpDate)) } if v.TargetDateTime != nil { - encoder.SetHeader("X-targetDateTime").String(smithytime.FormatDateTime(*v.TargetDateTime)) + locationName := "X-targetDateTime" + encoder.SetHeader(locationName).String(smithytime.FormatDateTime(*v.TargetDateTime)) } if v.TargetEpochSeconds != nil { - encoder.SetHeader("X-targetEpochSeconds").Double(smithytime.FormatEpochSeconds(*v.TargetEpochSeconds)) + locationName := "X-targetEpochSeconds" + encoder.SetHeader(locationName).Double(smithytime.FormatEpochSeconds(*v.TargetEpochSeconds)) } if v.TargetHttpDate != nil { - encoder.SetHeader("X-targetHttpDate").String(smithytime.FormatHTTPDate(*v.TargetHttpDate)) + locationName := "X-targetHttpDate" + encoder.SetHeader(locationName).String(smithytime.FormatHTTPDate(*v.TargetHttpDate)) } return nil diff --git a/service/dynamodb/deserializers.go b/service/dynamodb/deserializers.go index fdf7d673090..01744789ce3 100644 --- a/service/dynamodb/deserializers.go +++ b/service/dynamodb/deserializers.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" smithy "github.com/awslabs/smithy-go" smithyio "github.com/awslabs/smithy-go/io" + smithyjson "github.com/awslabs/smithy-go/json" "github.com/awslabs/smithy-go/middleware" "github.com/awslabs/smithy-go/ptr" smithytime "github.com/awslabs/smithy-go/time" @@ -5244,7 +5245,7 @@ func awsAwsjson10_deserializeDocumentArchivalSummary(v **types.ArchivalSummary, } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5321,7 +5322,7 @@ func awsAwsjson10_deserializeDocumentAttributeDefinition(v **types.AttributeDefi } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5608,7 +5609,7 @@ func awsAwsjson10_deserializeDocumentAttributeValue(v **types.AttributeValue, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5677,7 +5678,7 @@ func awsAwsjson10_deserializeDocumentAutoScalingPolicyDescription(v **types.Auto } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5838,7 +5839,7 @@ func awsAwsjson10_deserializeDocumentAutoScalingSettingsDescription(v **types.Au } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -5953,7 +5954,7 @@ func awsAwsjson10_deserializeDocumentAutoScalingTargetTrackingScalingPolicyConfi } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -6019,7 +6020,7 @@ func awsAwsjson10_deserializeDocumentBackupDescription(v **types.BackupDescripti } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -6173,7 +6174,7 @@ func awsAwsjson10_deserializeDocumentBackupDetails(v **types.BackupDetails, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -6237,7 +6238,7 @@ func awsAwsjson10_deserializeDocumentBackupInUseException(v **types.BackupInUseE } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -6301,7 +6302,7 @@ func awsAwsjson10_deserializeDocumentBackupNotFoundException(v **types.BackupNot } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -6539,7 +6540,7 @@ func awsAwsjson10_deserializeDocumentBackupSummary(v **types.BackupSummary, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -6785,7 +6786,7 @@ func awsAwsjson10_deserializeDocumentBillingModeSummary(v **types.BillingModeSum } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -6913,7 +6914,7 @@ func awsAwsjson10_deserializeDocumentCancellationReason(v **types.CancellationRe } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7060,7 +7061,7 @@ func awsAwsjson10_deserializeDocumentCapacity(v **types.Capacity, decoder *json. } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7124,7 +7125,7 @@ func awsAwsjson10_deserializeDocumentConditionalCheckFailedException(v **types.C } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7254,7 +7255,7 @@ func awsAwsjson10_deserializeDocumentConsumedCapacity(v **types.ConsumedCapacity } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7368,7 +7369,7 @@ func awsAwsjson10_deserializeDocumentContinuousBackupsDescription(v **types.Cont } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7432,7 +7433,7 @@ func awsAwsjson10_deserializeDocumentContinuousBackupsUnavailableException(v **t } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7620,7 +7621,7 @@ func awsAwsjson10_deserializeDocumentContributorInsightsSummary(v **types.Contri } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7676,7 +7677,7 @@ func awsAwsjson10_deserializeDocumentDeleteRequest(v **types.DeleteRequest, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7757,7 +7758,7 @@ func awsAwsjson10_deserializeDocumentEndpoint(v **types.Endpoint, decoder *json. } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -7942,7 +7943,7 @@ func awsAwsjson10_deserializeDocumentFailureException(v **types.FailureException } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8094,7 +8095,7 @@ func awsAwsjson10_deserializeDocumentGlobalSecondaryIndexDescription(v **types.G } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8263,7 +8264,7 @@ func awsAwsjson10_deserializeDocumentGlobalSecondaryIndexInfo(v **types.GlobalSe } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8332,7 +8333,7 @@ func awsAwsjson10_deserializeDocumentGlobalTable(v **types.GlobalTable, decoder } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8396,7 +8397,7 @@ func awsAwsjson10_deserializeDocumentGlobalTableAlreadyExistsException(v **types } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8508,7 +8509,7 @@ func awsAwsjson10_deserializeDocumentGlobalTableDescription(v **types.GlobalTabl } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8617,7 +8618,7 @@ func awsAwsjson10_deserializeDocumentGlobalTableNotFoundException(v **types.Glob } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8681,7 +8682,7 @@ func awsAwsjson10_deserializeDocumentIdempotentParameterMismatchException(v **ty } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8745,7 +8746,7 @@ func awsAwsjson10_deserializeDocumentIndexNotFoundException(v **types.IndexNotFo } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8809,7 +8810,7 @@ func awsAwsjson10_deserializeDocumentInternalServerError(v **types.InternalServe } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8873,7 +8874,7 @@ func awsAwsjson10_deserializeDocumentInvalidEndpointException(v **types.InvalidE } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -8937,7 +8938,7 @@ func awsAwsjson10_deserializeDocumentInvalidRestoreTimeException(v **types.Inval } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -9053,7 +9054,7 @@ func awsAwsjson10_deserializeDocumentItemCollectionMetrics(v **types.ItemCollect } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -9274,7 +9275,7 @@ func awsAwsjson10_deserializeDocumentItemCollectionSizeLimitExceededException(v } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -9375,7 +9376,7 @@ func awsAwsjson10_deserializeDocumentItemResponse(v **types.ItemResponse, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -9612,7 +9613,7 @@ func awsAwsjson10_deserializeDocumentKeysAndAttributes(v **types.KeysAndAttribut } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -9734,7 +9735,7 @@ func awsAwsjson10_deserializeDocumentKeySchemaElement(v **types.KeySchemaElement } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -9798,7 +9799,7 @@ func awsAwsjson10_deserializeDocumentLimitExceededException(v **types.LimitExcee } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -9964,7 +9965,7 @@ func awsAwsjson10_deserializeDocumentLocalSecondaryIndexDescription(v **types.Lo } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10128,7 +10129,7 @@ func awsAwsjson10_deserializeDocumentLocalSecondaryIndexInfo(v **types.LocalSeco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10387,7 +10388,7 @@ func awsAwsjson10_deserializeDocumentPointInTimeRecoveryDescription(v **types.Po } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10451,7 +10452,7 @@ func awsAwsjson10_deserializeDocumentPointInTimeRecoveryUnavailableException(v * } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10520,7 +10521,7 @@ func awsAwsjson10_deserializeDocumentProjection(v **types.Projection, decoder *j } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10605,7 +10606,7 @@ func awsAwsjson10_deserializeDocumentProvisionedThroughput(v **types.Provisioned } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10741,7 +10742,7 @@ func awsAwsjson10_deserializeDocumentProvisionedThroughputDescription(v **types. } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10805,7 +10806,7 @@ func awsAwsjson10_deserializeDocumentProvisionedThroughputExceededException(v ** } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10873,7 +10874,7 @@ func awsAwsjson10_deserializeDocumentProvisionedThroughputOverride(v **types.Pro } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -10984,7 +10985,7 @@ func awsAwsjson10_deserializeDocumentPutRequest(v **types.PutRequest, decoder *j } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11048,7 +11049,7 @@ func awsAwsjson10_deserializeDocumentReplica(v **types.Replica, decoder *json.De } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11112,7 +11113,7 @@ func awsAwsjson10_deserializeDocumentReplicaAlreadyExistsException(v **types.Rep } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11204,7 +11205,7 @@ func awsAwsjson10_deserializeDocumentReplicaAutoScalingDescription(v **types.Rep } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11375,7 +11376,7 @@ func awsAwsjson10_deserializeDocumentReplicaDescription(v **types.ReplicaDescrip } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11507,7 +11508,7 @@ func awsAwsjson10_deserializeDocumentReplicaGlobalSecondaryIndexAutoScalingDescr } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11621,7 +11622,7 @@ func awsAwsjson10_deserializeDocumentReplicaGlobalSecondaryIndexDescription(v ** } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11787,7 +11788,7 @@ func awsAwsjson10_deserializeDocumentReplicaGlobalSecondaryIndexSettingsDescript } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -11941,7 +11942,7 @@ func awsAwsjson10_deserializeDocumentReplicaNotFoundException(v **types.ReplicaN } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12072,7 +12073,7 @@ func awsAwsjson10_deserializeDocumentReplicaSettingsDescription(v **types.Replic } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12181,7 +12182,7 @@ func awsAwsjson10_deserializeDocumentRequestLimitExceeded(v **types.RequestLimit } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12245,7 +12246,7 @@ func awsAwsjson10_deserializeDocumentResourceInUseException(v **types.ResourceIn } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12309,7 +12310,7 @@ func awsAwsjson10_deserializeDocumentResourceNotFoundException(v **types.Resourc } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12416,7 +12417,7 @@ func awsAwsjson10_deserializeDocumentRestoreSummary(v **types.RestoreSummary, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12635,7 +12636,7 @@ func awsAwsjson10_deserializeDocumentSourceTableDetails(v **types.SourceTableDet } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12711,7 +12712,7 @@ func awsAwsjson10_deserializeDocumentSourceTableFeatureDetails(v **types.SourceT } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12818,7 +12819,7 @@ func awsAwsjson10_deserializeDocumentSSEDescription(v **types.SSEDescription, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -12895,7 +12896,7 @@ func awsAwsjson10_deserializeDocumentStreamSpecification(v **types.StreamSpecifi } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13012,7 +13013,7 @@ func awsAwsjson10_deserializeDocumentTableAlreadyExistsException(v **types.Table } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13094,7 +13095,7 @@ func awsAwsjson10_deserializeDocumentTableAutoScalingDescription(v **types.Table } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13342,7 +13343,7 @@ func awsAwsjson10_deserializeDocumentTableDescription(v **types.TableDescription } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13406,7 +13407,7 @@ func awsAwsjson10_deserializeDocumentTableInUseException(v **types.TableInUseExc } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13523,7 +13524,7 @@ func awsAwsjson10_deserializeDocumentTableNotFoundException(v **types.TableNotFo } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13600,7 +13601,7 @@ func awsAwsjson10_deserializeDocumentTag(v **types.Tag, decoder *json.Decoder) e } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13722,7 +13723,7 @@ func awsAwsjson10_deserializeDocumentTimeToLiveDescription(v **types.TimeToLiveD } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13799,7 +13800,7 @@ func awsAwsjson10_deserializeDocumentTimeToLiveSpecification(v **types.TimeToLiv } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13868,7 +13869,7 @@ func awsAwsjson10_deserializeDocumentTransactionCanceledException(v **types.Tran } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13932,7 +13933,7 @@ func awsAwsjson10_deserializeDocumentTransactionConflictException(v **types.Tran } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -13996,7 +13997,7 @@ func awsAwsjson10_deserializeDocumentTransactionInProgressException(v **types.Tr } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14057,7 +14058,7 @@ func awsAwsjson10_deserializeDocumentWriteRequest(v **types.WriteRequest, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14168,7 +14169,7 @@ func awsAwsjson10_deserializeDocumentBatchGetItemOutput(v **BatchGetItemOutput, } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14234,7 +14235,7 @@ func awsAwsjson10_deserializeDocumentBatchWriteItemOutput(v **BatchWriteItemOutp } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14290,7 +14291,7 @@ func awsAwsjson10_deserializeDocumentCreateBackupOutput(v **CreateBackupOutput, } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14346,7 +14347,7 @@ func awsAwsjson10_deserializeDocumentCreateGlobalTableOutput(v **CreateGlobalTab } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14402,7 +14403,7 @@ func awsAwsjson10_deserializeDocumentCreateTableOutput(v **CreateTableOutput, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14458,7 +14459,7 @@ func awsAwsjson10_deserializeDocumentDeleteBackupOutput(v **DeleteBackupOutput, } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14524,7 +14525,7 @@ func awsAwsjson10_deserializeDocumentDeleteItemOutput(v **DeleteItemOutput, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14580,7 +14581,7 @@ func awsAwsjson10_deserializeDocumentDeleteTableOutput(v **DeleteTableOutput, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14636,7 +14637,7 @@ func awsAwsjson10_deserializeDocumentDescribeBackupOutput(v **DescribeBackupOutp } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14692,7 +14693,7 @@ func awsAwsjson10_deserializeDocumentDescribeContinuousBackupsOutput(v **Describ } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14809,7 +14810,7 @@ func awsAwsjson10_deserializeDocumentDescribeContributorInsightsOutput(v **Descr } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14865,7 +14866,7 @@ func awsAwsjson10_deserializeDocumentDescribeEndpointsOutput(v **DescribeEndpoin } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14921,7 +14922,7 @@ func awsAwsjson10_deserializeDocumentDescribeGlobalTableOutput(v **DescribeGloba } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -14990,7 +14991,7 @@ func awsAwsjson10_deserializeDocumentDescribeGlobalTableSettingsOutput(v **Descr } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15109,7 +15110,7 @@ func awsAwsjson10_deserializeDocumentDescribeLimitsOutput(v **DescribeLimitsOutp } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15165,7 +15166,7 @@ func awsAwsjson10_deserializeDocumentDescribeTableOutput(v **DescribeTableOutput } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15221,7 +15222,7 @@ func awsAwsjson10_deserializeDocumentDescribeTableReplicaAutoScalingOutput(v **D } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15277,7 +15278,7 @@ func awsAwsjson10_deserializeDocumentDescribeTimeToLiveOutput(v **DescribeTimeTo } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15338,7 +15339,7 @@ func awsAwsjson10_deserializeDocumentGetItemOutput(v **GetItemOutput, decoder *j } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15407,7 +15408,7 @@ func awsAwsjson10_deserializeDocumentListBackupsOutput(v **ListBackupsOutput, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15476,7 +15477,7 @@ func awsAwsjson10_deserializeDocumentListContributorInsightsOutput(v **ListContr } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15545,7 +15546,7 @@ func awsAwsjson10_deserializeDocumentListGlobalTablesOutput(v **ListGlobalTables } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15614,7 +15615,7 @@ func awsAwsjson10_deserializeDocumentListTablesOutput(v **ListTablesOutput, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15683,7 +15684,7 @@ func awsAwsjson10_deserializeDocumentListTagsOfResourceOutput(v **ListTagsOfReso } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15749,7 +15750,7 @@ func awsAwsjson10_deserializeDocumentPutItemOutput(v **PutItemOutput, decoder *j } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15849,7 +15850,7 @@ func awsAwsjson10_deserializeDocumentQueryOutput(v **QueryOutput, decoder *json. } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15905,7 +15906,7 @@ func awsAwsjson10_deserializeDocumentRestoreTableFromBackupOutput(v **RestoreTab } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -15961,7 +15962,7 @@ func awsAwsjson10_deserializeDocumentRestoreTableToPointInTimeOutput(v **Restore } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16061,7 +16062,7 @@ func awsAwsjson10_deserializeDocumentScanOutput(v **ScanOutput, decoder *json.De } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16112,7 +16113,7 @@ func awsAwsjson10_deserializeDocumentTagResourceOutput(v **TagResourceOutput, de } switch t { default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16173,7 +16174,7 @@ func awsAwsjson10_deserializeDocumentTransactGetItemsOutput(v **TransactGetItems } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16234,7 +16235,7 @@ func awsAwsjson10_deserializeDocumentTransactWriteItemsOutput(v **TransactWriteI } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16285,7 +16286,7 @@ func awsAwsjson10_deserializeDocumentUntagResourceOutput(v **UntagResourceOutput } switch t { default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16341,7 +16342,7 @@ func awsAwsjson10_deserializeDocumentUpdateContinuousBackupsOutput(v **UpdateCon } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16431,7 +16432,7 @@ func awsAwsjson10_deserializeDocumentUpdateContributorInsightsOutput(v **UpdateC } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16487,7 +16488,7 @@ func awsAwsjson10_deserializeDocumentUpdateGlobalTableOutput(v **UpdateGlobalTab } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16556,7 +16557,7 @@ func awsAwsjson10_deserializeDocumentUpdateGlobalTableSettingsOutput(v **UpdateG } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16622,7 +16623,7 @@ func awsAwsjson10_deserializeDocumentUpdateItemOutput(v **UpdateItemOutput, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16678,7 +16679,7 @@ func awsAwsjson10_deserializeDocumentUpdateTableOutput(v **UpdateTableOutput, de } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16734,7 +16735,7 @@ func awsAwsjson10_deserializeDocumentUpdateTableReplicaAutoScalingOutput(v **Upd } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -16790,7 +16791,7 @@ func awsAwsjson10_deserializeDocumentUpdateTimeToLiveOutput(v **UpdateTimeToLive } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } diff --git a/service/dynamodb/go.mod b/service/dynamodb/go.mod index cc84c3e89c7..0115f9dd5c8 100644 --- a/service/dynamodb/go.mod +++ b/service/dynamodb/go.mod @@ -3,6 +3,6 @@ module github.com/aws/aws-sdk-go-v2/service/dynamodb go 1.15 require ( - github.com/aws/aws-sdk-go-v2 v0.24.1-0.20200821181726-bc564654ccac - github.com/awslabs/smithy-go v0.0.0-20200820215706-7b32252c1389 + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 ) diff --git a/service/lexruntimeservice/deserializers.go b/service/lexruntimeservice/deserializers.go index c665cb6609c..74370d27a21 100644 --- a/service/lexruntimeservice/deserializers.go +++ b/service/lexruntimeservice/deserializers.go @@ -5,12 +5,14 @@ package lexruntimeservice import ( "bytes" "context" + "encoding/base64" "encoding/json" "fmt" "github.com/aws/aws-sdk-go-v2/aws/protocol/restjson" "github.com/aws/aws-sdk-go-v2/service/lexruntimeservice/types" smithy "github.com/awslabs/smithy-go" smithyio "github.com/awslabs/smithy-go/io" + smithyjson "github.com/awslabs/smithy-go/json" "github.com/awslabs/smithy-go/middleware" "github.com/awslabs/smithy-go/ptr" smithyhttp "github.com/awslabs/smithy-go/transport/http" @@ -215,7 +217,7 @@ func awsRestjson1_deserializeDocumentDeleteSessionOutput(v **DeleteSessionOutput } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -404,7 +406,7 @@ func awsRestjson1_deserializeDocumentGetSessionOutput(v **GetSessionOutput, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -588,7 +590,11 @@ func awsRestjson1_deserializeHttpBindingsPostContentOutput(v *PostContentOutput, if headerValues := response.Header.Values("x-amz-lex-session-attributes"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) - v.SessionAttributes = ptr.String(headerValues[0]) + b, err := base64.StdEncoding.DecodeString(headerValues[0]) + if err != nil { + return err + } + v.SessionAttributes = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-session-id"); len(headerValues) != 0 { @@ -598,7 +604,11 @@ func awsRestjson1_deserializeHttpBindingsPostContentOutput(v *PostContentOutput, if headerValues := response.Header.Values("x-amz-lex-slots"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) - v.Slots = ptr.String(headerValues[0]) + b, err := base64.StdEncoding.DecodeString(headerValues[0]) + if err != nil { + return err + } + v.Slots = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-slot-to-elicit"); len(headerValues) != 0 { @@ -869,7 +879,7 @@ func awsRestjson1_deserializeDocumentPostTextOutput(v **PostTextOutput, decoder } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1034,7 +1044,11 @@ func awsRestjson1_deserializeHttpBindingsPutSessionOutput(v *PutSessionOutput, r if headerValues := response.Header.Values("x-amz-lex-session-attributes"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) - v.SessionAttributes = ptr.String(headerValues[0]) + b, err := base64.StdEncoding.DecodeString(headerValues[0]) + if err != nil { + return err + } + v.SessionAttributes = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-session-id"); len(headerValues) != 0 { @@ -1044,7 +1058,11 @@ func awsRestjson1_deserializeHttpBindingsPutSessionOutput(v *PutSessionOutput, r if headerValues := response.Header.Values("x-amz-lex-slots"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) - v.Slots = ptr.String(headerValues[0]) + b, err := base64.StdEncoding.DecodeString(headerValues[0]) + if err != nil { + return err + } + v.Slots = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-slot-to-elicit"); len(headerValues) != 0 { @@ -1399,7 +1417,7 @@ func awsRestjson1_deserializeDocumentBadRequestException(v **types.BadRequestExc } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1463,7 +1481,7 @@ func awsRestjson1_deserializeDocumentConflictException(v **types.ConflictExcepti } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1527,7 +1545,7 @@ func awsRestjson1_deserializeDocumentInternalFailureException(v **types.Internal } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1604,7 +1622,7 @@ func awsRestjson1_deserializeDocumentLimitExceededException(v **types.LimitExcee } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1668,7 +1686,7 @@ func awsRestjson1_deserializeDocumentNotAcceptableException(v **types.NotAccepta } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1732,7 +1750,7 @@ func awsRestjson1_deserializeDocumentNotFoundException(v **types.NotFoundExcepti } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1796,7 +1814,7 @@ func awsRestjson1_deserializeDocumentRequestTimeoutException(v **types.RequestTi } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1860,7 +1878,7 @@ func awsRestjson1_deserializeDocumentUnsupportedMediaTypeException(v **types.Uns } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1924,7 +1942,7 @@ func awsRestjson1_deserializeDocumentBadGatewayException(v **types.BadGatewayExc } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -1988,7 +2006,7 @@ func awsRestjson1_deserializeDocumentDependencyFailedException(v **types.Depende } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2122,7 +2140,7 @@ func awsRestjson1_deserializeDocumentDialogAction(v **types.DialogAction, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2256,7 +2274,7 @@ func awsRestjson1_deserializeDocumentIntentSummary(v **types.IntentSummary, deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2365,7 +2383,7 @@ func awsRestjson1_deserializeDocumentLoopDetectedException(v **types.LoopDetecte } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2442,7 +2460,7 @@ func awsRestjson1_deserializeDocumentSentimentResponse(v **types.SentimentRespon } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2582,7 +2600,7 @@ func awsRestjson1_deserializeDocumentButton(v **types.Button, decoder *json.Deco } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2690,7 +2708,7 @@ func awsRestjson1_deserializeDocumentGenericAttachment(v **types.GenericAttachme } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } @@ -2862,7 +2880,7 @@ func awsRestjson1_deserializeDocumentResponseCard(v **types.ResponseCard, decode } default: - err := restjson.DiscardUnknownField(decoder) + err := smithyjson.DiscardUnknownField(decoder) if err != nil { return err } diff --git a/service/lexruntimeservice/go.mod b/service/lexruntimeservice/go.mod index aaf70d7a6eb..5d451e00235 100644 --- a/service/lexruntimeservice/go.mod +++ b/service/lexruntimeservice/go.mod @@ -3,6 +3,6 @@ module github.com/aws/aws-sdk-go-v2/service/lexruntimeservice go 1.15 require ( - github.com/aws/aws-sdk-go-v2 v0.24.1-0.20200821181726-bc564654ccac - github.com/awslabs/smithy-go v0.0.0-20200820215706-7b32252c1389 + github.com/aws/aws-sdk-go-v2 v0.0.0-20200825204738-85a040a34371 + github.com/awslabs/smithy-go v0.0.0-20200827001424-5fb68d03f931 ) diff --git a/service/lexruntimeservice/serializers.go b/service/lexruntimeservice/serializers.go index 81c5f4f4514..2d94ff6de7a 100644 --- a/service/lexruntimeservice/serializers.go +++ b/service/lexruntimeservice/serializers.go @@ -5,12 +5,14 @@ package lexruntimeservice import ( "bytes" "context" + "encoding/base64" "fmt" "github.com/aws/aws-sdk-go-v2/service/lexruntimeservice/types" smithy "github.com/awslabs/smithy-go" "github.com/awslabs/smithy-go/httpbinding" smithyjson "github.com/awslabs/smithy-go/json" "github.com/awslabs/smithy-go/middleware" + "github.com/awslabs/smithy-go/ptr" smithyhttp "github.com/awslabs/smithy-go/transport/http" ) @@ -225,8 +227,9 @@ func awsRestjson1_serializeHttpBindingsPostContentInput(v *PostContentInput, enc } if v.Accept != nil { + locationName := "Accept" if len(*v.Accept) > 0 { - encoder.SetHeader("Accept").String(*v.Accept) + encoder.SetHeader(locationName).String(*v.Accept) } } @@ -243,20 +246,25 @@ func awsRestjson1_serializeHttpBindingsPostContentInput(v *PostContentInput, enc } if v.ContentType != nil { + locationName := "Content-Type" if len(*v.ContentType) > 0 { - encoder.SetHeader("Content-Type").String(*v.ContentType) + encoder.SetHeader(locationName).String(*v.ContentType) } } if v.RequestAttributes != nil { + locationName := "x-amz-lex-request-attributes" if len(*v.RequestAttributes) > 0 { - encoder.SetHeader("x-amz-lex-request-attributes").String(*v.RequestAttributes) + encoded := ptr.String(base64.StdEncoding.EncodeToString([]byte(*v.RequestAttributes))) + encoder.SetHeader(locationName).String(*encoded) } } if v.SessionAttributes != nil { + locationName := "x-amz-lex-session-attributes" if len(*v.SessionAttributes) > 0 { - encoder.SetHeader("x-amz-lex-session-attributes").String(*v.SessionAttributes) + encoded := ptr.String(base64.StdEncoding.EncodeToString([]byte(*v.SessionAttributes))) + encoder.SetHeader(locationName).String(*encoded) } } @@ -441,8 +449,9 @@ func awsRestjson1_serializeHttpBindingsPutSessionInput(v *PutSessionInput, encod } if v.Accept != nil { + locationName := "Accept" if len(*v.Accept) > 0 { - encoder.SetHeader("Accept").String(*v.Accept) + encoder.SetHeader(locationName).String(*v.Accept) } }