// 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"
)

// This example operation serializes a structure in the HTTP body.
//
// It should ensure Content-Type: application/json is used in all requests and
// that an "empty" body is an empty JSON document ({}).
func (c *Client) TestBodyStructure(ctx context.Context, params *TestBodyStructureInput, optFns ...func(*Options)) (*TestBodyStructureOutput, error) {
	if params == nil {
		params = &TestBodyStructureInput{}
	}

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

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

type TestBodyStructureInput struct {
	TestConfig *types.TestConfig

	TestId *string

	noSmithyDocumentSerde
}

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

func (v *TestBodyStructureInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.TestConfig != nil {
		s.WriteStruct(schemas.TestBodyStructureInputOutput_testConfig)
		v.TestConfig.SerializeMembers(s)
		s.CloseStruct()
	}
	if v.TestId != nil {
		s.WriteString(schemas.TestBodyStructureInputOutput_testId, *v.TestId)
	}
}
func (v *TestBodyStructureInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.TestBodyStructureInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.TestBodyStructureInputOutput_testConfig:
			v.TestConfig = &types.TestConfig{}
			return v.TestConfig.Deserialize(d)
		case schemas.TestBodyStructureInputOutput_testId:
			v.TestId = new(string)
			return d.ReadString(schemas.TestBodyStructureInputOutput_testId, v.TestId)
		}
		return nil
	})
}

type TestBodyStructureOutput struct {
	TestConfig *types.TestConfig

	TestId *string

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

	noSmithyDocumentSerde
}

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

func (v *TestBodyStructureOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.TestConfig != nil {
		s.WriteStruct(schemas.TestBodyStructureInputOutput_testConfig)
		v.TestConfig.SerializeMembers(s)
		s.CloseStruct()
	}
	if v.TestId != nil {
		s.WriteString(schemas.TestBodyStructureInputOutput_testId, *v.TestId)
	}
}
func (v *TestBodyStructureOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.TestBodyStructureInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.TestBodyStructureInputOutput_testConfig:
			v.TestConfig = &types.TestConfig{}
			return v.TestConfig.Deserialize(d)
		case schemas.TestBodyStructureInputOutput_testId:
			v.TestId = new(string)
			return d.ReadString(schemas.TestBodyStructureInputOutput_testId, v.TestId)
		}
		return nil
	})
}
func (c *Client) addOperationTestBodyStructureMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.TestBodyStructure, schemas.TestBodyStructureInputOutput, schemas.TestBodyStructureInputOutput)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.TestBodyStructure, schemas.TestBodyStructureInputOutput, schemas.TestBodyStructureInputOutput), output: &TestBodyStructureOutput{}}, 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, "TestBodyStructure"), 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
}
