All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.dynamodb.model.UpdateItemResponse 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.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.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.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 output of an UpdateItem operation. *

*/ @Generated("software.amazon.awssdk:codegen") public final class UpdateItemResponse extends DynamoDbResponse implements ToCopyableBuilder { private static final SdkField> ATTRIBUTES_FIELD = SdkField .> builder(MarshallingType.MAP) .memberName("Attributes") .getter(getter(UpdateItemResponse::attributes)) .setter(setter(Builder::attributes)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Attributes").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(AttributeValue::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField CONSUMED_CAPACITY_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("ConsumedCapacity") .getter(getter(UpdateItemResponse::consumedCapacity)).setter(setter(Builder::consumedCapacity)) .constructor(ConsumedCapacity::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConsumedCapacity").build()).build(); private static final SdkField ITEM_COLLECTION_METRICS_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("ItemCollectionMetrics") .getter(getter(UpdateItemResponse::itemCollectionMetrics)).setter(setter(Builder::itemCollectionMetrics)) .constructor(ItemCollectionMetrics::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ItemCollectionMetrics").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ATTRIBUTES_FIELD, CONSUMED_CAPACITY_FIELD, ITEM_COLLECTION_METRICS_FIELD)); private final Map attributes; private final ConsumedCapacity consumedCapacity; private final ItemCollectionMetrics itemCollectionMetrics; private UpdateItemResponse(BuilderImpl builder) { super(builder); this.attributes = builder.attributes; this.consumedCapacity = builder.consumedCapacity; this.itemCollectionMetrics = builder.itemCollectionMetrics; } /** * For responses, this returns true if the service returned a value for the Attributes 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 hasAttributes() { return attributes != null && !(attributes instanceof SdkAutoConstructMap); } /** *

* A map of attribute values as they appear before or after the UpdateItem operation, as determined by * the ReturnValues parameter. *

*

* The Attributes map is only present if the update was successful and ReturnValues was * specified as something other than NONE in the request. Each element represents one attribute. *

*

* 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 #hasAttributes} method. *

* * @return A map of attribute values as they appear before or after the UpdateItem operation, as * determined by the ReturnValues parameter.

*

* The Attributes map is only present if the update was successful and * ReturnValues was specified as something other than NONE in the request. Each * element represents one attribute. */ public final Map attributes() { return attributes; } /** *

* The capacity units consumed by the UpdateItem operation. The data returned includes the total * provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. * ConsumedCapacity is only returned if the ReturnConsumedCapacity parameter was * specified. For more information, see Capacity unity consumption for write operations in the Amazon DynamoDB Developer Guide. *

* * @return The capacity units consumed by the UpdateItem operation. The data returned includes the * total provisioned throughput consumed, along with statistics for the table and any indexes involved in * the operation. ConsumedCapacity is only returned if the ReturnConsumedCapacity * parameter was specified. For more information, see Capacity unity consumption for write operations in the Amazon DynamoDB Developer Guide. */ public final ConsumedCapacity consumedCapacity() { return consumedCapacity; } /** *

* Information about item collections, if any, that were affected by the UpdateItem operation. * ItemCollectionMetrics is only returned if the ReturnItemCollectionMetrics parameter was * specified. If the table does not have any local secondary indexes, this information is not returned in the * response. *

*

* Each ItemCollectionMetrics element consists of: *

*
    *
  • *

    * ItemCollectionKey - The partition key value of the item collection. This is the same as the * partition key value of the item itself. *

    *
  • *
  • *

    * SizeEstimateRangeGB - An estimate of item collection size, in gigabytes. This value is a two-element * array containing a lower bound and an upper bound for the estimate. The estimate includes the size of all the * items in the table, plus the size of all attributes projected into all of the local secondary indexes on that * table. Use this estimate to measure whether a local secondary index is approaching its size limit. *

    *

    * The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate. *

    *
  • *
* * @return Information about item collections, if any, that were affected by the UpdateItem operation. * ItemCollectionMetrics is only returned if the ReturnItemCollectionMetrics * parameter was specified. If the table does not have any local secondary indexes, this information is not * returned in the response.

*

* Each ItemCollectionMetrics element consists of: *

*
    *
  • *

    * ItemCollectionKey - The partition key value of the item collection. This is the same as the * partition key value of the item itself. *

    *
  • *
  • *

    * SizeEstimateRangeGB - An estimate of item collection size, in gigabytes. This value is a * two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the * size of all the items in the table, plus the size of all attributes projected into all of the local * secondary indexes on that table. Use this estimate to measure whether a local secondary index is * approaching its size limit. *

    *

    * The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the * estimate. *

    *
  • */ public final ItemCollectionMetrics itemCollectionMetrics() { return itemCollectionMetrics; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(hasAttributes() ? attributes() : null); hashCode = 31 * hashCode + Objects.hashCode(consumedCapacity()); hashCode = 31 * hashCode + Objects.hashCode(itemCollectionMetrics()); 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 UpdateItemResponse)) { return false; } UpdateItemResponse other = (UpdateItemResponse) obj; return hasAttributes() == other.hasAttributes() && Objects.equals(attributes(), other.attributes()) && Objects.equals(consumedCapacity(), other.consumedCapacity()) && Objects.equals(itemCollectionMetrics(), other.itemCollectionMetrics()); } /** * 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("UpdateItemResponse").add("Attributes", hasAttributes() ? attributes() : null) .add("ConsumedCapacity", consumedCapacity()).add("ItemCollectionMetrics", itemCollectionMetrics()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Attributes": return Optional.ofNullable(clazz.cast(attributes())); case "ConsumedCapacity": return Optional.ofNullable(clazz.cast(consumedCapacity())); case "ItemCollectionMetrics": return Optional.ofNullable(clazz.cast(itemCollectionMetrics())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((UpdateItemResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends DynamoDbResponse.Builder, SdkPojo, CopyableBuilder { /** *

    * A map of attribute values as they appear before or after the UpdateItem operation, as determined * by the ReturnValues parameter. *

    *

    * The Attributes map is only present if the update was successful and ReturnValues * was specified as something other than NONE in the request. Each element represents one * attribute. *

    * * @param attributes * A map of attribute values as they appear before or after the UpdateItem operation, as * determined by the ReturnValues parameter.

    *

    * The Attributes map is only present if the update was successful and * ReturnValues was specified as something other than NONE in the request. Each * element represents one attribute. * @return Returns a reference to this object so that method calls can be chained together. */ Builder attributes(Map attributes); /** *

    * The capacity units consumed by the UpdateItem operation. The data returned includes the total * provisioned throughput consumed, along with statistics for the table and any indexes involved in the * operation. ConsumedCapacity is only returned if the ReturnConsumedCapacity * parameter was specified. For more information, see Capacity unity consumption for write operations in the Amazon DynamoDB Developer Guide. *

    * * @param consumedCapacity * The capacity units consumed by the UpdateItem operation. The data returned includes the * total provisioned throughput consumed, along with statistics for the table and any indexes involved in * the operation. ConsumedCapacity is only returned if the * ReturnConsumedCapacity parameter was specified. For more information, see Capacity unity consumption for write operations in the Amazon DynamoDB Developer Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder consumedCapacity(ConsumedCapacity consumedCapacity); /** *

    * The capacity units consumed by the UpdateItem operation. The data returned includes the total * provisioned throughput consumed, along with statistics for the table and any indexes involved in the * operation. ConsumedCapacity is only returned if the ReturnConsumedCapacity * parameter was specified. For more information, see Capacity unity consumption for write operations in the Amazon DynamoDB Developer Guide. *

    * This is a convenience method that creates an instance of the {@link ConsumedCapacity.Builder} avoiding the * need to create one manually via {@link ConsumedCapacity#builder()}. * *

    * When the {@link Consumer} completes, {@link ConsumedCapacity.Builder#build()} is called immediately and its * result is passed to {@link #consumedCapacity(ConsumedCapacity)}. * * @param consumedCapacity * a consumer that will call methods on {@link ConsumedCapacity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #consumedCapacity(ConsumedCapacity) */ default Builder consumedCapacity(Consumer consumedCapacity) { return consumedCapacity(ConsumedCapacity.builder().applyMutation(consumedCapacity).build()); } /** *

    * Information about item collections, if any, that were affected by the UpdateItem operation. * ItemCollectionMetrics is only returned if the ReturnItemCollectionMetrics parameter * was specified. If the table does not have any local secondary indexes, this information is not returned in * the response. *

    *

    * Each ItemCollectionMetrics element consists of: *

    *
      *
    • *

      * ItemCollectionKey - The partition key value of the item collection. This is the same as the * partition key value of the item itself. *

      *
    • *
    • *

      * SizeEstimateRangeGB - An estimate of item collection size, in gigabytes. This value is a * two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the * size of all the items in the table, plus the size of all attributes projected into all of the local secondary * indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size * limit. *

      *

      * The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the * estimate. *

      *
    • *
    * * @param itemCollectionMetrics * Information about item collections, if any, that were affected by the UpdateItem * operation. ItemCollectionMetrics is only returned if the * ReturnItemCollectionMetrics parameter was specified. If the table does not have any local * secondary indexes, this information is not returned in the response.

    *

    * Each ItemCollectionMetrics element consists of: *

    *
      *
    • *

      * ItemCollectionKey - The partition key value of the item collection. This is the same as * the partition key value of the item itself. *

      *
    • *
    • *

      * SizeEstimateRangeGB - An estimate of item collection size, in gigabytes. This value is a * two-element array containing a lower bound and an upper bound for the estimate. The estimate includes * the size of all the items in the table, plus the size of all attributes projected into all of the * local secondary indexes on that table. Use this estimate to measure whether a local secondary index is * approaching its size limit. *

      *

      * The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of * the estimate. *

      *
    • * @return Returns a reference to this object so that method calls can be chained together. */ Builder itemCollectionMetrics(ItemCollectionMetrics itemCollectionMetrics); /** *

      * Information about item collections, if any, that were affected by the UpdateItem operation. * ItemCollectionMetrics is only returned if the ReturnItemCollectionMetrics parameter * was specified. If the table does not have any local secondary indexes, this information is not returned in * the response. *

      *

      * Each ItemCollectionMetrics element consists of: *

      *
        *
      • *

        * ItemCollectionKey - The partition key value of the item collection. This is the same as the * partition key value of the item itself. *

        *
      • *
      • *

        * SizeEstimateRangeGB - An estimate of item collection size, in gigabytes. This value is a * two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the * size of all the items in the table, plus the size of all attributes projected into all of the local secondary * indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size * limit. *

        *

        * The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the * estimate. *

        *
      • *
      * This is a convenience method that creates an instance of the {@link ItemCollectionMetrics.Builder} avoiding * the need to create one manually via {@link ItemCollectionMetrics#builder()}. * *

      * When the {@link Consumer} completes, {@link ItemCollectionMetrics.Builder#build()} is called immediately and * its result is passed to {@link #itemCollectionMetrics(ItemCollectionMetrics)}. * * @param itemCollectionMetrics * a consumer that will call methods on {@link ItemCollectionMetrics.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #itemCollectionMetrics(ItemCollectionMetrics) */ default Builder itemCollectionMetrics(Consumer itemCollectionMetrics) { return itemCollectionMetrics(ItemCollectionMetrics.builder().applyMutation(itemCollectionMetrics).build()); } } static final class BuilderImpl extends DynamoDbResponse.BuilderImpl implements Builder { private Map attributes = DefaultSdkAutoConstructMap.getInstance(); private ConsumedCapacity consumedCapacity; private ItemCollectionMetrics itemCollectionMetrics; private BuilderImpl() { } private BuilderImpl(UpdateItemResponse model) { super(model); attributes(model.attributes); consumedCapacity(model.consumedCapacity); itemCollectionMetrics(model.itemCollectionMetrics); } public final Map getAttributes() { Map result = AttributeMapCopier.copyToBuilder(this.attributes); if (result instanceof SdkAutoConstructMap) { return null; } return result; } public final void setAttributes(Map attributes) { this.attributes = AttributeMapCopier.copyFromBuilder(attributes); } @Override public final Builder attributes(Map attributes) { this.attributes = AttributeMapCopier.copy(attributes); return this; } public final ConsumedCapacity.Builder getConsumedCapacity() { return consumedCapacity != null ? consumedCapacity.toBuilder() : null; } public final void setConsumedCapacity(ConsumedCapacity.BuilderImpl consumedCapacity) { this.consumedCapacity = consumedCapacity != null ? consumedCapacity.build() : null; } @Override public final Builder consumedCapacity(ConsumedCapacity consumedCapacity) { this.consumedCapacity = consumedCapacity; return this; } public final ItemCollectionMetrics.Builder getItemCollectionMetrics() { return itemCollectionMetrics != null ? itemCollectionMetrics.toBuilder() : null; } public final void setItemCollectionMetrics(ItemCollectionMetrics.BuilderImpl itemCollectionMetrics) { this.itemCollectionMetrics = itemCollectionMetrics != null ? itemCollectionMetrics.build() : null; } @Override public final Builder itemCollectionMetrics(ItemCollectionMetrics itemCollectionMetrics) { this.itemCollectionMetrics = itemCollectionMetrics; return this; } @Override public UpdateItemResponse build() { return new UpdateItemResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy