software.amazon.awssdk.services.costexplorer.model.SavingsPlansPurchaseRecommendation 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;
/**
*
* Contains your request parameters, Savings Plan Recommendations Summary, and Details.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SavingsPlansPurchaseRecommendation implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ACCOUNT_SCOPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccountScope").getter(getter(SavingsPlansPurchaseRecommendation::accountScopeAsString))
.setter(setter(Builder::accountScope))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountScope").build()).build();
private static final SdkField SAVINGS_PLANS_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SavingsPlansType").getter(getter(SavingsPlansPurchaseRecommendation::savingsPlansTypeAsString))
.setter(setter(Builder::savingsPlansType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SavingsPlansType").build()).build();
private static final SdkField TERM_IN_YEARS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TermInYears").getter(getter(SavingsPlansPurchaseRecommendation::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(SavingsPlansPurchaseRecommendation::paymentOptionAsString))
.setter(setter(Builder::paymentOption))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PaymentOption").build()).build();
private static final SdkField LOOKBACK_PERIOD_IN_DAYS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LookbackPeriodInDays").getter(getter(SavingsPlansPurchaseRecommendation::lookbackPeriodInDaysAsString))
.setter(setter(Builder::lookbackPeriodInDays))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LookbackPeriodInDays").build())
.build();
private static final SdkField> SAVINGS_PLANS_PURCHASE_RECOMMENDATION_DETAILS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SavingsPlansPurchaseRecommendationDetails")
.getter(getter(SavingsPlansPurchaseRecommendation::savingsPlansPurchaseRecommendationDetails))
.setter(setter(Builder::savingsPlansPurchaseRecommendationDetails))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("SavingsPlansPurchaseRecommendationDetails").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(SavingsPlansPurchaseRecommendationDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField SAVINGS_PLANS_PURCHASE_RECOMMENDATION_SUMMARY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("SavingsPlansPurchaseRecommendationSummary")
.getter(getter(SavingsPlansPurchaseRecommendation::savingsPlansPurchaseRecommendationSummary))
.setter(setter(Builder::savingsPlansPurchaseRecommendationSummary))
.constructor(SavingsPlansPurchaseRecommendationSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("SavingsPlansPurchaseRecommendationSummary").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACCOUNT_SCOPE_FIELD,
SAVINGS_PLANS_TYPE_FIELD, TERM_IN_YEARS_FIELD, PAYMENT_OPTION_FIELD, LOOKBACK_PERIOD_IN_DAYS_FIELD,
SAVINGS_PLANS_PURCHASE_RECOMMENDATION_DETAILS_FIELD, SAVINGS_PLANS_PURCHASE_RECOMMENDATION_SUMMARY_FIELD));
private static final long serialVersionUID = 1L;
private final String accountScope;
private final String savingsPlansType;
private final String termInYears;
private final String paymentOption;
private final String lookbackPeriodInDays;
private final List savingsPlansPurchaseRecommendationDetails;
private final SavingsPlansPurchaseRecommendationSummary savingsPlansPurchaseRecommendationSummary;
private SavingsPlansPurchaseRecommendation(BuilderImpl builder) {
this.accountScope = builder.accountScope;
this.savingsPlansType = builder.savingsPlansType;
this.termInYears = builder.termInYears;
this.paymentOption = builder.paymentOption;
this.lookbackPeriodInDays = builder.lookbackPeriodInDays;
this.savingsPlansPurchaseRecommendationDetails = builder.savingsPlansPurchaseRecommendationDetails;
this.savingsPlansPurchaseRecommendationSummary = builder.savingsPlansPurchaseRecommendationSummary;
}
/**
*
* The account scope that you want your recommendations for. Amazon Web Services calculates recommendations that
* include the management account and member accounts if the value is set to PAYER
. If the value is
* LINKED
, recommendations are calculated for individual member accounts only.
*
*
* 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 you want your recommendations for. Amazon Web Services calculates recommendations
* that include the management account and member accounts if the value is set to PAYER
. If the
* value is LINKED
, recommendations are calculated for individual member accounts only.
* @see AccountScope
*/
public final AccountScope accountScope() {
return AccountScope.fromValue(accountScope);
}
/**
*
* The account scope that you want your recommendations for. Amazon Web Services calculates recommendations that
* include the management account and member accounts if the value is set to PAYER
. If the value is
* LINKED
, recommendations are calculated for individual member accounts only.
*
*
* 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 you want your recommendations for. Amazon Web Services calculates recommendations
* that include the management account and member accounts if the value is set to PAYER
. If the
* value is LINKED
, recommendations are calculated for individual member accounts only.
* @see AccountScope
*/
public final String accountScopeAsString() {
return accountScope;
}
/**
*
* The requested Savings Plans recommendation type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #savingsPlansType}
* will return {@link SupportedSavingsPlansType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #savingsPlansTypeAsString}.
*
*
* @return The requested Savings Plans recommendation type.
* @see SupportedSavingsPlansType
*/
public final SupportedSavingsPlansType savingsPlansType() {
return SupportedSavingsPlansType.fromValue(savingsPlansType);
}
/**
*
* The requested Savings Plans recommendation type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #savingsPlansType}
* will return {@link SupportedSavingsPlansType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is
* available from {@link #savingsPlansTypeAsString}.
*
*
* @return The requested Savings Plans recommendation type.
* @see SupportedSavingsPlansType
*/
public final String savingsPlansTypeAsString() {
return savingsPlansType;
}
/**
*
* The Savings Plans recommendation term in years. It's used to generate the recommendation.
*
*
* 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 Savings Plans recommendation term in years. It's used to generate the recommendation.
* @see TermInYears
*/
public final TermInYears termInYears() {
return TermInYears.fromValue(termInYears);
}
/**
*
* The Savings Plans recommendation term in years. It's used to generate the recommendation.
*
*
* 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 Savings Plans recommendation term in years. It's used to generate the recommendation.
* @see TermInYears
*/
public final String termInYearsAsString() {
return termInYears;
}
/**
*
* The payment option that's used to generate the recommendation.
*
*
* 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 that's used to generate the recommendation.
* @see PaymentOption
*/
public final PaymentOption paymentOption() {
return PaymentOption.fromValue(paymentOption);
}
/**
*
* The payment option that's used to generate the recommendation.
*
*
* 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 that's used to generate the recommendation.
* @see PaymentOption
*/
public final String paymentOptionAsString() {
return paymentOption;
}
/**
*
* The lookback period in days that's used to generate the 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 The lookback period in days that's used to generate the recommendation.
* @see LookbackPeriodInDays
*/
public final LookbackPeriodInDays lookbackPeriodInDays() {
return LookbackPeriodInDays.fromValue(lookbackPeriodInDays);
}
/**
*
* The lookback period in days that's used to generate the 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 The lookback period in days that's used to generate the recommendation.
* @see LookbackPeriodInDays
*/
public final String lookbackPeriodInDaysAsString() {
return lookbackPeriodInDays;
}
/**
* For responses, this returns true if the service returned a value for the
* SavingsPlansPurchaseRecommendationDetails 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 hasSavingsPlansPurchaseRecommendationDetails() {
return savingsPlansPurchaseRecommendationDetails != null
&& !(savingsPlansPurchaseRecommendationDetails instanceof SdkAutoConstructList);
}
/**
*
* Details for the Savings Plans that we recommend that you purchase to cover existing Savings Plans eligible
* workloads.
*
*
* 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 #hasSavingsPlansPurchaseRecommendationDetails} method.
*
*
* @return Details for the Savings Plans that we recommend that you purchase to cover existing Savings Plans
* eligible workloads.
*/
public final List savingsPlansPurchaseRecommendationDetails() {
return savingsPlansPurchaseRecommendationDetails;
}
/**
*
* Summary metrics for your Savings Plans Recommendations.
*
*
* @return Summary metrics for your Savings Plans Recommendations.
*/
public final SavingsPlansPurchaseRecommendationSummary savingsPlansPurchaseRecommendationSummary() {
return savingsPlansPurchaseRecommendationSummary;
}
@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(savingsPlansTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(termInYearsAsString());
hashCode = 31 * hashCode + Objects.hashCode(paymentOptionAsString());
hashCode = 31 * hashCode + Objects.hashCode(lookbackPeriodInDaysAsString());
hashCode = 31
* hashCode
+ Objects.hashCode(hasSavingsPlansPurchaseRecommendationDetails() ? savingsPlansPurchaseRecommendationDetails()
: null);
hashCode = 31 * hashCode + Objects.hashCode(savingsPlansPurchaseRecommendationSummary());
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 SavingsPlansPurchaseRecommendation)) {
return false;
}
SavingsPlansPurchaseRecommendation other = (SavingsPlansPurchaseRecommendation) obj;
return Objects.equals(accountScopeAsString(), other.accountScopeAsString())
&& Objects.equals(savingsPlansTypeAsString(), other.savingsPlansTypeAsString())
&& Objects.equals(termInYearsAsString(), other.termInYearsAsString())
&& Objects.equals(paymentOptionAsString(), other.paymentOptionAsString())
&& Objects.equals(lookbackPeriodInDaysAsString(), other.lookbackPeriodInDaysAsString())
&& hasSavingsPlansPurchaseRecommendationDetails() == other.hasSavingsPlansPurchaseRecommendationDetails()
&& Objects.equals(savingsPlansPurchaseRecommendationDetails(), other.savingsPlansPurchaseRecommendationDetails())
&& Objects.equals(savingsPlansPurchaseRecommendationSummary(), other.savingsPlansPurchaseRecommendationSummary());
}
/**
* 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("SavingsPlansPurchaseRecommendation")
.add("AccountScope", accountScopeAsString())
.add("SavingsPlansType", savingsPlansTypeAsString())
.add("TermInYears", termInYearsAsString())
.add("PaymentOption", paymentOptionAsString())
.add("LookbackPeriodInDays", lookbackPeriodInDaysAsString())
.add("SavingsPlansPurchaseRecommendationDetails",
hasSavingsPlansPurchaseRecommendationDetails() ? savingsPlansPurchaseRecommendationDetails() : null)
.add("SavingsPlansPurchaseRecommendationSummary", savingsPlansPurchaseRecommendationSummary()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AccountScope":
return Optional.ofNullable(clazz.cast(accountScopeAsString()));
case "SavingsPlansType":
return Optional.ofNullable(clazz.cast(savingsPlansTypeAsString()));
case "TermInYears":
return Optional.ofNullable(clazz.cast(termInYearsAsString()));
case "PaymentOption":
return Optional.ofNullable(clazz.cast(paymentOptionAsString()));
case "LookbackPeriodInDays":
return Optional.ofNullable(clazz.cast(lookbackPeriodInDaysAsString()));
case "SavingsPlansPurchaseRecommendationDetails":
return Optional.ofNullable(clazz.cast(savingsPlansPurchaseRecommendationDetails()));
case "SavingsPlansPurchaseRecommendationSummary":
return Optional.ofNullable(clazz.cast(savingsPlansPurchaseRecommendationSummary()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function