Search in sources :

Example 6 with DynamoDbClient

use of software.amazon.awssdk.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.

the class EnhancedQueryRecordsWithFilter method main.

// Query the Customer table using a filter.
public static void main(String[] args) {
    Region region = Region.US_EAST_1;
    DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
    DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder().dynamoDbClient(ddb).build();
    queryTableFilter(enhancedClient);
    ddb.close();
}
Also used : DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) Region(software.amazon.awssdk.regions.Region) DynamoDbEnhancedClient(software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient)

Example 7 with DynamoDbClient

use of software.amazon.awssdk.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.

the class CreateTable method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <tableName> <key>\n\n" + "Where:\n" + "    tableName - the Amazon DynamoDB table to create (for example, Music3).\n\n" + "    key - the key for the Amazon DynamoDB table (for example, Artist).\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String tableName = args[0];
    String key = args[1];
    System.out.format("Creating an Amazon DynamoDB table \"%s\" with a simple primary key: \"Name\".\n", tableName);
    Region region = Region.US_EAST_1;
    DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
    String result = createTable(ddb, tableName, key);
    System.out.println("New table is " + result);
    ddb.close();
}
Also used : DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) Region(software.amazon.awssdk.regions.Region)

Example 8 with DynamoDbClient

use of software.amazon.awssdk.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.

the class DeleteTable method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <tableName>\n\n" + "Where:\n" + "    tableName - the Amazon DynamoDB table to delete (for example, Music3).\n\n" + "**Warning** This program will delete the table that you specify!\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    // Read the command line argument
    String tableName = args[0];
    System.out.format("Deleting the Amazon DynamoDB table %s...\n", tableName);
    // Create the DynamoDbClient object
    Region region = Region.US_EAST_1;
    DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
    deleteDynamoDBTable(ddb, tableName);
    ddb.close();
}
Also used : DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) Region(software.amazon.awssdk.regions.Region)

Example 9 with DynamoDbClient

use of software.amazon.awssdk.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.

the class DynamoDBScanItems method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <tableName>\n\n" + "Where:\n" + "    tableName - the Amazon DynamoDB table to get information from (for example, Music3).\n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String tableName = args[0];
    Region region = Region.US_EAST_1;
    DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
    scanItems(ddb, tableName);
    ddb.close();
}
Also used : DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) Region(software.amazon.awssdk.regions.Region)

Example 10 with DynamoDbClient

use of software.amazon.awssdk.services.dynamodb.DynamoDbClient in project aws-doc-sdk-examples by awsdocs.

the class UpdateTable method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    UpdateTable <tableName> <readCapacity> <writeCapacity>\n\n" + "Where:\n" + "    tableName - the Amazon DynamoDB table to update (for example, Music3).\n" + "    readCapacity  - the new read capacity of the table (for example, 16).\n" + "    writeCapacity - the new write capacity of the table (for example, 10).\n\n" + "Example:\n" + "    UpdateTable Music3 16 10\n";
    if (args.length != 3) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String tableName = args[0];
    Long readCapacity = Long.parseLong(args[1]);
    Long writeCapacity = Long.parseLong(args[2]);
    Region region = Region.US_WEST_2;
    DynamoDbClient ddb = DynamoDbClient.builder().region(region).build();
    updateDynamoDBTable(ddb, tableName, readCapacity, writeCapacity);
    ddb.close();
}
Also used : DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) Region(software.amazon.awssdk.regions.Region)

Aggregations

DynamoDbClient (software.amazon.awssdk.services.dynamodb.DynamoDbClient)40 Region (software.amazon.awssdk.regions.Region)32 DynamoDbEnhancedClient (software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient)13 DynamoDbException (software.amazon.awssdk.services.dynamodb.model.DynamoDbException)5 Instant (java.time.Instant)2 LocalDateTime (java.time.LocalDateTime)2 List (java.util.List)2 Map (java.util.Map)2 AttributeValue (software.amazon.awssdk.services.dynamodb.model.AttributeValue)2 Segment (com.amazonaws.xray.entities.Segment)1 Subsegment (com.amazonaws.xray.entities.Subsegment)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 UtilityClass (lombok.experimental.UtilityClass)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1