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

package ec2query

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

// This example serializes enums as top level properties, in lists, sets, and maps.
func (c *Client) XmlEnums(ctx context.Context, params *XmlEnumsInput, optFns ...func(*Options)) (*XmlEnumsOutput, error) {
	if params == nil {
		params = &XmlEnumsInput{}
	}

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

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

type XmlEnumsInput struct {
	noSmithyDocumentSerde
}

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

func (v *XmlEnumsInput) SerializeMembers(s smithy.ShapeSerializer) {
}
func (v *XmlEnumsInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, nil, func(s *smithy.Schema) error {
		switch s {
		}
		return nil
	})
}

type XmlEnumsOutput struct {
	FooEnum1 types.FooEnum

	FooEnum2 types.FooEnum

	FooEnum3 types.FooEnum

	FooEnumList []types.FooEnum

	FooEnumMap map[string]types.FooEnum

	FooEnumSet []types.FooEnum

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

	noSmithyDocumentSerde
}

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

func (v *XmlEnumsOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.FooEnum1 != "" {
		s.WriteString(schemas.XmlEnumsOutput_fooEnum1, string(v.FooEnum1))
	}
	if v.FooEnum2 != "" {
		s.WriteString(schemas.XmlEnumsOutput_fooEnum2, string(v.FooEnum2))
	}
	if v.FooEnum3 != "" {
		s.WriteString(schemas.XmlEnumsOutput_fooEnum3, string(v.FooEnum3))
	}
	serializeFooEnumList(s, schemas.XmlEnumsOutput_fooEnumList, v.FooEnumList)
	serializeFooEnumMap(s, schemas.XmlEnumsOutput_fooEnumMap, v.FooEnumMap)
	serializeFooEnumSet(s, schemas.XmlEnumsOutput_fooEnumSet, v.FooEnumSet)
}
func (v *XmlEnumsOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.XmlEnumsOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.XmlEnumsOutput_fooEnum1:
			var ev string
			if err := d.ReadString(schemas.XmlEnumsOutput_fooEnum1, &ev); err != nil {
				return err
			}
			v.FooEnum1 = types.FooEnum(ev)
			return nil
		case schemas.XmlEnumsOutput_fooEnum2:
			var ev string
			if err := d.ReadString(schemas.XmlEnumsOutput_fooEnum2, &ev); err != nil {
				return err
			}
			v.FooEnum2 = types.FooEnum(ev)
			return nil
		case schemas.XmlEnumsOutput_fooEnum3:
			var ev string
			if err := d.ReadString(schemas.XmlEnumsOutput_fooEnum3, &ev); err != nil {
				return err
			}
			v.FooEnum3 = types.FooEnum(ev)
			return nil
		case schemas.XmlEnumsOutput_fooEnumList:
			return deserializeFooEnumList(d, schemas.XmlEnumsOutput_fooEnumList, &v.FooEnumList)
		case schemas.XmlEnumsOutput_fooEnumMap:
			return deserializeFooEnumMap(d, schemas.XmlEnumsOutput_fooEnumMap, &v.FooEnumMap)
		case schemas.XmlEnumsOutput_fooEnumSet:
			return deserializeFooEnumSet(d, schemas.XmlEnumsOutput_fooEnumSet, &v.FooEnumSet)
		}
		return nil
	})
}
func (c *Client) addOperationXmlEnumsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.XmlEnums, nil, schemas.XmlEnumsOutput)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.XmlEnums, nil, schemas.XmlEnumsOutput), output: &XmlEnumsOutput{}}, 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, "XmlEnums"), 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
}
