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

package awsrestjson

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

// This example ensures that mediaType strings are base64 encoded in headers.
func (c *Client) MediaTypeHeader(ctx context.Context, params *MediaTypeHeaderInput, optFns ...func(*Options)) (*MediaTypeHeaderOutput, error) {
	if params == nil {
		params = &MediaTypeHeaderInput{}
	}

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

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

type MediaTypeHeaderInput struct {

	// This value conforms to the media type: application/json
	Json *string

	noSmithyDocumentSerde
}

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

func (v *MediaTypeHeaderInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.Json != nil {
		s.WriteString(schemas.MediaTypeHeaderInput_json, *v.Json)
	}
}
func (v *MediaTypeHeaderInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.MediaTypeHeaderInput, func(s *smithy.Schema) error {
		switch s {
		case schemas.MediaTypeHeaderInput_json:
			v.Json = new(string)
			return d.ReadString(schemas.MediaTypeHeaderInput_json, v.Json)
		}
		return nil
	})
}

type MediaTypeHeaderOutput struct {

	// This value conforms to the media type: application/json
	Json *string

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

	noSmithyDocumentSerde
}

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

func (v *MediaTypeHeaderOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.Json != nil {
		s.WriteString(schemas.MediaTypeHeaderOutput_json, *v.Json)
	}
}
func (v *MediaTypeHeaderOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.MediaTypeHeaderOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.MediaTypeHeaderOutput_json:
			v.Json = new(string)
			return d.ReadString(schemas.MediaTypeHeaderOutput_json, v.Json)
		}
		return nil
	})
}
func (c *Client) addOperationMediaTypeHeaderMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.MediaTypeHeader, schemas.MediaTypeHeaderInput, schemas.MediaTypeHeaderOutput)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.MediaTypeHeader, schemas.MediaTypeHeaderInput, schemas.MediaTypeHeaderOutput), output: &MediaTypeHeaderOutput{}}, 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, "MediaTypeHeader"), 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
}
