55package aws.sdk.kotlin.example
66
77import aws.sdk.kotlin.runtime.AwsServiceException
8- import aws.sdk.kotlin.services.dynamodb.DynamodbClient
8+ import aws.sdk.kotlin.services.dynamodb.DynamoDbClient
99import aws.sdk.kotlin.services.dynamodb.model.*
1010import com.google.gson.JsonElement
1111import com.google.gson.JsonParser
@@ -17,7 +17,7 @@ import java.lang.IllegalStateException
1717 * Partial implementation of: https://docs.amazonaws.cn/en_us/amazondynamodb/latest/developerguide/GettingStarted.Java.html
1818 */
1919fun main () = runBlocking {
20- val client = DynamodbClient { region = " us-east-2" }
20+ val client = DynamoDbClient { region = " us-east-2" }
2121
2222 val tableName = " dynamo-movies-example"
2323
@@ -44,7 +44,7 @@ fun main() = runBlocking {
4444 client.close()
4545}
4646
47- suspend fun createMoviesTable (client : DynamodbClient , name : String ) {
47+ suspend fun createMoviesTable (client : DynamoDbClient , name : String ) {
4848 val tableExists = client.listTables(ListTablesRequest {}).tableNames?.contains(name) ? : false
4949 if (tableExists) return
5050
@@ -82,7 +82,7 @@ suspend fun createMoviesTable(client: DynamodbClient, name: String) {
8282}
8383
8484// no waiters support (yet)
85- suspend fun DynamodbClient .waitForTableReady (name : String ) {
85+ suspend fun DynamoDbClient .waitForTableReady (name : String ) {
8686 while (true ) {
8787 try {
8888 val req = DescribeTableRequest { tableName = name }
@@ -91,14 +91,14 @@ suspend fun DynamodbClient.waitForTableReady(name: String) {
9191 return
9292 }
9393 } catch (ex: AwsServiceException ) {
94- if (! ex.isRetryable) throw ex
94+ if (! ex.sdkErrorMetadata. isRetryable) throw ex
9595 }
9696 println (" waiting for table to be ready..." )
9797 delay(1000 )
9898 }
9999}
100100
101- suspend fun loadMoviesTable (client : DynamodbClient , name : String ) {
101+ suspend fun loadMoviesTable (client : DynamoDbClient , name : String ) {
102102 // load items into table
103103 val data = getResourceAsText(" data.json" )
104104 val elements = JsonParser .parseString(data).asJsonArray
@@ -114,7 +114,7 @@ suspend fun loadMoviesTable(client: DynamodbClient, name: String) {
114114 }
115115}
116116
117- suspend fun DynamodbClient .moviesInYear (name : String , year : Int ): QueryResponse {
117+ suspend fun DynamoDbClient .moviesInYear (name : String , year : Int ): QueryResponse {
118118 val req = QueryRequest {
119119 tableName = name
120120 keyConditionExpression = " #yr = :yyyy"
@@ -139,7 +139,7 @@ fun jsonElementToAttributeValue(element: JsonElement): AttributeValue = when {
139139 element.isJsonPrimitive -> {
140140 val primitive = element.asJsonPrimitive
141141 when {
142- primitive.isBoolean -> AttributeValue .BOOL (primitive.asBoolean)
142+ primitive.isBoolean -> AttributeValue .Bool (primitive.asBoolean)
143143 primitive.isString -> AttributeValue .S (primitive.asString)
144144 else -> {
145145 check(primitive.isNumber) { " expected number" }
0 commit comments