// Code generated by smithy-go-codegen DO NOT EDIT.

package query

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/internal/protocoltest/query/schemas"
	"github.com/aws/aws-sdk-go-v2/internal/protocoltest/query/types"
	smithy "github.com/aws/smithy-go"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// This test serializes simple and complex maps.
func (c *Client) QueryMaps(ctx context.Context, params *QueryMapsInput, optFns ...func(*Options)) (*QueryMapsOutput, error) {
	if params == nil {
		params = &QueryMapsInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "QueryMaps", params, optFns, c.addOperationQueryMapsMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*QueryMapsOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type QueryMapsInput struct {
	ComplexMapArg map[string]types.GreetingStruct

	FlattenedMap map[string]string

	FlattenedMapWithXmlName map[string]string

	MapArg map[string]string

	MapOfLists map[string][]string

	MapWithXmlMemberName map[string]string

	NestedStructWithMap *types.NestedStructWithMap

	RenamedMapArg map[string]string

	noSmithyDocumentSerde
}

func (v *QueryMapsInput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(schemas.QueryMapsInput)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *QueryMapsInput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeComplexMap(s, schemas.QueryMapsInput_ComplexMapArg, v.ComplexMapArg)
	serializeStringMap(s, schemas.QueryMapsInput_FlattenedMap, v.FlattenedMap)
	serializeMapWithXmlName(s, schemas.QueryMapsInput_FlattenedMapWithXmlName, v.FlattenedMapWithXmlName)
	serializeStringMap(s, schemas.QueryMapsInput_MapArg, v.MapArg)
	serializeMapOfLists(s, schemas.QueryMapsInput_MapOfLists, v.MapOfLists)
	serializeMapWithXmlName(s, schemas.QueryMapsInput_MapWithXmlMemberName, v.MapWithXmlMemberName)
	if v.NestedStructWithMap != nil {
		s.WriteStruct(schemas.QueryMapsInput_NestedStructWithMap)
		v.NestedStructWithMap.SerializeMembers(s)
		s.CloseStruct()
	}
	serializeStringMap(s, schemas.QueryMapsInput_RenamedMapArg, v.RenamedMapArg)
}
func (v *QueryMapsInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.QueryMapsInput, func(s *smithy.Schema) error {
		switch s {
		case schemas.QueryMapsInput_ComplexMapArg:
			return deserializeComplexMap(d, schemas.QueryMapsInput_ComplexMapArg, &v.ComplexMapArg)
		case schemas.QueryMapsInput_FlattenedMap:
			return deserializeStringMap(d, schemas.QueryMapsInput_FlattenedMap, &v.FlattenedMap)
		case schemas.QueryMapsInput_FlattenedMapWithXmlName:
			return deserializeMapWithXmlName(d, schemas.QueryMapsInput_FlattenedMapWithXmlName, &v.FlattenedMapWithXmlName)
		case schemas.QueryMapsInput_MapArg:
			return deserializeStringMap(d, schemas.QueryMapsInput_MapArg, &v.MapArg)
		case schemas.QueryMapsInput_MapOfLists:
			return deserializeMapOfLists(d, schemas.QueryMapsInput_MapOfLists, &v.MapOfLists)
		case schemas.QueryMapsInput_MapWithXmlMemberName:
			return deserializeMapWithXmlName(d, schemas.QueryMapsInput_MapWithXmlMemberName, &v.MapWithXmlMemberName)
		case schemas.QueryMapsInput_NestedStructWithMap:
			v.NestedStructWithMap = &types.NestedStructWithMap{}
			return v.NestedStructWithMap.Deserialize(d)
		case schemas.QueryMapsInput_RenamedMapArg:
			return deserializeStringMap(d, schemas.QueryMapsInput_RenamedMapArg, &v.RenamedMapArg)
		}
		return nil
	})
}

type QueryMapsOutput struct {
	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (v *QueryMapsOutput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(nil)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *QueryMapsOutput) SerializeMembers(s smithy.ShapeSerializer) {
}
func (v *QueryMapsOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, nil, func(s *smithy.Schema) error {
		switch s {
		}
		return nil
	})
}
func (c *Client) addOperationQueryMapsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.QueryMaps, schemas.QueryMapsInput, nil)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.QueryMaps, schemas.QueryMapsInput, nil), output: &QueryMapsOutput{}}, middleware.After); err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "QueryMaps"), middleware.Before); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
