List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient createTable
@Override
public CreateTableResult createTable(CreateTableRequest request)
The CreateTable
operation adds a new table to your account.
From source file:com.vivastream.security.oauth2.common.util.DynamoDBInitializationHelper.java
License:Apache License
public static void createTokenTables(AmazonDynamoDBClient client, DynamoDBTokenSchema schema) { GlobalSecondaryIndex gsiAuthenticationIdToken = new GlobalSecondaryIndex() // .withIndexName(schema.getAccessIndexAuthenticationId()) // .withKeySchema(new KeySchemaElement(schema.getAccessColumnAuthenticationId(), KeyType.HASH)) // .withProvisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) // .withProjection(new Projection().withProjectionType(ProjectionType.KEYS_ONLY)); GlobalSecondaryIndex gsiRefreshToken = new GlobalSecondaryIndex() // .withIndexName(schema.getAccessIndexRefreshToken()) // .withKeySchema(new KeySchemaElement(schema.getAccessColumnRefreshToken(), KeyType.HASH)) // .withProvisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) // .withProjection(new Projection().withProjectionType(ProjectionType.KEYS_ONLY)); GlobalSecondaryIndex gsiClientIdAndUserName = new GlobalSecondaryIndex() // .withIndexName(schema.getAccessIndexClientIdAndUserName()) // .withKeySchema( // new KeySchemaElement(schema.getAccessColumnClientId(), KeyType.HASH), // new KeySchemaElement(schema.getAccessColumnUserName(), KeyType.RANGE) // ) //// ww w . j a v a 2 s. c o m .withProvisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) // .withProjection(new Projection().withProjectionType(ProjectionType.KEYS_ONLY)); CreateTableRequest accessTableRequest = new CreateTableRequest() // .withTableName(schema.getAccessTableName()) // .withKeySchema(new KeySchemaElement(schema.getAccessColumnTokenId(), KeyType.HASH)) // .withGlobalSecondaryIndexes(gsiAuthenticationIdToken, gsiRefreshToken, gsiClientIdAndUserName) // .withAttributeDefinitions( new AttributeDefinition(schema.getAccessColumnTokenId(), ScalarAttributeType.S), // new AttributeDefinition(schema.getAccessColumnAuthenticationId(), ScalarAttributeType.S), // new AttributeDefinition(schema.getAccessColumnRefreshToken(), ScalarAttributeType.S), // new AttributeDefinition(schema.getAccessColumnClientId(), ScalarAttributeType.S), // new AttributeDefinition(schema.getAccessColumnUserName(), ScalarAttributeType.S) // ) // .withProvisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) // ; CreateTableResult accessTableresponse = client.createTable(accessTableRequest); CreateTableRequest refreshTableRequest = new CreateTableRequest() // .withTableName(schema.getRefreshTableName()) // .withKeySchema(new KeySchemaElement(schema.getRefreshColumnTokenId(), KeyType.HASH)) // .withAttributeDefinitions( new AttributeDefinition(schema.getRefreshColumnTokenId(), ScalarAttributeType.S) // ) // .withProvisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) // ; CreateTableResult refreshTableresponse = client.createTable(refreshTableRequest); }
From source file:com.vivastream.security.oauth2.common.util.DynamoDBInitializationHelper.java
License:Apache License
public static void createHashTable(AmazonDynamoDBClient client, String tableName, String hashColumnName) { CreateTableRequest accessTableRequest = new CreateTableRequest() // .withTableName(tableName) // .withKeySchema(new KeySchemaElement(hashColumnName, KeyType.HASH)) // .withAttributeDefinitions(new AttributeDefinition(hashColumnName, ScalarAttributeType.S) // ) ////www .j a va 2 s. co m .withProvisionedThroughput(DEFAULT_PROVISIONED_THROUGHPUT) // ; CreateTableResult accessTableresponse = client.createTable(accessTableRequest); }
From source file:examples.csci567.demo.userpreferencesom.DynamoDBManager.java
License:Open Source License
public static void createTable() { Log.d(TAG, "Create table called"); AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager.ddb(); KeySchemaElement kse = new KeySchemaElement().withAttributeName("userNo").withKeyType(KeyType.HASH); AttributeDefinition ad = new AttributeDefinition().withAttributeName("userNo") .withAttributeType(ScalarAttributeType.N); ProvisionedThroughput pt = new ProvisionedThroughput().withReadCapacityUnits(10l) .withWriteCapacityUnits(5l); CreateTableRequest request = new CreateTableRequest().withTableName(Constants.TEST_TABLE_NAME) .withKeySchema(kse).withAttributeDefinitions(ad).withProvisionedThroughput(pt); try {/*from ww w . j a va 2s.co m*/ Log.d(TAG, "Sending Create table request"); ddb.createTable(request); Log.d(TAG, "Create request response successfully recieved"); } catch (AmazonServiceException ex) { Log.e(TAG, "Error sending create table request", ex); UserPreferenceDemoActivity.clientManager.wipeCredentialsOnAuthError(ex); } }