software.amazon.awssdk.services.costexplorer.model.ReservationPurchaseRecommendation Maven / Gradle / Ivy
Show all versions of costexplorer 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.costexplorer.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;
/**
*
* A specific reservation that Amazon Web Services recommends for purchase.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ReservationPurchaseRecommendation implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ACCOUNT_SCOPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccountScope").getter(getter(ReservationPurchaseRecommendation::accountScopeAsString))
.setter(setter(Builder::accountScope))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountScope").build()).build();
private static final SdkField LOOKBACK_PERIOD_IN_DAYS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LookbackPeriodInDays").getter(getter(ReservationPurchaseRecommendation::lookbackPeriodInDaysAsString))
.setter(setter(Builder::lookbackPeriodInDays))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LookbackPeriodInDays").build())
.build();
private static final SdkField TERM_IN_YEARS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TermInYears").getter(getter(ReservationPurchaseRecommendation::termInYearsAsString))
.setter(setter(Builder::termInYears))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TermInYears").build()).build();
private static final SdkField PAYMENT_OPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PaymentOption").getter(getter(ReservationPurchaseRecommendation::paymentOptionAsString))
.setter(setter(Builder::paymentOption))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PaymentOption").build()).build();
private static final SdkField SERVICE_SPECIFICATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ServiceSpecification")
.getter(getter(ReservationPurchaseRecommendation::serviceSpecification))
.setter(setter(Builder::serviceSpecification)).constructor(ServiceSpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ServiceSpecification").build())
.build();
private static final SdkField> RECOMMENDATION_DETAILS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RecommendationDetails")
.getter(getter(ReservationPurchaseRecommendation::recommendationDetails))
.setter(setter(Builder::recommendationDetails))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecommendationDetails").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ReservationPurchaseRecommendationDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField RECOMMENDATION_SUMMARY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("RecommendationSummary")
.getter(getter(ReservationPurchaseRecommendation::recommendationSummary))
.setter(setter(Builder::recommendationSummary)).constructor(ReservationPurchaseRecommendationSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecommendationSummary").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACCOUNT_SCOPE_FIELD,
LOOKBACK_PERIOD_IN_DAYS_FIELD, TERM_IN_YEARS_FIELD, PAYMENT_OPTION_FIELD, SERVICE_SPECIFICATION_FIELD,
RECOMMENDATION_DETAILS_FIELD, RECOMMENDATION_SUMMARY_FIELD));
private static final long serialVersionUID = 1L;
private final String accountScope;
private final String lookbackPeriodInDays;
private final String termInYears;
private final String paymentOption;
private final ServiceSpecification serviceSpecification;
private final List recommendationDetails;
private final ReservationPurchaseRecommendationSummary recommendationSummary;
private ReservationPurchaseRecommendation(BuilderImpl builder) {
this.accountScope = builder.accountScope;
this.lookbackPeriodInDays = builder.lookbackPeriodInDays;
this.termInYears = builder.termInYears;
this.paymentOption = builder.paymentOption;
this.serviceSpecification = builder.serviceSpecification;
this.recommendationDetails = builder.recommendationDetails;
this.recommendationSummary = builder.recommendationSummary;
}
/**
*
* The account scope that Amazon Web Services recommends that you purchase this instance for. For example, you can
* purchase this reservation for an entire organization in Amazon Web Services Organizations.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #accountScope} will
* return {@link AccountScope#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #accountScopeAsString}.
*
*
* @return The account scope that Amazon Web Services recommends that you purchase this instance for. For example,
* you can purchase this reservation for an entire organization in Amazon Web Services Organizations.
* @see AccountScope
*/
public final AccountScope accountScope() {
return AccountScope.fromValue(accountScope);
}
/**
*
* The account scope that Amazon Web Services recommends that you purchase this instance for. For example, you can
* purchase this reservation for an entire organization in Amazon Web Services Organizations.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #accountScope} will
* return {@link AccountScope#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #accountScopeAsString}.
*
*
* @return The account scope that Amazon Web Services recommends that you purchase this instance for. For example,
* you can purchase this reservation for an entire organization in Amazon Web Services Organizations.
* @see AccountScope
*/
public final String accountScopeAsString() {
return accountScope;
}
/**
*
* How many days of previous usage that Amazon Web Services considers when making this recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #lookbackPeriodInDays} will return {@link LookbackPeriodInDays#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #lookbackPeriodInDaysAsString}.
*
*
* @return How many days of previous usage that Amazon Web Services considers when making this recommendation.
* @see LookbackPeriodInDays
*/
public final LookbackPeriodInDays lookbackPeriodInDays() {
return LookbackPeriodInDays.fromValue(lookbackPeriodInDays);
}
/**
*
* How many days of previous usage that Amazon Web Services considers when making this recommendation.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #lookbackPeriodInDays} will return {@link LookbackPeriodInDays#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #lookbackPeriodInDaysAsString}.
*
*
* @return How many days of previous usage that Amazon Web Services considers when making this recommendation.
* @see LookbackPeriodInDays
*/
public final String lookbackPeriodInDaysAsString() {
return lookbackPeriodInDays;
}
/**
*
* The term of the reservation that you want recommendations for, in years.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #termInYears} will
* return {@link TermInYears#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #termInYearsAsString}.
*
*
* @return The term of the reservation that you want recommendations for, in years.
* @see TermInYears
*/
public final TermInYears termInYears() {
return TermInYears.fromValue(termInYears);
}
/**
*
* The term of the reservation that you want recommendations for, in years.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #termInYears} will
* return {@link TermInYears#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #termInYearsAsString}.
*
*
* @return The term of the reservation that you want recommendations for, in years.
* @see TermInYears
*/
public final String termInYearsAsString() {
return termInYears;
}
/**
*
* The payment option for the reservation (for example, AllUpfront
or NoUpfront
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #paymentOption}
* will return {@link PaymentOption#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #paymentOptionAsString}.
*
*
* @return The payment option for the reservation (for example, AllUpfront
or NoUpfront
).
* @see PaymentOption
*/
public final PaymentOption paymentOption() {
return PaymentOption.fromValue(paymentOption);
}
/**
*
* The payment option for the reservation (for example, AllUpfront
or NoUpfront
).
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #paymentOption}
* will return {@link PaymentOption#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #paymentOptionAsString}.
*
*
* @return The payment option for the reservation (for example, AllUpfront
or NoUpfront
).
* @see PaymentOption
*/
public final String paymentOptionAsString() {
return paymentOption;
}
/**
*
* Hardware specifications for the service that you want recommendations for.
*
*
* @return Hardware specifications for the service that you want recommendations for.
*/
public final ServiceSpecification serviceSpecification() {
return serviceSpecification;
}
/**
* For responses, this returns true if the service returned a value for the RecommendationDetails 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 hasRecommendationDetails() {
return recommendationDetails != null && !(recommendationDetails instanceof SdkAutoConstructList);
}
/**
*
* Details about the recommended purchases.
*
*
* 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 #hasRecommendationDetails} method.
*
*
* @return Details about the recommended purchases.
*/
public final List recommendationDetails() {
return recommendationDetails;
}
/**
*
* A summary about the recommended purchase.
*
*
* @return A summary about the recommended purchase.
*/
public final ReservationPurchaseRecommendationSummary recommendationSummary() {
return recommendationSummary;
}
@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(accountScopeAsString());
hashCode = 31 * hashCode + Objects.hashCode(lookbackPeriodInDaysAsString());
hashCode = 31 * hashCode + Objects.hashCode(termInYearsAsString());
hashCode = 31 * hashCode + Objects.hashCode(paymentOptionAsString());
hashCode = 31 * hashCode + Objects.hashCode(serviceSpecification());
hashCode = 31 * hashCode + Objects.hashCode(hasRecommendationDetails() ? recommendationDetails() : null);
hashCode = 31 * hashCode + Objects.hashCode(recommendationSummary());
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 ReservationPurchaseRecommendation)) {
return false;
}
ReservationPurchaseRecommendation other = (ReservationPurchaseRecommendation) obj;
return Objects.equals(accountScopeAsString(), other.accountScopeAsString())
&& Objects.equals(lookbackPeriodInDaysAsString(), other.lookbackPeriodInDaysAsString())
&& Objects.equals(termInYearsAsString(), other.termInYearsAsString())
&& Objects.equals(paymentOptionAsString(), other.paymentOptionAsString())
&& Objects.equals(serviceSpecification(), other.serviceSpecification())
&& hasRecommendationDetails() == other.hasRecommendationDetails()
&& Objects.equals(recommendationDetails(), other.recommendationDetails())
&& Objects.equals(recommendationSummary(), other.recommendationSummary());
}
/**
* 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("ReservationPurchaseRecommendation").add("AccountScope", accountScopeAsString())
.add("LookbackPeriodInDays", lookbackPeriodInDaysAsString()).add("TermInYears", termInYearsAsString())
.add("PaymentOption", paymentOptionAsString()).add("ServiceSpecification", serviceSpecification())
.add("RecommendationDetails", hasRecommendationDetails() ? recommendationDetails() : null)
.add("RecommendationSummary", recommendationSummary()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AccountScope":
return Optional.ofNullable(clazz.cast(accountScopeAsString()));
case "LookbackPeriodInDays":
return Optional.ofNullable(clazz.cast(lookbackPeriodInDaysAsString()));
case "TermInYears":
return Optional.ofNullable(clazz.cast(termInYearsAsString()));
case "PaymentOption":
return Optional.ofNullable(clazz.cast(paymentOptionAsString()));
case "ServiceSpecification":
return Optional.ofNullable(clazz.cast(serviceSpecification()));
case "RecommendationDetails":
return Optional.ofNullable(clazz.cast(recommendationDetails()));
case "RecommendationSummary":
return Optional.ofNullable(clazz.cast(recommendationSummary()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function