// 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"
	"io"
)

// This examples serializes a streaming blob shape in the request body.
//
// In this example, no JSON document is synthesized because the payload is not a
// structure or a union type.
func (c *Client) StreamingTraits(ctx context.Context, params *StreamingTraitsInput, optFns ...func(*Options)) (*StreamingTraitsOutput, error) {
	if params == nil {
		params = &StreamingTraitsInput{}
	}

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

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

type StreamingTraitsInput struct {
	Blob io.Reader

	Foo *string

	noSmithyDocumentSerde
}

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

func (v *StreamingTraitsInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.Foo != nil {
		s.WriteString(schemas.StreamingTraitsInputOutput_foo, *v.Foo)
	}
}
func (v *StreamingTraitsInput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.StreamingTraitsInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.StreamingTraitsInputOutput_foo:
			v.Foo = new(string)
			return d.ReadString(schemas.StreamingTraitsInputOutput_foo, v.Foo)
		}
		return nil
	})
}
func (v *StreamingTraitsInput) GetPayloadStream() io.Reader { return v.Blob }

var _ smithy.StreamingInput = (*StreamingTraitsInput)(nil)

func (v *StreamingTraitsInput) SetPayloadStream(r io.ReadCloser) { v.Blob = r }

var _ smithy.StreamingOutput = (*StreamingTraitsInput)(nil)

type StreamingTraitsOutput struct {
	Blob io.ReadCloser

	Foo *string

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

	noSmithyDocumentSerde
}

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

func (v *StreamingTraitsOutput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.Foo != nil {
		s.WriteString(schemas.StreamingTraitsInputOutput_foo, *v.Foo)
	}
}
func (v *StreamingTraitsOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.StreamingTraitsInputOutput, func(s *smithy.Schema) error {
		switch s {
		case schemas.StreamingTraitsInputOutput_foo:
			v.Foo = new(string)
			return d.ReadString(schemas.StreamingTraitsInputOutput_foo, v.Foo)
		}
		return nil
	})
}
func (v *StreamingTraitsOutput) GetPayloadStream() io.Reader { return v.Blob }

var _ smithy.StreamingInput = (*StreamingTraitsOutput)(nil)

func (v *StreamingTraitsOutput) SetPayloadStream(r io.ReadCloser) { v.Blob = r }

var _ smithy.StreamingOutput = (*StreamingTraitsOutput)(nil)

func (c *Client) addOperationStreamingTraitsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.StreamingTraits, schemas.StreamingTraitsInputOutput, schemas.StreamingTraitsInputOutput)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.StreamingTraits, schemas.StreamingTraitsInputOutput, schemas.StreamingTraitsInputOutput), output: &StreamingTraitsOutput{}}, 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 = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "StreamingTraits"), 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
}
