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

package restxml

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

// The example tests how timestamp request and response headers are serialized.
func (c *Client) TimestampFormatHeaders(ctx context.Context, params *TimestampFormatHeadersInput, optFns ...func(*Options)) (*TimestampFormatHeadersOutput, error) {
	if params == nil {
		params = &TimestampFormatHeadersInput{}
	}

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

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

type TimestampFormatHeadersInput struct {
	DefaultFormat *time.Time

	MemberDateTime *time.Time

	MemberEpochSeconds *time.Time

	MemberHttpDate *time.Time

	TargetDateTime *time.Time

	TargetEpochSeconds *time.Time

	TargetHttpDate *time.Time

	noSmithyDocumentSerde
}

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

func (v *TimestampFormatHeadersInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.DefaultFormat != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_defaultFormat, *v.DefaultFormat)
	}
	if v.MemberDateTime != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_memberDateTime, *v.MemberDateTime)
	}
	if v.MemberEpochSeconds != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_memberEpochSeconds, *v.MemberEpochSeconds)
	}
	if v.MemberHttpDate != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_memberHttpDate, *v.MemberHttpDate)
	}
	if v.TargetDateTime != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_targetDateTime, *v.TargetDateTime)
	}
	if v.TargetEpochSeconds != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_targetEpochSeconds, *v.TargetEpochSeconds)
	}
	if v.TargetHttpDate != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_targetHttpDate, *v.TargetHttpDate)
	}
}
func (v *TimestampFormatHeadersInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.TimestampFormatHeadersIO, func(s *smithy.Schema) error {
		switch s {
		case schemas.TimestampFormatHeadersIO_defaultFormat:
			v.DefaultFormat = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_defaultFormat, v.DefaultFormat)
		case schemas.TimestampFormatHeadersIO_memberDateTime:
			v.MemberDateTime = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_memberDateTime, v.MemberDateTime)
		case schemas.TimestampFormatHeadersIO_memberEpochSeconds:
			v.MemberEpochSeconds = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_memberEpochSeconds, v.MemberEpochSeconds)
		case schemas.TimestampFormatHeadersIO_memberHttpDate:
			v.MemberHttpDate = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_memberHttpDate, v.MemberHttpDate)
		case schemas.TimestampFormatHeadersIO_targetDateTime:
			v.TargetDateTime = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_targetDateTime, v.TargetDateTime)
		case schemas.TimestampFormatHeadersIO_targetEpochSeconds:
			v.TargetEpochSeconds = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_targetEpochSeconds, v.TargetEpochSeconds)
		case schemas.TimestampFormatHeadersIO_targetHttpDate:
			v.TargetHttpDate = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_targetHttpDate, v.TargetHttpDate)
		}
		return nil
	})
}

type TimestampFormatHeadersOutput struct {
	DefaultFormat *time.Time

	MemberDateTime *time.Time

	MemberEpochSeconds *time.Time

	MemberHttpDate *time.Time

	TargetDateTime *time.Time

	TargetEpochSeconds *time.Time

	TargetHttpDate *time.Time

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

	noSmithyDocumentSerde
}

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

func (v *TimestampFormatHeadersOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.DefaultFormat != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_defaultFormat, *v.DefaultFormat)
	}
	if v.MemberDateTime != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_memberDateTime, *v.MemberDateTime)
	}
	if v.MemberEpochSeconds != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_memberEpochSeconds, *v.MemberEpochSeconds)
	}
	if v.MemberHttpDate != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_memberHttpDate, *v.MemberHttpDate)
	}
	if v.TargetDateTime != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_targetDateTime, *v.TargetDateTime)
	}
	if v.TargetEpochSeconds != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_targetEpochSeconds, *v.TargetEpochSeconds)
	}
	if v.TargetHttpDate != nil {
		s.WriteTime(schemas.TimestampFormatHeadersIO_targetHttpDate, *v.TargetHttpDate)
	}
}
func (v *TimestampFormatHeadersOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.TimestampFormatHeadersIO, func(s *smithy.Schema) error {
		switch s {
		case schemas.TimestampFormatHeadersIO_defaultFormat:
			v.DefaultFormat = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_defaultFormat, v.DefaultFormat)
		case schemas.TimestampFormatHeadersIO_memberDateTime:
			v.MemberDateTime = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_memberDateTime, v.MemberDateTime)
		case schemas.TimestampFormatHeadersIO_memberEpochSeconds:
			v.MemberEpochSeconds = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_memberEpochSeconds, v.MemberEpochSeconds)
		case schemas.TimestampFormatHeadersIO_memberHttpDate:
			v.MemberHttpDate = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_memberHttpDate, v.MemberHttpDate)
		case schemas.TimestampFormatHeadersIO_targetDateTime:
			v.TargetDateTime = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_targetDateTime, v.TargetDateTime)
		case schemas.TimestampFormatHeadersIO_targetEpochSeconds:
			v.TargetEpochSeconds = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_targetEpochSeconds, v.TargetEpochSeconds)
		case schemas.TimestampFormatHeadersIO_targetHttpDate:
			v.TargetHttpDate = new(time.Time)
			return d.ReadTime(schemas.TimestampFormatHeadersIO_targetHttpDate, v.TargetHttpDate)
		}
		return nil
	})
}
func (c *Client) addOperationTimestampFormatHeadersMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.TimestampFormatHeaders, schemas.TimestampFormatHeadersIO, schemas.TimestampFormatHeadersIO)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.TimestampFormatHeaders, schemas.TimestampFormatHeadersIO, schemas.TimestampFormatHeadersIO), output: &TimestampFormatHeadersOutput{}}, 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 = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "TimestampFormatHeaders"), 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
}
