| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699 |
- // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
- package dynamodb_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/dynamodb"
- )
- 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 retrieve multiple items from a table
- //
- // This example reads multiple items from the Music table using a batch of three GetItem
- // requests. Only the AlbumTitle attribute is returned.
- func ExampleDynamoDB_BatchGetItem_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.BatchGetItemInput{
- RequestItems: map[string]*dynamodb.KeysAndAttributes{
- "Music": {
- Keys: []map[string]*dynamodb.AttributeValue{
- {
- "Artist": &dynamodb.AttributeValue{
- S: aws.String("No One You Know"),
- },
- "SongTitle": &dynamodb.AttributeValue{
- S: aws.String("Call Me Today"),
- },
- },
- {
- "Artist": &dynamodb.AttributeValue{
- S: aws.String("Acme Band"),
- },
- "SongTitle": &dynamodb.AttributeValue{
- S: aws.String("Happy Day"),
- },
- },
- {
- "Artist": &dynamodb.AttributeValue{
- S: aws.String("No One You Know"),
- },
- "SongTitle": &dynamodb.AttributeValue{
- S: aws.String("Scared of My Shadow"),
- },
- },
- },
- ProjectionExpression: aws.String("AlbumTitle"),
- },
- },
- }
- result, err := svc.BatchGetItem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 multiple items to a table
- //
- // This example adds three new items to the Music table using a batch of three PutItem
- // requests.
- func ExampleDynamoDB_BatchWriteItem_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.BatchWriteItemInput{
- RequestItems: map[string][]*dynamodb.WriteRequest{
- "Music": {
- {
- PutRequest: &dynamodb.PutRequest{
- Item: map[string]*dynamodb.AttributeValue{
- "AlbumTitle": {
- S: aws.String("Somewhat Famous"),
- },
- "Artist": {
- S: aws.String("No One You Know"),
- },
- "SongTitle": {
- S: aws.String("Call Me Today"),
- },
- },
- },
- },
- {
- PutRequest: &dynamodb.PutRequest{
- Item: map[string]*dynamodb.AttributeValue{
- "AlbumTitle": {
- S: aws.String("Songs About Life"),
- },
- "Artist": {
- S: aws.String("Acme Band"),
- },
- "SongTitle": {
- S: aws.String("Happy Day"),
- },
- },
- },
- },
- {
- PutRequest: &dynamodb.PutRequest{
- Item: map[string]*dynamodb.AttributeValue{
- "AlbumTitle": {
- S: aws.String("Blue Sky Blues"),
- },
- "Artist": {
- S: aws.String("No One You Know"),
- },
- "SongTitle": {
- S: aws.String("Scared of My Shadow"),
- },
- },
- },
- },
- },
- },
- }
- result, err := svc.BatchWriteItem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeItemCollectionSizeLimitExceededException:
- fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 table
- //
- // This example creates a table named Music.
- func ExampleDynamoDB_CreateTable_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.CreateTableInput{
- AttributeDefinitions: []*dynamodb.AttributeDefinition{
- {
- AttributeName: aws.String("Artist"),
- AttributeType: aws.String("S"),
- },
- {
- AttributeName: aws.String("SongTitle"),
- AttributeType: aws.String("S"),
- },
- },
- KeySchema: []*dynamodb.KeySchemaElement{
- {
- AttributeName: aws.String("Artist"),
- KeyType: aws.String("HASH"),
- },
- {
- AttributeName: aws.String("SongTitle"),
- KeyType: aws.String("RANGE"),
- },
- },
- ProvisionedThroughput: &dynamodb.ProvisionedThroughput{
- ReadCapacityUnits: aws.Int64(5),
- WriteCapacityUnits: aws.Int64(5),
- },
- TableName: aws.String("Music"),
- }
- result, err := svc.CreateTable(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeResourceInUseException:
- fmt.Println(dynamodb.ErrCodeResourceInUseException, aerr.Error())
- case dynamodb.ErrCodeLimitExceededException:
- fmt.Println(dynamodb.ErrCodeLimitExceededException, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 item
- //
- // This example deletes an item from the Music table.
- func ExampleDynamoDB_DeleteItem_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.DeleteItemInput{
- Key: map[string]*dynamodb.AttributeValue{
- "Artist": {
- S: aws.String("No One You Know"),
- },
- "SongTitle": {
- S: aws.String("Scared of My Shadow"),
- },
- },
- TableName: aws.String("Music"),
- }
- result, err := svc.DeleteItem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeConditionalCheckFailedException:
- fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error())
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeItemCollectionSizeLimitExceededException:
- fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error())
- case dynamodb.ErrCodeTransactionConflictException:
- fmt.Println(dynamodb.ErrCodeTransactionConflictException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 table
- //
- // This example deletes the Music table.
- func ExampleDynamoDB_DeleteTable_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.DeleteTableInput{
- TableName: aws.String("Music"),
- }
- result, err := svc.DeleteTable(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeResourceInUseException:
- fmt.Println(dynamodb.ErrCodeResourceInUseException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeLimitExceededException:
- fmt.Println(dynamodb.ErrCodeLimitExceededException, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 determine capacity limits per table and account, in the current AWS region
- //
- // The following example returns the maximum read and write capacity units per table,
- // and for the AWS account, in the current AWS region.
- func ExampleDynamoDB_DescribeLimits_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.DescribeLimitsInput{}
- result, err := svc.DescribeLimits(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 a table
- //
- // This example describes the Music table.
- func ExampleDynamoDB_DescribeTable_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.DescribeTableInput{
- TableName: aws.String("Music"),
- }
- result, err := svc.DescribeTable(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 read an item from a table
- //
- // This example retrieves an item from the Music table. The table has a partition key
- // and a sort key (Artist and SongTitle), so you must specify both of these attributes.
- func ExampleDynamoDB_GetItem_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.GetItemInput{
- Key: map[string]*dynamodb.AttributeValue{
- "Artist": {
- S: aws.String("Acme Band"),
- },
- "SongTitle": {
- S: aws.String("Happy Day"),
- },
- },
- TableName: aws.String("Music"),
- }
- result, err := svc.GetItem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 tables
- //
- // This example lists all of the tables associated with the current AWS account and
- // endpoint.
- func ExampleDynamoDB_ListTables_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.ListTablesInput{}
- result, err := svc.ListTables(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 an item to a table
- //
- // This example adds a new item to the Music table.
- func ExampleDynamoDB_PutItem_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.PutItemInput{
- Item: map[string]*dynamodb.AttributeValue{
- "AlbumTitle": {
- S: aws.String("Somewhat Famous"),
- },
- "Artist": {
- S: aws.String("No One You Know"),
- },
- "SongTitle": {
- S: aws.String("Call Me Today"),
- },
- },
- ReturnConsumedCapacity: aws.String("TOTAL"),
- TableName: aws.String("Music"),
- }
- result, err := svc.PutItem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeConditionalCheckFailedException:
- fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error())
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeItemCollectionSizeLimitExceededException:
- fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error())
- case dynamodb.ErrCodeTransactionConflictException:
- fmt.Println(dynamodb.ErrCodeTransactionConflictException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 query an item
- //
- // This example queries items in the Music table. The table has a partition key and
- // sort key (Artist and SongTitle), but this query only specifies the partition key
- // value. It returns song titles by the artist named "No One You Know".
- func ExampleDynamoDB_Query_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.QueryInput{
- ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
- ":v1": {
- S: aws.String("No One You Know"),
- },
- },
- KeyConditionExpression: aws.String("Artist = :v1"),
- ProjectionExpression: aws.String("SongTitle"),
- TableName: aws.String("Music"),
- }
- result, err := svc.Query(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 scan a table
- //
- // This example scans the entire Music table, and then narrows the results to songs
- // by the artist "No One You Know". For each item, only the album title and song title
- // are returned.
- func ExampleDynamoDB_Scan_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.ScanInput{
- ExpressionAttributeNames: map[string]*string{
- "AT": aws.String("AlbumTitle"),
- "ST": aws.String("SongTitle"),
- },
- ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
- ":a": {
- S: aws.String("No One You Know"),
- },
- },
- FilterExpression: aws.String("Artist = :a"),
- ProjectionExpression: aws.String("#ST, #AT"),
- TableName: aws.String("Music"),
- }
- result, err := svc.Scan(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 update an item in a table
- //
- // This example updates an item in the Music table. It adds a new attribute (Year) and
- // modifies the AlbumTitle attribute. All of the attributes in the item, as they appear
- // after the update, are returned in the response.
- func ExampleDynamoDB_UpdateItem_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.UpdateItemInput{
- ExpressionAttributeNames: map[string]*string{
- "#AT": aws.String("AlbumTitle"),
- "#Y": aws.String("Year"),
- },
- ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
- ":t": {
- S: aws.String("Louder Than Ever"),
- },
- ":y": {
- N: aws.String("2015"),
- },
- },
- Key: map[string]*dynamodb.AttributeValue{
- "Artist": {
- S: aws.String("Acme Band"),
- },
- "SongTitle": {
- S: aws.String("Happy Day"),
- },
- },
- ReturnValues: aws.String("ALL_NEW"),
- TableName: aws.String("Music"),
- UpdateExpression: aws.String("SET #Y = :y, #AT = :t"),
- }
- result, err := svc.UpdateItem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeConditionalCheckFailedException:
- fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error())
- case dynamodb.ErrCodeProvisionedThroughputExceededException:
- fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeItemCollectionSizeLimitExceededException:
- fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error())
- case dynamodb.ErrCodeTransactionConflictException:
- fmt.Println(dynamodb.ErrCodeTransactionConflictException, aerr.Error())
- case dynamodb.ErrCodeRequestLimitExceeded:
- fmt.Println(dynamodb.ErrCodeRequestLimitExceeded, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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 modify a table's provisioned throughput
- //
- // This example increases the provisioned read and write capacity on the Music table.
- func ExampleDynamoDB_UpdateTable_shared00() {
- svc := dynamodb.New(session.New())
- input := &dynamodb.UpdateTableInput{
- ProvisionedThroughput: &dynamodb.ProvisionedThroughput{
- ReadCapacityUnits: aws.Int64(10),
- WriteCapacityUnits: aws.Int64(10),
- },
- TableName: aws.String("MusicCollection"),
- }
- result, err := svc.UpdateTable(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case dynamodb.ErrCodeResourceInUseException:
- fmt.Println(dynamodb.ErrCodeResourceInUseException, aerr.Error())
- case dynamodb.ErrCodeResourceNotFoundException:
- fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
- case dynamodb.ErrCodeLimitExceededException:
- fmt.Println(dynamodb.ErrCodeLimitExceededException, aerr.Error())
- case dynamodb.ErrCodeInternalServerError:
- fmt.Println(dynamodb.ErrCodeInternalServerError, 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)
- }
|