software.amazon.awssdk.services.computeoptimizer.model.ExportEc2InstanceRecommendationsRequest Maven / Gradle / Ivy
Show all versions of computeoptimizer 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.computeoptimizer.model;
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.awscore.AwsRequestOverrideConfiguration;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class ExportEc2InstanceRecommendationsRequest extends ComputeOptimizerRequest implements
ToCopyableBuilder {
private static final SdkField> ACCOUNT_IDS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("accountIds")
.getter(getter(ExportEc2InstanceRecommendationsRequest::accountIds))
.setter(setter(Builder::accountIds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("accountIds").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> FILTERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("filters")
.getter(getter(ExportEc2InstanceRecommendationsRequest::filters))
.setter(setter(Builder::filters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("filters").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Filter::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> FIELDS_TO_EXPORT_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("fieldsToExport")
.getter(getter(ExportEc2InstanceRecommendationsRequest::fieldsToExportAsStrings))
.setter(setter(Builder::fieldsToExportWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fieldsToExport").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 S3_DESTINATION_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("s3DestinationConfig")
.getter(getter(ExportEc2InstanceRecommendationsRequest::s3DestinationConfig))
.setter(setter(Builder::s3DestinationConfig)).constructor(S3DestinationConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("s3DestinationConfig").build())
.build();
private static final SdkField FILE_FORMAT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("fileFormat").getter(getter(ExportEc2InstanceRecommendationsRequest::fileFormatAsString))
.setter(setter(Builder::fileFormat))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("fileFormat").build()).build();
private static final SdkField INCLUDE_MEMBER_ACCOUNTS_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("includeMemberAccounts").getter(getter(ExportEc2InstanceRecommendationsRequest::includeMemberAccounts))
.setter(setter(Builder::includeMemberAccounts))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("includeMemberAccounts").build())
.build();
private static final SdkField RECOMMENDATION_PREFERENCES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("recommendationPreferences")
.getter(getter(ExportEc2InstanceRecommendationsRequest::recommendationPreferences))
.setter(setter(Builder::recommendationPreferences)).constructor(RecommendationPreferences::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("recommendationPreferences").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACCOUNT_IDS_FIELD,
FILTERS_FIELD, FIELDS_TO_EXPORT_FIELD, S3_DESTINATION_CONFIG_FIELD, FILE_FORMAT_FIELD, INCLUDE_MEMBER_ACCOUNTS_FIELD,
RECOMMENDATION_PREFERENCES_FIELD));
private final List accountIds;
private final List filters;
private final List fieldsToExport;
private final S3DestinationConfig s3DestinationConfig;
private final String fileFormat;
private final Boolean includeMemberAccounts;
private final RecommendationPreferences recommendationPreferences;
private ExportEc2InstanceRecommendationsRequest(BuilderImpl builder) {
super(builder);
this.accountIds = builder.accountIds;
this.filters = builder.filters;
this.fieldsToExport = builder.fieldsToExport;
this.s3DestinationConfig = builder.s3DestinationConfig;
this.fileFormat = builder.fileFormat;
this.includeMemberAccounts = builder.includeMemberAccounts;
this.recommendationPreferences = builder.recommendationPreferences;
}
/**
* For responses, this returns true if the service returned a value for the AccountIds 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 hasAccountIds() {
return accountIds != null && !(accountIds instanceof SdkAutoConstructList);
}
/**
*
* The IDs of the Amazon Web Services accounts for which to export instance recommendations.
*
*
* If your account is the management account of an organization, use this parameter to specify the member account
* for which you want to export recommendations.
*
*
* This parameter cannot be specified together with the include member accounts parameter. The parameters are
* mutually exclusive.
*
*
* Recommendations for member accounts are not included in the export if this parameter, or the include member
* accounts parameter, is omitted.
*
*
* You can specify multiple account IDs per request.
*
*
* 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 #hasAccountIds} method.
*
*
* @return The IDs of the Amazon Web Services accounts for which to export instance recommendations.
*
* If your account is the management account of an organization, use this parameter to specify the member
* account for which you want to export recommendations.
*
*
* This parameter cannot be specified together with the include member accounts parameter. The parameters
* are mutually exclusive.
*
*
* Recommendations for member accounts are not included in the export if this parameter, or the include
* member accounts parameter, is omitted.
*
*
* You can specify multiple account IDs per request.
*/
public final List accountIds() {
return accountIds;
}
/**
* For responses, this returns true if the service returned a value for the Filters 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 hasFilters() {
return filters != null && !(filters instanceof SdkAutoConstructList);
}
/**
*
* An array of objects to specify a filter that exports a more specific set of instance 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 #hasFilters} method.
*
*
* @return An array of objects to specify a filter that exports a more specific set of instance recommendations.
*/
public final List filters() {
return filters;
}
/**
*
* The recommendations data to include in the export file. For more information about the fields that can be
* exported, see Exported files in the Compute Optimizer User Guide.
*
*
* 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 #hasFieldsToExport} method.
*
*
* @return The recommendations data to include in the export file. For more information about the fields that can be
* exported, see Exported files in the Compute Optimizer User Guide.
*/
public final List fieldsToExport() {
return ExportableInstanceFieldsCopier.copyStringToEnum(fieldsToExport);
}
/**
* For responses, this returns true if the service returned a value for the FieldsToExport 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 hasFieldsToExport() {
return fieldsToExport != null && !(fieldsToExport instanceof SdkAutoConstructList);
}
/**
*
* The recommendations data to include in the export file. For more information about the fields that can be
* exported, see Exported files in the Compute Optimizer User Guide.
*
*
* 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 #hasFieldsToExport} method.
*
*
* @return The recommendations data to include in the export file. For more information about the fields that can be
* exported, see Exported files in the Compute Optimizer User Guide.
*/
public final List fieldsToExportAsStrings() {
return fieldsToExport;
}
/**
*
* An object to specify the destination Amazon Simple Storage Service (Amazon S3) bucket name and key prefix for the
* export job.
*
*
* You must create the destination Amazon S3 bucket for your recommendations export before you create the export
* job. Compute Optimizer does not create the S3 bucket for you. After you create the S3 bucket, ensure that it has
* the required permissions policy to allow Compute Optimizer to write the export file to it. If you plan to specify
* an object prefix when you create the export job, you must include the object prefix in the policy that you add to
* the S3 bucket. For more information, see Amazon S3 Bucket Policy for Compute Optimizer in the Compute Optimizer User Guide.
*
*
* @return An object to specify the destination Amazon Simple Storage Service (Amazon S3) bucket name and key prefix
* for the export job.
*
* You must create the destination Amazon S3 bucket for your recommendations export before you create the
* export job. Compute Optimizer does not create the S3 bucket for you. After you create the S3 bucket,
* ensure that it has the required permissions policy to allow Compute Optimizer to write the export file to
* it. If you plan to specify an object prefix when you create the export job, you must include the object
* prefix in the policy that you add to the S3 bucket. For more information, see Amazon S3 Bucket Policy for Compute Optimizer in the Compute Optimizer User Guide.
*/
public final S3DestinationConfig s3DestinationConfig() {
return s3DestinationConfig;
}
/**
*
* The format of the export file.
*
*
* The only export file format currently supported is Csv
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #fileFormat} will
* return {@link FileFormat#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #fileFormatAsString}.
*
*
* @return The format of the export file.
*
* The only export file format currently supported is Csv
.
* @see FileFormat
*/
public final FileFormat fileFormat() {
return FileFormat.fromValue(fileFormat);
}
/**
*
* The format of the export file.
*
*
* The only export file format currently supported is Csv
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #fileFormat} will
* return {@link FileFormat#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #fileFormatAsString}.
*
*
* @return The format of the export file.
*
* The only export file format currently supported is Csv
.
* @see FileFormat
*/
public final String fileFormatAsString() {
return fileFormat;
}
/**
*
* Indicates whether to include recommendations for resources in all member accounts of the organization if your
* account is the management account of an organization.
*
*
* The member accounts must also be opted in to Compute Optimizer, and trusted access for Compute Optimizer must be
* enabled in the organization account. For more information, see Compute
* Optimizer and Amazon Web Services Organizations trusted access in the Compute Optimizer User Guide.
*
*
* Recommendations for member accounts of the organization are not included in the export file if this parameter is
* omitted.
*
*
* Recommendations for member accounts are not included in the export if this parameter, or the account IDs
* parameter, is omitted.
*
*
* @return Indicates whether to include recommendations for resources in all member accounts of the organization if
* your account is the management account of an organization.
*
* The member accounts must also be opted in to Compute Optimizer, and trusted access for Compute Optimizer
* must be enabled in the organization account. For more information, see Compute Optimizer and Amazon Web Services Organizations trusted access in the Compute Optimizer
* User Guide.
*
*
* Recommendations for member accounts of the organization are not included in the export file if this
* parameter is omitted.
*
*
* Recommendations for member accounts are not included in the export if this parameter, or the account IDs
* parameter, is omitted.
*/
public final Boolean includeMemberAccounts() {
return includeMemberAccounts;
}
/**
*
* An object to specify the preferences for the Amazon EC2 instance recommendations to export.
*
*
* @return An object to specify the preferences for the Amazon EC2 instance recommendations to export.
*/
public final RecommendationPreferences recommendationPreferences() {
return recommendationPreferences;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(hasAccountIds() ? accountIds() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasFilters() ? filters() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasFieldsToExport() ? fieldsToExportAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(s3DestinationConfig());
hashCode = 31 * hashCode + Objects.hashCode(fileFormatAsString());
hashCode = 31 * hashCode + Objects.hashCode(includeMemberAccounts());
hashCode = 31 * hashCode + Objects.hashCode(recommendationPreferences());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ExportEc2InstanceRecommendationsRequest)) {
return false;
}
ExportEc2InstanceRecommendationsRequest other = (ExportEc2InstanceRecommendationsRequest) obj;
return hasAccountIds() == other.hasAccountIds() && Objects.equals(accountIds(), other.accountIds())
&& hasFilters() == other.hasFilters() && Objects.equals(filters(), other.filters())
&& hasFieldsToExport() == other.hasFieldsToExport()
&& Objects.equals(fieldsToExportAsStrings(), other.fieldsToExportAsStrings())
&& Objects.equals(s3DestinationConfig(), other.s3DestinationConfig())
&& Objects.equals(fileFormatAsString(), other.fileFormatAsString())
&& Objects.equals(includeMemberAccounts(), other.includeMemberAccounts())
&& Objects.equals(recommendationPreferences(), other.recommendationPreferences());
}
/**
* 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("ExportEc2InstanceRecommendationsRequest")
.add("AccountIds", hasAccountIds() ? accountIds() : null).add("Filters", hasFilters() ? filters() : null)
.add("FieldsToExport", hasFieldsToExport() ? fieldsToExportAsStrings() : null)
.add("S3DestinationConfig", s3DestinationConfig()).add("FileFormat", fileFormatAsString())
.add("IncludeMemberAccounts", includeMemberAccounts())
.add("RecommendationPreferences", recommendationPreferences()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "accountIds":
return Optional.ofNullable(clazz.cast(accountIds()));
case "filters":
return Optional.ofNullable(clazz.cast(filters()));
case "fieldsToExport":
return Optional.ofNullable(clazz.cast(fieldsToExportAsStrings()));
case "s3DestinationConfig":
return Optional.ofNullable(clazz.cast(s3DestinationConfig()));
case "fileFormat":
return Optional.ofNullable(clazz.cast(fileFormatAsString()));
case "includeMemberAccounts":
return Optional.ofNullable(clazz.cast(includeMemberAccounts()));
case "recommendationPreferences":
return Optional.ofNullable(clazz.cast(recommendationPreferences()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function