software.amazon.awssdk.services.elasticsearch.model.ReservedElasticsearchInstanceOffering Maven / Gradle / Ivy
Show all versions of elasticsearch 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.elasticsearch.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;
/**
*
* Details of a reserved Elasticsearch instance offering.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReservedElasticsearchInstanceOffering implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField RESERVED_ELASTICSEARCH_INSTANCE_OFFERING_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ReservedElasticsearchInstanceOfferingId")
.getter(getter(ReservedElasticsearchInstanceOffering::reservedElasticsearchInstanceOfferingId))
.setter(setter(Builder::reservedElasticsearchInstanceOfferingId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("ReservedElasticsearchInstanceOfferingId").build()).build();
private static final SdkField ELASTICSEARCH_INSTANCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ElasticsearchInstanceType")
.getter(getter(ReservedElasticsearchInstanceOffering::elasticsearchInstanceTypeAsString))
.setter(setter(Builder::elasticsearchInstanceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ElasticsearchInstanceType").build())
.build();
private static final SdkField DURATION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Duration").getter(getter(ReservedElasticsearchInstanceOffering::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(ReservedElasticsearchInstanceOffering::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(ReservedElasticsearchInstanceOffering::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(ReservedElasticsearchInstanceOffering::currencyCode))
.setter(setter(Builder::currencyCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CurrencyCode").build()).build();
private static final SdkField PAYMENT_OPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PaymentOption").getter(getter(ReservedElasticsearchInstanceOffering::paymentOptionAsString))
.setter(setter(Builder::paymentOption))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PaymentOption").build()).build();
private static final SdkField> RECURRING_CHARGES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RecurringCharges")
.getter(getter(ReservedElasticsearchInstanceOffering::recurringCharges))
.setter(setter(Builder::recurringCharges))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecurringCharges").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(RecurringCharge::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
RESERVED_ELASTICSEARCH_INSTANCE_OFFERING_ID_FIELD, ELASTICSEARCH_INSTANCE_TYPE_FIELD, DURATION_FIELD,
FIXED_PRICE_FIELD, USAGE_PRICE_FIELD, CURRENCY_CODE_FIELD, PAYMENT_OPTION_FIELD, RECURRING_CHARGES_FIELD));
private static final long serialVersionUID = 1L;
private final String reservedElasticsearchInstanceOfferingId;
private final String elasticsearchInstanceType;
private final Integer duration;
private final Double fixedPrice;
private final Double usagePrice;
private final String currencyCode;
private final String paymentOption;
private final List recurringCharges;
private ReservedElasticsearchInstanceOffering(BuilderImpl builder) {
this.reservedElasticsearchInstanceOfferingId = builder.reservedElasticsearchInstanceOfferingId;
this.elasticsearchInstanceType = builder.elasticsearchInstanceType;
this.duration = builder.duration;
this.fixedPrice = builder.fixedPrice;
this.usagePrice = builder.usagePrice;
this.currencyCode = builder.currencyCode;
this.paymentOption = builder.paymentOption;
this.recurringCharges = builder.recurringCharges;
}
/**
*
* The Elasticsearch reserved instance offering identifier.
*
*
* @return The Elasticsearch reserved instance offering identifier.
*/
public final String reservedElasticsearchInstanceOfferingId() {
return reservedElasticsearchInstanceOfferingId;
}
/**
*
* The Elasticsearch instance type offered by the reserved instance offering.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #elasticsearchInstanceType} will return {@link ESPartitionInstanceType#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #elasticsearchInstanceTypeAsString}.
*
*
* @return The Elasticsearch instance type offered by the reserved instance offering.
* @see ESPartitionInstanceType
*/
public final ESPartitionInstanceType elasticsearchInstanceType() {
return ESPartitionInstanceType.fromValue(elasticsearchInstanceType);
}
/**
*
* The Elasticsearch instance type offered by the reserved instance offering.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #elasticsearchInstanceType} will return {@link ESPartitionInstanceType#UNKNOWN_TO_SDK_VERSION}. The raw
* value returned by the service is available from {@link #elasticsearchInstanceTypeAsString}.
*
*
* @return The Elasticsearch instance type offered by the reserved instance offering.
* @see ESPartitionInstanceType
*/
public final String elasticsearchInstanceTypeAsString() {
return elasticsearchInstanceType;
}
/**
*
* The duration, in seconds, for which the offering will reserve the Elasticsearch instance.
*
*
* @return The duration, in seconds, for which the offering will reserve the Elasticsearch instance.
*/
public final Integer duration() {
return duration;
}
/**
*
* The upfront fixed charge you will pay to purchase the specific reserved Elasticsearch instance offering.
*
*
* @return The upfront fixed charge you will pay to purchase the specific reserved Elasticsearch instance offering.
*/
public final Double fixedPrice() {
return fixedPrice;
}
/**
*
* The rate you are charged for each hour the domain that is using the offering is running.
*
*
* @return The rate you are charged for each hour the domain that is using the offering is running.
*/
public final Double usagePrice() {
return usagePrice;
}
/**
*
* The currency code for the reserved Elasticsearch instance offering.
*
*
* @return The currency code for the reserved Elasticsearch instance offering.
*/
public final String currencyCode() {
return currencyCode;
}
/**
*
* Payment option for the reserved Elasticsearch instance offering
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #paymentOption}
* will return {@link ReservedElasticsearchInstancePaymentOption#UNKNOWN_TO_SDK_VERSION}. The raw value returned by
* the service is available from {@link #paymentOptionAsString}.
*
*
* @return Payment option for the reserved Elasticsearch instance offering
* @see ReservedElasticsearchInstancePaymentOption
*/
public final ReservedElasticsearchInstancePaymentOption paymentOption() {
return ReservedElasticsearchInstancePaymentOption.fromValue(paymentOption);
}
/**
*
* Payment option for the reserved Elasticsearch instance offering
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #paymentOption}
* will return {@link ReservedElasticsearchInstancePaymentOption#UNKNOWN_TO_SDK_VERSION}. The raw value returned by
* the service is available from {@link #paymentOptionAsString}.
*
*
* @return Payment option for the reserved Elasticsearch instance offering
* @see ReservedElasticsearchInstancePaymentOption
*/
public final String paymentOptionAsString() {
return paymentOption;
}
/**
* 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 charge to your account regardless of whether you are creating any domains using the instance offering.
*
*
* 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 charge to your account regardless of whether you are creating any domains using the instance
* offering.
*/
public final List recurringCharges() {
return recurringCharges;
}
@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(reservedElasticsearchInstanceOfferingId());
hashCode = 31 * hashCode + Objects.hashCode(elasticsearchInstanceTypeAsString());
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(paymentOptionAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasRecurringCharges() ? recurringCharges() : 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 ReservedElasticsearchInstanceOffering)) {
return false;
}
ReservedElasticsearchInstanceOffering other = (ReservedElasticsearchInstanceOffering) obj;
return Objects.equals(reservedElasticsearchInstanceOfferingId(), other.reservedElasticsearchInstanceOfferingId())
&& Objects.equals(elasticsearchInstanceTypeAsString(), other.elasticsearchInstanceTypeAsString())
&& Objects.equals(duration(), other.duration()) && Objects.equals(fixedPrice(), other.fixedPrice())
&& Objects.equals(usagePrice(), other.usagePrice()) && Objects.equals(currencyCode(), other.currencyCode())
&& Objects.equals(paymentOptionAsString(), other.paymentOptionAsString())
&& hasRecurringCharges() == other.hasRecurringCharges()
&& Objects.equals(recurringCharges(), other.recurringCharges());
}
/**
* 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("ReservedElasticsearchInstanceOffering")
.add("ReservedElasticsearchInstanceOfferingId", reservedElasticsearchInstanceOfferingId())
.add("ElasticsearchInstanceType", elasticsearchInstanceTypeAsString()).add("Duration", duration())
.add("FixedPrice", fixedPrice()).add("UsagePrice", usagePrice()).add("CurrencyCode", currencyCode())
.add("PaymentOption", paymentOptionAsString())
.add("RecurringCharges", hasRecurringCharges() ? recurringCharges() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ReservedElasticsearchInstanceOfferingId":
return Optional.ofNullable(clazz.cast(reservedElasticsearchInstanceOfferingId()));
case "ElasticsearchInstanceType":
return Optional.ofNullable(clazz.cast(elasticsearchInstanceTypeAsString()));
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 "PaymentOption":
return Optional.ofNullable(clazz.cast(paymentOptionAsString()));
case "RecurringCharges":
return Optional.ofNullable(clazz.cast(recurringCharges()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function