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

package chimesdkvoice

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/service/chimesdkvoice/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Creates a voice profile, which consists of an enrolled user and their latest
// voice print.
//
// Before creating any voice profiles, you must provide all notices and obtain all
// consents from the speaker as required under applicable privacy and biometrics
// laws, and as required under the [AWS service terms]for the Amazon Chime SDK.
//
// For more information about voice profiles and voice analytics, see [Using Amazon Chime SDK Voice Analytics] in the
// Amazon Chime SDK Developer Guide.
//
// [AWS service terms]: https://aws.amazon.com/service-terms/
// [Using Amazon Chime SDK Voice Analytics]: https://docs.aws.amazon.com/chime-sdk/latest/dg/pstn-voice-analytics.html
func (c *Client) CreateVoiceProfile(ctx context.Context, params *CreateVoiceProfileInput, optFns ...func(*Options)) (*CreateVoiceProfileOutput, error) {
	if params == nil {
		params = &CreateVoiceProfileInput{}
	}

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

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

type CreateVoiceProfileInput struct {

	// The ID of the speaker search task.
	//
	// This member is required.
	SpeakerSearchTaskId *string

	noSmithyDocumentSerde
}

type CreateVoiceProfileOutput struct {

	// The requested voice profile.
	VoiceProfile *types.VoiceProfile

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

	noSmithyDocumentSerde
}

func (c *Client) addOperationCreateVoiceProfileMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateVoiceProfile{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateVoiceProfile{}, middleware.After)
	if 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 = addOpCreateVoiceProfileValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "CreateVoiceProfile"), 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
}
