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

software.amazon.awssdk.services.applicationdiscovery.model.Ec2RecommendationsExportPreferences Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Application Discovery Service module holds the client classes that are used for communicating with AWS Application Discovery Service.

There is a newer version: 2.28.6
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.applicationdiscovery.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;

/**
 * 

* Indicates that the exported data must include EC2 instance type matches for on-premises servers that are discovered * through Amazon Web Services Application Discovery Service. *

*/ @Generated("software.amazon.awssdk:codegen") public final class Ec2RecommendationsExportPreferences implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .memberName("enabled").getter(getter(Ec2RecommendationsExportPreferences::enabled)).setter(setter(Builder::enabled)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("enabled").build()).build(); private static final SdkField CPU_PERFORMANCE_METRIC_BASIS_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("cpuPerformanceMetricBasis") .getter(getter(Ec2RecommendationsExportPreferences::cpuPerformanceMetricBasis)) .setter(setter(Builder::cpuPerformanceMetricBasis)).constructor(UsageMetricBasis::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("cpuPerformanceMetricBasis").build()) .build(); private static final SdkField RAM_PERFORMANCE_METRIC_BASIS_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("ramPerformanceMetricBasis") .getter(getter(Ec2RecommendationsExportPreferences::ramPerformanceMetricBasis)) .setter(setter(Builder::ramPerformanceMetricBasis)).constructor(UsageMetricBasis::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ramPerformanceMetricBasis").build()) .build(); private static final SdkField TENANCY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("tenancy") .getter(getter(Ec2RecommendationsExportPreferences::tenancyAsString)).setter(setter(Builder::tenancy)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tenancy").build()).build(); private static final SdkField> EXCLUDED_INSTANCE_TYPES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("excludedInstanceTypes") .getter(getter(Ec2RecommendationsExportPreferences::excludedInstanceTypes)) .setter(setter(Builder::excludedInstanceTypes)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("excludedInstanceTypes").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 SdkField PREFERRED_REGION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("preferredRegion").getter(getter(Ec2RecommendationsExportPreferences::preferredRegion)) .setter(setter(Builder::preferredRegion)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("preferredRegion").build()).build(); private static final SdkField RESERVED_INSTANCE_OPTIONS_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("reservedInstanceOptions") .getter(getter(Ec2RecommendationsExportPreferences::reservedInstanceOptions)) .setter(setter(Builder::reservedInstanceOptions)).constructor(ReservedInstanceOptions::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("reservedInstanceOptions").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ENABLED_FIELD, CPU_PERFORMANCE_METRIC_BASIS_FIELD, RAM_PERFORMANCE_METRIC_BASIS_FIELD, TENANCY_FIELD, EXCLUDED_INSTANCE_TYPES_FIELD, PREFERRED_REGION_FIELD, RESERVED_INSTANCE_OPTIONS_FIELD)); private static final long serialVersionUID = 1L; private final Boolean enabled; private final UsageMetricBasis cpuPerformanceMetricBasis; private final UsageMetricBasis ramPerformanceMetricBasis; private final String tenancy; private final List excludedInstanceTypes; private final String preferredRegion; private final ReservedInstanceOptions reservedInstanceOptions; private Ec2RecommendationsExportPreferences(BuilderImpl builder) { this.enabled = builder.enabled; this.cpuPerformanceMetricBasis = builder.cpuPerformanceMetricBasis; this.ramPerformanceMetricBasis = builder.ramPerformanceMetricBasis; this.tenancy = builder.tenancy; this.excludedInstanceTypes = builder.excludedInstanceTypes; this.preferredRegion = builder.preferredRegion; this.reservedInstanceOptions = builder.reservedInstanceOptions; } /** *

* If set to true, the export preferences is set to Ec2RecommendationsExportPreferences. *

* * @return If set to true, the export preferences is set to Ec2RecommendationsExportPreferences. */ public final Boolean enabled() { return enabled; } /** *

* The recommended EC2 instance type that matches the CPU usage metric of server performance data. *

* * @return The recommended EC2 instance type that matches the CPU usage metric of server performance data. */ public final UsageMetricBasis cpuPerformanceMetricBasis() { return cpuPerformanceMetricBasis; } /** *

* The recommended EC2 instance type that matches the Memory usage metric of server performance data. *

* * @return The recommended EC2 instance type that matches the Memory usage metric of server performance data. */ public final UsageMetricBasis ramPerformanceMetricBasis() { return ramPerformanceMetricBasis; } /** *

* The target tenancy to use for your recommended EC2 instances. *

*

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

* * @return The target tenancy to use for your recommended EC2 instances. * @see Tenancy */ public final Tenancy tenancy() { return Tenancy.fromValue(tenancy); } /** *

* The target tenancy to use for your recommended EC2 instances. *

*

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

* * @return The target tenancy to use for your recommended EC2 instances. * @see Tenancy */ public final String tenancyAsString() { return tenancy; } /** * For responses, this returns true if the service returned a value for the ExcludedInstanceTypes 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 hasExcludedInstanceTypes() { return excludedInstanceTypes != null && !(excludedInstanceTypes instanceof SdkAutoConstructList); } /** *

* An array of instance types to exclude from recommendations. *

*

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

* * @return An array of instance types to exclude from recommendations. */ public final List excludedInstanceTypes() { return excludedInstanceTypes; } /** *

* The target Amazon Web Services Region for the recommendations. You can use any of the Region codes available for * the chosen service, as listed in Amazon Web * Services service endpoints in the Amazon Web Services General Reference. *

* * @return The target Amazon Web Services Region for the recommendations. You can use any of the Region codes * available for the chosen service, as listed in Amazon Web Services service endpoints * in the Amazon Web Services General Reference. */ public final String preferredRegion() { return preferredRegion; } /** *

* The contract type for a reserved instance. If blank, we assume an On-Demand instance is preferred. *

* * @return The contract type for a reserved instance. If blank, we assume an On-Demand instance is preferred. */ public final ReservedInstanceOptions reservedInstanceOptions() { return reservedInstanceOptions; } @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(enabled()); hashCode = 31 * hashCode + Objects.hashCode(cpuPerformanceMetricBasis()); hashCode = 31 * hashCode + Objects.hashCode(ramPerformanceMetricBasis()); hashCode = 31 * hashCode + Objects.hashCode(tenancyAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasExcludedInstanceTypes() ? excludedInstanceTypes() : null); hashCode = 31 * hashCode + Objects.hashCode(preferredRegion()); hashCode = 31 * hashCode + Objects.hashCode(reservedInstanceOptions()); 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 Ec2RecommendationsExportPreferences)) { return false; } Ec2RecommendationsExportPreferences other = (Ec2RecommendationsExportPreferences) obj; return Objects.equals(enabled(), other.enabled()) && Objects.equals(cpuPerformanceMetricBasis(), other.cpuPerformanceMetricBasis()) && Objects.equals(ramPerformanceMetricBasis(), other.ramPerformanceMetricBasis()) && Objects.equals(tenancyAsString(), other.tenancyAsString()) && hasExcludedInstanceTypes() == other.hasExcludedInstanceTypes() && Objects.equals(excludedInstanceTypes(), other.excludedInstanceTypes()) && Objects.equals(preferredRegion(), other.preferredRegion()) && Objects.equals(reservedInstanceOptions(), other.reservedInstanceOptions()); } /** * 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("Ec2RecommendationsExportPreferences").add("Enabled", enabled()) .add("CpuPerformanceMetricBasis", cpuPerformanceMetricBasis()) .add("RamPerformanceMetricBasis", ramPerformanceMetricBasis()).add("Tenancy", tenancyAsString()) .add("ExcludedInstanceTypes", hasExcludedInstanceTypes() ? excludedInstanceTypes() : null) .add("PreferredRegion", preferredRegion()).add("ReservedInstanceOptions", reservedInstanceOptions()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "enabled": return Optional.ofNullable(clazz.cast(enabled())); case "cpuPerformanceMetricBasis": return Optional.ofNullable(clazz.cast(cpuPerformanceMetricBasis())); case "ramPerformanceMetricBasis": return Optional.ofNullable(clazz.cast(ramPerformanceMetricBasis())); case "tenancy": return Optional.ofNullable(clazz.cast(tenancyAsString())); case "excludedInstanceTypes": return Optional.ofNullable(clazz.cast(excludedInstanceTypes())); case "preferredRegion": return Optional.ofNullable(clazz.cast(preferredRegion())); case "reservedInstanceOptions": return Optional.ofNullable(clazz.cast(reservedInstanceOptions())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((Ec2RecommendationsExportPreferences) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* If set to true, the export preferences is set to Ec2RecommendationsExportPreferences. *

* * @param enabled * If set to true, the export preferences is set to Ec2RecommendationsExportPreferences. * @return Returns a reference to this object so that method calls can be chained together. */ Builder enabled(Boolean enabled); /** *

* The recommended EC2 instance type that matches the CPU usage metric of server performance data. *

* * @param cpuPerformanceMetricBasis * The recommended EC2 instance type that matches the CPU usage metric of server performance data. * @return Returns a reference to this object so that method calls can be chained together. */ Builder cpuPerformanceMetricBasis(UsageMetricBasis cpuPerformanceMetricBasis); /** *

* The recommended EC2 instance type that matches the CPU usage metric of server performance data. *

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

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

* The recommended EC2 instance type that matches the Memory usage metric of server performance data. *

* * @param ramPerformanceMetricBasis * The recommended EC2 instance type that matches the Memory usage metric of server performance data. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ramPerformanceMetricBasis(UsageMetricBasis ramPerformanceMetricBasis); /** *

* The recommended EC2 instance type that matches the Memory usage metric of server performance data. *

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

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

* The target tenancy to use for your recommended EC2 instances. *

* * @param tenancy * The target tenancy to use for your recommended EC2 instances. * @see Tenancy * @return Returns a reference to this object so that method calls can be chained together. * @see Tenancy */ Builder tenancy(String tenancy); /** *

* The target tenancy to use for your recommended EC2 instances. *

* * @param tenancy * The target tenancy to use for your recommended EC2 instances. * @see Tenancy * @return Returns a reference to this object so that method calls can be chained together. * @see Tenancy */ Builder tenancy(Tenancy tenancy); /** *

* An array of instance types to exclude from recommendations. *

* * @param excludedInstanceTypes * An array of instance types to exclude from recommendations. * @return Returns a reference to this object so that method calls can be chained together. */ Builder excludedInstanceTypes(Collection excludedInstanceTypes); /** *

* An array of instance types to exclude from recommendations. *

* * @param excludedInstanceTypes * An array of instance types to exclude from recommendations. * @return Returns a reference to this object so that method calls can be chained together. */ Builder excludedInstanceTypes(String... excludedInstanceTypes); /** *

* The target Amazon Web Services Region for the recommendations. You can use any of the Region codes available * for the chosen service, as listed in Amazon Web Services service endpoints in * the Amazon Web Services General Reference. *

* * @param preferredRegion * The target Amazon Web Services Region for the recommendations. You can use any of the Region codes * available for the chosen service, as listed in Amazon Web Services service * endpoints in the Amazon Web Services General Reference. * @return Returns a reference to this object so that method calls can be chained together. */ Builder preferredRegion(String preferredRegion); /** *

* The contract type for a reserved instance. If blank, we assume an On-Demand instance is preferred. *

* * @param reservedInstanceOptions * The contract type for a reserved instance. If blank, we assume an On-Demand instance is preferred. * @return Returns a reference to this object so that method calls can be chained together. */ Builder reservedInstanceOptions(ReservedInstanceOptions reservedInstanceOptions); /** *

* The contract type for a reserved instance. If blank, we assume an On-Demand instance is preferred. *

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

* When the {@link Consumer} completes, {@link ReservedInstanceOptions.Builder#build()} is called immediately * and its result is passed to {@link #reservedInstanceOptions(ReservedInstanceOptions)}. * * @param reservedInstanceOptions * a consumer that will call methods on {@link ReservedInstanceOptions.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #reservedInstanceOptions(ReservedInstanceOptions) */ default Builder reservedInstanceOptions(Consumer reservedInstanceOptions) { return reservedInstanceOptions(ReservedInstanceOptions.builder().applyMutation(reservedInstanceOptions).build()); } } static final class BuilderImpl implements Builder { private Boolean enabled; private UsageMetricBasis cpuPerformanceMetricBasis; private UsageMetricBasis ramPerformanceMetricBasis; private String tenancy; private List excludedInstanceTypes = DefaultSdkAutoConstructList.getInstance(); private String preferredRegion; private ReservedInstanceOptions reservedInstanceOptions; private BuilderImpl() { } private BuilderImpl(Ec2RecommendationsExportPreferences model) { enabled(model.enabled); cpuPerformanceMetricBasis(model.cpuPerformanceMetricBasis); ramPerformanceMetricBasis(model.ramPerformanceMetricBasis); tenancy(model.tenancy); excludedInstanceTypes(model.excludedInstanceTypes); preferredRegion(model.preferredRegion); reservedInstanceOptions(model.reservedInstanceOptions); } public final Boolean getEnabled() { return enabled; } public final void setEnabled(Boolean enabled) { this.enabled = enabled; } @Override public final Builder enabled(Boolean enabled) { this.enabled = enabled; return this; } public final UsageMetricBasis.Builder getCpuPerformanceMetricBasis() { return cpuPerformanceMetricBasis != null ? cpuPerformanceMetricBasis.toBuilder() : null; } public final void setCpuPerformanceMetricBasis(UsageMetricBasis.BuilderImpl cpuPerformanceMetricBasis) { this.cpuPerformanceMetricBasis = cpuPerformanceMetricBasis != null ? cpuPerformanceMetricBasis.build() : null; } @Override public final Builder cpuPerformanceMetricBasis(UsageMetricBasis cpuPerformanceMetricBasis) { this.cpuPerformanceMetricBasis = cpuPerformanceMetricBasis; return this; } public final UsageMetricBasis.Builder getRamPerformanceMetricBasis() { return ramPerformanceMetricBasis != null ? ramPerformanceMetricBasis.toBuilder() : null; } public final void setRamPerformanceMetricBasis(UsageMetricBasis.BuilderImpl ramPerformanceMetricBasis) { this.ramPerformanceMetricBasis = ramPerformanceMetricBasis != null ? ramPerformanceMetricBasis.build() : null; } @Override public final Builder ramPerformanceMetricBasis(UsageMetricBasis ramPerformanceMetricBasis) { this.ramPerformanceMetricBasis = ramPerformanceMetricBasis; return this; } public final String getTenancy() { return tenancy; } public final void setTenancy(String tenancy) { this.tenancy = tenancy; } @Override public final Builder tenancy(String tenancy) { this.tenancy = tenancy; return this; } @Override public final Builder tenancy(Tenancy tenancy) { this.tenancy(tenancy == null ? null : tenancy.toString()); return this; } public final Collection getExcludedInstanceTypes() { if (excludedInstanceTypes instanceof SdkAutoConstructList) { return null; } return excludedInstanceTypes; } public final void setExcludedInstanceTypes(Collection excludedInstanceTypes) { this.excludedInstanceTypes = ExcludedInstanceTypesCopier.copy(excludedInstanceTypes); } @Override public final Builder excludedInstanceTypes(Collection excludedInstanceTypes) { this.excludedInstanceTypes = ExcludedInstanceTypesCopier.copy(excludedInstanceTypes); return this; } @Override @SafeVarargs public final Builder excludedInstanceTypes(String... excludedInstanceTypes) { excludedInstanceTypes(Arrays.asList(excludedInstanceTypes)); return this; } public final String getPreferredRegion() { return preferredRegion; } public final void setPreferredRegion(String preferredRegion) { this.preferredRegion = preferredRegion; } @Override public final Builder preferredRegion(String preferredRegion) { this.preferredRegion = preferredRegion; return this; } public final ReservedInstanceOptions.Builder getReservedInstanceOptions() { return reservedInstanceOptions != null ? reservedInstanceOptions.toBuilder() : null; } public final void setReservedInstanceOptions(ReservedInstanceOptions.BuilderImpl reservedInstanceOptions) { this.reservedInstanceOptions = reservedInstanceOptions != null ? reservedInstanceOptions.build() : null; } @Override public final Builder reservedInstanceOptions(ReservedInstanceOptions reservedInstanceOptions) { this.reservedInstanceOptions = reservedInstanceOptions; return this; } @Override public Ec2RecommendationsExportPreferences build() { return new Ec2RecommendationsExportPreferences(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy