software.amazon.awssdk.services.elasticache.model.NodeGroupConfiguration Maven / Gradle / Ivy
Show all versions of elasticache 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.elasticache.model;
import java.beans.Transient;
import java.io.Serializable;
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.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.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;
/**
*
* Node group (shard) configuration options. Each node group (shard) configuration has the following: Slots
, PrimaryAvailabilityZone
, ReplicaAvailabilityZones
, ReplicaCount
.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class NodeGroupConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NODE_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NodeGroupId").getter(getter(NodeGroupConfiguration::nodeGroupId)).setter(setter(Builder::nodeGroupId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeGroupId").build()).build();
private static final SdkField SLOTS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Slots")
.getter(getter(NodeGroupConfiguration::slots)).setter(setter(Builder::slots))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Slots").build()).build();
private static final SdkField REPLICA_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ReplicaCount").getter(getter(NodeGroupConfiguration::replicaCount))
.setter(setter(Builder::replicaCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaCount").build()).build();
private static final SdkField PRIMARY_AVAILABILITY_ZONE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrimaryAvailabilityZone").getter(getter(NodeGroupConfiguration::primaryAvailabilityZone))
.setter(setter(Builder::primaryAvailabilityZone))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrimaryAvailabilityZone").build())
.build();
private static final SdkField> REPLICA_AVAILABILITY_ZONES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ReplicaAvailabilityZones")
.getter(getter(NodeGroupConfiguration::replicaAvailabilityZones))
.setter(setter(Builder::replicaAvailabilityZones))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaAvailabilityZones").build(),
ListTrait
.builder()
.memberLocationName("AvailabilityZone")
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("AvailabilityZone").build()).build()).build()).build();
private static final SdkField PRIMARY_OUTPOST_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrimaryOutpostArn").getter(getter(NodeGroupConfiguration::primaryOutpostArn))
.setter(setter(Builder::primaryOutpostArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrimaryOutpostArn").build()).build();
private static final SdkField> REPLICA_OUTPOST_ARNS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ReplicaOutpostArns")
.getter(getter(NodeGroupConfiguration::replicaOutpostArns))
.setter(setter(Builder::replicaOutpostArns))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaOutpostArns").build(),
ListTrait
.builder()
.memberLocationName("OutpostArn")
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("OutpostArn").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NODE_GROUP_ID_FIELD,
SLOTS_FIELD, REPLICA_COUNT_FIELD, PRIMARY_AVAILABILITY_ZONE_FIELD, REPLICA_AVAILABILITY_ZONES_FIELD,
PRIMARY_OUTPOST_ARN_FIELD, REPLICA_OUTPOST_ARNS_FIELD));
private static final long serialVersionUID = 1L;
private final String nodeGroupId;
private final String slots;
private final Integer replicaCount;
private final String primaryAvailabilityZone;
private final List replicaAvailabilityZones;
private final String primaryOutpostArn;
private final List replicaOutpostArns;
private NodeGroupConfiguration(BuilderImpl builder) {
this.nodeGroupId = builder.nodeGroupId;
this.slots = builder.slots;
this.replicaCount = builder.replicaCount;
this.primaryAvailabilityZone = builder.primaryAvailabilityZone;
this.replicaAvailabilityZones = builder.replicaAvailabilityZones;
this.primaryOutpostArn = builder.primaryOutpostArn;
this.replicaOutpostArns = builder.replicaOutpostArns;
}
/**
*
* Either the ElastiCache for Redis supplied 4-digit id or a user supplied id for the node group these configuration
* values apply to.
*
*
* @return Either the ElastiCache for Redis supplied 4-digit id or a user supplied id for the node group these
* configuration values apply to.
*/
public final String nodeGroupId() {
return nodeGroupId;
}
/**
*
* A string that specifies the keyspace for a particular node group. Keyspaces range from 0 to 16,383. The string is
* in the format startkey-endkey
.
*
*
* Example: "0-3999"
*
*
* @return A string that specifies the keyspace for a particular node group. Keyspaces range from 0 to 16,383. The
* string is in the format startkey-endkey
.
*
* Example: "0-3999"
*/
public final String slots() {
return slots;
}
/**
*
* The number of read replica nodes in this node group (shard).
*
*
* @return The number of read replica nodes in this node group (shard).
*/
public final Integer replicaCount() {
return replicaCount;
}
/**
*
* The Availability Zone where the primary node of this node group (shard) is launched.
*
*
* @return The Availability Zone where the primary node of this node group (shard) is launched.
*/
public final String primaryAvailabilityZone() {
return primaryAvailabilityZone;
}
/**
* For responses, this returns true if the service returned a value for the ReplicaAvailabilityZones 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 hasReplicaAvailabilityZones() {
return replicaAvailabilityZones != null && !(replicaAvailabilityZones instanceof SdkAutoConstructList);
}
/**
*
* A list of Availability Zones to be used for the read replicas. The number of Availability Zones in this list must
* match the value of ReplicaCount
or ReplicasPerNodeGroup
if not specified.
*
*
* 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 #hasReplicaAvailabilityZones} method.
*
*
* @return A list of Availability Zones to be used for the read replicas. The number of Availability Zones in this
* list must match the value of ReplicaCount
or ReplicasPerNodeGroup
if not
* specified.
*/
public final List replicaAvailabilityZones() {
return replicaAvailabilityZones;
}
/**
*
* The outpost ARN of the primary node.
*
*
* @return The outpost ARN of the primary node.
*/
public final String primaryOutpostArn() {
return primaryOutpostArn;
}
/**
* For responses, this returns true if the service returned a value for the ReplicaOutpostArns 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 hasReplicaOutpostArns() {
return replicaOutpostArns != null && !(replicaOutpostArns instanceof SdkAutoConstructList);
}
/**
*
* The outpost ARN of the node replicas.
*
*
* 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 #hasReplicaOutpostArns} method.
*
*
* @return The outpost ARN of the node replicas.
*/
public final List replicaOutpostArns() {
return replicaOutpostArns;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(nodeGroupId());
hashCode = 31 * hashCode + Objects.hashCode(slots());
hashCode = 31 * hashCode + Objects.hashCode(replicaCount());
hashCode = 31 * hashCode + Objects.hashCode(primaryAvailabilityZone());
hashCode = 31 * hashCode + Objects.hashCode(hasReplicaAvailabilityZones() ? replicaAvailabilityZones() : null);
hashCode = 31 * hashCode + Objects.hashCode(primaryOutpostArn());
hashCode = 31 * hashCode + Objects.hashCode(hasReplicaOutpostArns() ? replicaOutpostArns() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof NodeGroupConfiguration)) {
return false;
}
NodeGroupConfiguration other = (NodeGroupConfiguration) obj;
return Objects.equals(nodeGroupId(), other.nodeGroupId()) && Objects.equals(slots(), other.slots())
&& Objects.equals(replicaCount(), other.replicaCount())
&& Objects.equals(primaryAvailabilityZone(), other.primaryAvailabilityZone())
&& hasReplicaAvailabilityZones() == other.hasReplicaAvailabilityZones()
&& Objects.equals(replicaAvailabilityZones(), other.replicaAvailabilityZones())
&& Objects.equals(primaryOutpostArn(), other.primaryOutpostArn())
&& hasReplicaOutpostArns() == other.hasReplicaOutpostArns()
&& Objects.equals(replicaOutpostArns(), other.replicaOutpostArns());
}
/**
* 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("NodeGroupConfiguration").add("NodeGroupId", nodeGroupId()).add("Slots", slots())
.add("ReplicaCount", replicaCount()).add("PrimaryAvailabilityZone", primaryAvailabilityZone())
.add("ReplicaAvailabilityZones", hasReplicaAvailabilityZones() ? replicaAvailabilityZones() : null)
.add("PrimaryOutpostArn", primaryOutpostArn())
.add("ReplicaOutpostArns", hasReplicaOutpostArns() ? replicaOutpostArns() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "NodeGroupId":
return Optional.ofNullable(clazz.cast(nodeGroupId()));
case "Slots":
return Optional.ofNullable(clazz.cast(slots()));
case "ReplicaCount":
return Optional.ofNullable(clazz.cast(replicaCount()));
case "PrimaryAvailabilityZone":
return Optional.ofNullable(clazz.cast(primaryAvailabilityZone()));
case "ReplicaAvailabilityZones":
return Optional.ofNullable(clazz.cast(replicaAvailabilityZones()));
case "PrimaryOutpostArn":
return Optional.ofNullable(clazz.cast(primaryOutpostArn()));
case "ReplicaOutpostArns":
return Optional.ofNullable(clazz.cast(replicaOutpostArns()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function