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

package awsrestjson

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

func (c *Client) OperationWithNestedStructure(ctx context.Context, params *OperationWithNestedStructureInput, optFns ...func(*Options)) (*OperationWithNestedStructureOutput, error) {
	if params == nil {
		params = &OperationWithNestedStructureInput{}
	}

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

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

type OperationWithNestedStructureInput struct {

	// This member is required.
	TopLevel *types.TopLevel

	noSmithyDocumentSerde
}

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

func (v *OperationWithNestedStructureInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.TopLevel != nil {
		s.WriteStruct(schemas.OperationWithNestedStructureInput_topLevel)
		v.TopLevel.SerializeMembers(s)
		s.CloseStruct()
	}
}

type OperationWithNestedStructureOutput struct {

	// This member is required.
	Dialog *types.Dialog

	DialogList []types.Dialog

	DialogMap map[string]types.Dialog

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

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

func (v *OperationWithNestedStructureOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.Dialog != nil {
		s.WriteStruct(schemas.OperationWithNestedStructureOutput_dialog)
		v.Dialog.SerializeMembers(s)
		s.CloseStruct()
	}
	serializeDialogList(s, schemas.OperationWithNestedStructureOutput_dialogList, v.DialogList)
	serializeDialogMap(s, schemas.OperationWithNestedStructureOutput_dialogMap, v.DialogMap)
}
func (v *OperationWithNestedStructureOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.OperationWithNestedStructureOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.OperationWithNestedStructureOutput_dialog:
			v.Dialog = &types.Dialog{}
			return v.Dialog.Deserialize(d)
		case schemas.OperationWithNestedStructureOutput_dialogList:
			return deserializeDialogList(d, schemas.OperationWithNestedStructureOutput_dialogList, &v.DialogList)
		case schemas.OperationWithNestedStructureOutput_dialogMap:
			return deserializeDialogMap(d, schemas.OperationWithNestedStructureOutput_dialogMap, &v.DialogMap)
		}
		return nil
	})
}
func (c *Client) addOperationOperationWithNestedStructureMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.OperationWithNestedStructure, schemas.OperationWithNestedStructureInput, schemas.OperationWithNestedStructureOutput)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.OperationWithNestedStructure, schemas.OperationWithNestedStructureInput, schemas.OperationWithNestedStructureOutput), output: &OperationWithNestedStructureOutput{}}, 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, options); 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 = addOpOperationWithNestedStructureValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "OperationWithNestedStructure"), 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
}
