Example usage for com.amazonaws.services.dynamodbv2.document Table deleteItem

List of usage examples for com.amazonaws.services.dynamodbv2.document Table deleteItem

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.document Table deleteItem.

Prototype

@Override
    public DeleteItemOutcome deleteItem(String hashKeyName, Object hashKeyValue) 

Source Link

Usage

From source file:io.ignitr.dispatchr.manager.core.data.ClientRepository.java

License:Apache License

/**
 * Deletes a client from DynamoDB./* w  w  w. j a v a2s.c o  m*/
 *
 * @param clientId client identifier
 * @return an {@link Observable} that emits <code>true</code> if the delete was successful; otherwise <code>false</code>
 */
public Observable<Boolean> delete(String clientId) {
    return findOne(clientId).flatMap(client -> Observable.create(subscriber -> {
        Table clientTable = dynamoDB.getTable(CLIENT_TABLE_NAME);

        clientTable.deleteItem("clientId", client.getClientId());

        subscriber.onNext(true);
        subscriber.onCompleted();
    }));
}

From source file:io.ignitr.dispatchr.manager.core.data.TopicRepository.java

License:Apache License

/**
 * Deletes the metadata about a registered topic.
 *
 * @param topicName name of the topic/*w w w  .j a  v  a 2  s.co m*/
 * @param topicArn arn of the topic
 * @return an {@link Observable} of {@link Topic} containing the metadata about the topic that was deleted
 */
public Observable<Topic> delete(String topicName, String topicArn) {
    return Observable.create(subscriber -> {
        Topic metadata = new Topic();
        metadata.setName(topicName);
        metadata.setArn(topicArn);
        metadata.setRegistered(false);

        Table table = dynamoDB.getTable(TOPIC_TABLE_NAME);

        if (table.getItem("name", metadata.getName()) == null) {
            throw new TopicNotFoundException(metadata.getName());
        }

        table.deleteItem("name", metadata.getName());

        subscriber.onNext(metadata);
        subscriber.onCompleted();
    });
}