21
21
import software .amazon .awssdk .enhanced .dynamodb .model .CreateTableEnhancedRequest ;
22
22
import software .amazon .awssdk .enhanced .dynamodb .model .DeleteItemEnhancedRequest ;
23
23
import software .amazon .awssdk .enhanced .dynamodb .model .DeleteItemEnhancedResponse ;
24
+ import software .amazon .awssdk .enhanced .dynamodb .model .DescribeTableEnhancedResponse ;
24
25
import software .amazon .awssdk .enhanced .dynamodb .model .GetItemEnhancedRequest ;
25
26
import software .amazon .awssdk .enhanced .dynamodb .model .Page ;
26
27
import software .amazon .awssdk .enhanced .dynamodb .model .PageIterable ;
33
34
import software .amazon .awssdk .enhanced .dynamodb .model .UpdateItemEnhancedResponse ;
34
35
import software .amazon .awssdk .services .dynamodb .DynamoDbClient ;
35
36
import software .amazon .awssdk .services .dynamodb .model .ConsumedCapacity ;
37
+ import software .amazon .awssdk .services .dynamodb .model .DescribeTableRequest ;
38
+ import software .amazon .awssdk .services .dynamodb .waiters .DynamoDbWaiter ;
36
39
37
40
/**
38
41
* Synchronous interface for running commands against an object that is linked to a specific DynamoDb table resource
@@ -62,9 +65,8 @@ public interface DynamoDbTable<T> extends MappedTableResource<T> {
62
65
* Use {@link DynamoDbEnhancedClient#table(String, TableSchema)} to define the mapped table resource.
63
66
* <p>
64
67
* This operation calls the low-level DynamoDB API CreateTable operation. Note that this is an asynchronous
65
- * operation and that the table may not immediately be available for writes and reads. Currently, there is no
66
- * mechanism supported within this library to wait for/check the status of a created table. You must provide this
67
- * functionality yourself. Consult the CreateTable documentation for further details and constraints.
68
+ * operation and that the table may not immediately be available for writes and reads. You can use
69
+ * {@link DynamoDbWaiter#waitUntilTableExists(DescribeTableRequest)} to wait for the resource to be ready.
68
70
* <p>
69
71
* Example:
70
72
* <pre>
@@ -77,6 +79,8 @@ public interface DynamoDbTable<T> extends MappedTableResource<T> {
77
79
* mappedTable.createTable(CreateTableEnhancedRequest.builder()
78
80
* .provisionedThroughput(provisionedThroughput)
79
81
* .build());
82
+ *
83
+ * dynamoDbClient.waiter().waitUntilTableExists(b -> b.tableName(tableName));
80
84
* }
81
85
* </pre>
82
86
*
@@ -93,9 +97,8 @@ default void createTable(CreateTableEnhancedRequest request) {
93
97
* Use {@link DynamoDbEnhancedClient#table(String, TableSchema)} to define the mapped table resource.
94
98
* <p>
95
99
* This operation calls the low-level DynamoDB API CreateTable operation. Note that this is an asynchronous
96
- * operation and that the table may not immediately be available for writes and reads. Currently, there is no
97
- * mechanism supported within this library to wait for/check the status of a created table. You must provide this
98
- * functionality yourself. Consult the CreateTable documentation for further details and constraints.
100
+ * operation and that the table may not immediately be available for writes and reads. You can use
101
+ * {@link DynamoDbWaiter#waitUntilTableExists(DescribeTableRequest)} to wait for the resource to be ready.
99
102
* <p>
100
103
* <b>Note:</b> This is a convenience method that creates an instance of the request builder avoiding the need to
101
104
* create one manually via {@link CreateTableEnhancedRequest#builder()}.
@@ -109,6 +112,7 @@ default void createTable(CreateTableEnhancedRequest request) {
109
112
* .writeCapacityUnits(50L)
110
113
* .build();
111
114
* mappedTable.createTable(r -> r.provisionedThroughput(provisionedThroughput));
115
+ * dynamoDbClient.waiter().waitUntilTableExists(b -> b.tableName(tableName));
112
116
* }
113
117
* </pre>
114
118
*
@@ -125,15 +129,15 @@ default void createTable(Consumer<CreateTableEnhancedRequest.Builder> requestCon
125
129
* Use {@link DynamoDbEnhancedClient#table(String, TableSchema)} to define the mapped table resource.
126
130
* <p>
127
131
* This operation calls the low-level DynamoDB API CreateTable operation. Note that this is an asynchronous
128
- * operation and that the table may not immediately be available for writes and reads. Currently, there is no
129
- * mechanism supported within this library to wait for/check the status of a created table. You must provide this
130
- * functionality yourself. Consult the CreateTable documentation for further details and constraints.
132
+ * operation and that the table may not immediately be available for writes and reads. You can use
133
+ * {@link DynamoDbWaiter#waitUntilTableExists(DescribeTableRequest)} to wait for the resource to be ready.
131
134
* <p>
132
135
* Example:
133
136
* <pre>
134
137
* {@code
135
138
*
136
139
* mappedTable.createTable();
140
+ * dynamoDbClient.waiter().waitUntilTableExists(b -> b.tableName(tableName));
137
141
* }
138
142
* </pre>
139
143
*
@@ -827,8 +831,8 @@ default UpdateItemEnhancedResponse<T> updateItemWithResponse(Consumer<UpdateItem
827
831
* Use {@link DynamoDbEnhancedClient#table(String, TableSchema)} to define the mapped table resource.
828
832
* <p>
829
833
* This operation calls the low-level DynamoDB API DeleteTable operation.
830
- * Note that this is an asynchronousoperation and that the table may not immediately be deleted. You can use
831
- * {@link software.amazon.awssdk.services.dynamodb.waiters. DynamoDbWaiter#waitUntilTableNotExists}
834
+ * Note that this is an asynchronous operation and that the table may not immediately be deleted. You can use
835
+ * {@link DynamoDbWaiter#waitUntilTableNotExists}
832
836
* in the underlying client.
833
837
* <p>
834
838
* Example:
@@ -843,4 +847,22 @@ default UpdateItemEnhancedResponse<T> updateItemWithResponse(Consumer<UpdateItem
843
847
default void deleteTable () {
844
848
throw new UnsupportedOperationException ();
845
849
}
850
+
851
+ /**
852
+ * Describes a table in DynamoDb with the name defined for this {@link DynamoDbTable).
853
+ * This operation calls the low-level DynamoDB API DescribeTable operation,
854
+ * see {@link DynamoDbClient#describeTable(DescribeTableRequest)}
855
+ * <p>
856
+ * Example:
857
+ * <pre>
858
+ * {@code
859
+ *
860
+ * DescribeTableEnhancedResponse response = mappedTable.describeTable();
861
+ * }
862
+ * </pre>
863
+ *
864
+ */
865
+ default DescribeTableEnhancedResponse describeTable () {
866
+ throw new UnsupportedOperationException ();
867
+ }
846
868
}
0 commit comments