/** * <p> * The name of the table to contain the item. * </p> * * @param tableName * The name of the table to contain the item. * @return Returns a reference to this object so that method calls can be chained together. */ public PutItemRequest withTableName(String tableName) { setTableName(tableName); return this; }
/** * Constructs a new PutItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table to contain the item. * @param item * A map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; * you can optionally provide other attribute name-value pairs for the item.</p> * <p> * You must provide all of the attributes for the primary key. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide both * values for both the partition key and the sort key. * </p> * <p> * If you specify any attributes that are part of an index key, then the data types for those attributes must * match those of the schema in the table's attribute definition. * </p> * <p> * For more information about primary keys, see <a href= * "http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html#DataModelPrimaryKey" * >Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>. * </p> * <p> * Each element in the <code>Item</code> map is an <code>AttributeValue</code> object. */ public PutItemRequest(String tableName, java.util.Map<String, AttributeValue> item) { setTableName(tableName); setItem(item); }
setTableName(tableName); setItem(item); setReturnValues(returnValues);
setTableName(tableName); setItem(item); setReturnValues(returnValues.toString());
setTableName(tableName); setItem(item);
setTableName(tableName); setItem(item); setReturnValues(returnValues);
setTableName(tableName); setItem(item); setReturnValues(returnValues.toString());
throws AmazonServiceException, AmazonClientException { PutItemRequest putItemRequest = new PutItemRequest(); putItemRequest.setTableName(tableName); putItemRequest.setItem(item); return putItem(putItemRequest);
/** * <p> * The name of the table to contain the item. * </p> * * @param tableName * The name of the table to contain the item. * @return Returns a reference to this object so that method calls can be chained together. */ public PutItemRequest withTableName(String tableName) { setTableName(tableName); return this; }
throws AmazonServiceException, AmazonClientException { PutItemRequest putItemRequest = new PutItemRequest(); putItemRequest.setTableName(tableName); putItemRequest.setItem(item); putItemRequest.setReturnValues(returnValues);
/** * Puts a document into DynamoDB. * * @param document the {@link Document}. * @param config {@link PutItemOperationConfig}. * @return the dynamodb {@link Document}. */ public Document putItem(Document document, PutItemOperationConfig config) { final PutItemRequest request = new PutItemRequest(); request.setTableName(this.tableName); request.setItem(toAttributeMap(document)); if (config != null && config.getReturnValue().compareTo(ReturnValue.ALL_OLD) == 0) { request.setReturnValues(ReturnValue.ALL_OLD); } Table.appendDynamoDBDocumentUserAgentString(request); final PutItemResult result = client.putItem(request); Document ret = null; if (config != null && config.getReturnValue().compareTo(ReturnValue.ALL_OLD) == 0) { final Map<String, AttributeValue> values = result.getAttributes(); ret = this.fromAttributeMap(values); ret.commit(); } return ret; }
/** * Constructs a new PutItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table to contain the item. * @param item * A map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; * you can optionally provide other attribute name-value pairs for the item.</p> * <p> * You must provide all of the attributes for the primary key. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide both * values for both the partition key and the sort key. * </p> * <p> * If you specify any attributes that are part of an index key, then the data types for those attributes must * match those of the schema in the table's attribute definition. * </p> * <p> * For more information about primary keys, see <a href= * "http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html#DataModelPrimaryKey" * >Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>. * </p> * <p> * Each element in the <code>Item</code> map is an <code>AttributeValue</code> object. */ public PutItemRequest(String tableName, java.util.Map<String, AttributeValue> item) { setTableName(tableName); setItem(item); }
setTableName(tableName); setItem(item); setReturnValues(returnValues);
/** * {@inheritDoc} */ @Override public boolean createLeaseIfNotExists(T lease) throws DependencyException, InvalidStateException, ProvisionedThroughputException { verifyNotNull(lease, "lease cannot be null"); if (LOG.isDebugEnabled()) { LOG.debug("Creating lease " + lease); } PutItemRequest request = new PutItemRequest(); request.setTableName(table); request.setItem(serializer.toDynamoRecord(lease)); request.setExpected(serializer.getDynamoNonexistantExpectation()); try { dynamoDBClient.putItem(request); } catch (ConditionalCheckFailedException e) { if (LOG.isDebugEnabled()) { LOG.debug("Did not create lease " + lease + " because it already existed"); } return false; } catch (AmazonClientException e) { throw convertAndRethrowExceptions("create", lease.getLeaseKey(), e); } return true; }
setTableName(tableName); setItem(item); setReturnValues(returnValues.toString());
putItemRequest.setTableName(getTableName()); request = putItemRequest; } else if (eventName.equalsIgnoreCase(OperationType.REMOVE.toString())) {
public PutPointResult putPoint(PutPointRequest putPointRequest) { long geohash = S2Manager.generateGeohash(putPointRequest.getGeoPoint()); long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength()); String geoJson = GeoJsonMapper.stringFromGeoObject(putPointRequest.getGeoPoint()); PutItemRequest putItemRequest = putPointRequest.getPutItemRequest(); putItemRequest.setTableName(config.getTableName()); AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey)); putItemRequest.getItem().put(config.getHashKeyAttributeName(), hashKeyValue); putItemRequest.getItem().put(config.getRangeKeyAttributeName(), putPointRequest.getRangeKeyValue()); AttributeValue geohashValue = new AttributeValue().withN(Long.toString(geohash)); putItemRequest.getItem().put(config.getGeohashAttributeName(), geohashValue); AttributeValue geoJsonValue = new AttributeValue().withS(geoJson); putItemRequest.getItem().put(config.getGeoJsonAttributeName(), geoJsonValue); PutItemResult putItemResult = config.getDynamoDBClient().putItem(putItemRequest); PutPointResult putPointResult = new PutPointResult(putItemResult); return putPointResult; }
@Override public String lock(final String name, final String label) throws IOException { final AmazonDynamoDB aws = this.table.region().aws(); String msg = ""; try { final PutItemRequest request = new PutItemRequest(); request.setTableName(this.table.name()); request.setItem( new Attributes() .with(DyLocks.HASH, this.owner) .with(DyLocks.RANGE, name) .with(DyLocks.ATTR_LABEL, label) ); request.setExpected( new ImmutableMap.Builder<String, ExpectedAttributeValue>().put( DyLocks.ATTR_LABEL, new ExpectedAttributeValue().withExists(false) ).build() ); aws.putItem(request); } catch (final ConditionalCheckFailedException ex) { msg = ex.getLocalizedMessage(); } catch (final AmazonClientException ex) { throw new IOException(ex); } finally { aws.shutdown(); } return msg; }
try { final PutItemRequest request = new PutItemRequest(); request.setTableName(this.self); request.setItem(attributes); request.setReturnValues(ReturnValue.NONE);
try { final PutItemRequest request = new PutItemRequest(); request.setTableName(this.self); request.setItem(attributes); request.setReturnValues(ReturnValue.NONE);