software.amazon.awssdk.services.elasticache.model.DecreaseReplicaCountRequest Maven / Gradle / Ivy
Show all versions of elasticache Show documentation
/*
* Copyright 2014-2019 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.elasticache.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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class DecreaseReplicaCountRequest extends ElastiCacheRequest implements
ToCopyableBuilder {
private static final SdkField REPLICATION_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(DecreaseReplicaCountRequest::replicationGroupId)).setter(setter(Builder::replicationGroupId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicationGroupId").build())
.build();
private static final SdkField NEW_REPLICA_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(DecreaseReplicaCountRequest::newReplicaCount)).setter(setter(Builder::newReplicaCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NewReplicaCount").build()).build();
private static final SdkField> REPLICA_CONFIGURATION_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(DecreaseReplicaCountRequest::replicaConfiguration))
.setter(setter(Builder::replicaConfiguration))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaConfiguration").build(),
ListTrait
.builder()
.memberLocationName("ConfigureShard")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ConfigureShard::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("ConfigureShard").build()).build()).build()).build();
private static final SdkField> REPLICAS_TO_REMOVE_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(DecreaseReplicaCountRequest::replicasToRemove))
.setter(setter(Builder::replicasToRemove))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicasToRemove").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField APPLY_IMMEDIATELY_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.getter(getter(DecreaseReplicaCountRequest::applyImmediately)).setter(setter(Builder::applyImmediately))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ApplyImmediately").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(REPLICATION_GROUP_ID_FIELD,
NEW_REPLICA_COUNT_FIELD, REPLICA_CONFIGURATION_FIELD, REPLICAS_TO_REMOVE_FIELD, APPLY_IMMEDIATELY_FIELD));
private final String replicationGroupId;
private final Integer newReplicaCount;
private final List replicaConfiguration;
private final List replicasToRemove;
private final Boolean applyImmediately;
private DecreaseReplicaCountRequest(BuilderImpl builder) {
super(builder);
this.replicationGroupId = builder.replicationGroupId;
this.newReplicaCount = builder.newReplicaCount;
this.replicaConfiguration = builder.replicaConfiguration;
this.replicasToRemove = builder.replicasToRemove;
this.applyImmediately = builder.applyImmediately;
}
/**
*
* The id of the replication group from which you want to remove replica nodes.
*
*
* @return The id of the replication group from which you want to remove replica nodes.
*/
public String replicationGroupId() {
return replicationGroupId;
}
/**
*
* The number of read replica nodes you want at the completion of this operation. For Redis (cluster mode disabled)
* replication groups, this is the number of replica nodes in the replication group. For Redis (cluster mode
* enabled) replication groups, this is the number of replica nodes in each of the replication group's node groups.
*
*
* The minimum number of replicas in a shard or replication group is:
*
*
* -
*
* Redis (cluster mode disabled)
*
*
* -
*
* If Multi-AZ with Automatic Failover is enabled: 1
*
*
* -
*
* If Multi-AZ with Automatic Failover is not enabled: 0
*
*
*
*
* -
*
* Redis (cluster mode enabled): 0 (though you will not be able to failover to a replica if your primary node fails)
*
*
*
*
* @return The number of read replica nodes you want at the completion of this operation. For Redis (cluster mode
* disabled) replication groups, this is the number of replica nodes in the replication group. For Redis
* (cluster mode enabled) replication groups, this is the number of replica nodes in each of the replication
* group's node groups.
*
* The minimum number of replicas in a shard or replication group is:
*
*
* -
*
* Redis (cluster mode disabled)
*
*
* -
*
* If Multi-AZ with Automatic Failover is enabled: 1
*
*
* -
*
* If Multi-AZ with Automatic Failover is not enabled: 0
*
*
*
*
* -
*
* Redis (cluster mode enabled): 0 (though you will not be able to failover to a replica if your primary
* node fails)
*
*
*/
public Integer newReplicaCount() {
return newReplicaCount;
}
/**
*
* A list of ConfigureShard
objects that can be used to configure each shard in a Redis (cluster mode
* enabled) replication group. The ConfigureShard
has three members: NewReplicaCount
,
* NodeGroupId
, and PreferredAvailabilityZones
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of ConfigureShard
objects that can be used to configure each shard in a Redis
* (cluster mode enabled) replication group. The ConfigureShard
has three members:
* NewReplicaCount
, NodeGroupId
, and PreferredAvailabilityZones
.
*/
public List replicaConfiguration() {
return replicaConfiguration;
}
/**
*
* A list of the node ids to remove from the replication group or node group (shard).
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of the node ids to remove from the replication group or node group (shard).
*/
public List replicasToRemove() {
return replicasToRemove;
}
/**
*
* If True
, the number of replica nodes is decreased immediately. ApplyImmediately=False
* is not currently supported.
*
*
* @return If True
, the number of replica nodes is decreased immediately.
* ApplyImmediately=False
is not currently supported.
*/
public Boolean applyImmediately() {
return applyImmediately;
}
@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(replicationGroupId());
hashCode = 31 * hashCode + Objects.hashCode(newReplicaCount());
hashCode = 31 * hashCode + Objects.hashCode(replicaConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(replicasToRemove());
hashCode = 31 * hashCode + Objects.hashCode(applyImmediately());
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 DecreaseReplicaCountRequest)) {
return false;
}
DecreaseReplicaCountRequest other = (DecreaseReplicaCountRequest) obj;
return Objects.equals(replicationGroupId(), other.replicationGroupId())
&& Objects.equals(newReplicaCount(), other.newReplicaCount())
&& Objects.equals(replicaConfiguration(), other.replicaConfiguration())
&& Objects.equals(replicasToRemove(), other.replicasToRemove())
&& Objects.equals(applyImmediately(), other.applyImmediately());
}
/**
* 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("DecreaseReplicaCountRequest").add("ReplicationGroupId", replicationGroupId())
.add("NewReplicaCount", newReplicaCount()).add("ReplicaConfiguration", replicaConfiguration())
.add("ReplicasToRemove", replicasToRemove()).add("ApplyImmediately", applyImmediately()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ReplicationGroupId":
return Optional.ofNullable(clazz.cast(replicationGroupId()));
case "NewReplicaCount":
return Optional.ofNullable(clazz.cast(newReplicaCount()));
case "ReplicaConfiguration":
return Optional.ofNullable(clazz.cast(replicaConfiguration()));
case "ReplicasToRemove":
return Optional.ofNullable(clazz.cast(replicasToRemove()));
case "ApplyImmediately":
return Optional.ofNullable(clazz.cast(applyImmediately()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function