Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.dynamodb.model.BatchWriteItemRequest Maven / Gradle / Ivy
/*
* Copyright 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.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
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 static final SdkField>> REQUEST_ITEMS_FIELD = SdkField
.>> builder(MarshallingType.MAP)
.memberName("RequestItems")
.getter(getter(BatchWriteItemRequest::requestItems))
.setter(setter(Builder::requestItems))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RequestItems").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField.> builder(MarshallingType.LIST)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(WriteRequest::builder)
.traits(LocationTrait.builder()
.location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build())
.build()).build()).build()).build();
private static final SdkField RETURN_CONSUMED_CAPACITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReturnConsumedCapacity").getter(getter(BatchWriteItemRequest::returnConsumedCapacityAsString))
.setter(setter(Builder::returnConsumedCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReturnConsumedCapacity").build())
.build();
private static final SdkField RETURN_ITEM_COLLECTION_METRICS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ReturnItemCollectionMetrics")
.getter(getter(BatchWriteItemRequest::returnItemCollectionMetricsAsString))
.setter(setter(Builder::returnItemCollectionMetrics))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReturnItemCollectionMetrics")
.build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(REQUEST_ITEMS_FIELD,
RETURN_CONSUMED_CAPACITY_FIELD, RETURN_ITEM_COLLECTION_METRICS_FIELD));
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;
}
/**
* For responses, this returns true if the service returned a value for the RequestItems property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasRequestItems() {
return requestItems != null && !(requestItems instanceof SdkAutoConstructMap);
}
/**
*
* A map of one or more table names or table ARNs 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 are 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.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasRequestItems} method.
*
*
* @return A map of one or more table names or table ARNs 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 are 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 final 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 final 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 final 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 final 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 final 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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(hasRequestItems() ? requestItems() : null);
hashCode = 31 * hashCode + Objects.hashCode(returnConsumedCapacityAsString());
hashCode = 31 * hashCode + Objects.hashCode(returnItemCollectionMetricsAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof BatchWriteItemRequest)) {
return false;
}
BatchWriteItemRequest other = (BatchWriteItemRequest) obj;
return hasRequestItems() == other.hasRequestItems() && Objects.equals(requestItems(), other.requestItems())
&& Objects.equals(returnConsumedCapacityAsString(), other.returnConsumedCapacityAsString())
&& Objects.equals(returnItemCollectionMetricsAsString(), other.returnItemCollectionMetricsAsString());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("BatchWriteItemRequest").add("RequestItems", hasRequestItems() ? requestItems() : null)
.add("ReturnConsumedCapacity", returnConsumedCapacityAsString())
.add("ReturnItemCollectionMetrics", returnItemCollectionMetricsAsString()).build();
}
public final 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();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((BatchWriteItemRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends DynamoDbRequest.Builder, SdkPojo, CopyableBuilder {
/**
*
* A map of one or more table names or table ARNs 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 are
* 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 or table ARNs 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 are 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() {
Map> result = BatchWriteItemRequestMapCopier.copyToBuilder(this.requestItems);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setRequestItems(Map> requestItems) {
this.requestItems = BatchWriteItemRequestMapCopier.copyFromBuilder(requestItems);
}
@Override
public final Builder requestItems(Map> requestItems) {
this.requestItems = BatchWriteItemRequestMapCopier.copy(requestItems);
return this;
}
public final String getReturnConsumedCapacity() {
return returnConsumedCapacity;
}
public final void setReturnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
}
@Override
public final Builder returnConsumedCapacity(String returnConsumedCapacity) {
this.returnConsumedCapacity = returnConsumedCapacity;
return this;
}
@Override
public final Builder returnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity) {
this.returnConsumedCapacity(returnConsumedCapacity == null ? null : returnConsumedCapacity.toString());
return this;
}
public final String getReturnItemCollectionMetrics() {
return returnItemCollectionMetrics;
}
public final void setReturnItemCollectionMetrics(String returnItemCollectionMetrics) {
this.returnItemCollectionMetrics = returnItemCollectionMetrics;
}
@Override
public final Builder returnItemCollectionMetrics(String returnItemCollectionMetrics) {
this.returnItemCollectionMetrics = returnItemCollectionMetrics;
return this;
}
@Override
public final Builder returnItemCollectionMetrics(ReturnItemCollectionMetrics returnItemCollectionMetrics) {
this.returnItemCollectionMetrics(returnItemCollectionMetrics == null ? null : returnItemCollectionMetrics.toString());
return this;
}
@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);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}