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

software.amazon.awssdk.services.elasticache.model.DecreaseReplicaCountRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon ElastiCache module holds the client classes that are used for communicating with Amazon ElastiCache Service

The newest version!
/*
 * 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.elasticache.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
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 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;

/**
 */
@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)
            .memberName("ReplicationGroupId").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)
            .memberName("NewReplicaCount").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)
            .memberName("ReplicaConfiguration")
            .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)
            .memberName("ReplicasToRemove")
            .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)
            .memberName("ApplyImmediately").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 static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();

    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 final String replicationGroupId() { return replicationGroupId; } /** *

* The number of read replica nodes you want at the completion of this operation. For Valkey or Redis OSS (cluster * mode disabled) replication groups, this is the number of replica nodes in the replication group. For Valkey or * Redis OSS (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: *

*
    *
  • *

    * Valkey or Redis OSS (cluster mode disabled) *

    *
      *
    • *

      * If Multi-AZ is enabled: 1 *

      *
    • *
    • *

      * If Multi-AZ is not enabled: 0 *

      *
    • *
    *
  • *
  • *

    * Valkey or Redis OSS (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 Valkey or Redis OSS * (cluster mode disabled) replication groups, this is the number of replica nodes in the replication group. * For Valkey or Redis OSS (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: *

*
    *
  • *

    * Valkey or Redis OSS (cluster mode disabled) *

    *
      *
    • *

      * If Multi-AZ is enabled: 1 *

      *
    • *
    • *

      * If Multi-AZ is not enabled: 0 *

      *
    • *
    *
  • *
  • *

    * Valkey or Redis OSS (cluster mode enabled): 0 (though you will not be able to failover to a replica if * your primary node fails) *

    *
  • */ public final Integer newReplicaCount() { return newReplicaCount; } /** * For responses, this returns true if the service returned a value for the ReplicaConfiguration 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 hasReplicaConfiguration() { return replicaConfiguration != null && !(replicaConfiguration instanceof SdkAutoConstructList); } /** *

    * A list of ConfigureShard objects that can be used to configure each shard in a Valkey or Redis OSS * (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. *

    *

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

    * * @return A list of ConfigureShard objects that can be used to configure each shard in a Valkey or * Redis OSS (cluster mode enabled) replication group. The ConfigureShard has three members: * NewReplicaCount, NodeGroupId, and PreferredAvailabilityZones. */ public final List replicaConfiguration() { return replicaConfiguration; } /** * For responses, this returns true if the service returned a value for the ReplicasToRemove 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 hasReplicasToRemove() { return replicasToRemove != null && !(replicasToRemove instanceof SdkAutoConstructList); } /** *

    * 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. *

    *

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

    * * @return A list of the node ids to remove from the replication group or node group (shard). */ public final 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 final Boolean applyImmediately() { return applyImmediately; } @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(replicationGroupId()); hashCode = 31 * hashCode + Objects.hashCode(newReplicaCount()); hashCode = 31 * hashCode + Objects.hashCode(hasReplicaConfiguration() ? replicaConfiguration() : null); hashCode = 31 * hashCode + Objects.hashCode(hasReplicasToRemove() ? replicasToRemove() : null); hashCode = 31 * hashCode + Objects.hashCode(applyImmediately()); 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 DecreaseReplicaCountRequest)) { return false; } DecreaseReplicaCountRequest other = (DecreaseReplicaCountRequest) obj; return Objects.equals(replicationGroupId(), other.replicationGroupId()) && Objects.equals(newReplicaCount(), other.newReplicaCount()) && hasReplicaConfiguration() == other.hasReplicaConfiguration() && Objects.equals(replicaConfiguration(), other.replicaConfiguration()) && hasReplicasToRemove() == other.hasReplicasToRemove() && 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 final String toString() { return ToString.builder("DecreaseReplicaCountRequest").add("ReplicationGroupId", replicationGroupId()) .add("NewReplicaCount", newReplicaCount()) .add("ReplicaConfiguration", hasReplicaConfiguration() ? replicaConfiguration() : null) .add("ReplicasToRemove", hasReplicasToRemove() ? replicasToRemove() : null) .add("ApplyImmediately", applyImmediately()).build(); } public final 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 final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Map> memberNameToFieldInitializer() { Map> map = new HashMap<>(); map.put("ReplicationGroupId", REPLICATION_GROUP_ID_FIELD); map.put("NewReplicaCount", NEW_REPLICA_COUNT_FIELD); map.put("ReplicaConfiguration", REPLICA_CONFIGURATION_FIELD); map.put("ReplicasToRemove", REPLICAS_TO_REMOVE_FIELD); map.put("ApplyImmediately", APPLY_IMMEDIATELY_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((DecreaseReplicaCountRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends ElastiCacheRequest.Builder, SdkPojo, CopyableBuilder { /** *

    * The id of the replication group from which you want to remove replica nodes. *

    * * @param replicationGroupId * The id of the replication group from which you want to remove replica nodes. * @return Returns a reference to this object so that method calls can be chained together. */ Builder replicationGroupId(String replicationGroupId); /** *

    * The number of read replica nodes you want at the completion of this operation. For Valkey or Redis OSS * (cluster mode disabled) replication groups, this is the number of replica nodes in the replication group. For * Valkey or Redis OSS (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: *

    *
      *
    • *

      * Valkey or Redis OSS (cluster mode disabled) *

      *
        *
      • *

        * If Multi-AZ is enabled: 1 *

        *
      • *
      • *

        * If Multi-AZ is not enabled: 0 *

        *
      • *
      *
    • *
    • *

      * Valkey or Redis OSS (cluster mode enabled): 0 (though you will not be able to failover to a replica if your * primary node fails) *

      *
    • *
    * * @param newReplicaCount * The number of read replica nodes you want at the completion of this operation. For Valkey or Redis OSS * (cluster mode disabled) replication groups, this is the number of replica nodes in the replication * group. For Valkey or Redis OSS (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: *

    *
      *
    • *

      * Valkey or Redis OSS (cluster mode disabled) *

      *
        *
      • *

        * If Multi-AZ is enabled: 1 *

        *
      • *
      • *

        * If Multi-AZ is not enabled: 0 *

        *
      • *
      *
    • *
    • *

      * Valkey or Redis OSS (cluster mode enabled): 0 (though you will not be able to failover to a replica if * your primary node fails) *

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

      * A list of ConfigureShard objects that can be used to configure each shard in a Valkey or Redis * OSS (cluster mode enabled) replication group. The ConfigureShard has three members: * NewReplicaCount, NodeGroupId, and PreferredAvailabilityZones. *

      * * @param replicaConfiguration * A list of ConfigureShard objects that can be used to configure each shard in a Valkey or * Redis OSS (cluster mode enabled) replication group. The ConfigureShard has three members: * NewReplicaCount, NodeGroupId, and PreferredAvailabilityZones. * @return Returns a reference to this object so that method calls can be chained together. */ Builder replicaConfiguration(Collection replicaConfiguration); /** *

      * A list of ConfigureShard objects that can be used to configure each shard in a Valkey or Redis * OSS (cluster mode enabled) replication group. The ConfigureShard has three members: * NewReplicaCount, NodeGroupId, and PreferredAvailabilityZones. *

      * * @param replicaConfiguration * A list of ConfigureShard objects that can be used to configure each shard in a Valkey or * Redis OSS (cluster mode enabled) replication group. The ConfigureShard has three members: * NewReplicaCount, NodeGroupId, and PreferredAvailabilityZones. * @return Returns a reference to this object so that method calls can be chained together. */ Builder replicaConfiguration(ConfigureShard... replicaConfiguration); /** *

      * A list of ConfigureShard objects that can be used to configure each shard in a Valkey or Redis * OSS (cluster mode enabled) replication group. The ConfigureShard has three members: * NewReplicaCount, NodeGroupId, and PreferredAvailabilityZones. *

      * This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.elasticache.model.ConfigureShard.Builder} avoiding the need to create * one manually via {@link software.amazon.awssdk.services.elasticache.model.ConfigureShard#builder()}. * *

      * When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.elasticache.model.ConfigureShard.Builder#build()} is called * immediately and its result is passed to {@link #replicaConfiguration(List)}. * * @param replicaConfiguration * a consumer that will call methods on * {@link software.amazon.awssdk.services.elasticache.model.ConfigureShard.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #replicaConfiguration(java.util.Collection) */ Builder replicaConfiguration(Consumer... replicaConfiguration); /** *

      * A list of the node ids to remove from the replication group or node group (shard). *

      * * @param replicasToRemove * A list of the node ids to remove from the replication group or node group (shard). * @return Returns a reference to this object so that method calls can be chained together. */ Builder replicasToRemove(Collection replicasToRemove); /** *

      * A list of the node ids to remove from the replication group or node group (shard). *

      * * @param replicasToRemove * A list of the node ids to remove from the replication group or node group (shard). * @return Returns a reference to this object so that method calls can be chained together. */ Builder replicasToRemove(String... replicasToRemove); /** *

      * If True, the number of replica nodes is decreased immediately. * ApplyImmediately=False is not currently supported. *

      * * @param applyImmediately * If True, the number of replica nodes is decreased immediately. * ApplyImmediately=False is not currently supported. * @return Returns a reference to this object so that method calls can be chained together. */ Builder applyImmediately(Boolean applyImmediately); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends ElastiCacheRequest.BuilderImpl implements Builder { private String replicationGroupId; private Integer newReplicaCount; private List replicaConfiguration = DefaultSdkAutoConstructList.getInstance(); private List replicasToRemove = DefaultSdkAutoConstructList.getInstance(); private Boolean applyImmediately; private BuilderImpl() { } private BuilderImpl(DecreaseReplicaCountRequest model) { super(model); replicationGroupId(model.replicationGroupId); newReplicaCount(model.newReplicaCount); replicaConfiguration(model.replicaConfiguration); replicasToRemove(model.replicasToRemove); applyImmediately(model.applyImmediately); } public final String getReplicationGroupId() { return replicationGroupId; } public final void setReplicationGroupId(String replicationGroupId) { this.replicationGroupId = replicationGroupId; } @Override public final Builder replicationGroupId(String replicationGroupId) { this.replicationGroupId = replicationGroupId; return this; } public final Integer getNewReplicaCount() { return newReplicaCount; } public final void setNewReplicaCount(Integer newReplicaCount) { this.newReplicaCount = newReplicaCount; } @Override public final Builder newReplicaCount(Integer newReplicaCount) { this.newReplicaCount = newReplicaCount; return this; } public final List getReplicaConfiguration() { List result = ReplicaConfigurationListCopier.copyToBuilder(this.replicaConfiguration); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setReplicaConfiguration(Collection replicaConfiguration) { this.replicaConfiguration = ReplicaConfigurationListCopier.copyFromBuilder(replicaConfiguration); } @Override public final Builder replicaConfiguration(Collection replicaConfiguration) { this.replicaConfiguration = ReplicaConfigurationListCopier.copy(replicaConfiguration); return this; } @Override @SafeVarargs public final Builder replicaConfiguration(ConfigureShard... replicaConfiguration) { replicaConfiguration(Arrays.asList(replicaConfiguration)); return this; } @Override @SafeVarargs public final Builder replicaConfiguration(Consumer... replicaConfiguration) { replicaConfiguration(Stream.of(replicaConfiguration).map(c -> ConfigureShard.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final Collection getReplicasToRemove() { if (replicasToRemove instanceof SdkAutoConstructList) { return null; } return replicasToRemove; } public final void setReplicasToRemove(Collection replicasToRemove) { this.replicasToRemove = RemoveReplicasListCopier.copy(replicasToRemove); } @Override public final Builder replicasToRemove(Collection replicasToRemove) { this.replicasToRemove = RemoveReplicasListCopier.copy(replicasToRemove); return this; } @Override @SafeVarargs public final Builder replicasToRemove(String... replicasToRemove) { replicasToRemove(Arrays.asList(replicasToRemove)); return this; } public final Boolean getApplyImmediately() { return applyImmediately; } public final void setApplyImmediately(Boolean applyImmediately) { this.applyImmediately = applyImmediately; } @Override public final Builder applyImmediately(Boolean applyImmediately) { this.applyImmediately = applyImmediately; 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 DecreaseReplicaCountRequest build() { return new DecreaseReplicaCountRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy