// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. package rekognition_test import ( "fmt" "strings" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/rekognition" ) var _ time.Duration var _ strings.Reader var _ aws.Config func parseTime(layout, value string) *time.Time { t, err := time.Parse(layout, value) if err != nil { panic(err) } return &t } // To compare two images // // This operation compares the largest face detected in the source image with each face // detected in the target image. func ExampleRekognition_CompareFaces_shared00() { svc := rekognition.New(session.New()) input := &rekognition.CompareFacesInput{ SimilarityThreshold: aws.Float64(90.000000), SourceImage: &rekognition.Image{ S3Object: &rekognition.S3Object{ Bucket: aws.String("mybucket"), Name: aws.String("mysourceimage"), }, }, TargetImage: &rekognition.Image{ S3Object: &rekognition.S3Object{ Bucket: aws.String("mybucket"), Name: aws.String("mytargetimage"), }, }, } result, err := svc.CompareFaces(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeInvalidS3ObjectException: fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error()) case rekognition.ErrCodeImageTooLargeException: fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeInvalidImageFormatException: fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // CopyProjectVersion // // This operation copies a version of an Amazon Rekognition Custom Labels model from // a source project to a destination project. func ExampleRekognition_CopyProjectVersion_shared00() { svc := rekognition.New(session.New()) input := &rekognition.CopyProjectVersionInput{ DestinationProjectArn: aws.String("arn:aws:rekognition:us-east-1:555555555555:project/DestinationProject/1656705098765"), KmsKeyId: aws.String("arn:1234abcd-12ab-34cd-56ef-1234567890ab"), OutputConfig: &rekognition.OutputConfig{ S3Bucket: aws.String("bucket-name"), S3KeyPrefix: aws.String("path_to_folder"), }, SourceProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/SourceProject/16565123456"), SourceProjectVersionArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/SourceProject/version/model_1/1656611123456"), Tags: map[string]*string{ "key1": aws.String("val1"), }, VersionName: aws.String("DestinationVersionName_cross_account"), } result, err := svc.CopyProjectVersion(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeLimitExceededException: fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeServiceQuotaExceededException: fmt.Println(rekognition.ErrCodeServiceQuotaExceededException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeResourceInUseException: fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To create a collection // // This operation creates a Rekognition collection for storing image data. func ExampleRekognition_CreateCollection_shared00() { svc := rekognition.New(session.New()) input := &rekognition.CreateCollectionInput{ CollectionId: aws.String("myphotos"), } result, err := svc.CreateCollection(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeResourceAlreadyExistsException: fmt.Println(rekognition.ErrCodeResourceAlreadyExistsException, aerr.Error()) case rekognition.ErrCodeServiceQuotaExceededException: fmt.Println(rekognition.ErrCodeServiceQuotaExceededException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To delete a collection // // This operation deletes a Rekognition collection. func ExampleRekognition_DeleteCollection_shared00() { svc := rekognition.New(session.New()) input := &rekognition.DeleteCollectionInput{ CollectionId: aws.String("myphotos"), } result, err := svc.DeleteCollection(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To delete a face // // This operation deletes one or more faces from a Rekognition collection. func ExampleRekognition_DeleteFaces_shared00() { svc := rekognition.New(session.New()) input := &rekognition.DeleteFacesInput{ CollectionId: aws.String("myphotos"), FaceIds: []*string{ aws.String("ff43d742-0c13-5d16-a3e8-03d3f58e980b"), }, } result, err := svc.DeleteFaces(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // DeleteProjectPolicy // // This operation deletes a revision of an existing project policy from an Amazon Rekognition // Custom Labels project. func ExampleRekognition_DeleteProjectPolicy_shared00() { svc := rekognition.New(session.New()) input := &rekognition.DeleteProjectPolicyInput{ PolicyName: aws.String("testPolicy1"), PolicyRevisionId: aws.String("3b274c25e9203a56a99e00e3ff205fbc"), ProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/SourceProject/1656557123456"), } result, err := svc.DeleteProjectPolicy(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeInvalidPolicyRevisionIdException: fmt.Println(rekognition.ErrCodeInvalidPolicyRevisionIdException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To detect faces in an image // // This operation detects faces in an image stored in an AWS S3 bucket. func ExampleRekognition_DetectFaces_shared00() { svc := rekognition.New(session.New()) input := &rekognition.DetectFacesInput{ Image: &rekognition.Image{ S3Object: &rekognition.S3Object{ Bucket: aws.String("mybucket"), Name: aws.String("myphoto"), }, }, } result, err := svc.DetectFaces(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidS3ObjectException: fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeImageTooLargeException: fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeInvalidImageFormatException: fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To detect labels // // This operation detects labels in the supplied image func ExampleRekognition_DetectLabels_shared00() { svc := rekognition.New(session.New()) input := &rekognition.DetectLabelsInput{ Image: &rekognition.Image{ S3Object: &rekognition.S3Object{ Bucket: aws.String("mybucket"), Name: aws.String("myphoto"), }, }, MaxLabels: aws.Int64(123), MinConfidence: aws.Float64(70.000000), } result, err := svc.DetectLabels(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidS3ObjectException: fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeImageTooLargeException: fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeInvalidImageFormatException: fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To add a face to a collection // // This operation detects faces in an image and adds them to the specified Rekognition // collection. func ExampleRekognition_IndexFaces_shared00() { svc := rekognition.New(session.New()) input := &rekognition.IndexFacesInput{ CollectionId: aws.String("myphotos"), ExternalImageId: aws.String("myphotoid"), Image: &rekognition.Image{ S3Object: &rekognition.S3Object{ Bucket: aws.String("mybucket"), Name: aws.String("myphoto"), }, }, } result, err := svc.IndexFaces(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidS3ObjectException: fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeImageTooLargeException: fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) case rekognition.ErrCodeInvalidImageFormatException: fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error()) case rekognition.ErrCodeServiceQuotaExceededException: fmt.Println(rekognition.ErrCodeServiceQuotaExceededException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list the collections // // This operation returns a list of Rekognition collections. func ExampleRekognition_ListCollections_shared00() { svc := rekognition.New(session.New()) input := &rekognition.ListCollectionsInput{} result, err := svc.ListCollections(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeInvalidPaginationTokenException: fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To list the faces in a collection // // This operation lists the faces in a Rekognition collection. func ExampleRekognition_ListFaces_shared00() { svc := rekognition.New(session.New()) input := &rekognition.ListFacesInput{ CollectionId: aws.String("myphotos"), MaxResults: aws.Int64(20), } result, err := svc.ListFaces(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeInvalidPaginationTokenException: fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // ListProjectPolicies // // This operation lists the project policies that are attached to an Amazon Rekognition // Custom Labels project. func ExampleRekognition_ListProjectPolicies_shared00() { svc := rekognition.New(session.New()) input := &rekognition.ListProjectPoliciesInput{ MaxResults: aws.Int64(5), NextToken: aws.String(""), ProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-sdk-project/1656557051929"), } result, err := svc.ListProjectPolicies(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeInvalidPaginationTokenException: fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // PutProjectPolicy // // This operation attaches a project policy to a Amazon Rekognition Custom Labels project // in a trusting AWS account. func ExampleRekognition_PutProjectPolicy_shared00() { svc := rekognition.New(session.New()) input := &rekognition.PutProjectPolicyInput{ PolicyDocument: aws.String("'{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"ALLOW\",\"Principal\":{\"AWS\":\"principal\"},\"Action\":\"rekognition:CopyProjectVersion\",\"Resource\":\"arn:aws:rekognition:us-east-1:123456789012:project/my-sdk-project/version/DestinationVersionName/1627045542080\"}]}'"), PolicyName: aws.String("SamplePolicy"), PolicyRevisionId: aws.String("0123456789abcdef"), ProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-sdk-project/1656557051929"), } result, err := svc.PutProjectPolicy(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeInvalidPolicyRevisionIdException: fmt.Println(rekognition.ErrCodeInvalidPolicyRevisionIdException, aerr.Error()) case rekognition.ErrCodeMalformedPolicyDocumentException: fmt.Println(rekognition.ErrCodeMalformedPolicyDocumentException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) case rekognition.ErrCodeResourceAlreadyExistsException: fmt.Println(rekognition.ErrCodeResourceAlreadyExistsException, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeServiceQuotaExceededException: fmt.Println(rekognition.ErrCodeServiceQuotaExceededException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeLimitExceededException: fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To delete a face // // This operation searches for matching faces in the collection the supplied face belongs // to. func ExampleRekognition_SearchFaces_shared00() { svc := rekognition.New(session.New()) input := &rekognition.SearchFacesInput{ CollectionId: aws.String("myphotos"), FaceId: aws.String("70008e50-75e4-55d0-8e80-363fb73b3a14"), FaceMatchThreshold: aws.Float64(90.000000), MaxFaces: aws.Int64(10), } result, err := svc.SearchFaces(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) } // To search for faces matching a supplied image // // This operation searches for faces in a Rekognition collection that match the largest // face in an S3 bucket stored image. func ExampleRekognition_SearchFacesByImage_shared00() { svc := rekognition.New(session.New()) input := &rekognition.SearchFacesByImageInput{ CollectionId: aws.String("myphotos"), FaceMatchThreshold: aws.Float64(95.000000), Image: &rekognition.Image{ S3Object: &rekognition.S3Object{ Bucket: aws.String("mybucket"), Name: aws.String("myphoto"), }, }, MaxFaces: aws.Int64(5), } result, err := svc.SearchFacesByImage(input) if err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { case rekognition.ErrCodeInvalidS3ObjectException: fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error()) case rekognition.ErrCodeInvalidParameterException: fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error()) case rekognition.ErrCodeImageTooLargeException: fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error()) case rekognition.ErrCodeAccessDeniedException: fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error()) case rekognition.ErrCodeInternalServerError: fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error()) case rekognition.ErrCodeThrottlingException: fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error()) case rekognition.ErrCodeProvisionedThroughputExceededException: fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error()) case rekognition.ErrCodeResourceNotFoundException: fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error()) case rekognition.ErrCodeInvalidImageFormatException: fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error()) default: fmt.Println(aerr.Error()) } } else { // Print the error, cast err to awserr.Error to get the Code and // Message from an error. fmt.Println(err.Error()) } return } fmt.Println(result) }