All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.costexplorer.model.RightsizingRecommendation Maven / Gradle / Ivy

/*
 * 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 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;

/**
 * 

* Recommendations to rightsize resources. *

*/ @Generated("software.amazon.awssdk:codegen") public final class RightsizingRecommendation implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("AccountId").getter(getter(RightsizingRecommendation::accountId)).setter(setter(Builder::accountId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountId").build()).build(); private static final SdkField CURRENT_INSTANCE_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("CurrentInstance") .getter(getter(RightsizingRecommendation::currentInstance)).setter(setter(Builder::currentInstance)) .constructor(CurrentInstance::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CurrentInstance").build()).build(); private static final SdkField RIGHTSIZING_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("RightsizingType").getter(getter(RightsizingRecommendation::rightsizingTypeAsString)) .setter(setter(Builder::rightsizingType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RightsizingType").build()).build(); private static final SdkField MODIFY_RECOMMENDATION_DETAIL_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("ModifyRecommendationDetail") .getter(getter(RightsizingRecommendation::modifyRecommendationDetail)) .setter(setter(Builder::modifyRecommendationDetail)) .constructor(ModifyRecommendationDetail::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ModifyRecommendationDetail").build()) .build(); private static final SdkField TERMINATE_RECOMMENDATION_DETAIL_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("TerminateRecommendationDetail") .getter(getter(RightsizingRecommendation::terminateRecommendationDetail)) .setter(setter(Builder::terminateRecommendationDetail)) .constructor(TerminateRecommendationDetail::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TerminateRecommendationDetail") .build()).build(); private static final SdkField> FINDING_REASON_CODES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("FindingReasonCodes") .getter(getter(RightsizingRecommendation::findingReasonCodesAsStrings)) .setter(setter(Builder::findingReasonCodesWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FindingReasonCodes").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACCOUNT_ID_FIELD, CURRENT_INSTANCE_FIELD, RIGHTSIZING_TYPE_FIELD, MODIFY_RECOMMENDATION_DETAIL_FIELD, TERMINATE_RECOMMENDATION_DETAIL_FIELD, FINDING_REASON_CODES_FIELD)); private static final long serialVersionUID = 1L; private final String accountId; private final CurrentInstance currentInstance; private final String rightsizingType; private final ModifyRecommendationDetail modifyRecommendationDetail; private final TerminateRecommendationDetail terminateRecommendationDetail; private final List findingReasonCodes; private RightsizingRecommendation(BuilderImpl builder) { this.accountId = builder.accountId; this.currentInstance = builder.currentInstance; this.rightsizingType = builder.rightsizingType; this.modifyRecommendationDetail = builder.modifyRecommendationDetail; this.terminateRecommendationDetail = builder.terminateRecommendationDetail; this.findingReasonCodes = builder.findingReasonCodes; } /** *

* The account that this recommendation is for. *

* * @return The account that this recommendation is for. */ public final String accountId() { return accountId; } /** *

* Context regarding the current instance. *

* * @return Context regarding the current instance. */ public final CurrentInstance currentInstance() { return currentInstance; } /** *

* Recommendation to either terminate or modify the resource. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #rightsizingType} * will return {@link RightsizingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #rightsizingTypeAsString}. *

* * @return Recommendation to either terminate or modify the resource. * @see RightsizingType */ public final RightsizingType rightsizingType() { return RightsizingType.fromValue(rightsizingType); } /** *

* Recommendation to either terminate or modify the resource. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #rightsizingType} * will return {@link RightsizingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available * from {@link #rightsizingTypeAsString}. *

* * @return Recommendation to either terminate or modify the resource. * @see RightsizingType */ public final String rightsizingTypeAsString() { return rightsizingType; } /** *

* Details for modification recommendations. *

* * @return Details for modification recommendations. */ public final ModifyRecommendationDetail modifyRecommendationDetail() { return modifyRecommendationDetail; } /** *

* Details for termination recommendations. *

* * @return Details for termination recommendations. */ public final TerminateRecommendationDetail terminateRecommendationDetail() { return terminateRecommendationDetail; } /** *

* The list of possible reasons why the recommendation is generated such as under or over utilization of specific * metrics (for example, CPU, Memory, Network). *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasFindingReasonCodes()} to see if a value was sent in this field. *

* * @return The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). */ public final List findingReasonCodes() { return FindingReasonCodesCopier.copyStringToEnum(findingReasonCodes); } /** * Returns true if the FindingReasonCodes property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasFindingReasonCodes() { return findingReasonCodes != null && !(findingReasonCodes instanceof SdkAutoConstructList); } /** *

* The list of possible reasons why the recommendation is generated such as under or over utilization of specific * metrics (for example, CPU, Memory, Network). *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasFindingReasonCodes()} to see if a value was sent in this field. *

* * @return The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). */ public final List findingReasonCodesAsStrings() { return findingReasonCodes; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(accountId()); hashCode = 31 * hashCode + Objects.hashCode(currentInstance()); hashCode = 31 * hashCode + Objects.hashCode(rightsizingTypeAsString()); hashCode = 31 * hashCode + Objects.hashCode(modifyRecommendationDetail()); hashCode = 31 * hashCode + Objects.hashCode(terminateRecommendationDetail()); hashCode = 31 * hashCode + Objects.hashCode(hasFindingReasonCodes() ? findingReasonCodesAsStrings() : 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 RightsizingRecommendation)) { return false; } RightsizingRecommendation other = (RightsizingRecommendation) obj; return Objects.equals(accountId(), other.accountId()) && Objects.equals(currentInstance(), other.currentInstance()) && Objects.equals(rightsizingTypeAsString(), other.rightsizingTypeAsString()) && Objects.equals(modifyRecommendationDetail(), other.modifyRecommendationDetail()) && Objects.equals(terminateRecommendationDetail(), other.terminateRecommendationDetail()) && hasFindingReasonCodes() == other.hasFindingReasonCodes() && Objects.equals(findingReasonCodesAsStrings(), other.findingReasonCodesAsStrings()); } /** * 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("RightsizingRecommendation").add("AccountId", accountId()) .add("CurrentInstance", currentInstance()).add("RightsizingType", rightsizingTypeAsString()) .add("ModifyRecommendationDetail", modifyRecommendationDetail()) .add("TerminateRecommendationDetail", terminateRecommendationDetail()) .add("FindingReasonCodes", hasFindingReasonCodes() ? findingReasonCodesAsStrings() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "AccountId": return Optional.ofNullable(clazz.cast(accountId())); case "CurrentInstance": return Optional.ofNullable(clazz.cast(currentInstance())); case "RightsizingType": return Optional.ofNullable(clazz.cast(rightsizingTypeAsString())); case "ModifyRecommendationDetail": return Optional.ofNullable(clazz.cast(modifyRecommendationDetail())); case "TerminateRecommendationDetail": return Optional.ofNullable(clazz.cast(terminateRecommendationDetail())); case "FindingReasonCodes": return Optional.ofNullable(clazz.cast(findingReasonCodesAsStrings())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((RightsizingRecommendation) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The account that this recommendation is for. *

* * @param accountId * The account that this recommendation is for. * @return Returns a reference to this object so that method calls can be chained together. */ Builder accountId(String accountId); /** *

* Context regarding the current instance. *

* * @param currentInstance * Context regarding the current instance. * @return Returns a reference to this object so that method calls can be chained together. */ Builder currentInstance(CurrentInstance currentInstance); /** *

* Context regarding the current instance. *

* This is a convenience that creates an instance of the {@link CurrentInstance.Builder} avoiding the need to * create one manually via {@link CurrentInstance#builder()}. * * When the {@link Consumer} completes, {@link CurrentInstance.Builder#build()} is called immediately and its * result is passed to {@link #currentInstance(CurrentInstance)}. * * @param currentInstance * a consumer that will call methods on {@link CurrentInstance.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #currentInstance(CurrentInstance) */ default Builder currentInstance(Consumer currentInstance) { return currentInstance(CurrentInstance.builder().applyMutation(currentInstance).build()); } /** *

* Recommendation to either terminate or modify the resource. *

* * @param rightsizingType * Recommendation to either terminate or modify the resource. * @see RightsizingType * @return Returns a reference to this object so that method calls can be chained together. * @see RightsizingType */ Builder rightsizingType(String rightsizingType); /** *

* Recommendation to either terminate or modify the resource. *

* * @param rightsizingType * Recommendation to either terminate or modify the resource. * @see RightsizingType * @return Returns a reference to this object so that method calls can be chained together. * @see RightsizingType */ Builder rightsizingType(RightsizingType rightsizingType); /** *

* Details for modification recommendations. *

* * @param modifyRecommendationDetail * Details for modification recommendations. * @return Returns a reference to this object so that method calls can be chained together. */ Builder modifyRecommendationDetail(ModifyRecommendationDetail modifyRecommendationDetail); /** *

* Details for modification recommendations. *

* This is a convenience that creates an instance of the {@link ModifyRecommendationDetail.Builder} avoiding the * need to create one manually via {@link ModifyRecommendationDetail#builder()}. * * When the {@link Consumer} completes, {@link ModifyRecommendationDetail.Builder#build()} is called immediately * and its result is passed to {@link #modifyRecommendationDetail(ModifyRecommendationDetail)}. * * @param modifyRecommendationDetail * a consumer that will call methods on {@link ModifyRecommendationDetail.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #modifyRecommendationDetail(ModifyRecommendationDetail) */ default Builder modifyRecommendationDetail(Consumer modifyRecommendationDetail) { return modifyRecommendationDetail(ModifyRecommendationDetail.builder().applyMutation(modifyRecommendationDetail) .build()); } /** *

* Details for termination recommendations. *

* * @param terminateRecommendationDetail * Details for termination recommendations. * @return Returns a reference to this object so that method calls can be chained together. */ Builder terminateRecommendationDetail(TerminateRecommendationDetail terminateRecommendationDetail); /** *

* Details for termination recommendations. *

* This is a convenience that creates an instance of the {@link TerminateRecommendationDetail.Builder} avoiding * the need to create one manually via {@link TerminateRecommendationDetail#builder()}. * * When the {@link Consumer} completes, {@link TerminateRecommendationDetail.Builder#build()} is called * immediately and its result is passed to {@link #terminateRecommendationDetail(TerminateRecommendationDetail)} * . * * @param terminateRecommendationDetail * a consumer that will call methods on {@link TerminateRecommendationDetail.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #terminateRecommendationDetail(TerminateRecommendationDetail) */ default Builder terminateRecommendationDetail( Consumer terminateRecommendationDetail) { return terminateRecommendationDetail(TerminateRecommendationDetail.builder() .applyMutation(terminateRecommendationDetail).build()); } /** *

* The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). *

* * @param findingReasonCodes * The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). * @return Returns a reference to this object so that method calls can be chained together. */ Builder findingReasonCodesWithStrings(Collection findingReasonCodes); /** *

* The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). *

* * @param findingReasonCodes * The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). * @return Returns a reference to this object so that method calls can be chained together. */ Builder findingReasonCodesWithStrings(String... findingReasonCodes); /** *

* The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). *

* * @param findingReasonCodes * The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). * @return Returns a reference to this object so that method calls can be chained together. */ Builder findingReasonCodes(Collection findingReasonCodes); /** *

* The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). *

* * @param findingReasonCodes * The list of possible reasons why the recommendation is generated such as under or over utilization of * specific metrics (for example, CPU, Memory, Network). * @return Returns a reference to this object so that method calls can be chained together. */ Builder findingReasonCodes(FindingReasonCode... findingReasonCodes); } static final class BuilderImpl implements Builder { private String accountId; private CurrentInstance currentInstance; private String rightsizingType; private ModifyRecommendationDetail modifyRecommendationDetail; private TerminateRecommendationDetail terminateRecommendationDetail; private List findingReasonCodes = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(RightsizingRecommendation model) { accountId(model.accountId); currentInstance(model.currentInstance); rightsizingType(model.rightsizingType); modifyRecommendationDetail(model.modifyRecommendationDetail); terminateRecommendationDetail(model.terminateRecommendationDetail); findingReasonCodesWithStrings(model.findingReasonCodes); } public final String getAccountId() { return accountId; } @Override public final Builder accountId(String accountId) { this.accountId = accountId; return this; } public final void setAccountId(String accountId) { this.accountId = accountId; } public final CurrentInstance.Builder getCurrentInstance() { return currentInstance != null ? currentInstance.toBuilder() : null; } @Override public final Builder currentInstance(CurrentInstance currentInstance) { this.currentInstance = currentInstance; return this; } public final void setCurrentInstance(CurrentInstance.BuilderImpl currentInstance) { this.currentInstance = currentInstance != null ? currentInstance.build() : null; } public final String getRightsizingType() { return rightsizingType; } @Override public final Builder rightsizingType(String rightsizingType) { this.rightsizingType = rightsizingType; return this; } @Override public final Builder rightsizingType(RightsizingType rightsizingType) { this.rightsizingType(rightsizingType == null ? null : rightsizingType.toString()); return this; } public final void setRightsizingType(String rightsizingType) { this.rightsizingType = rightsizingType; } public final ModifyRecommendationDetail.Builder getModifyRecommendationDetail() { return modifyRecommendationDetail != null ? modifyRecommendationDetail.toBuilder() : null; } @Override public final Builder modifyRecommendationDetail(ModifyRecommendationDetail modifyRecommendationDetail) { this.modifyRecommendationDetail = modifyRecommendationDetail; return this; } public final void setModifyRecommendationDetail(ModifyRecommendationDetail.BuilderImpl modifyRecommendationDetail) { this.modifyRecommendationDetail = modifyRecommendationDetail != null ? modifyRecommendationDetail.build() : null; } public final TerminateRecommendationDetail.Builder getTerminateRecommendationDetail() { return terminateRecommendationDetail != null ? terminateRecommendationDetail.toBuilder() : null; } @Override public final Builder terminateRecommendationDetail(TerminateRecommendationDetail terminateRecommendationDetail) { this.terminateRecommendationDetail = terminateRecommendationDetail; return this; } public final void setTerminateRecommendationDetail(TerminateRecommendationDetail.BuilderImpl terminateRecommendationDetail) { this.terminateRecommendationDetail = terminateRecommendationDetail != null ? terminateRecommendationDetail.build() : null; } public final Collection getFindingReasonCodes() { if (findingReasonCodes instanceof SdkAutoConstructList) { return null; } return findingReasonCodes; } @Override public final Builder findingReasonCodesWithStrings(Collection findingReasonCodes) { this.findingReasonCodes = FindingReasonCodesCopier.copy(findingReasonCodes); return this; } @Override @SafeVarargs public final Builder findingReasonCodesWithStrings(String... findingReasonCodes) { findingReasonCodesWithStrings(Arrays.asList(findingReasonCodes)); return this; } @Override public final Builder findingReasonCodes(Collection findingReasonCodes) { this.findingReasonCodes = FindingReasonCodesCopier.copyEnumToString(findingReasonCodes); return this; } @Override @SafeVarargs public final Builder findingReasonCodes(FindingReasonCode... findingReasonCodes) { findingReasonCodes(Arrays.asList(findingReasonCodes)); return this; } public final void setFindingReasonCodes(Collection findingReasonCodes) { this.findingReasonCodes = FindingReasonCodesCopier.copy(findingReasonCodes); } @Override public RightsizingRecommendation build() { return new RightsizingRecommendation(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy