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

package jsonrpc

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

func (c *Client) SparseNullsOperation(ctx context.Context, params *SparseNullsOperationInput, optFns ...func(*Options)) (*SparseNullsOperationOutput, error) {
	if params == nil {
		params = &SparseNullsOperationInput{}
	}

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

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

type SparseNullsOperationInput struct {
	SparseStringList []*string

	SparseStringMap map[string]*string

	noSmithyDocumentSerde
}

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

func (v *SparseNullsOperationInput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeSparseStringList(s, schemas.SparseNullsOperationInputOutput_sparseStringList, v.SparseStringList)
	serializeSparseStringMap(s, schemas.SparseNullsOperationInputOutput_sparseStringMap, v.SparseStringMap)
}
func (v *SparseNullsOperationInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.SparseNullsOperationInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.SparseNullsOperationInputOutput_sparseStringList:
			return deserializeSparseStringList(d, schemas.SparseNullsOperationInputOutput_sparseStringList, &v.SparseStringList)
		case schemas.SparseNullsOperationInputOutput_sparseStringMap:
			return deserializeSparseStringMap(d, schemas.SparseNullsOperationInputOutput_sparseStringMap, &v.SparseStringMap)
		}
		return nil
	})
}

type SparseNullsOperationOutput struct {
	SparseStringList []*string

	SparseStringMap map[string]*string

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

	noSmithyDocumentSerde
}

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

func (v *SparseNullsOperationOutput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeSparseStringList(s, schemas.SparseNullsOperationInputOutput_sparseStringList, v.SparseStringList)
	serializeSparseStringMap(s, schemas.SparseNullsOperationInputOutput_sparseStringMap, v.SparseStringMap)
}
func (v *SparseNullsOperationOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.SparseNullsOperationInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.SparseNullsOperationInputOutput_sparseStringList:
			return deserializeSparseStringList(d, schemas.SparseNullsOperationInputOutput_sparseStringList, &v.SparseStringList)
		case schemas.SparseNullsOperationInputOutput_sparseStringMap:
			return deserializeSparseStringMap(d, schemas.SparseNullsOperationInputOutput_sparseStringMap, &v.SparseStringMap)
		}
		return nil
	})
}
func (c *Client) addOperationSparseNullsOperationMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.SparseNullsOperation, schemas.SparseNullsOperationInputOutput, schemas.SparseNullsOperationInputOutput)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.SparseNullsOperation, schemas.SparseNullsOperationInputOutput, schemas.SparseNullsOperationInputOutput), output: &SparseNullsOperationOutput{}}, 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, "SparseNullsOperation"), 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
}
