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

software.amazon.awssdk.services.computeoptimizer.model.LambdaFunctionMemoryRecommendationOption Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Compute Optimizer module holds the client classes that are used for communicating with Compute Optimizer.

There is a newer version: 2.29.15
Show newest version
/*
 * 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.computeoptimizer.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;

/**
 * 

* Describes a recommendation option for an Lambda function. *

*/ @Generated("software.amazon.awssdk:codegen") public final class LambdaFunctionMemoryRecommendationOption implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField RANK_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("rank") .getter(getter(LambdaFunctionMemoryRecommendationOption::rank)).setter(setter(Builder::rank)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("rank").build()).build(); private static final SdkField MEMORY_SIZE_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("memorySize").getter(getter(LambdaFunctionMemoryRecommendationOption::memorySize)) .setter(setter(Builder::memorySize)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("memorySize").build()).build(); private static final SdkField> PROJECTED_UTILIZATION_METRICS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("projectedUtilizationMetrics") .getter(getter(LambdaFunctionMemoryRecommendationOption::projectedUtilizationMetrics)) .setter(setter(Builder::projectedUtilizationMetrics)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("projectedUtilizationMetrics") .build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(LambdaFunctionMemoryProjectedMetric::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField SAVINGS_OPPORTUNITY_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("savingsOpportunity") .getter(getter(LambdaFunctionMemoryRecommendationOption::savingsOpportunity)) .setter(setter(Builder::savingsOpportunity)).constructor(SavingsOpportunity::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("savingsOpportunity").build()) .build(); private static final SdkField SAVINGS_OPPORTUNITY_AFTER_DISCOUNTS_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("savingsOpportunityAfterDiscounts") .getter(getter(LambdaFunctionMemoryRecommendationOption::savingsOpportunityAfterDiscounts)) .setter(setter(Builder::savingsOpportunityAfterDiscounts)) .constructor(LambdaSavingsOpportunityAfterDiscounts::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("savingsOpportunityAfterDiscounts") .build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RANK_FIELD, MEMORY_SIZE_FIELD, PROJECTED_UTILIZATION_METRICS_FIELD, SAVINGS_OPPORTUNITY_FIELD, SAVINGS_OPPORTUNITY_AFTER_DISCOUNTS_FIELD)); private static final long serialVersionUID = 1L; private final Integer rank; private final Integer memorySize; private final List projectedUtilizationMetrics; private final SavingsOpportunity savingsOpportunity; private final LambdaSavingsOpportunityAfterDiscounts savingsOpportunityAfterDiscounts; private LambdaFunctionMemoryRecommendationOption(BuilderImpl builder) { this.rank = builder.rank; this.memorySize = builder.memorySize; this.projectedUtilizationMetrics = builder.projectedUtilizationMetrics; this.savingsOpportunity = builder.savingsOpportunity; this.savingsOpportunityAfterDiscounts = builder.savingsOpportunityAfterDiscounts; } /** *

* The rank of the function recommendation option. *

*

* The top recommendation option is ranked as 1. *

* * @return The rank of the function recommendation option.

*

* The top recommendation option is ranked as 1. */ public final Integer rank() { return rank; } /** *

* The memory size, in MB, of the function recommendation option. *

* * @return The memory size, in MB, of the function recommendation option. */ public final Integer memorySize() { return memorySize; } /** * For responses, this returns true if the service returned a value for the ProjectedUtilizationMetrics 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 hasProjectedUtilizationMetrics() { return projectedUtilizationMetrics != null && !(projectedUtilizationMetrics instanceof SdkAutoConstructList); } /** *

* An array of objects that describe the projected utilization metrics of the function recommendation option. *

*

* 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 #hasProjectedUtilizationMetrics} method. *

* * @return An array of objects that describe the projected utilization metrics of the function recommendation * option. */ public final List projectedUtilizationMetrics() { return projectedUtilizationMetrics; } /** *

* An object that describes the savings opportunity for the Lambda function recommendation option. Savings * opportunity includes the estimated monthly savings amount and percentage. *

* * @return An object that describes the savings opportunity for the Lambda function recommendation option. Savings * opportunity includes the estimated monthly savings amount and percentage. */ public final SavingsOpportunity savingsOpportunity() { return savingsOpportunity; } /** *

* An object that describes the savings opportunity for the Lambda recommendation option which includes Saving Plans * discounts. Savings opportunity includes the estimated monthly savings and percentage. *

* * @return An object that describes the savings opportunity for the Lambda recommendation option which includes * Saving Plans discounts. Savings opportunity includes the estimated monthly savings and percentage. */ public final LambdaSavingsOpportunityAfterDiscounts savingsOpportunityAfterDiscounts() { return savingsOpportunityAfterDiscounts; } @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(rank()); hashCode = 31 * hashCode + Objects.hashCode(memorySize()); hashCode = 31 * hashCode + Objects.hashCode(hasProjectedUtilizationMetrics() ? projectedUtilizationMetrics() : null); hashCode = 31 * hashCode + Objects.hashCode(savingsOpportunity()); hashCode = 31 * hashCode + Objects.hashCode(savingsOpportunityAfterDiscounts()); 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 LambdaFunctionMemoryRecommendationOption)) { return false; } LambdaFunctionMemoryRecommendationOption other = (LambdaFunctionMemoryRecommendationOption) obj; return Objects.equals(rank(), other.rank()) && Objects.equals(memorySize(), other.memorySize()) && hasProjectedUtilizationMetrics() == other.hasProjectedUtilizationMetrics() && Objects.equals(projectedUtilizationMetrics(), other.projectedUtilizationMetrics()) && Objects.equals(savingsOpportunity(), other.savingsOpportunity()) && Objects.equals(savingsOpportunityAfterDiscounts(), other.savingsOpportunityAfterDiscounts()); } /** * 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("LambdaFunctionMemoryRecommendationOption").add("Rank", rank()).add("MemorySize", memorySize()) .add("ProjectedUtilizationMetrics", hasProjectedUtilizationMetrics() ? projectedUtilizationMetrics() : null) .add("SavingsOpportunity", savingsOpportunity()) .add("SavingsOpportunityAfterDiscounts", savingsOpportunityAfterDiscounts()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "rank": return Optional.ofNullable(clazz.cast(rank())); case "memorySize": return Optional.ofNullable(clazz.cast(memorySize())); case "projectedUtilizationMetrics": return Optional.ofNullable(clazz.cast(projectedUtilizationMetrics())); case "savingsOpportunity": return Optional.ofNullable(clazz.cast(savingsOpportunity())); case "savingsOpportunityAfterDiscounts": return Optional.ofNullable(clazz.cast(savingsOpportunityAfterDiscounts())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((LambdaFunctionMemoryRecommendationOption) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The rank of the function recommendation option. *

*

* The top recommendation option is ranked as 1. *

* * @param rank * The rank of the function recommendation option.

*

* The top recommendation option is ranked as 1. * @return Returns a reference to this object so that method calls can be chained together. */ Builder rank(Integer rank); /** *

* The memory size, in MB, of the function recommendation option. *

* * @param memorySize * The memory size, in MB, of the function recommendation option. * @return Returns a reference to this object so that method calls can be chained together. */ Builder memorySize(Integer memorySize); /** *

* An array of objects that describe the projected utilization metrics of the function recommendation option. *

* * @param projectedUtilizationMetrics * An array of objects that describe the projected utilization metrics of the function recommendation * option. * @return Returns a reference to this object so that method calls can be chained together. */ Builder projectedUtilizationMetrics(Collection projectedUtilizationMetrics); /** *

* An array of objects that describe the projected utilization metrics of the function recommendation option. *

* * @param projectedUtilizationMetrics * An array of objects that describe the projected utilization metrics of the function recommendation * option. * @return Returns a reference to this object so that method calls can be chained together. */ Builder projectedUtilizationMetrics(LambdaFunctionMemoryProjectedMetric... projectedUtilizationMetrics); /** *

* An array of objects that describe the projected utilization metrics of the function recommendation option. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.computeoptimizer.model.LambdaFunctionMemoryProjectedMetric.Builder} * avoiding the need to create one manually via * {@link software.amazon.awssdk.services.computeoptimizer.model.LambdaFunctionMemoryProjectedMetric#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.computeoptimizer.model.LambdaFunctionMemoryProjectedMetric.Builder#build()} * is called immediately and its result is passed to {@link * #projectedUtilizationMetrics(List)}. * * @param projectedUtilizationMetrics * a consumer that will call methods on * {@link software.amazon.awssdk.services.computeoptimizer.model.LambdaFunctionMemoryProjectedMetric.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #projectedUtilizationMetrics(java.util.Collection) */ Builder projectedUtilizationMetrics(Consumer... projectedUtilizationMetrics); /** *

* An object that describes the savings opportunity for the Lambda function recommendation option. Savings * opportunity includes the estimated monthly savings amount and percentage. *

* * @param savingsOpportunity * An object that describes the savings opportunity for the Lambda function recommendation option. * Savings opportunity includes the estimated monthly savings amount and percentage. * @return Returns a reference to this object so that method calls can be chained together. */ Builder savingsOpportunity(SavingsOpportunity savingsOpportunity); /** *

* An object that describes the savings opportunity for the Lambda function recommendation option. Savings * opportunity includes the estimated monthly savings amount and percentage. *

* This is a convenience method that creates an instance of the {@link SavingsOpportunity.Builder} avoiding the * need to create one manually via {@link SavingsOpportunity#builder()}. * *

* When the {@link Consumer} completes, {@link SavingsOpportunity.Builder#build()} is called immediately and its * result is passed to {@link #savingsOpportunity(SavingsOpportunity)}. * * @param savingsOpportunity * a consumer that will call methods on {@link SavingsOpportunity.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #savingsOpportunity(SavingsOpportunity) */ default Builder savingsOpportunity(Consumer savingsOpportunity) { return savingsOpportunity(SavingsOpportunity.builder().applyMutation(savingsOpportunity).build()); } /** *

* An object that describes the savings opportunity for the Lambda recommendation option which includes Saving * Plans discounts. Savings opportunity includes the estimated monthly savings and percentage. *

* * @param savingsOpportunityAfterDiscounts * An object that describes the savings opportunity for the Lambda recommendation option which includes * Saving Plans discounts. Savings opportunity includes the estimated monthly savings and percentage. * @return Returns a reference to this object so that method calls can be chained together. */ Builder savingsOpportunityAfterDiscounts(LambdaSavingsOpportunityAfterDiscounts savingsOpportunityAfterDiscounts); /** *

* An object that describes the savings opportunity for the Lambda recommendation option which includes Saving * Plans discounts. Savings opportunity includes the estimated monthly savings and percentage. *

* This is a convenience method that creates an instance of the * {@link LambdaSavingsOpportunityAfterDiscounts.Builder} avoiding the need to create one manually via * {@link LambdaSavingsOpportunityAfterDiscounts#builder()}. * *

* When the {@link Consumer} completes, {@link LambdaSavingsOpportunityAfterDiscounts.Builder#build()} is called * immediately and its result is passed to * {@link #savingsOpportunityAfterDiscounts(LambdaSavingsOpportunityAfterDiscounts)}. * * @param savingsOpportunityAfterDiscounts * a consumer that will call methods on {@link LambdaSavingsOpportunityAfterDiscounts.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #savingsOpportunityAfterDiscounts(LambdaSavingsOpportunityAfterDiscounts) */ default Builder savingsOpportunityAfterDiscounts( Consumer savingsOpportunityAfterDiscounts) { return savingsOpportunityAfterDiscounts(LambdaSavingsOpportunityAfterDiscounts.builder() .applyMutation(savingsOpportunityAfterDiscounts).build()); } } static final class BuilderImpl implements Builder { private Integer rank; private Integer memorySize; private List projectedUtilizationMetrics = DefaultSdkAutoConstructList.getInstance(); private SavingsOpportunity savingsOpportunity; private LambdaSavingsOpportunityAfterDiscounts savingsOpportunityAfterDiscounts; private BuilderImpl() { } private BuilderImpl(LambdaFunctionMemoryRecommendationOption model) { rank(model.rank); memorySize(model.memorySize); projectedUtilizationMetrics(model.projectedUtilizationMetrics); savingsOpportunity(model.savingsOpportunity); savingsOpportunityAfterDiscounts(model.savingsOpportunityAfterDiscounts); } public final Integer getRank() { return rank; } public final void setRank(Integer rank) { this.rank = rank; } @Override public final Builder rank(Integer rank) { this.rank = rank; return this; } public final Integer getMemorySize() { return memorySize; } public final void setMemorySize(Integer memorySize) { this.memorySize = memorySize; } @Override public final Builder memorySize(Integer memorySize) { this.memorySize = memorySize; return this; } public final List getProjectedUtilizationMetrics() { List result = LambdaFunctionMemoryProjectedMetricsCopier .copyToBuilder(this.projectedUtilizationMetrics); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setProjectedUtilizationMetrics( Collection projectedUtilizationMetrics) { this.projectedUtilizationMetrics = LambdaFunctionMemoryProjectedMetricsCopier .copyFromBuilder(projectedUtilizationMetrics); } @Override public final Builder projectedUtilizationMetrics( Collection projectedUtilizationMetrics) { this.projectedUtilizationMetrics = LambdaFunctionMemoryProjectedMetricsCopier.copy(projectedUtilizationMetrics); return this; } @Override @SafeVarargs public final Builder projectedUtilizationMetrics(LambdaFunctionMemoryProjectedMetric... projectedUtilizationMetrics) { projectedUtilizationMetrics(Arrays.asList(projectedUtilizationMetrics)); return this; } @Override @SafeVarargs public final Builder projectedUtilizationMetrics( Consumer... projectedUtilizationMetrics) { projectedUtilizationMetrics(Stream.of(projectedUtilizationMetrics) .map(c -> LambdaFunctionMemoryProjectedMetric.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final SavingsOpportunity.Builder getSavingsOpportunity() { return savingsOpportunity != null ? savingsOpportunity.toBuilder() : null; } public final void setSavingsOpportunity(SavingsOpportunity.BuilderImpl savingsOpportunity) { this.savingsOpportunity = savingsOpportunity != null ? savingsOpportunity.build() : null; } @Override public final Builder savingsOpportunity(SavingsOpportunity savingsOpportunity) { this.savingsOpportunity = savingsOpportunity; return this; } public final LambdaSavingsOpportunityAfterDiscounts.Builder getSavingsOpportunityAfterDiscounts() { return savingsOpportunityAfterDiscounts != null ? savingsOpportunityAfterDiscounts.toBuilder() : null; } public final void setSavingsOpportunityAfterDiscounts( LambdaSavingsOpportunityAfterDiscounts.BuilderImpl savingsOpportunityAfterDiscounts) { this.savingsOpportunityAfterDiscounts = savingsOpportunityAfterDiscounts != null ? savingsOpportunityAfterDiscounts .build() : null; } @Override public final Builder savingsOpportunityAfterDiscounts( LambdaSavingsOpportunityAfterDiscounts savingsOpportunityAfterDiscounts) { this.savingsOpportunityAfterDiscounts = savingsOpportunityAfterDiscounts; return this; } @Override public LambdaFunctionMemoryRecommendationOption build() { return new LambdaFunctionMemoryRecommendationOption(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy