
software.amazon.awssdk.services.dynamodb.model.BatchWriteItemRequest Maven / Gradle / Ivy
/*
* Copyright 2013-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.dynamodb.model;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the input of a BatchWriteItem
operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class BatchWriteItemRequest extends DynamoDbRequest implements
ToCopyableBuilder {
private final Map> requestItems;
private final String returnConsumedCapacity;
private final String returnItemCollectionMetrics;
private BatchWriteItemRequest(BuilderImpl builder) {
super(builder);
this.requestItems = builder.requestItems;
this.returnConsumedCapacity = builder.returnConsumedCapacity;
this.returnItemCollectionMetrics = builder.returnItemCollectionMetrics;
}
/**
*
* A map of one or more table names and, for each table, a list of operations to be performed (
* DeleteRequest
or PutRequest
). Each element in the map consists of the following:
*
*
* -
*
* DeleteRequest
- Perform a DeleteItem
operation on the specified item. The item to be
* deleted is identified by a Key
subelement:
*
*
* -
*
* Key
- A map of primary key attribute values that uniquely identify the item. Each entry in this map
* consists of an attribute name and an attribute value. For each primary key, you must provide all of the
* key attributes. 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 values for both the partition key and the sort key.
*
*
*
*
* -
*
* PutRequest
- Perform a PutItem
operation on the specified item. The item to be put is
* identified by an Item
subelement:
*
*
* -
*
* Item
- A map of attributes and their values. Each entry in this map consists of an attribute name
* and an attribute value. Attribute values must not be null; string and binary type attributes must have lengths
* greater than zero; and set type attributes must not be empty. Requests that contain empty values will be rejected
* with a ValidationException
exception.
*
*
* 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.
*
*
*
*
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A map of one or more table names and, for each table, a list of operations to be performed (
* DeleteRequest
or PutRequest
). Each element in the map consists of the
* following:
*
* -
*
* DeleteRequest
- Perform a DeleteItem
operation on the specified item. The item
* to be deleted is identified by a Key
subelement:
*
*
* -
*
* Key
- A map of primary key attribute values that uniquely identify the item. Each entry in
* this map consists of an attribute name and an attribute value. For each primary key, you must provide
* all of the key attributes. 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 values for both the
* partition key and the sort key.
*
*
*
*
* -
*
* PutRequest
- Perform a PutItem
operation on the specified item. The item to be
* put is identified by an Item
subelement:
*
*
* -
*
* Item
- A map of attributes and their values. Each entry in this map consists of an attribute
* name and an attribute value. Attribute values must not be null; string and binary type attributes must
* have lengths greater than zero; and set type attributes must not be empty. Requests that contain empty
* values will be rejected with a ValidationException
exception.
*
*
* 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.
*
*
*
*
*/
public Map> requestItems() {
return requestItems;
}
/**
* Returns the value of the ReturnConsumedCapacity property for this object.
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnConsumedCapacity} will return {@link ReturnConsumedCapacity#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #returnConsumedCapacityAsString}.
*
*
* @return The value of the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
*/
public ReturnConsumedCapacity returnConsumedCapacity() {
return ReturnConsumedCapacity.fromValue(returnConsumedCapacity);
}
/**
* Returns the value of the ReturnConsumedCapacity property for this object.
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnConsumedCapacity} will return {@link ReturnConsumedCapacity#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #returnConsumedCapacityAsString}.
*
*
* @return The value of the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
*/
public String returnConsumedCapacityAsString() {
return returnConsumedCapacity;
}
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the response.
* If set to NONE
(the default), no statistics are returned.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnItemCollectionMetrics} will return {@link ReturnItemCollectionMetrics#UNKNOWN_TO_SDK_VERSION}. The
* raw value returned by the service is available from {@link #returnItemCollectionMetricsAsString}.
*
*
* @return Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are returned
* in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
*/
public ReturnItemCollectionMetrics returnItemCollectionMetrics() {
return ReturnItemCollectionMetrics.fromValue(returnItemCollectionMetrics);
}
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the response.
* If set to NONE
(the default), no statistics are returned.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #returnItemCollectionMetrics} will return {@link ReturnItemCollectionMetrics#UNKNOWN_TO_SDK_VERSION}. The
* raw value returned by the service is available from {@link #returnItemCollectionMetricsAsString}.
*
*
* @return Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are returned
* in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
*/
public String returnItemCollectionMetricsAsString() {
return returnItemCollectionMetrics;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(requestItems());
hashCode = 31 * hashCode + Objects.hashCode(returnConsumedCapacityAsString());
hashCode = 31 * hashCode + Objects.hashCode(returnItemCollectionMetricsAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof BatchWriteItemRequest)) {
return false;
}
BatchWriteItemRequest other = (BatchWriteItemRequest) obj;
return Objects.equals(requestItems(), other.requestItems())
&& Objects.equals(returnConsumedCapacityAsString(), other.returnConsumedCapacityAsString())
&& Objects.equals(returnItemCollectionMetricsAsString(), other.returnItemCollectionMetricsAsString());
}
@Override
public String toString() {
return ToString.builder("BatchWriteItemRequest").add("RequestItems", requestItems())
.add("ReturnConsumedCapacity", returnConsumedCapacityAsString())
.add("ReturnItemCollectionMetrics", returnItemCollectionMetricsAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RequestItems":
return Optional.ofNullable(clazz.cast(requestItems()));
case "ReturnConsumedCapacity":
return Optional.ofNullable(clazz.cast(returnConsumedCapacityAsString()));
case "ReturnItemCollectionMetrics":
return Optional.ofNullable(clazz.cast(returnItemCollectionMetricsAsString()));
default:
return Optional.empty();
}
}
public interface Builder extends DynamoDbRequest.Builder, CopyableBuilder {
/**
*
* A map of one or more table names and, for each table, a list of operations to be performed (
* DeleteRequest
or PutRequest
). Each element in the map consists of the following:
*
*
* -
*
* DeleteRequest
- Perform a DeleteItem
operation on the specified item. The item to
* be deleted is identified by a Key
subelement:
*
*
* -
*
* Key
- A map of primary key attribute values that uniquely identify the item. Each entry in this
* map consists of an attribute name and an attribute value. For each primary key, you must provide all
* of the key attributes. 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 values for both the partition key and the
* sort key.
*
*
*
*
* -
*
* PutRequest
- Perform a PutItem
operation on the specified item. The item to be put
* is identified by an Item
subelement:
*
*
* -
*
* Item
- A map of attributes and their values. Each entry in this map consists of an attribute
* name and an attribute value. Attribute values must not be null; string and binary type attributes must have
* lengths greater than zero; and set type attributes must not be empty. Requests that contain empty values will
* be rejected with a ValidationException
exception.
*
*
* 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.
*
*
*
*
*
*
* @param requestItems
* A map of one or more table names and, for each table, a list of operations to be performed (
* DeleteRequest
or PutRequest
). Each element in the map consists of the
* following:
*
* -
*
* DeleteRequest
- Perform a DeleteItem
operation on the specified item. The
* item to be deleted is identified by a Key
subelement:
*
*
* -
*
* Key
- A map of primary key attribute values that uniquely identify the item. Each entry
* in this map consists of an attribute name and an attribute value. For each primary key, you must
* provide all of the key attributes. 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 values for
* both the partition key and the sort key.
*
*
*
*
* -
*
* PutRequest
- Perform a PutItem
operation on the specified item. The item to
* be put is identified by an Item
subelement:
*
*
* -
*
* Item
- A map of attributes and their values. Each entry in this map consists of an
* attribute name and an attribute value. Attribute values must not be null; string and binary type
* attributes must have lengths greater than zero; and set type attributes must not be empty. Requests
* that contain empty values will be rejected with a ValidationException
exception.
*
*
* 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.
*
*
*
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder requestItems(Map> requestItems);
/**
* Sets the value of the ReturnConsumedCapacity property for this object.
*
* @param returnConsumedCapacity
* The new value for the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnConsumedCapacity
*/
Builder returnConsumedCapacity(String returnConsumedCapacity);
/**
* Sets the value of the ReturnConsumedCapacity property for this object.
*
* @param returnConsumedCapacity
* The new value for the ReturnConsumedCapacity property for this object.
* @see ReturnConsumedCapacity
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnConsumedCapacity
*/
Builder returnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity);
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the
* response. If set to NONE
(the default), no statistics are returned.
*
*
* @param returnItemCollectionMetrics
* Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are
* returned in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnItemCollectionMetrics
*/
Builder returnItemCollectionMetrics(String returnItemCollectionMetrics);
/**
*
* Determines whether item collection metrics are returned. If set to SIZE
, the response includes
* statistics about item collections, if any, that were modified during the operation are returned in the
* response. If set to NONE
(the default), no statistics are returned.
*
*
* @param returnItemCollectionMetrics
* Determines whether item collection metrics are returned. If set to SIZE
, the response
* includes statistics about item collections, if any, that were modified during the operation are
* returned in the response. If set to NONE
(the default), no statistics are returned.
* @see ReturnItemCollectionMetrics
* @return Returns a reference to this object so that method calls can be chained together.
* @see ReturnItemCollectionMetrics
*/
Builder returnItemCollectionMetrics(ReturnItemCollectionMetrics returnItemCollectionMetrics);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends DynamoDbRequest.BuilderImpl implements Builder {
private Map> requestItems = DefaultSdkAutoConstructMap.getInstance();
private String returnConsumedCapacity;
private String returnItemCollectionMetrics;
private BuilderImpl() {
}
private BuilderImpl(BatchWriteItemRequest model) {
super(model);
requestItems(model.requestItems);
returnConsumedCapacity(model.returnConsumedCapacity);
returnItemCollectionMetrics(model.returnItemCollectionMetrics);
}
public final Map> getRequestItems() {
return requestItems;
}
@Override
public final Builder requestItems(Map> requestItems) {
this.requestItems = BatchWriteItemRequestMapCopier.copy(requestItems);
return this;
}
public final void setRequestItems(Map> requestItems) {
this.requestItems = BatchWriteItemRequestMapCopier.copy(requestItems);
}
public final String getReturnConsumedCapacity() {
return returnConsumedCapacity;
}
@Override
public final Builder returnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
return this;
}
@Override
public final Builder returnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity) {
this.returnConsumedCapacity(returnConsumedCapacity.toString());
return this;
}
public final void setReturnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
}
public final String getReturnItemCollectionMetrics() {
return returnItemCollectionMetrics;
}
@Override
public final Builder returnItemCollectionMetrics(String returnItemCollectionMetrics) {
this.returnItemCollectionMetrics = returnItemCollectionMetrics;
return this;
}
@Override
public final Builder returnItemCollectionMetrics(ReturnItemCollectionMetrics returnItemCollectionMetrics) {
this.returnItemCollectionMetrics(returnItemCollectionMetrics.toString());
return this;
}
public final void setReturnItemCollectionMetrics(String returnItemCollectionMetrics) {
this.returnItemCollectionMetrics = returnItemCollectionMetrics;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public BatchWriteItemRequest build() {
return new BatchWriteItemRequest(this);
}
}
}