
software.amazon.awssdk.services.ec2.model.FleetLaunchTemplateOverridesRequest 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.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;
/**
*
* Describes overrides for a launch template.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class FleetLaunchTemplateOverridesRequest implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField INSTANCE_TYPE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("InstanceType")
.getter(getter(FleetLaunchTemplateOverridesRequest::instanceTypeAsString))
.setter(setter(Builder::instanceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceType")
.unmarshallLocationName("InstanceType").build()).build();
private static final SdkField MAX_PRICE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("MaxPrice")
.getter(getter(FleetLaunchTemplateOverridesRequest::maxPrice))
.setter(setter(Builder::maxPrice))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxPrice")
.unmarshallLocationName("MaxPrice").build()).build();
private static final SdkField SUBNET_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("SubnetId")
.getter(getter(FleetLaunchTemplateOverridesRequest::subnetId))
.setter(setter(Builder::subnetId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SubnetId")
.unmarshallLocationName("SubnetId").build()).build();
private static final SdkField AVAILABILITY_ZONE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("AvailabilityZone")
.getter(getter(FleetLaunchTemplateOverridesRequest::availabilityZone))
.setter(setter(Builder::availabilityZone))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AvailabilityZone")
.unmarshallLocationName("AvailabilityZone").build()).build();
private static final SdkField WEIGHTED_CAPACITY_FIELD = SdkField
. builder(MarshallingType.DOUBLE)
.memberName("WeightedCapacity")
.getter(getter(FleetLaunchTemplateOverridesRequest::weightedCapacity))
.setter(setter(Builder::weightedCapacity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WeightedCapacity")
.unmarshallLocationName("WeightedCapacity").build()).build();
private static final SdkField PRIORITY_FIELD = SdkField
. builder(MarshallingType.DOUBLE)
.memberName("Priority")
.getter(getter(FleetLaunchTemplateOverridesRequest::priority))
.setter(setter(Builder::priority))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Priority")
.unmarshallLocationName("Priority").build()).build();
private static final SdkField PLACEMENT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("Placement")
.getter(getter(FleetLaunchTemplateOverridesRequest::placement))
.setter(setter(Builder::placement))
.constructor(Placement::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Placement")
.unmarshallLocationName("Placement").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INSTANCE_TYPE_FIELD,
MAX_PRICE_FIELD, SUBNET_ID_FIELD, AVAILABILITY_ZONE_FIELD, WEIGHTED_CAPACITY_FIELD, PRIORITY_FIELD, PLACEMENT_FIELD));
private static final long serialVersionUID = 1L;
private final String instanceType;
private final String maxPrice;
private final String subnetId;
private final String availabilityZone;
private final Double weightedCapacity;
private final Double priority;
private final Placement placement;
private FleetLaunchTemplateOverridesRequest(BuilderImpl builder) {
this.instanceType = builder.instanceType;
this.maxPrice = builder.maxPrice;
this.subnetId = builder.subnetId;
this.availabilityZone = builder.availabilityZone;
this.weightedCapacity = builder.weightedCapacity;
this.priority = builder.priority;
this.placement = builder.placement;
}
/**
*
* The instance type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceType} will
* return {@link InstanceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #instanceTypeAsString}.
*
*
* @return The instance type.
* @see InstanceType
*/
public InstanceType instanceType() {
return InstanceType.fromValue(instanceType);
}
/**
*
* The instance type.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #instanceType} will
* return {@link InstanceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #instanceTypeAsString}.
*
*
* @return The instance type.
* @see InstanceType
*/
public String instanceTypeAsString() {
return instanceType;
}
/**
*
* The maximum price per unit hour that you are willing to pay for a Spot Instance.
*
*
* @return The maximum price per unit hour that you are willing to pay for a Spot Instance.
*/
public String maxPrice() {
return maxPrice;
}
/**
*
* The IDs of the subnets in which to launch the instances. Separate multiple subnet IDs using commas (for example,
* subnet-1234abcdeexample1, subnet-0987cdef6example2
). A request of type instant
can have
* only one subnet ID.
*
*
* @return The IDs of the subnets in which to launch the instances. Separate multiple subnet IDs using commas (for
* example, subnet-1234abcdeexample1, subnet-0987cdef6example2
). A request of type
* instant
can have only one subnet ID.
*/
public String subnetId() {
return subnetId;
}
/**
*
* The Availability Zone in which to launch the instances.
*
*
* @return The Availability Zone in which to launch the instances.
*/
public String availabilityZone() {
return availabilityZone;
}
/**
*
* The number of units provided by the specified instance type.
*
*
* @return The number of units provided by the specified instance type.
*/
public Double weightedCapacity() {
return weightedCapacity;
}
/**
*
* The priority for the launch template override. If AllocationStrategy is set to prioritized
,
* EC2 Fleet uses priority to determine which launch template override to use first in fulfilling On-Demand
* capacity. The highest priority is launched first. Valid values are whole numbers starting at 0
. The
* lower the number, the higher the priority. If no number is set, the launch template override has the lowest
* priority.
*
*
* @return The priority for the launch template override. If AllocationStrategy is set to
* prioritized
, EC2 Fleet uses priority to determine which launch template override to use
* first in fulfilling On-Demand capacity. The highest priority is launched first. Valid values are whole
* numbers starting at 0
. The lower the number, the higher the priority. If no number is set,
* the launch template override has the lowest priority.
*/
public Double priority() {
return priority;
}
/**
*
* The location where the instance launched, if applicable.
*
*
* @return The location where the instance launched, if applicable.
*/
public Placement placement() {
return placement;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(instanceTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(maxPrice());
hashCode = 31 * hashCode + Objects.hashCode(subnetId());
hashCode = 31 * hashCode + Objects.hashCode(availabilityZone());
hashCode = 31 * hashCode + Objects.hashCode(weightedCapacity());
hashCode = 31 * hashCode + Objects.hashCode(priority());
hashCode = 31 * hashCode + Objects.hashCode(placement());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof FleetLaunchTemplateOverridesRequest)) {
return false;
}
FleetLaunchTemplateOverridesRequest other = (FleetLaunchTemplateOverridesRequest) obj;
return Objects.equals(instanceTypeAsString(), other.instanceTypeAsString())
&& Objects.equals(maxPrice(), other.maxPrice()) && Objects.equals(subnetId(), other.subnetId())
&& Objects.equals(availabilityZone(), other.availabilityZone())
&& Objects.equals(weightedCapacity(), other.weightedCapacity()) && Objects.equals(priority(), other.priority())
&& Objects.equals(placement(), other.placement());
}
/**
* 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("FleetLaunchTemplateOverridesRequest").add("InstanceType", instanceTypeAsString())
.add("MaxPrice", maxPrice()).add("SubnetId", subnetId()).add("AvailabilityZone", availabilityZone())
.add("WeightedCapacity", weightedCapacity()).add("Priority", priority()).add("Placement", placement()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "InstanceType":
return Optional.ofNullable(clazz.cast(instanceTypeAsString()));
case "MaxPrice":
return Optional.ofNullable(clazz.cast(maxPrice()));
case "SubnetId":
return Optional.ofNullable(clazz.cast(subnetId()));
case "AvailabilityZone":
return Optional.ofNullable(clazz.cast(availabilityZone()));
case "WeightedCapacity":
return Optional.ofNullable(clazz.cast(weightedCapacity()));
case "Priority":
return Optional.ofNullable(clazz.cast(priority()));
case "Placement":
return Optional.ofNullable(clazz.cast(placement()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function