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

package smithyrpcv2cbor

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

func (c *Client) RpcV2CborSparseMaps(ctx context.Context, params *RpcV2CborSparseMapsInput, optFns ...func(*Options)) (*RpcV2CborSparseMapsOutput, error) {
	if params == nil {
		params = &RpcV2CborSparseMapsInput{}
	}

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

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

type RpcV2CborSparseMapsInput struct {
	SparseBooleanMap map[string]*bool

	SparseNumberMap map[string]*int32

	SparseSetMap map[string][]string

	SparseStringMap map[string]*string

	SparseStructMap map[string]*types.GreetingStruct

	noSmithyDocumentSerde
}

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

func (v *RpcV2CborSparseMapsInput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeSparseBooleanMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseBooleanMap, v.SparseBooleanMap)
	serializeSparseNumberMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseNumberMap, v.SparseNumberMap)
	serializeSparseSetMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseSetMap, v.SparseSetMap)
	serializeSparseStringMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseStringMap, v.SparseStringMap)
	serializeSparseStructMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseStructMap, v.SparseStructMap)
}
func (v *RpcV2CborSparseMapsInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.RpcV2CborSparseMapsInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.RpcV2CborSparseMapsInputOutput_sparseBooleanMap:
			return deserializeSparseBooleanMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseBooleanMap, &v.SparseBooleanMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseNumberMap:
			return deserializeSparseNumberMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseNumberMap, &v.SparseNumberMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseSetMap:
			return deserializeSparseSetMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseSetMap, &v.SparseSetMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseStringMap:
			return deserializeSparseStringMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseStringMap, &v.SparseStringMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseStructMap:
			return deserializeSparseStructMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseStructMap, &v.SparseStructMap)
		}
		return nil
	})
}

type RpcV2CborSparseMapsOutput struct {
	SparseBooleanMap map[string]*bool

	SparseNumberMap map[string]*int32

	SparseSetMap map[string][]string

	SparseStringMap map[string]*string

	SparseStructMap map[string]*types.GreetingStruct

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

	noSmithyDocumentSerde
}

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

func (v *RpcV2CborSparseMapsOutput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeSparseBooleanMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseBooleanMap, v.SparseBooleanMap)
	serializeSparseNumberMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseNumberMap, v.SparseNumberMap)
	serializeSparseSetMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseSetMap, v.SparseSetMap)
	serializeSparseStringMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseStringMap, v.SparseStringMap)
	serializeSparseStructMap(s, schemas.RpcV2CborSparseMapsInputOutput_sparseStructMap, v.SparseStructMap)
}
func (v *RpcV2CborSparseMapsOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.RpcV2CborSparseMapsInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.RpcV2CborSparseMapsInputOutput_sparseBooleanMap:
			return deserializeSparseBooleanMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseBooleanMap, &v.SparseBooleanMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseNumberMap:
			return deserializeSparseNumberMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseNumberMap, &v.SparseNumberMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseSetMap:
			return deserializeSparseSetMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseSetMap, &v.SparseSetMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseStringMap:
			return deserializeSparseStringMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseStringMap, &v.SparseStringMap)
		case schemas.RpcV2CborSparseMapsInputOutput_sparseStructMap:
			return deserializeSparseStructMap(d, schemas.RpcV2CborSparseMapsInputOutput_sparseStructMap, &v.SparseStructMap)
		}
		return nil
	})
}
func (c *Client) addOperationRpcV2CborSparseMapsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.RpcV2CborSparseMaps, schemas.RpcV2CborSparseMapsInputOutput, schemas.RpcV2CborSparseMapsInputOutput)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.RpcV2CborSparseMaps, schemas.RpcV2CborSparseMapsInputOutput, schemas.RpcV2CborSparseMapsInputOutput), output: &RpcV2CborSparseMapsOutput{}}, 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 = 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 = addUserAgentFeatureProtocolRPCV2CBOR(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "RpcV2CborSparseMaps"), 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
}
