software.amazon.awssdk.services.redshift.model.ReservedNode Maven / Gradle / Ivy
Show all versions of redshift 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.redshift.model;
import java.io.Serializable;
import java.time.Instant;
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;
/**
*
* Describes a reserved node. You can call the DescribeReservedNodeOfferings API to obtain the available reserved
* node offerings.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReservedNode implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField RESERVED_NODE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReservedNodeId").getter(getter(ReservedNode::reservedNodeId)).setter(setter(Builder::reservedNodeId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReservedNodeId").build()).build();
private static final SdkField RESERVED_NODE_OFFERING_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReservedNodeOfferingId").getter(getter(ReservedNode::reservedNodeOfferingId))
.setter(setter(Builder::reservedNodeOfferingId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReservedNodeOfferingId").build())
.build();
private static final SdkField NODE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NodeType").getter(getter(ReservedNode::nodeType)).setter(setter(Builder::nodeType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeType").build()).build();
private static final SdkField START_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("StartTime").getter(getter(ReservedNode::startTime)).setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartTime").build()).build();
private static final SdkField DURATION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Duration").getter(getter(ReservedNode::duration)).setter(setter(Builder::duration))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Duration").build()).build();
private static final SdkField FIXED_PRICE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("FixedPrice").getter(getter(ReservedNode::fixedPrice)).setter(setter(Builder::fixedPrice))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FixedPrice").build()).build();
private static final SdkField USAGE_PRICE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("UsagePrice").getter(getter(ReservedNode::usagePrice)).setter(setter(Builder::usagePrice))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UsagePrice").build()).build();
private static final SdkField CURRENCY_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CurrencyCode").getter(getter(ReservedNode::currencyCode)).setter(setter(Builder::currencyCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CurrencyCode").build()).build();
private static final SdkField NODE_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("NodeCount").getter(getter(ReservedNode::nodeCount)).setter(setter(Builder::nodeCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeCount").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(ReservedNode::state)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField OFFERING_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("OfferingType").getter(getter(ReservedNode::offeringType)).setter(setter(Builder::offeringType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OfferingType").build()).build();
private static final SdkField> RECURRING_CHARGES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RecurringCharges")
.getter(getter(ReservedNode::recurringCharges))
.setter(setter(Builder::recurringCharges))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecurringCharges").build(),
ListTrait
.builder()
.memberLocationName("RecurringCharge")
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(RecurringCharge::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("RecurringCharge").build()).build()).build()).build();
private static final SdkField RESERVED_NODE_OFFERING_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ReservedNodeOfferingType").getter(getter(ReservedNode::reservedNodeOfferingTypeAsString))
.setter(setter(Builder::reservedNodeOfferingType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReservedNodeOfferingType").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RESERVED_NODE_ID_FIELD,
RESERVED_NODE_OFFERING_ID_FIELD, NODE_TYPE_FIELD, START_TIME_FIELD, DURATION_FIELD, FIXED_PRICE_FIELD,
USAGE_PRICE_FIELD, CURRENCY_CODE_FIELD, NODE_COUNT_FIELD, STATE_FIELD, OFFERING_TYPE_FIELD, RECURRING_CHARGES_FIELD,
RESERVED_NODE_OFFERING_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String reservedNodeId;
private final String reservedNodeOfferingId;
private final String nodeType;
private final Instant startTime;
private final Integer duration;
private final Double fixedPrice;
private final Double usagePrice;
private final String currencyCode;
private final Integer nodeCount;
private final String state;
private final String offeringType;
private final List recurringCharges;
private final String reservedNodeOfferingType;
private ReservedNode(BuilderImpl builder) {
this.reservedNodeId = builder.reservedNodeId;
this.reservedNodeOfferingId = builder.reservedNodeOfferingId;
this.nodeType = builder.nodeType;
this.startTime = builder.startTime;
this.duration = builder.duration;
this.fixedPrice = builder.fixedPrice;
this.usagePrice = builder.usagePrice;
this.currencyCode = builder.currencyCode;
this.nodeCount = builder.nodeCount;
this.state = builder.state;
this.offeringType = builder.offeringType;
this.recurringCharges = builder.recurringCharges;
this.reservedNodeOfferingType = builder.reservedNodeOfferingType;
}
/**
*
* The unique identifier for the reservation.
*
*
* @return The unique identifier for the reservation.
*/
public final String reservedNodeId() {
return reservedNodeId;
}
/**
*
* The identifier for the reserved node offering.
*
*
* @return The identifier for the reserved node offering.
*/
public final String reservedNodeOfferingId() {
return reservedNodeOfferingId;
}
/**
*
* The node type of the reserved node.
*
*
* @return The node type of the reserved node.
*/
public final String nodeType() {
return nodeType;
}
/**
*
* The time the reservation started. You purchase a reserved node offering for a duration. This is the start time of
* that duration.
*
*
* @return The time the reservation started. You purchase a reserved node offering for a duration. This is the start
* time of that duration.
*/
public final Instant startTime() {
return startTime;
}
/**
*
* The duration of the node reservation in seconds.
*
*
* @return The duration of the node reservation in seconds.
*/
public final Integer duration() {
return duration;
}
/**
*
* The fixed cost Amazon Redshift charges you for this reserved node.
*
*
* @return The fixed cost Amazon Redshift charges you for this reserved node.
*/
public final Double fixedPrice() {
return fixedPrice;
}
/**
*
* The hourly rate Amazon Redshift charges you for this reserved node.
*
*
* @return The hourly rate Amazon Redshift charges you for this reserved node.
*/
public final Double usagePrice() {
return usagePrice;
}
/**
*
* The currency code for the reserved cluster.
*
*
* @return The currency code for the reserved cluster.
*/
public final String currencyCode() {
return currencyCode;
}
/**
*
* The number of reserved compute nodes.
*
*
* @return The number of reserved compute nodes.
*/
public final Integer nodeCount() {
return nodeCount;
}
/**
*
* The state of the reserved compute node.
*
*
* Possible Values:
*
*
* -
*
* pending-payment-This reserved node has recently been purchased, and the sale has been approved, but payment has
* not yet been confirmed.
*
*
* -
*
* active-This reserved node is owned by the caller and is available for use.
*
*
* -
*
* payment-failed-Payment failed for the purchase attempt.
*
*
* -
*
* retired-The reserved node is no longer available.
*
*
* -
*
* exchanging-The owner is exchanging the reserved node for another reserved node.
*
*
*
*
* @return The state of the reserved compute node.
*
* Possible Values:
*
*
* -
*
* pending-payment-This reserved node has recently been purchased, and the sale has been approved, but
* payment has not yet been confirmed.
*
*
* -
*
* active-This reserved node is owned by the caller and is available for use.
*
*
* -
*
* payment-failed-Payment failed for the purchase attempt.
*
*
* -
*
* retired-The reserved node is no longer available.
*
*
* -
*
* exchanging-The owner is exchanging the reserved node for another reserved node.
*
*
*/
public final String state() {
return state;
}
/**
*
* The anticipated utilization of the reserved node, as defined in the reserved node offering.
*
*
* @return The anticipated utilization of the reserved node, as defined in the reserved node offering.
*/
public final String offeringType() {
return offeringType;
}
/**
* For responses, this returns true if the service returned a value for the RecurringCharges 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 hasRecurringCharges() {
return recurringCharges != null && !(recurringCharges instanceof SdkAutoConstructList);
}
/**
*
* The recurring charges for the reserved node.
*
*
* 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 #hasRecurringCharges} method.
*
*
* @return The recurring charges for the reserved node.
*/
public final List recurringCharges() {
return recurringCharges;
}
/**
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #reservedNodeOfferingType} will return {@link ReservedNodeOfferingType#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #reservedNodeOfferingTypeAsString}.
*
*
* @return
* @see ReservedNodeOfferingType
*/
public final ReservedNodeOfferingType reservedNodeOfferingType() {
return ReservedNodeOfferingType.fromValue(reservedNodeOfferingType);
}
/**
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #reservedNodeOfferingType} will return {@link ReservedNodeOfferingType#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #reservedNodeOfferingTypeAsString}.
*
*
* @return
* @see ReservedNodeOfferingType
*/
public final String reservedNodeOfferingTypeAsString() {
return reservedNodeOfferingType;
}
@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(reservedNodeId());
hashCode = 31 * hashCode + Objects.hashCode(reservedNodeOfferingId());
hashCode = 31 * hashCode + Objects.hashCode(nodeType());
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(duration());
hashCode = 31 * hashCode + Objects.hashCode(fixedPrice());
hashCode = 31 * hashCode + Objects.hashCode(usagePrice());
hashCode = 31 * hashCode + Objects.hashCode(currencyCode());
hashCode = 31 * hashCode + Objects.hashCode(nodeCount());
hashCode = 31 * hashCode + Objects.hashCode(state());
hashCode = 31 * hashCode + Objects.hashCode(offeringType());
hashCode = 31 * hashCode + Objects.hashCode(hasRecurringCharges() ? recurringCharges() : null);
hashCode = 31 * hashCode + Objects.hashCode(reservedNodeOfferingTypeAsString());
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 ReservedNode)) {
return false;
}
ReservedNode other = (ReservedNode) obj;
return Objects.equals(reservedNodeId(), other.reservedNodeId())
&& Objects.equals(reservedNodeOfferingId(), other.reservedNodeOfferingId())
&& Objects.equals(nodeType(), other.nodeType()) && Objects.equals(startTime(), other.startTime())
&& Objects.equals(duration(), other.duration()) && Objects.equals(fixedPrice(), other.fixedPrice())
&& Objects.equals(usagePrice(), other.usagePrice()) && Objects.equals(currencyCode(), other.currencyCode())
&& Objects.equals(nodeCount(), other.nodeCount()) && Objects.equals(state(), other.state())
&& Objects.equals(offeringType(), other.offeringType()) && hasRecurringCharges() == other.hasRecurringCharges()
&& Objects.equals(recurringCharges(), other.recurringCharges())
&& Objects.equals(reservedNodeOfferingTypeAsString(), other.reservedNodeOfferingTypeAsString());
}
/**
* 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("ReservedNode").add("ReservedNodeId", reservedNodeId())
.add("ReservedNodeOfferingId", reservedNodeOfferingId()).add("NodeType", nodeType())
.add("StartTime", startTime()).add("Duration", duration()).add("FixedPrice", fixedPrice())
.add("UsagePrice", usagePrice()).add("CurrencyCode", currencyCode()).add("NodeCount", nodeCount())
.add("State", state()).add("OfferingType", offeringType())
.add("RecurringCharges", hasRecurringCharges() ? recurringCharges() : null)
.add("ReservedNodeOfferingType", reservedNodeOfferingTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ReservedNodeId":
return Optional.ofNullable(clazz.cast(reservedNodeId()));
case "ReservedNodeOfferingId":
return Optional.ofNullable(clazz.cast(reservedNodeOfferingId()));
case "NodeType":
return Optional.ofNullable(clazz.cast(nodeType()));
case "StartTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "Duration":
return Optional.ofNullable(clazz.cast(duration()));
case "FixedPrice":
return Optional.ofNullable(clazz.cast(fixedPrice()));
case "UsagePrice":
return Optional.ofNullable(clazz.cast(usagePrice()));
case "CurrencyCode":
return Optional.ofNullable(clazz.cast(currencyCode()));
case "NodeCount":
return Optional.ofNullable(clazz.cast(nodeCount()));
case "State":
return Optional.ofNullable(clazz.cast(state()));
case "OfferingType":
return Optional.ofNullable(clazz.cast(offeringType()));
case "RecurringCharges":
return Optional.ofNullable(clazz.cast(recurringCharges()));
case "ReservedNodeOfferingType":
return Optional.ofNullable(clazz.cast(reservedNodeOfferingTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function