Example usage for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient AmazonDynamoDBClient

List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient AmazonDynamoDBClient

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient AmazonDynamoDBClient.

Prototype

AmazonDynamoDBClient(AwsSyncClientParams clientParams) 

Source Link

Document

Constructs a new client to invoke service methods on DynamoDB using the specified parameters.

Usage

From source file:com.github.sporcina.mule.modules.DynamoDBConnector.java

License:Open Source License

/**
 * Creates a DynamoDB client using the security values passed in
 *
 * @param accessKey/*from   w w  w . j  av a2 s .  c  o  m*/
 *         the access key provided to you through your Amazon AWS account
 * @param secretKey
 *         the secret key provided to you through your Amazon AWS account
 *
 * @throws ConnectionException
 */
private void createDynamoDBClient(String accessKey, String secretKey) throws ConnectionException {
    try {
        AWSCredentials credentialsProvider = new BasicAWSCredentials(accessKey, secretKey);
        setDynamoDBClient(new AmazonDynamoDBClient(credentialsProvider));
    } catch (Exception e) {
        throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, null, e.getMessage(), e);
    }
}

From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.DbTableDetail.java

License:Open Source License

@Override
public String retrieveDetails(ResourceDetailRequest detailRequest) {

    String response = null;/*from w w w  .j a va 2s .  com*/

    try {

        AmazonDynamoDB client = new AmazonDynamoDBClient(credentials);
        client.setRegion(Region.getRegion(Regions.fromName(detailRequest.getRegion())));

        DescribeTableRequest request = new DescribeTableRequest();
        request.setTableName(detailRequest.getResourceName());

        DescribeTableResult result = client.describeTable(request);
        buildUI(result);

    } catch (IllegalArgumentException | AmazonClientException e) {
        response = e.getMessage();
        LOGGER.log(Level.WARNING, "Problem retrieving DynamoDb details from AWS", e);
    }

    return response;
}

From source file:com.hussi.aws.dynamoDB.AmazonDynamoDBSample.java

License:Open Source License

/**
 * The only information needed to create a client are security credentials
 * consisting of the AWS Access Key ID and Secret Access Key. All other
 * configuration, such as the service endpoints, are performed
 * automatically. Client parameters, such as proxies, can be specified in an
 * optional ClientConfiguration object when constructing a client.
 *
 * @see com.amazonaws.auth.BasicAWSCredentials
 * @see com.amazonaws.auth.ProfilesConfigFile
 * @see com.amazonaws.ClientConfiguration
 *//* w ww . ja va2 s .  co  m*/
private static void init() throws Exception {
    /*
     * The ProfileCredentialsProvider will return your [default]
     * credential profile by reading from the credentials file located at
     * (~/.aws/credentials).
     */
    AWSCredentials credentials = null;
    try {
        credentials = new ProfileCredentialsProvider().getCredentials();
        System.out.println("credentials.getAWSAccessKeyId()===>>>" + credentials.getAWSAccessKeyId());
        System.out.println("credentials.getAWSSecretKey()===>>>" + credentials.getAWSSecretKey());
        //System.exi   t(0);

    } catch (Exception e) {
        throw new AmazonClientException("Cannot load the credentials from the credential profiles file. "
                + "Please make sure that your credentials file is at the correct "
                + "location (~/.aws/credentials), and is in valid format.", e);
    }
    dynamoDB = new AmazonDynamoDBClient(credentials);
    Region usWest2 = Region.getRegion(Regions.US_WEST_2);
    dynamoDB.setRegion(usWest2);
}

From source file:com.lvl6.mobsters.dynamo.setup.TransactionExamples.java

License:Open Source License

public TransactionExamples() {
    AWSCredentials credentials;/*from w  ww  . j ava2  s  .  com*/
    try {
        credentials = new PropertiesCredentials(
                TransactionExamples.class.getResourceAsStream("AwsCredentials.properties"));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    dynamodb = new AmazonDynamoDBClient(credentials);
    dynamodb.setEndpoint(DYNAMODB_ENDPOINT);
    txManager = new TransactionManager(dynamodb, TX_TABLE_NAME, TX_IMAGES_TABLE_NAME);
}

From source file:com.makariev.dynamodb.config.aws.DynamoDbContext.java

License:Open Source License

public DynamoDbContext() throws IOException {
    final AWSCredentials credentials = new PropertiesCredentials(
            DynamoDbContext.class.getResourceAsStream("/AwsCredentials.properties"));
    //        final AWSCredentials credentials = new BasicAWSCredentials("", "");
    this.dynamoDb = new AmazonDynamoDBClient(credentials);
    final String endpoint = System.getProperty("dynamodb.endpoint");
    this.dynamoDb.setEndpoint(String.format(endpoint));

    this.mapper = new DynamoDBMapper(this.dynamoDb);
}

From source file:com.mortardata.pig.storage.DynamoDBStorage.java

License:Apache License

private AmazonDynamoDBClient loadDynamoDB() {
    if (this.dynamo == null) {
        this.dynamo = new AmazonDynamoDBClient(new BasicAWSCredentials(this.awsAccessKeyId, this.awsSecretKey));
    }//from  w ww .  j  a  va2s  .c o m
    return this.dynamo;
}

From source file:com.mycompany.rproject.runnableClass.java

public static void putInDb(String s, String id) throws IOException {
    AWSCredentials credentials = new PropertiesCredentials(
            new File("/Users/paulamontojo/Desktop/AwsCredentials.properties"));

    dynamoDBClient = new AmazonDynamoDBClient(new STSSessionCredentialsProvider(credentials));
    dynamoDBClient.setRegion(Region.getRegion(Regions.US_WEST_2));
    createTable();//from w w w . j  a  va  2 s.  c  om

    // Describe our new table
    describeTable();

    // Add some items
    putItem(newItem(id, "url", s));

}

From source file:com.nandanu.halomama.controller.AmazonClientManager.java

License:Open Source License

private void initClients() {
    // CognitoCachingCredentialsProvider credentials = new
    // CognitoCachingCredentialsProvider(
    // context, Constants.AWS_ACCOUNT_ID, Constants.COGNITO_POOL_ID,
    // Constants.COGNITO_ROLE_UNAUTH, null, Constants.COGNITO_REGION);

    CognitoCachingCredentialsProvider credentials = new CognitoCachingCredentialsProvider(context,
            Constants.AWS_ACCOUNT_ID, Constants.COGNITO_POOL_ID, Constants.COGNITO_ROLE_UNAUTH, null,
            Constants.COGNITO_REGION);/*  w  ww. java 2  s .  co  m*/

    ddb = new AmazonDynamoDBClient(credentials);
    ddb.setRegion(Region.getRegion(Constants.DDB_REGION));

    identityId = credentials.getIdentityId();
}

From source file:com.netflix.config.sources.AbstractDynamoDbConfigurationSource.java

License:Apache License

public AbstractDynamoDbConfigurationSource(ClientConfiguration clientConfiguration) {
    this(new AmazonDynamoDBClient(clientConfiguration));
    setEndpoint();
}

From source file:com.netflix.config.sources.AbstractDynamoDbConfigurationSource.java

License:Apache License

public AbstractDynamoDbConfigurationSource(AWSCredentials credentials) {
    this(new AmazonDynamoDBClient(credentials));
    setEndpoint();
}