Created
October 18, 2020 07:33
-
-
Save vladdima94/82079519b0ce3a90c7ded2a1c62a1776 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DynamoDBLocalStarterTest { | |
// ... | |
public static CreateTableResult createTable( | |
AmazonDynamoDB ddb, String tableName, String hashKeyName, String rangeKeyName) { | |
List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>(); | |
List<KeySchemaElement> ks = new ArrayList<KeySchemaElement>(); | |
attributeDefinitions.add(new AttributeDefinition(hashKeyName, ScalarAttributeType.S)); | |
ks.add(new KeySchemaElement(hashKeyName, KeyType.HASH)); | |
if(!Strings.isNullOrEmpty(rangeKeyName)) { | |
attributeDefinitions.add(new AttributeDefinition(rangeKeyName, ScalarAttributeType.S)); | |
ks.add(new KeySchemaElement(rangeKeyName, KeyType.RANGE)); | |
} | |
ProvisionedThroughput provisionedthroughput = new ProvisionedThroughput(1000L, 1000L); | |
CreateTableRequest request = | |
new CreateTableRequest() | |
.withTableName(tableName) | |
.withAttributeDefinitions(attributeDefinitions) | |
.withKeySchema(ks) | |
.withProvisionedThroughput(provisionedthroughput); | |
return ddb.createTable(request); | |
} | |
public static DeleteTableResult deleteTable(AmazonDynamoDB ddb, String tableName) { | |
return ddb.deleteTable(tableName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment