File: //opt/go/pkg/mod/github.com/aws/
[email protected]/service/rekognition/examples_test.go
// 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
}
// AssociateFaces
// This operation associates one or more faces with an existing UserID.
func ExampleRekognition_AssociateFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.AssociateFacesInput{
ClientRequestToken: aws.String("550e8400-e29b-41d4-a716-446655440002"),
CollectionId: aws.String("MyCollection"),
FaceIds: []*string{
aws.String("f5817d37-94f6-4335-bfee-6cf79a3d806e"),
aws.String("851cb847-dccc-4fea-9309-9f4805967855"),
aws.String("35ebbb41-7f67-4263-908d-dd0ecba05ab9"),
},
UserId: aws.String("DemoUser"),
UserMatchThreshold: aws.Float64(70.000000),
}
result, err := svc.AssociateFaces(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.ErrCodeIdempotentParameterMismatchException:
fmt.Println(rekognition.ErrCodeIdempotentParameterMismatchException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeConflictException:
fmt.Println(rekognition.ErrCodeConflictException, 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 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
// 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 create an Amazon Rekognition Custom Labels dataset
// Creates an Amazon Rekognition Custom Labels dataset with a manifest file stored in
// an Amazon S3 bucket.
func ExampleRekognition_CreateDataset_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.CreateDatasetInput{
DatasetSource: &rekognition.DatasetSource{
GroundTruthManifest: &rekognition.GroundTruthManifest{
S3Object: &rekognition.S3Object{
Bucket: aws.String("my-bucket"),
Name: aws.String("datasets/flowers_training/manifests/output/output.manifest"),
},
},
},
DatasetType: aws.String("TRAIN"),
ProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/1690474772815"),
}
result, err := svc.CreateDataset(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
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.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error())
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeResourceAlreadyExistsException:
fmt.Println(rekognition.ErrCodeResourceAlreadyExistsException, 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 create an Amazon Rekognition Custom Labels project
// Creates an Amazon Rekognition Custom Labels project.
func ExampleRekognition_CreateProject_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.CreateProjectInput{
ProjectName: aws.String("my-project"),
}
result, err := svc.CreateProject(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
case rekognition.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error())
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())
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 train an Amazon Rekognition Custom Labels model
// Trains a version of an Amazon Rekognition Custom Labels model.
func ExampleRekognition_CreateProjectVersion_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.CreateProjectVersionInput{
OutputConfig: &rekognition.OutputConfig{
S3Bucket: aws.String("output_bucket"),
S3KeyPrefix: aws.String("output_folder"),
},
ProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/1690474772815"),
VersionName: aws.String("1"),
}
result, err := svc.CreateProjectVersion(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error())
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.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)
}
// CreateUser
// Creates a new User within a collection specified by CollectionId.
func ExampleRekognition_CreateUser_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.CreateUserInput{
CollectionId: aws.String("MyCollection"),
UserId: aws.String("DemoUser"),
}
result, err := svc.CreateUser(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.ErrCodeConflictException:
fmt.Println(rekognition.ErrCodeConflictException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeServiceQuotaExceededException:
fmt.Println(rekognition.ErrCodeServiceQuotaExceededException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeIdempotentParameterMismatchException:
fmt.Println(rekognition.ErrCodeIdempotentParameterMismatchException, 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())
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 an Amazon Rekognition Custom Labels dataset
// Deletes an Amazon Rekognition Custom Labels dataset.
func ExampleRekognition_DeleteDataset_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DeleteDatasetInput{
DatasetArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/dataset/test/1690556733321"),
}
result, err := svc.DeleteDataset(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
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.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error())
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, 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)
}
// To delete an Amazon Rekognition Custom Labels project
// Deletes an Amazon Rekognition Custom Labels projects.
func ExampleRekognition_DeleteProject_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DeleteProjectInput{
ProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/1690405809285"),
}
result, err := svc.DeleteProject(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
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())
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 delete an Amazon Rekognition Custom Labels model
// Deletes a version of an Amazon Rekognition Custom Labels model.
func ExampleRekognition_DeleteProjectVersion_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DeleteProjectVersionInput{
ProjectVersionArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/version/1/1690556751958"),
}
result, err := svc.DeleteProjectVersion(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
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())
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)
}
// DeleteUser
// Deletes the specified UserID within the collection.
func ExampleRekognition_DeleteUser_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DeleteUserInput{
ClientRequestToken: aws.String("550e8400-e29b-41d4-a716-446655440001"),
CollectionId: aws.String("MyCollection"),
UserId: aws.String("DemoUser"),
}
result, err := svc.DeleteUser(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.ErrCodeConflictException:
fmt.Println(rekognition.ErrCodeConflictException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeIdempotentParameterMismatchException:
fmt.Println(rekognition.ErrCodeIdempotentParameterMismatchException, 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())
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 describe an Amazon Rekognition Custom Labels dataset
// Describes an Amazon Rekognition Custom Labels dataset.
func ExampleRekognition_DescribeDataset_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DescribeDatasetInput{
DatasetArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/dataset/train/1690476084535"),
}
result, err := svc.DescribeDataset(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
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.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, 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 describe an Amazon Rekognition Custom Labels model
// Describes a version of an Amazon Rekognition Custom Labels model.
func ExampleRekognition_DescribeProjectVersions_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DescribeProjectVersionsInput{
ProjectArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/1690474772815"),
VersionNames: []*string{
aws.String("1"),
},
}
result, err := svc.DescribeProjectVersions(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
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())
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 describe an Amazon Rekognition Custom Labels project.
// Describes an Amazon Rekognition Custom Labels projects.
func ExampleRekognition_DescribeProjects_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DescribeProjectsInput{
ProjectNames: []*string{
aws.String("my-project"),
},
}
result, err := svc.DescribeProjects(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
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())
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 custom labels in an image with an Amazon Rekognition Custom Labels model
// Detects custom labels in an image with an Amazon Rekognition Custom Labels model
func ExampleRekognition_DetectCustomLabels_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DetectCustomLabelsInput{
Image: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("custom-labels-console-us-east-1-1111111111"),
Name: aws.String("assets/flowers_1_test_dataset/camellia4.jpg"),
},
},
MaxResults: aws.Int64(100),
MinConfidence: aws.Float64(50.000000),
ProjectVersionArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/version/my-project.2023-07-31T11.49.37/1690829378219"),
}
result, err := svc.DetectCustomLabels(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeResourceNotReadyException:
fmt.Println(rekognition.ErrCodeResourceNotReadyException, aerr.Error())
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.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, 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 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)
}
// DisassociateFaces
// Removes the association between a Face supplied in an array of FaceIds and the User.
func ExampleRekognition_DisassociateFaces_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DisassociateFacesInput{
ClientRequestToken: aws.String("550e8400-e29b-41d4-a716-446655440003"),
CollectionId: aws.String("MyCollection"),
FaceIds: []*string{
aws.String("f5817d37-94f6-4335-bfee-6cf79a3d806e"),
aws.String("c92265d4-5f9c-43af-a58e-12be0ce02bc3"),
},
UserId: aws.String("DemoUser"),
}
result, err := svc.DisassociateFaces(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.ErrCodeIdempotentParameterMismatchException:
fmt.Println(rekognition.ErrCodeIdempotentParameterMismatchException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeConflictException:
fmt.Println(rekognition.ErrCodeConflictException, 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 distribute an Amazon Rekognition Custom Labels dataset
// Distributes an Amazon Rekognition Custom Labels training dataset to a test dataset.
func ExampleRekognition_DistributeDatasetEntries_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.DistributeDatasetEntriesInput{
Datasets: []*rekognition.DistributeDataset{
{
Arn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-proj-2/dataset/train/1690564858106"),
},
{
Arn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-proj-2/dataset/test/1690564858106"),
},
},
}
result, err := svc.DistributeDatasetEntries(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
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.ErrCodeResourceNotReadyException:
fmt.Println(rekognition.ErrCodeResourceNotReadyException, 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)
}
// GetMediaAnalysisJob
// Retrieves the results for a given media analysis job.
func ExampleRekognition_GetMediaAnalysisJob_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.GetMediaAnalysisJobInput{
JobId: aws.String("861a0645d98ef88efb75477628c011c04942d9d5f58faf2703c393c8cf8c1537"),
}
result, err := svc.GetMediaAnalysisJob(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.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, 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 entries in an Amazon Rekognition Custom Labels dataset
// Lists the JSON line entries in an Amazon Rekognition Custom Labels dataset.
func ExampleRekognition_ListDatasetEntries_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.ListDatasetEntriesInput{
ContainsLabels: []*string{
aws.String("camellia"),
},
DatasetArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-proj-2/dataset/train/1690564858106"),
HasErrors: aws.Bool(true),
Labeled: aws.Bool(true),
MaxResults: aws.Int64(100),
NextToken: aws.String(""),
SourceRefContains: aws.String("camellia4.jpg"),
}
result, err := svc.ListDatasetEntries(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
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.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
case rekognition.ErrCodeResourceNotReadyException:
fmt.Println(rekognition.ErrCodeResourceNotReadyException, 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 entries in an Amazon Rekognition Custom Labels dataset
// Lists the JSON line entries in an Amazon Rekognition Custom Labels dataset.
func ExampleRekognition_ListDatasetLabels_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.ListDatasetLabelsInput{
DatasetArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-proj-2/dataset/train/1690564858106"),
MaxResults: aws.Int64(100),
NextToken: aws.String(""),
}
result, err := svc.ListDatasetLabels(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
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.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
case rekognition.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeResourceNotReadyException:
fmt.Println(rekognition.ErrCodeResourceNotReadyException, 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)
}
// ListMediaAnalysisJobs
// Returns a list of media analysis jobs.
func ExampleRekognition_ListMediaAnalysisJobs_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.ListMediaAnalysisJobsInput{
MaxResults: aws.Int64(10),
}
result, err := svc.ListMediaAnalysisJobs(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.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, 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)
}
// ListUsers
// Returns metadata of the User such as UserID in the specified collection.
func ExampleRekognition_ListUsers_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.ListUsersInput{
CollectionId: aws.String("MyCollection"),
}
result, err := svc.ListUsers(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.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeInvalidPaginationTokenException:
fmt.Println(rekognition.ErrCodeInvalidPaginationTokenException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, 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())
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)
}
// SearchUsers
// Searches for UserIDs within a collection based on a FaceId or UserId.
func ExampleRekognition_SearchUsers_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.SearchUsersInput{
CollectionId: aws.String("MyCollection"),
MaxUsers: aws.Int64(2),
UserId: aws.String("DemoUser"),
UserMatchThreshold: aws.Float64(70.000000),
}
result, err := svc.SearchUsers(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.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, 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())
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)
}
// SearchUsersByImage
// Searches for UserIDs using a supplied image.
func ExampleRekognition_SearchUsersByImage_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.SearchUsersByImageInput{
CollectionId: aws.String("MyCollection"),
Image: &rekognition.Image{
S3Object: &rekognition.S3Object{
Bucket: aws.String("bucket"),
Name: aws.String("input.jpg"),
},
},
MaxUsers: aws.Int64(2),
QualityFilter: aws.String("MEDIUM"),
UserMatchThreshold: aws.Float64(70.000000),
}
result, err := svc.SearchUsersByImage(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.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeInvalidImageFormatException:
fmt.Println(rekognition.ErrCodeInvalidImageFormatException, aerr.Error())
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeImageTooLargeException:
fmt.Println(rekognition.ErrCodeImageTooLargeException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, 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())
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)
}
// StartMediaAnalysisJob
// Initiates a new media analysis job.
func ExampleRekognition_StartMediaAnalysisJob_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.StartMediaAnalysisJobInput{
Input: &rekognition.MediaAnalysisInput_{
S3Object: &rekognition.S3Object{
Bucket: aws.String("input-bucket"),
Name: aws.String("input-manifest.json"),
},
},
JobName: aws.String("job-name"),
OperationsConfig: &rekognition.MediaAnalysisOperationsConfig{
DetectModerationLabels: &rekognition.MediaAnalysisDetectModerationLabelsConfig{
MinConfidence: aws.Float64(50.000000),
ProjectVersion: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/version/1/1690556751958"),
},
},
OutputConfig: &rekognition.MediaAnalysisOutputConfig{
S3Bucket: aws.String("output-bucket"),
S3KeyPrefix: aws.String("output-location"),
},
}
result, err := svc.StartMediaAnalysisJob(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeInternalServerError:
fmt.Println(rekognition.ErrCodeInternalServerError, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeInvalidManifestException:
fmt.Println(rekognition.ErrCodeInvalidManifestException, aerr.Error())
case rekognition.ErrCodeInvalidS3ObjectException:
fmt.Println(rekognition.ErrCodeInvalidS3ObjectException, aerr.Error())
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeResourceNotReadyException:
fmt.Println(rekognition.ErrCodeResourceNotReadyException, aerr.Error())
case rekognition.ErrCodeProvisionedThroughputExceededException:
fmt.Println(rekognition.ErrCodeProvisionedThroughputExceededException, aerr.Error())
case rekognition.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error())
case rekognition.ErrCodeThrottlingException:
fmt.Println(rekognition.ErrCodeThrottlingException, aerr.Error())
case rekognition.ErrCodeIdempotentParameterMismatchException:
fmt.Println(rekognition.ErrCodeIdempotentParameterMismatchException, 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 start an Amazon Rekognition Custom Labels model
// Starts a version of an Amazon Rekognition Custom Labels model.
func ExampleRekognition_StartProjectVersion_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.StartProjectVersionInput{
MaxInferenceUnits: aws.Int64(1),
MinInferenceUnits: aws.Int64(1),
ProjectVersionArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/version/1/1690556751958"),
}
result, err := svc.StartProjectVersion(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
case rekognition.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error())
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())
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 stop an Amazon Rekognition Custom Labels model.
// Stops a version of an Amazon Rekognition Custom Labels model.
func ExampleRekognition_StopProjectVersion_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.StopProjectVersionInput{
ProjectVersionArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-project/version/1/1690556751958"),
}
result, err := svc.StopProjectVersion(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case rekognition.ErrCodeResourceNotFoundException:
fmt.Println(rekognition.ErrCodeResourceNotFoundException, aerr.Error())
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, aerr.Error())
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())
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 dataset entries to an Amazon Rekognition Custom Labels dataset
// Adds dataset entries to an Amazon Rekognition Custom Labels dataset.
func ExampleRekognition_UpdateDatasetEntries_shared00() {
svc := rekognition.New(session.New())
input := &rekognition.UpdateDatasetEntriesInput{
Changes: &rekognition.DatasetChanges{
GroundTruth: []byte("{\"source-ref\":\"s3://custom-labels-console-us-east-1-111111111/assets/flowers_1_test_dataset/mediterranean_spurge4.jpg\",\"mediterranean_spurge\":1,\"mediterranean_spurge-metadata\":{\"confidence\":1,\"job-name\":\"labeling-job/mediterranean_spurge\",\"class-name\":\"mediterranean_spurge\",\"human-annotated\":\"yes\",\"creation-date\":\"2021-07-11T03:33:42.025Z\",\"type\":\"groundtruth/image-classification\"},\"with_leaves\":1,\"with_leaves-metadata\":{\"confidence\":1,\"job-name\":\"labeling-job/with_leaves\",\"class-name\":\"with_leaves\",\"human-annotated\":\"yes\",\"creation-date\":\"2021-07-11T03:33:42.025Z\",\"type\":\"groundtruth/image-classification\"}}"),
},
DatasetArn: aws.String("arn:aws:rekognition:us-east-1:111122223333:project/my-proj-2/dataset/train/1690564858106"),
}
result, err := svc.UpdateDatasetEntries(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
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.ErrCodeInvalidParameterException:
fmt.Println(rekognition.ErrCodeInvalidParameterException, aerr.Error())
case rekognition.ErrCodeAccessDeniedException:
fmt.Println(rekognition.ErrCodeAccessDeniedException, aerr.Error())
case rekognition.ErrCodeLimitExceededException:
fmt.Println(rekognition.ErrCodeLimitExceededException, aerr.Error())
case rekognition.ErrCodeResourceInUseException:
fmt.Println(rekognition.ErrCodeResourceInUseException, 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)
}