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

package connect

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

// Starts a Contact Lens post-call analytics job for the specified contact. This
// API runs Conversational Analytics post-contact analysis on a voice recording
// that is already attached to the contact, generating transcription, sentiment
// analysis, redaction, and summarization results based on the provided
// configuration.
//
// A voice recording must already be attached to the contact before calling this
// API. Use CreateAttachedFile to attach a recording from an S3 source URI.
//
// For example, you can call CreateContact , then CreateAttachedFile , then
// StartContactConversationalAnalyticsJob to create a contact, attach a recording,
// and run post-call analytics.
func (c *Client) StartContactConversationalAnalyticsJob(ctx context.Context, params *StartContactConversationalAnalyticsJobInput, optFns ...func(*Options)) (*StartContactConversationalAnalyticsJobOutput, error) {
	if params == nil {
		params = &StartContactConversationalAnalyticsJobInput{}
	}

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

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

type StartContactConversationalAnalyticsJobInput struct {

	// The configuration for the conversational analytics job.
	//
	// This member is required.
	AnalyticsConfiguration *types.AnalyticsConfiguration

	// The analytics modes to run for the contact. Valid values: PostContact .
	//
	// This member is required.
	AnalyticsModes []types.AnalyticsMode

	// The identifier of the contact in this instance of Connect Customer.
	//
	// This member is required.
	ContactId *string

	// The identifier of the Connect Customer instance. You can [find the instance ID] in the Amazon
	// Resource Name (ARN) of the instance.
	//
	// [find the instance ID]: https://docs.aws.amazon.com/connect/latest/adminguide/find-instance-arn.html
	//
	// This member is required.
	InstanceId *string

	// A unique, case-sensitive identifier that you provide to ensure the idempotency
	// of the request. If not provided, the Amazon Web Services SDK populates this
	// field. For more information about idempotency, see [Making retries safe with idempotent APIs].
	//
	// [Making retries safe with idempotent APIs]: https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/
	ClientToken *string

	noSmithyDocumentSerde
}

type StartContactConversationalAnalyticsJobOutput struct {

	// The identifier of the contact.
	ContactId *string

	// The identifier of the Connect Customer instance.
	InstanceId *string

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

	noSmithyDocumentSerde
}

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