software.amazon.awssdk.services.costexplorer.model.RightsizingRecommendation 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.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.LocationTrait;
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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACCOUNT_ID_FIELD,
CURRENT_INSTANCE_FIELD, RIGHTSIZING_TYPE_FIELD, MODIFY_RECOMMENDATION_DETAIL_FIELD,
TERMINATE_RECOMMENDATION_DETAIL_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 RightsizingRecommendation(BuilderImpl builder) {
this.accountId = builder.accountId;
this.currentInstance = builder.currentInstance;
this.rightsizingType = builder.rightsizingType;
this.modifyRecommendationDetail = builder.modifyRecommendationDetail;
this.terminateRecommendationDetail = builder.terminateRecommendationDetail;
}
/**
*
* 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;
}
@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());
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());
}
/**
* 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()).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()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function