Creating alternator keyspace using JAVA driver

Right now, I am using Python’s boto3 library to create my alternator space:

dynamodb = boto3.resource('dynamodb', endpoint_url=f'http://{alt_host}:8000',
                          region_name='None', aws_access_key_id='None', aws_secret_access_key='None')

According to documentation Using DynamoDB API in Scylla it should support several other languages:

In this example, we will use the Python language to interact with ScyllaDB
with the Boto 3 SDK for Python. It’s also possible to use the CLI or other 
languages such as Java, C#, Python, Perl, PHP, Ruby, Erlang, Javascript.

I was not able to find any examples of this being done in other languages. Anyone can share some code samples, specifically in JAVA (as I am writing my main application in JAVA, I would like to keep it to one language)

DynamoDB doesn’t have a notion of keyspaces, so it’s not possible to create one. Instead just create table, here are some samples from aws sdk (alternator is compatible with dynamodb): https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/dynamodb.

Additionally some example from our alternator load balancing library should demonstrate where to put unused placeholders as alternator doesn’t use AWS region configuration and endpoints: https://github.com/scylladb/alternator-load-balancing/blob/master/java/src/main/java/com/scylladb/alternator/AlternatorClient.java

I ended up coming up with this code:

    private static void createAlternatorKeyspaces() {
        AmazonDynamoDB client = AmazonDynamoDBClientBuilder
                .standard()
                .withEndpointConfiguration(
                        new AwsClientBuilder
                                .EndpointConfiguration("http://" + alternatorHost + ":8000", Constants.NONE))
                .withCredentials(provider)
                .build();

        ArrayList<KeySchemaElement> keySchema = new ArrayList<>();
        keySchema.add(new KeySchemaElement().withAttributeName("serial_number").withKeyType(KeyType.HASH));
        keySchema.add(new KeySchemaElement().withAttributeName("issuer_cn").withKeyType(KeyType.RANGE));

        ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<>();
        attributeDefinitions.add(new AttributeDefinition().withAttributeName("serial_number").withAttributeType("S"));
        attributeDefinitions.add(new AttributeDefinition().withAttributeName("issuer_cn").withAttributeType("S"));

        CreateTableRequest request = new CreateTableRequest()
                .withTableName("blocked_items")
                .withKeySchema(keySchema)
                .withAttributeDefinitions(attributeDefinitions)
                .withProvisionedThroughput(
                        new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(10L));
        DynamoDB dynamoDB = new DynamoDB(client);
        Table table = dynamoDB.createTable(request);
        System.out.println("Waiting for blocked_items to be created...this may take a while...");
        try {
            table.waitForActive();
        } catch (InterruptedException e) {
            System.err.println("CreateTable request failed for blocked_items");
            System.err.println(e.getMessage());
        }
        System.out.println("CreateTable request succeeded for blocked_items");
    }