software.amazon.awssdk.services.costexplorer.model.ReservationPurchaseRecommendation Maven / Gradle / Ivy
Show all versions of costexplorer Show documentation
/*
* Copyright 2014-2019 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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A specific reservation that AWS 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)
.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)
.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)
.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)
.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)
.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)
.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)
.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 AWS recommends that you purchase this instance for. For example, you can purchase this
* reservation for an entire organization in AWS 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 AWS recommends that you purchase this instance for. For example, you can purchase
* this reservation for an entire organization in AWS Organizations.
* @see AccountScope
*/
public AccountScope accountScope() {
return AccountScope.fromValue(accountScope);
}
/**
*
* The account scope that AWS recommends that you purchase this instance for. For example, you can purchase this
* reservation for an entire organization in AWS 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 AWS recommends that you purchase this instance for. For example, you can purchase
* this reservation for an entire organization in AWS Organizations.
* @see AccountScope
*/
public String accountScopeAsString() {
return accountScope;
}
/**
*
* How many days of previous usage that AWS 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 AWS considers when making this recommendation.
* @see LookbackPeriodInDays
*/
public LookbackPeriodInDays lookbackPeriodInDays() {
return LookbackPeriodInDays.fromValue(lookbackPeriodInDays);
}
/**
*
* How many days of previous usage that AWS 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 AWS considers when making this recommendation.
* @see LookbackPeriodInDays
*/
public 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 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 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 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 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 ServiceSpecification serviceSpecification() {
return serviceSpecification;
}
/**
*
* Details about the recommended purchases.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Details about the recommended purchases.
*/
public List recommendationDetails() {
return recommendationDetails;
}
/**
*
* A summary about the recommended purchase.
*
*
* @return A summary about the recommended purchase.
*/
public 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 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(recommendationDetails());
hashCode = 31 * hashCode + Objects.hashCode(recommendationSummary());
return hashCode;
}
@Override
public boolean equals(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())
&& 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 String toString() {
return ToString.builder("ReservationPurchaseRecommendation").add("AccountScope", accountScopeAsString())
.add("LookbackPeriodInDays", lookbackPeriodInDaysAsString()).add("TermInYears", termInYearsAsString())
.add("PaymentOption", paymentOptionAsString()).add("ServiceSpecification", serviceSpecification())
.add("RecommendationDetails", recommendationDetails()).add("RecommendationSummary", recommendationSummary())
.build();
}
public 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 List> sdkFields() {
return SDK_FIELDS;
}
private static Function