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

software.amazon.awssdk.services.ec2.model.ModifySpotFleetRequestRequest 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.ec2.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;

/**
 * 

* Contains the parameters for ModifySpotFleetRequest. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ModifySpotFleetRequestRequest extends Ec2Request implements ToCopyableBuilder { private static final SdkField EXCESS_CAPACITY_TERMINATION_POLICY_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("ExcessCapacityTerminationPolicy") .getter(getter(ModifySpotFleetRequestRequest::excessCapacityTerminationPolicyAsString)) .setter(setter(Builder::excessCapacityTerminationPolicy)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExcessCapacityTerminationPolicy") .unmarshallLocationName("excessCapacityTerminationPolicy").build()).build(); private static final SdkField> LAUNCH_TEMPLATE_CONFIGS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("LaunchTemplateConfigs") .getter(getter(ModifySpotFleetRequestRequest::launchTemplateConfigs)) .setter(setter(Builder::launchTemplateConfigs)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LaunchTemplateConfig") .unmarshallLocationName("LaunchTemplateConfig").build(), ListTrait .builder() .memberLocationName("item") .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(LaunchTemplateConfig::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("Item").unmarshallLocationName("item").build()).build()) .build()).build(); private static final SdkField SPOT_FLEET_REQUEST_ID_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("SpotFleetRequestId") .getter(getter(ModifySpotFleetRequestRequest::spotFleetRequestId)) .setter(setter(Builder::spotFleetRequestId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SpotFleetRequestId") .unmarshallLocationName("spotFleetRequestId").build()).build(); private static final SdkField TARGET_CAPACITY_FIELD = SdkField . builder(MarshallingType.INTEGER) .memberName("TargetCapacity") .getter(getter(ModifySpotFleetRequestRequest::targetCapacity)) .setter(setter(Builder::targetCapacity)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetCapacity") .unmarshallLocationName("targetCapacity").build()).build(); private static final SdkField ON_DEMAND_TARGET_CAPACITY_FIELD = SdkField . builder(MarshallingType.INTEGER) .memberName("OnDemandTargetCapacity") .getter(getter(ModifySpotFleetRequestRequest::onDemandTargetCapacity)) .setter(setter(Builder::onDemandTargetCapacity)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OnDemandTargetCapacity") .unmarshallLocationName("OnDemandTargetCapacity").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList( EXCESS_CAPACITY_TERMINATION_POLICY_FIELD, LAUNCH_TEMPLATE_CONFIGS_FIELD, SPOT_FLEET_REQUEST_ID_FIELD, TARGET_CAPACITY_FIELD, ON_DEMAND_TARGET_CAPACITY_FIELD)); private final String excessCapacityTerminationPolicy; private final List launchTemplateConfigs; private final String spotFleetRequestId; private final Integer targetCapacity; private final Integer onDemandTargetCapacity; private ModifySpotFleetRequestRequest(BuilderImpl builder) { super(builder); this.excessCapacityTerminationPolicy = builder.excessCapacityTerminationPolicy; this.launchTemplateConfigs = builder.launchTemplateConfigs; this.spotFleetRequestId = builder.spotFleetRequestId; this.targetCapacity = builder.targetCapacity; this.onDemandTargetCapacity = builder.onDemandTargetCapacity; } /** *

* Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet request is * decreased below the current size of the Spot Fleet. *

*

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

* * @return Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet * request is decreased below the current size of the Spot Fleet. * @see ExcessCapacityTerminationPolicy */ public ExcessCapacityTerminationPolicy excessCapacityTerminationPolicy() { return ExcessCapacityTerminationPolicy.fromValue(excessCapacityTerminationPolicy); } /** *

* Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet request is * decreased below the current size of the Spot Fleet. *

*

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

* * @return Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet * request is decreased below the current size of the Spot Fleet. * @see ExcessCapacityTerminationPolicy */ public String excessCapacityTerminationPolicyAsString() { return excessCapacityTerminationPolicy; } /** * Returns true if the LaunchTemplateConfigs 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 boolean hasLaunchTemplateConfigs() { return launchTemplateConfigs != null && !(launchTemplateConfigs instanceof SdkAutoConstructList); } /** *

* The launch template and overrides. You can only use this parameter if you specified a launch template ( * LaunchTemplateConfigs) in your Spot Fleet request. If you specified * LaunchSpecifications in your Spot Fleet request, then omit this parameter. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasLaunchTemplateConfigs()} to see if a value was sent in this field. *

* * @return The launch template and overrides. You can only use this parameter if you specified a launch template ( * LaunchTemplateConfigs) in your Spot Fleet request. If you specified * LaunchSpecifications in your Spot Fleet request, then omit this parameter. */ public List launchTemplateConfigs() { return launchTemplateConfigs; } /** *

* The ID of the Spot Fleet request. *

* * @return The ID of the Spot Fleet request. */ public String spotFleetRequestId() { return spotFleetRequestId; } /** *

* The size of the fleet. *

* * @return The size of the fleet. */ public Integer targetCapacity() { return targetCapacity; } /** *

* The number of On-Demand Instances in the fleet. *

* * @return The number of On-Demand Instances in the fleet. */ public Integer onDemandTargetCapacity() { return onDemandTargetCapacity; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(excessCapacityTerminationPolicyAsString()); hashCode = 31 * hashCode + Objects.hashCode(launchTemplateConfigs()); hashCode = 31 * hashCode + Objects.hashCode(spotFleetRequestId()); hashCode = 31 * hashCode + Objects.hashCode(targetCapacity()); hashCode = 31 * hashCode + Objects.hashCode(onDemandTargetCapacity()); return hashCode; } @Override public boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof ModifySpotFleetRequestRequest)) { return false; } ModifySpotFleetRequestRequest other = (ModifySpotFleetRequestRequest) obj; return Objects.equals(excessCapacityTerminationPolicyAsString(), other.excessCapacityTerminationPolicyAsString()) && Objects.equals(launchTemplateConfigs(), other.launchTemplateConfigs()) && Objects.equals(spotFleetRequestId(), other.spotFleetRequestId()) && Objects.equals(targetCapacity(), other.targetCapacity()) && Objects.equals(onDemandTargetCapacity(), other.onDemandTargetCapacity()); } /** * 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 String toString() { return ToString.builder("ModifySpotFleetRequestRequest") .add("ExcessCapacityTerminationPolicy", excessCapacityTerminationPolicyAsString()) .add("LaunchTemplateConfigs", launchTemplateConfigs()).add("SpotFleetRequestId", spotFleetRequestId()) .add("TargetCapacity", targetCapacity()).add("OnDemandTargetCapacity", onDemandTargetCapacity()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ExcessCapacityTerminationPolicy": return Optional.ofNullable(clazz.cast(excessCapacityTerminationPolicyAsString())); case "LaunchTemplateConfigs": return Optional.ofNullable(clazz.cast(launchTemplateConfigs())); case "SpotFleetRequestId": return Optional.ofNullable(clazz.cast(spotFleetRequestId())); case "TargetCapacity": return Optional.ofNullable(clazz.cast(targetCapacity())); case "OnDemandTargetCapacity": return Optional.ofNullable(clazz.cast(onDemandTargetCapacity())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((ModifySpotFleetRequestRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends Ec2Request.Builder, SdkPojo, CopyableBuilder { /** *

* Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet * request is decreased below the current size of the Spot Fleet. *

* * @param excessCapacityTerminationPolicy * Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet * request is decreased below the current size of the Spot Fleet. * @see ExcessCapacityTerminationPolicy * @return Returns a reference to this object so that method calls can be chained together. * @see ExcessCapacityTerminationPolicy */ Builder excessCapacityTerminationPolicy(String excessCapacityTerminationPolicy); /** *

* Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet * request is decreased below the current size of the Spot Fleet. *

* * @param excessCapacityTerminationPolicy * Indicates whether running Spot Instances should be terminated if the target capacity of the Spot Fleet * request is decreased below the current size of the Spot Fleet. * @see ExcessCapacityTerminationPolicy * @return Returns a reference to this object so that method calls can be chained together. * @see ExcessCapacityTerminationPolicy */ Builder excessCapacityTerminationPolicy(ExcessCapacityTerminationPolicy excessCapacityTerminationPolicy); /** *

* The launch template and overrides. You can only use this parameter if you specified a launch template ( * LaunchTemplateConfigs) in your Spot Fleet request. If you specified * LaunchSpecifications in your Spot Fleet request, then omit this parameter. *

* * @param launchTemplateConfigs * The launch template and overrides. You can only use this parameter if you specified a launch template * (LaunchTemplateConfigs) in your Spot Fleet request. If you specified * LaunchSpecifications in your Spot Fleet request, then omit this parameter. * @return Returns a reference to this object so that method calls can be chained together. */ Builder launchTemplateConfigs(Collection launchTemplateConfigs); /** *

* The launch template and overrides. You can only use this parameter if you specified a launch template ( * LaunchTemplateConfigs) in your Spot Fleet request. If you specified * LaunchSpecifications in your Spot Fleet request, then omit this parameter. *

* * @param launchTemplateConfigs * The launch template and overrides. You can only use this parameter if you specified a launch template * (LaunchTemplateConfigs) in your Spot Fleet request. If you specified * LaunchSpecifications in your Spot Fleet request, then omit this parameter. * @return Returns a reference to this object so that method calls can be chained together. */ Builder launchTemplateConfigs(LaunchTemplateConfig... launchTemplateConfigs); /** *

* The launch template and overrides. You can only use this parameter if you specified a launch template ( * LaunchTemplateConfigs) in your Spot Fleet request. If you specified * LaunchSpecifications in your Spot Fleet request, then omit this parameter. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the * need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately * and its result is passed to {@link #launchTemplateConfigs(List)}. * * @param launchTemplateConfigs * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #launchTemplateConfigs(List) */ Builder launchTemplateConfigs(Consumer... launchTemplateConfigs); /** *

* The ID of the Spot Fleet request. *

* * @param spotFleetRequestId * The ID of the Spot Fleet request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder spotFleetRequestId(String spotFleetRequestId); /** *

* The size of the fleet. *

* * @param targetCapacity * The size of the fleet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targetCapacity(Integer targetCapacity); /** *

* The number of On-Demand Instances in the fleet. *

* * @param onDemandTargetCapacity * The number of On-Demand Instances in the fleet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder onDemandTargetCapacity(Integer onDemandTargetCapacity); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends Ec2Request.BuilderImpl implements Builder { private String excessCapacityTerminationPolicy; private List launchTemplateConfigs = DefaultSdkAutoConstructList.getInstance(); private String spotFleetRequestId; private Integer targetCapacity; private Integer onDemandTargetCapacity; private BuilderImpl() { } private BuilderImpl(ModifySpotFleetRequestRequest model) { super(model); excessCapacityTerminationPolicy(model.excessCapacityTerminationPolicy); launchTemplateConfigs(model.launchTemplateConfigs); spotFleetRequestId(model.spotFleetRequestId); targetCapacity(model.targetCapacity); onDemandTargetCapacity(model.onDemandTargetCapacity); } public final String getExcessCapacityTerminationPolicy() { return excessCapacityTerminationPolicy; } @Override public final Builder excessCapacityTerminationPolicy(String excessCapacityTerminationPolicy) { this.excessCapacityTerminationPolicy = excessCapacityTerminationPolicy; return this; } @Override public final Builder excessCapacityTerminationPolicy(ExcessCapacityTerminationPolicy excessCapacityTerminationPolicy) { this.excessCapacityTerminationPolicy(excessCapacityTerminationPolicy == null ? null : excessCapacityTerminationPolicy .toString()); return this; } public final void setExcessCapacityTerminationPolicy(String excessCapacityTerminationPolicy) { this.excessCapacityTerminationPolicy = excessCapacityTerminationPolicy; } public final Collection getLaunchTemplateConfigs() { return launchTemplateConfigs != null ? launchTemplateConfigs.stream().map(LaunchTemplateConfig::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder launchTemplateConfigs(Collection launchTemplateConfigs) { this.launchTemplateConfigs = LaunchTemplateConfigListCopier.copy(launchTemplateConfigs); return this; } @Override @SafeVarargs public final Builder launchTemplateConfigs(LaunchTemplateConfig... launchTemplateConfigs) { launchTemplateConfigs(Arrays.asList(launchTemplateConfigs)); return this; } @Override @SafeVarargs public final Builder launchTemplateConfigs(Consumer... launchTemplateConfigs) { launchTemplateConfigs(Stream.of(launchTemplateConfigs) .map(c -> LaunchTemplateConfig.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setLaunchTemplateConfigs(Collection launchTemplateConfigs) { this.launchTemplateConfigs = LaunchTemplateConfigListCopier.copyFromBuilder(launchTemplateConfigs); } public final String getSpotFleetRequestId() { return spotFleetRequestId; } @Override public final Builder spotFleetRequestId(String spotFleetRequestId) { this.spotFleetRequestId = spotFleetRequestId; return this; } public final void setSpotFleetRequestId(String spotFleetRequestId) { this.spotFleetRequestId = spotFleetRequestId; } public final Integer getTargetCapacity() { return targetCapacity; } @Override public final Builder targetCapacity(Integer targetCapacity) { this.targetCapacity = targetCapacity; return this; } public final void setTargetCapacity(Integer targetCapacity) { this.targetCapacity = targetCapacity; } public final Integer getOnDemandTargetCapacity() { return onDemandTargetCapacity; } @Override public final Builder onDemandTargetCapacity(Integer onDemandTargetCapacity) { this.onDemandTargetCapacity = onDemandTargetCapacity; return this; } public final void setOnDemandTargetCapacity(Integer onDemandTargetCapacity) { this.onDemandTargetCapacity = onDemandTargetCapacity; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public ModifySpotFleetRequestRequest build() { return new ModifySpotFleetRequestRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy