11package com .launchdarkly .client .dynamodb ;
22
3- import com .amazonaws .ClientConfiguration ;
4- import com .amazonaws .auth .AWSCredentialsProvider ;
5- import com .amazonaws .client .builder .AwsClientBuilder ;
6- import com .amazonaws .regions .Regions ;
7- import com .amazonaws .services .dynamodbv2 .AmazonDynamoDB ;
8- import com .amazonaws .services .dynamodbv2 .AmazonDynamoDBClient ;
9- import com .amazonaws .services .dynamodbv2 .AmazonDynamoDBClientBuilder ;
103import com .launchdarkly .client .FeatureStore ;
114import com .launchdarkly .client .FeatureStoreCacheConfig ;
125import com .launchdarkly .client .FeatureStoreFactory ;
158
169import java .net .URI ;
1710
11+ import software .amazon .awssdk .auth .credentials .AwsCredentialsProvider ;
12+ import software .amazon .awssdk .core .client .config .ClientOverrideConfiguration ;
13+ import software .amazon .awssdk .regions .Region ;
14+ import software .amazon .awssdk .services .dynamodb .DynamoDbClient ;
15+ import software .amazon .awssdk .services .dynamodb .DynamoDbClientBuilder ;
16+
1817/**
1918 * Builder/factory class for the DynamoDB feature store.
2019 * <p>
2524 * The AWS SDK provides many configuration options for a DynamoDB client. This class has
2625 * corresponding methods for some of the most commonly used ones. If you need more sophisticated
2726 * control over the DynamoDB client, you can construct one of your own and pass it in with the
28- * {@link #existingClient(AmazonDynamoDB )} method.
27+ * {@link #existingClient(DynamoDbClient )} method.
2928 */
3029public class DynamoDbFeatureStoreBuilder implements FeatureStoreFactory {
3130 private final String tableName ;
3231
3332 private String prefix ;
34- private AmazonDynamoDB existingClient ;
35- private AmazonDynamoDBClientBuilder clientBuilder ;
33+ private DynamoDbClient existingClient ;
34+ private DynamoDbClientBuilder clientBuilder ;
3635
3736 private FeatureStoreCacheConfig caching = FeatureStoreCacheConfig .DEFAULT ;
3837
3938 DynamoDbFeatureStoreBuilder (String tableName ) {
4039 this .tableName = tableName ;
41- clientBuilder = AmazonDynamoDBClient .builder ();
40+ clientBuilder = DynamoDbClient .builder ();
4241 }
4342
4443 @ Override
4544 public FeatureStore createFeatureStore () {
46- AmazonDynamoDB client = (existingClient != null ) ? existingClient : clientBuilder .build ();
45+ DynamoDbClient client = (existingClient != null ) ? existingClient : clientBuilder .build ();
4746 DynamoDbFeatureStoreCore core = new DynamoDbFeatureStoreCore (client , tableName , prefix );
4847 CachingStoreWrapper wrapper = CachingStoreWrapper .builder (core ).caching (caching ).build ();
4948 return wrapper ;
@@ -55,8 +54,8 @@ public FeatureStore createFeatureStore() {
5554 * @param config an AWS client configuration object
5655 * @return the builder
5756 */
58- public DynamoDbFeatureStoreBuilder clientConfiguration ( ClientConfiguration config ) {
59- clientBuilder .setClientConfiguration (config );
57+ public DynamoDbFeatureStoreBuilder clientOverrideConfiguration ( ClientOverrideConfiguration config ) {
58+ clientBuilder .overrideConfiguration (config );
6059 return this ;
6160 }
6261
@@ -67,49 +66,36 @@ public DynamoDbFeatureStoreBuilder clientConfiguration(ClientConfiguration confi
6766 * @param credentialsProvider a source of credentials
6867 * @return the builder
6968 */
70- public DynamoDbFeatureStoreBuilder credentials (AWSCredentialsProvider credentialsProvider ) {
71- clientBuilder .setCredentials (credentialsProvider );
69+ public DynamoDbFeatureStoreBuilder credentials (AwsCredentialsProvider credentialsProvider ) {
70+ clientBuilder .credentialsProvider (credentialsProvider );
7271 return this ;
7372 }
7473
7574 /**
76- * Sets the service endpoint and AWS region to use. Normally, you will not use this, as AWS
77- * determines the service endpoint based on your region. However, you can set it explicitly if
78- * you are running your own DynamoDB instance.
75+ * Sets the service endpoint to use. Normally, you will not use this, as AWS determines the
76+ * service endpoint based on your region. However, you can set it explicitly if you are
77+ * running your own DynamoDB instance.
7978 *
8079 * @param endpointUri the custom endpoint URI
81- * @param region the AWS region name
8280 * @return the builder
8381 */
84- public DynamoDbFeatureStoreBuilder endpointAndRegion (URI endpointUri , String region ) {
85- clientBuilder .setEndpointConfiguration ( new AwsClientBuilder . EndpointConfiguration ( endpointUri . toString (), region ) );
82+ public DynamoDbFeatureStoreBuilder endpoint (URI endpointUri ) {
83+ clientBuilder .endpointOverride ( endpointUri );
8684 return this ;
8785 }
8886
8987 /**
9088 * Sets the AWS region to use. If you do not set this, AWS will attempt to determine it from
9189 * environment variables and/or local configuration files.
9290 *
93- * @param region the AWS region name
91+ * @param region the AWS region
9492 * @return the builder
9593 */
96- public DynamoDbFeatureStoreBuilder region (String region ) {
97- clientBuilder .setRegion (region );
94+ public DynamoDbFeatureStoreBuilder region (Region region ) {
95+ clientBuilder .region (region );
9896 return this ;
9997 }
10098
101- /**
102- * Sets the AWS region to use. If you do not set this, AWS will attempt to determine it from
103- * environment variables and/or local configuration files.
104- *
105- * @param region the AWS region enum
106- * @return the builder
107- */
108- public DynamoDbFeatureStoreBuilder region (Regions region ) {
109- clientBuilder .withRegion (region );
110- return this ;
111- }
112-
11399 /**
114100 * Sets an optional namespace prefix for all keys stored in DynamoDB. Use this if you are sharing
115101 * the same database table between multiple clients that are for different LaunchDarkly
@@ -131,15 +117,15 @@ public DynamoDbFeatureStoreBuilder prefix(String prefix) {
131117 * @param existingClient an existing DynamoDB client instance
132118 * @return the builder
133119 */
134- public DynamoDbFeatureStoreBuilder existingClient (AmazonDynamoDB existingClient ) {
120+ public DynamoDbFeatureStoreBuilder existingClient (DynamoDbClient existingClient ) {
135121 this .existingClient = existingClient ;
136122 return this ;
137123 }
138124
139125 /**
140126 * Specifies whether local caching should be enabled and if so, sets the cache properties. Local
141127 * caching is enabled by default; see {@link FeatureStoreCacheConfig#DEFAULT}. To disable it, pass
142- * {@link FeatureStoreCaching #disabled()} to this method.
128+ * {@link FeatureStoreCacheConfig #disabled()} to this method.
143129 *
144130 * @param caching a {@link FeatureStoreCacheConfig} object specifying caching parameters
145131 * @return the builder
0 commit comments