software.amazon.awssdk.services.elasticache.model.NodeGroup 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.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.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.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 a collection of cache nodes in a replication group. One node in the node group is the read/write primary
* node. All the other nodes are read-only Replica nodes.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class NodeGroup implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NODE_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NodeGroupId").getter(getter(NodeGroup::nodeGroupId)).setter(setter(Builder::nodeGroupId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeGroupId").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(NodeGroup::status)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField PRIMARY_ENDPOINT_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("PrimaryEndpoint").getter(getter(NodeGroup::primaryEndpoint)).setter(setter(Builder::primaryEndpoint))
.constructor(Endpoint::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrimaryEndpoint").build()).build();
private static final SdkField READER_ENDPOINT_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("ReaderEndpoint").getter(getter(NodeGroup::readerEndpoint)).setter(setter(Builder::readerEndpoint))
.constructor(Endpoint::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReaderEndpoint").build()).build();
private static final SdkField SLOTS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Slots")
.getter(getter(NodeGroup::slots)).setter(setter(Builder::slots))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Slots").build()).build();
private static final SdkField> NODE_GROUP_MEMBERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("NodeGroupMembers")
.getter(getter(NodeGroup::nodeGroupMembers))
.setter(setter(Builder::nodeGroupMembers))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeGroupMembers").build(),
ListTrait
.builder()
.memberLocationName("NodeGroupMember")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(NodeGroupMember::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("NodeGroupMember").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NODE_GROUP_ID_FIELD,
STATUS_FIELD, PRIMARY_ENDPOINT_FIELD, READER_ENDPOINT_FIELD, SLOTS_FIELD, NODE_GROUP_MEMBERS_FIELD));
private static final long serialVersionUID = 1L;
private final String nodeGroupId;
private final String status;
private final Endpoint primaryEndpoint;
private final Endpoint readerEndpoint;
private final String slots;
private final List nodeGroupMembers;
private NodeGroup(BuilderImpl builder) {
this.nodeGroupId = builder.nodeGroupId;
this.status = builder.status;
this.primaryEndpoint = builder.primaryEndpoint;
this.readerEndpoint = builder.readerEndpoint;
this.slots = builder.slots;
this.nodeGroupMembers = builder.nodeGroupMembers;
}
/**
*
* The identifier for the node group (shard). A Redis (cluster mode disabled) replication group contains only 1 node
* group; therefore, the node group ID is 0001. A Redis (cluster mode enabled) replication group contains 1 to 90
* node groups numbered 0001 to 0090. Optionally, the user can provide the id for a node group.
*
*
* @return The identifier for the node group (shard). A Redis (cluster mode disabled) replication group contains
* only 1 node group; therefore, the node group ID is 0001. A Redis (cluster mode enabled) replication group
* contains 1 to 90 node groups numbered 0001 to 0090. Optionally, the user can provide the id for a node
* group.
*/
public final String nodeGroupId() {
return nodeGroupId;
}
/**
*
* The current state of this replication group - creating
, available
,
* modifying
, deleting
.
*
*
* @return The current state of this replication group - creating
, available
,
* modifying
, deleting
.
*/
public final String status() {
return status;
}
/**
*
* The endpoint of the primary node in this node group (shard).
*
*
* @return The endpoint of the primary node in this node group (shard).
*/
public final Endpoint primaryEndpoint() {
return primaryEndpoint;
}
/**
*
* The endpoint of the replica nodes in this node group (shard).
*
*
* @return The endpoint of the replica nodes in this node group (shard).
*/
public final Endpoint readerEndpoint() {
return readerEndpoint;
}
/**
*
* The keyspace for this node group (shard).
*
*
* @return The keyspace for this node group (shard).
*/
public final String slots() {
return slots;
}
/**
* Returns true if the NodeGroupMembers 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 final boolean hasNodeGroupMembers() {
return nodeGroupMembers != null && !(nodeGroupMembers instanceof SdkAutoConstructList);
}
/**
*
* A list containing information about individual nodes within the node group (shard).
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasNodeGroupMembers()} to see if a value was sent in this field.
*
*
* @return A list containing information about individual nodes within the node group (shard).
*/
public final List nodeGroupMembers() {
return nodeGroupMembers;
}
@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(status());
hashCode = 31 * hashCode + Objects.hashCode(primaryEndpoint());
hashCode = 31 * hashCode + Objects.hashCode(readerEndpoint());
hashCode = 31 * hashCode + Objects.hashCode(slots());
hashCode = 31 * hashCode + Objects.hashCode(hasNodeGroupMembers() ? nodeGroupMembers() : 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 NodeGroup)) {
return false;
}
NodeGroup other = (NodeGroup) obj;
return Objects.equals(nodeGroupId(), other.nodeGroupId()) && Objects.equals(status(), other.status())
&& Objects.equals(primaryEndpoint(), other.primaryEndpoint())
&& Objects.equals(readerEndpoint(), other.readerEndpoint()) && Objects.equals(slots(), other.slots())
&& hasNodeGroupMembers() == other.hasNodeGroupMembers()
&& Objects.equals(nodeGroupMembers(), other.nodeGroupMembers());
}
/**
* 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("NodeGroup").add("NodeGroupId", nodeGroupId()).add("Status", status())
.add("PrimaryEndpoint", primaryEndpoint()).add("ReaderEndpoint", readerEndpoint()).add("Slots", slots())
.add("NodeGroupMembers", hasNodeGroupMembers() ? nodeGroupMembers() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "NodeGroupId":
return Optional.ofNullable(clazz.cast(nodeGroupId()));
case "Status":
return Optional.ofNullable(clazz.cast(status()));
case "PrimaryEndpoint":
return Optional.ofNullable(clazz.cast(primaryEndpoint()));
case "ReaderEndpoint":
return Optional.ofNullable(clazz.cast(readerEndpoint()));
case "Slots":
return Optional.ofNullable(clazz.cast(slots()));
case "NodeGroupMembers":
return Optional.ofNullable(clazz.cast(nodeGroupMembers()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function