software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughputDescription Maven / Gradle / Ivy
Show all versions of dynamodb Show documentation
/*
* 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.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the provisioned throughput settings for the table, consisting of read and write capacity units, along with
* data about increases and decreases.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ProvisionedThroughputDescription implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField LAST_INCREASE_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(ProvisionedThroughputDescription::lastIncreaseDateTime)).setter(setter(Builder::lastIncreaseDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastIncreaseDateTime").build())
.build();
private static final SdkField LAST_DECREASE_DATE_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(ProvisionedThroughputDescription::lastDecreaseDateTime)).setter(setter(Builder::lastDecreaseDateTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastDecreaseDateTime").build())
.build();
private static final SdkField NUMBER_OF_DECREASES_TODAY_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(ProvisionedThroughputDescription::numberOfDecreasesToday))
.setter(setter(Builder::numberOfDecreasesToday))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NumberOfDecreasesToday").build())
.build();
private static final SdkField READ_CAPACITY_UNITS_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(ProvisionedThroughputDescription::readCapacityUnits)).setter(setter(Builder::readCapacityUnits))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReadCapacityUnits").build()).build();
private static final SdkField WRITE_CAPACITY_UNITS_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(ProvisionedThroughputDescription::writeCapacityUnits)).setter(setter(Builder::writeCapacityUnits))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WriteCapacityUnits").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays
.asList(LAST_INCREASE_DATE_TIME_FIELD, LAST_DECREASE_DATE_TIME_FIELD, NUMBER_OF_DECREASES_TODAY_FIELD,
READ_CAPACITY_UNITS_FIELD, WRITE_CAPACITY_UNITS_FIELD));
private static final long serialVersionUID = 1L;
private final Instant lastIncreaseDateTime;
private final Instant lastDecreaseDateTime;
private final Long numberOfDecreasesToday;
private final Long readCapacityUnits;
private final Long writeCapacityUnits;
private ProvisionedThroughputDescription(BuilderImpl builder) {
this.lastIncreaseDateTime = builder.lastIncreaseDateTime;
this.lastDecreaseDateTime = builder.lastDecreaseDateTime;
this.numberOfDecreasesToday = builder.numberOfDecreasesToday;
this.readCapacityUnits = builder.readCapacityUnits;
this.writeCapacityUnits = builder.writeCapacityUnits;
}
/**
*
* The date and time of the last provisioned throughput increase for this table.
*
*
* @return The date and time of the last provisioned throughput increase for this table.
*/
public Instant lastIncreaseDateTime() {
return lastIncreaseDateTime;
}
/**
*
* The date and time of the last provisioned throughput decrease for this table.
*
*
* @return The date and time of the last provisioned throughput decrease for this table.
*/
public Instant lastDecreaseDateTime() {
return lastDecreaseDateTime;
}
/**
*
* The number of provisioned throughput decreases for this table during this UTC calendar day. For current maximums
* on provisioned throughput decreases, see Limits in the Amazon
* DynamoDB Developer Guide.
*
*
* @return The number of provisioned throughput decreases for this table during this UTC calendar day. For current
* maximums on provisioned throughput decreases, see Limits in the
* Amazon DynamoDB Developer Guide.
*/
public Long numberOfDecreasesToday() {
return numberOfDecreasesToday;
}
/**
*
* The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. Eventually consistent reads require less effort than strongly consistent reads,
* so a setting of 50 ReadCapacityUnits
per second provides 100 eventually consistent
* ReadCapacityUnits
per second.
*
*
* @return The maximum number of strongly consistent reads consumed per second before DynamoDB returns a
* ThrottlingException
. Eventually consistent reads require less effort than strongly
* consistent reads, so a setting of 50 ReadCapacityUnits
per second provides 100 eventually
* consistent ReadCapacityUnits
per second.
*/
public Long readCapacityUnits() {
return readCapacityUnits;
}
/**
*
* The maximum number of writes consumed per second before DynamoDB returns a ThrottlingException
.
*
*
* @return The maximum number of writes consumed per second before DynamoDB returns a
* ThrottlingException
.
*/
public Long writeCapacityUnits() {
return writeCapacityUnits;
}
@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(lastIncreaseDateTime());
hashCode = 31 * hashCode + Objects.hashCode(lastDecreaseDateTime());
hashCode = 31 * hashCode + Objects.hashCode(numberOfDecreasesToday());
hashCode = 31 * hashCode + Objects.hashCode(readCapacityUnits());
hashCode = 31 * hashCode + Objects.hashCode(writeCapacityUnits());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ProvisionedThroughputDescription)) {
return false;
}
ProvisionedThroughputDescription other = (ProvisionedThroughputDescription) obj;
return Objects.equals(lastIncreaseDateTime(), other.lastIncreaseDateTime())
&& Objects.equals(lastDecreaseDateTime(), other.lastDecreaseDateTime())
&& Objects.equals(numberOfDecreasesToday(), other.numberOfDecreasesToday())
&& Objects.equals(readCapacityUnits(), other.readCapacityUnits())
&& Objects.equals(writeCapacityUnits(), other.writeCapacityUnits());
}
/**
* 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 String toString() {
return ToString.builder("ProvisionedThroughputDescription").add("LastIncreaseDateTime", lastIncreaseDateTime())
.add("LastDecreaseDateTime", lastDecreaseDateTime()).add("NumberOfDecreasesToday", numberOfDecreasesToday())
.add("ReadCapacityUnits", readCapacityUnits()).add("WriteCapacityUnits", writeCapacityUnits()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "LastIncreaseDateTime":
return Optional.ofNullable(clazz.cast(lastIncreaseDateTime()));
case "LastDecreaseDateTime":
return Optional.ofNullable(clazz.cast(lastDecreaseDateTime()));
case "NumberOfDecreasesToday":
return Optional.ofNullable(clazz.cast(numberOfDecreasesToday()));
case "ReadCapacityUnits":
return Optional.ofNullable(clazz.cast(readCapacityUnits()));
case "WriteCapacityUnits":
return Optional.ofNullable(clazz.cast(writeCapacityUnits()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function