software.amazon.awssdk.services.dynamodb.model.ExpectedAttributeValue Java Examples

The following examples show how to use software.amazon.awssdk.services.dynamodb.model.ExpectedAttributeValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, ExpectedAttributeValue> getDynamoLeaseOwnerExpectation(final Lease lease) {
    Map<String, ExpectedAttributeValue> result = new HashMap<>();

    ExpectedAttributeValue.Builder eavBuilder = ExpectedAttributeValue.builder();
    
    if (lease.leaseOwner() == null) {
        eavBuilder = eavBuilder.exists(false);
    } else {
        eavBuilder = eavBuilder.value(DynamoUtils.createAttributeValue(lease.leaseOwner()));
    }
    
    result.put(LEASE_OWNER_KEY, eavBuilder.build());

    return result;
}
 
Example #2
Source File: MetaStore.java    From aws-dynamodb-encryption-java with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new MetaStore with specified table name and extra data supplier.
 *
 * @param ddb Interface for accessing DynamoDB.
 * @param tableName DynamoDB table name for this {@link MetaStore}.
 * @param encryptor used to perform crypto operations on the record attributes
 * @param extraDataSupplier provides extra data that should be stored along with the material.
 */
public MetaStore(final DynamoDbClient ddb, final String tableName,
                 final DynamoDbEncryptor encryptor, final ExtraDataSupplier extraDataSupplier) {
    this.ddb = checkNotNull(ddb, "ddb must not be null");
    this.tableName = checkNotNull(tableName, "tableName must not be null");
    this.encryptor = checkNotNull(encryptor, "encryptor must not be null");
    this.extraDataSupplier = checkNotNull(extraDataSupplier, "extraDataSupplier must not be null");

    final Map<String, ExpectedAttributeValue> tmpExpected = new HashMap<>();
    tmpExpected.put(DEFAULT_HASH_KEY, ExpectedAttributeValue.builder().exists(false).build());
    tmpExpected.put(DEFAULT_RANGE_KEY, ExpectedAttributeValue.builder().exists(false).build());
    doesNotExist = Collections.unmodifiableMap(tmpExpected);

    this.encryptionConfiguration = DynamoDbEncryptionConfiguration.builder()
        .encryptionContext(EncryptionContext.builder()
                               .tableName(this.tableName)
                               .hashKeyName(DEFAULT_HASH_KEY)
                               .rangeKeyName(DEFAULT_RANGE_KEY)
                               .build())
        // All fields default to ENCRYPT_AND_SIGN with 'sign only' fields being explicitly overridden
        .defaultEncryptionAction(EncryptionAction.ENCRYPT_AND_SIGN)
        .addEncryptionActionOverrides(getSignedOnlyFields(extraDataSupplier).stream()
                                     .collect(Collectors.toMap(Function.identity(),
                                                               ignored -> EncryptionAction.SIGN_ONLY)))
        .build();
    ;
}
 
Example #3
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 5 votes vote down vote up
public Map<String, ExpectedAttributeValue> getDynamoLeaseCounterExpectation(final Long leaseCounter) {
    Map<String, ExpectedAttributeValue> result = new HashMap<>();

    ExpectedAttributeValue eav = ExpectedAttributeValue.builder().value(DynamoUtils.createAttributeValue(leaseCounter)).build();
    result.put(LEASE_COUNTER_KEY, eav);

    return result;
}
 
Example #4
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, ExpectedAttributeValue> getDynamoNonexistantExpectation() {
    Map<String, ExpectedAttributeValue> result = new HashMap<>();

    ExpectedAttributeValue expectedAV = ExpectedAttributeValue.builder().exists(false).build();
    result.put(LEASE_KEY_KEY, expectedAV);

    return result;
}
 
Example #5
Source File: DynamoDBLeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, ExpectedAttributeValue> getDynamoLeaseCounterExpectation(final Lease lease) {
    return getDynamoLeaseCounterExpectation(lease.leaseCounter());
}
 
Example #6
Source File: LeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 2 votes vote down vote up
/**
 * @param lease
 * @return the attribute value map asserting that a lease counter is what we expect.
 */
Map<String, ExpectedAttributeValue> getDynamoLeaseCounterExpectation(Lease lease);
 
Example #7
Source File: LeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 2 votes vote down vote up
/**
 * @param lease
 * @return the attribute value map asserting that the lease owner is what we expect.
 */
Map<String, ExpectedAttributeValue> getDynamoLeaseOwnerExpectation(Lease lease);
 
Example #8
Source File: LeaseSerializer.java    From amazon-kinesis-client with Apache License 2.0 2 votes vote down vote up
/**
 * @return the attribute value map asserting that a lease does not exist.
 */
Map<String, ExpectedAttributeValue> getDynamoNonexistantExpectation();