software.amazon.awssdk.services.dynamodb.model.UpdateTableRequest 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.util.Arrays;
import java.util.Collection;
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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents the input of an UpdateTable
operation.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class UpdateTableRequest extends DynamoDbRequest implements
ToCopyableBuilder {
private static final SdkField> ATTRIBUTE_DEFINITIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(UpdateTableRequest::attributeDefinitions))
.setter(setter(Builder::attributeDefinitions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AttributeDefinitions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AttributeDefinition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField TABLE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(UpdateTableRequest::tableName)).setter(setter(Builder::tableName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TableName").build()).build();
private static final SdkField BILLING_MODE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(UpdateTableRequest::billingModeAsString)).setter(setter(Builder::billingMode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BillingMode").build()).build();
private static final SdkField PROVISIONED_THROUGHPUT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(UpdateTableRequest::provisionedThroughput))
.setter(setter(Builder::provisionedThroughput)).constructor(ProvisionedThroughput::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ProvisionedThroughput").build())
.build();
private static final SdkField> GLOBAL_SECONDARY_INDEX_UPDATES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(UpdateTableRequest::globalSecondaryIndexUpdates))
.setter(setter(Builder::globalSecondaryIndexUpdates))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GlobalSecondaryIndexUpdates")
.build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(GlobalSecondaryIndexUpdate::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField STREAM_SPECIFICATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(UpdateTableRequest::streamSpecification))
.setter(setter(Builder::streamSpecification)).constructor(StreamSpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StreamSpecification").build())
.build();
private static final SdkField SSE_SPECIFICATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(UpdateTableRequest::sseSpecification))
.setter(setter(Builder::sseSpecification)).constructor(SSESpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SSESpecification").build()).build();
private static final SdkField> REPLICA_UPDATES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(UpdateTableRequest::replicaUpdates))
.setter(setter(Builder::replicaUpdates))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaUpdates").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ReplicationGroupUpdate::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ATTRIBUTE_DEFINITIONS_FIELD,
TABLE_NAME_FIELD, BILLING_MODE_FIELD, PROVISIONED_THROUGHPUT_FIELD, GLOBAL_SECONDARY_INDEX_UPDATES_FIELD,
STREAM_SPECIFICATION_FIELD, SSE_SPECIFICATION_FIELD, REPLICA_UPDATES_FIELD));
private final List attributeDefinitions;
private final String tableName;
private final String billingMode;
private final ProvisionedThroughput provisionedThroughput;
private final List globalSecondaryIndexUpdates;
private final StreamSpecification streamSpecification;
private final SSESpecification sseSpecification;
private final List replicaUpdates;
private UpdateTableRequest(BuilderImpl builder) {
super(builder);
this.attributeDefinitions = builder.attributeDefinitions;
this.tableName = builder.tableName;
this.billingMode = builder.billingMode;
this.provisionedThroughput = builder.provisionedThroughput;
this.globalSecondaryIndexUpdates = builder.globalSecondaryIndexUpdates;
this.streamSpecification = builder.streamSpecification;
this.sseSpecification = builder.sseSpecification;
this.replicaUpdates = builder.replicaUpdates;
}
/**
* Returns true if the AttributeDefinitions property was specified by the sender (it may be empty), or false if the
* sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasAttributeDefinitions() {
return attributeDefinitions != null && !(attributeDefinitions instanceof SdkAutoConstructList);
}
/**
*
* An array of attributes that describe the key schema for the table and indexes. If you are adding a new global
* secondary index to the table, AttributeDefinitions
must include the key element(s) of the new index.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasAttributeDefinitions()} to see if a value was sent in this field.
*
*
* @return An array of attributes that describe the key schema for the table and indexes. If you are adding a new
* global secondary index to the table, AttributeDefinitions
must include the key element(s) of
* the new index.
*/
public List attributeDefinitions() {
return attributeDefinitions;
}
/**
*
* The name of the table to be updated.
*
*
* @return The name of the table to be updated.
*/
public String tableName() {
return tableName;
}
/**
*
* Controls how you are charged for read and write throughput and how you manage capacity. When switching from
* pay-per-request to provisioned capacity, initial provisioned capacity values must be set. The initial provisioned
* capacity values are estimated based on the consumed read and write capacity of your table and global secondary
* indexes over the past 30 minutes.
*
*
* -
*
* PROVISIONED
- We recommend using PROVISIONED
for predictable workloads.
* PROVISIONED
sets the billing mode to Provisioned Mode.
*
*
* -
*
* PAY_PER_REQUEST
- We recommend using PAY_PER_REQUEST
for unpredictable workloads.
* PAY_PER_REQUEST
sets the billing mode to On-Demand Mode.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #billingMode} will
* return {@link BillingMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #billingModeAsString}.
*
*
* @return Controls how you are charged for read and write throughput and how you manage capacity. When switching
* from pay-per-request to provisioned capacity, initial provisioned capacity values must be set. The
* initial provisioned capacity values are estimated based on the consumed read and write capacity of your
* table and global secondary indexes over the past 30 minutes.
*
* -
*
* PROVISIONED
- We recommend using PROVISIONED
for predictable workloads.
* PROVISIONED
sets the billing mode to Provisioned Mode.
*
*
* -
*
* PAY_PER_REQUEST
- We recommend using PAY_PER_REQUEST
for unpredictable
* workloads. PAY_PER_REQUEST
sets the billing mode to On-Demand Mode.
*
*
* @see BillingMode
*/
public BillingMode billingMode() {
return BillingMode.fromValue(billingMode);
}
/**
*
* Controls how you are charged for read and write throughput and how you manage capacity. When switching from
* pay-per-request to provisioned capacity, initial provisioned capacity values must be set. The initial provisioned
* capacity values are estimated based on the consumed read and write capacity of your table and global secondary
* indexes over the past 30 minutes.
*
*
* -
*
* PROVISIONED
- We recommend using PROVISIONED
for predictable workloads.
* PROVISIONED
sets the billing mode to Provisioned Mode.
*
*
* -
*
* PAY_PER_REQUEST
- We recommend using PAY_PER_REQUEST
for unpredictable workloads.
* PAY_PER_REQUEST
sets the billing mode to On-Demand Mode.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #billingMode} will
* return {@link BillingMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #billingModeAsString}.
*
*
* @return Controls how you are charged for read and write throughput and how you manage capacity. When switching
* from pay-per-request to provisioned capacity, initial provisioned capacity values must be set. The
* initial provisioned capacity values are estimated based on the consumed read and write capacity of your
* table and global secondary indexes over the past 30 minutes.
*
* -
*
* PROVISIONED
- We recommend using PROVISIONED
for predictable workloads.
* PROVISIONED
sets the billing mode to Provisioned Mode.
*
*
* -
*
* PAY_PER_REQUEST
- We recommend using PAY_PER_REQUEST
for unpredictable
* workloads. PAY_PER_REQUEST
sets the billing mode to On-Demand Mode.
*
*
* @see BillingMode
*/
public String billingModeAsString() {
return billingMode;
}
/**
*
* The new provisioned throughput settings for the specified table or index.
*
*
* @return The new provisioned throughput settings for the specified table or index.
*/
public ProvisionedThroughput provisionedThroughput() {
return provisionedThroughput;
}
/**
* Returns true if the GlobalSecondaryIndexUpdates property was specified by the sender (it may be empty), or false
* if the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the
* AWS service.
*/
public boolean hasGlobalSecondaryIndexUpdates() {
return globalSecondaryIndexUpdates != null && !(globalSecondaryIndexUpdates instanceof SdkAutoConstructList);
}
/**
*
* An array of one or more global secondary indexes for the table. For each index in the array, you can request one
* action:
*
*
* -
*
* Create
- add a new global secondary index to the table.
*
*
* -
*
* Update
- modify the provisioned throughput settings of an existing global secondary index.
*
*
* -
*
* Delete
- remove a global secondary index from the table.
*
*
*
*
* You can create or delete only one global secondary index per UpdateTable
operation.
*
*
* For more information, see Managing Global
* Secondary Indexes in the Amazon DynamoDB Developer Guide.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasGlobalSecondaryIndexUpdates()} to see if a value was sent in this field.
*
*
* @return An array of one or more global secondary indexes for the table. For each index in the array, you can
* request one action:
*
* -
*
* Create
- add a new global secondary index to the table.
*
*
* -
*
* Update
- modify the provisioned throughput settings of an existing global secondary index.
*
*
* -
*
* Delete
- remove a global secondary index from the table.
*
*
*
*
* You can create or delete only one global secondary index per UpdateTable
operation.
*
*
* For more information, see Managing
* Global Secondary Indexes in the Amazon DynamoDB Developer Guide.
*/
public List globalSecondaryIndexUpdates() {
return globalSecondaryIndexUpdates;
}
/**
*
* Represents the DynamoDB Streams configuration for the table.
*
*
*
* You receive a ResourceInUseException
if you try to enable a stream on a table that already has a
* stream, or if you try to disable a stream on a table that doesn't have a stream.
*
*
*
* @return Represents the DynamoDB Streams configuration for the table.
*
* You receive a ResourceInUseException
if you try to enable a stream on a table that already
* has a stream, or if you try to disable a stream on a table that doesn't have a stream.
*
*/
public StreamSpecification streamSpecification() {
return streamSpecification;
}
/**
*
* The new server-side encryption settings for the specified table.
*
*
* @return The new server-side encryption settings for the specified table.
*/
public SSESpecification sseSpecification() {
return sseSpecification;
}
/**
* Returns true if the ReplicaUpdates property was specified by the sender (it may be empty), or false if the sender
* did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public boolean hasReplicaUpdates() {
return replicaUpdates != null && !(replicaUpdates instanceof SdkAutoConstructList);
}
/**
*
* A list of replica update actions (create, delete, or update) for the table.
*
*
*
* This property only applies to Version
* 2019.11.21 of global tables.
*
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasReplicaUpdates()} to see if a value was sent in this field.
*
*
* @return A list of replica update actions (create, delete, or update) for the table.
*
* This property only applies to Version
* 2019.11.21 of global tables.
*
*/
public List replicaUpdates() {
return replicaUpdates;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(attributeDefinitions());
hashCode = 31 * hashCode + Objects.hashCode(tableName());
hashCode = 31 * hashCode + Objects.hashCode(billingModeAsString());
hashCode = 31 * hashCode + Objects.hashCode(provisionedThroughput());
hashCode = 31 * hashCode + Objects.hashCode(globalSecondaryIndexUpdates());
hashCode = 31 * hashCode + Objects.hashCode(streamSpecification());
hashCode = 31 * hashCode + Objects.hashCode(sseSpecification());
hashCode = 31 * hashCode + Objects.hashCode(replicaUpdates());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof UpdateTableRequest)) {
return false;
}
UpdateTableRequest other = (UpdateTableRequest) obj;
return Objects.equals(attributeDefinitions(), other.attributeDefinitions())
&& Objects.equals(tableName(), other.tableName())
&& Objects.equals(billingModeAsString(), other.billingModeAsString())
&& Objects.equals(provisionedThroughput(), other.provisionedThroughput())
&& Objects.equals(globalSecondaryIndexUpdates(), other.globalSecondaryIndexUpdates())
&& Objects.equals(streamSpecification(), other.streamSpecification())
&& Objects.equals(sseSpecification(), other.sseSpecification())
&& Objects.equals(replicaUpdates(), other.replicaUpdates());
}
/**
* 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("UpdateTableRequest").add("AttributeDefinitions", attributeDefinitions())
.add("TableName", tableName()).add("BillingMode", billingModeAsString())
.add("ProvisionedThroughput", provisionedThroughput())
.add("GlobalSecondaryIndexUpdates", globalSecondaryIndexUpdates())
.add("StreamSpecification", streamSpecification()).add("SSESpecification", sseSpecification())
.add("ReplicaUpdates", replicaUpdates()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AttributeDefinitions":
return Optional.ofNullable(clazz.cast(attributeDefinitions()));
case "TableName":
return Optional.ofNullable(clazz.cast(tableName()));
case "BillingMode":
return Optional.ofNullable(clazz.cast(billingModeAsString()));
case "ProvisionedThroughput":
return Optional.ofNullable(clazz.cast(provisionedThroughput()));
case "GlobalSecondaryIndexUpdates":
return Optional.ofNullable(clazz.cast(globalSecondaryIndexUpdates()));
case "StreamSpecification":
return Optional.ofNullable(clazz.cast(streamSpecification()));
case "SSESpecification":
return Optional.ofNullable(clazz.cast(sseSpecification()));
case "ReplicaUpdates":
return Optional.ofNullable(clazz.cast(replicaUpdates()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function