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 extends Builder> 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