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

software.amazon.awssdk.services.ec2.model.CreateFleetRequest 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.time.Instant;
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 CreateFleetRequest extends Ec2Request implements
        ToCopyableBuilder {
    private static final SdkField CLIENT_TOKEN_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("ClientToken")
            .getter(getter(CreateFleetRequest::clientToken))
            .setter(setter(Builder::clientToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ClientToken")
                    .unmarshallLocationName("ClientToken").build()).build();

    private static final SdkField SPOT_OPTIONS_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO)
            .memberName("SpotOptions")
            .getter(getter(CreateFleetRequest::spotOptions))
            .setter(setter(Builder::spotOptions))
            .constructor(SpotOptionsRequest::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SpotOptions")
                    .unmarshallLocationName("SpotOptions").build()).build();

    private static final SdkField ON_DEMAND_OPTIONS_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO)
            .memberName("OnDemandOptions")
            .getter(getter(CreateFleetRequest::onDemandOptions))
            .setter(setter(Builder::onDemandOptions))
            .constructor(OnDemandOptionsRequest::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OnDemandOptions")
                    .unmarshallLocationName("OnDemandOptions").build()).build();

    private static final SdkField EXCESS_CAPACITY_TERMINATION_POLICY_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("ExcessCapacityTerminationPolicy")
            .getter(getter(CreateFleetRequest::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(CreateFleetRequest::launchTemplateConfigs))
            .setter(setter(Builder::launchTemplateConfigs))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LaunchTemplateConfigs")
                    .unmarshallLocationName("LaunchTemplateConfigs").build(),
                    ListTrait
                            .builder()
                            .memberLocationName("item")
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(FleetLaunchTemplateConfigRequest::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("Item").unmarshallLocationName("item").build()).build())
                            .build()).build();

    private static final SdkField TARGET_CAPACITY_SPECIFICATION_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO)
            .memberName("TargetCapacitySpecification")
            .getter(getter(CreateFleetRequest::targetCapacitySpecification))
            .setter(setter(Builder::targetCapacitySpecification))
            .constructor(TargetCapacitySpecificationRequest::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetCapacitySpecification")
                    .unmarshallLocationName("TargetCapacitySpecification").build()).build();

    private static final SdkField TERMINATE_INSTANCES_WITH_EXPIRATION_FIELD = SdkField
            . builder(MarshallingType.BOOLEAN)
            .memberName("TerminateInstancesWithExpiration")
            .getter(getter(CreateFleetRequest::terminateInstancesWithExpiration))
            .setter(setter(Builder::terminateInstancesWithExpiration))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TerminateInstancesWithExpiration")
                    .unmarshallLocationName("TerminateInstancesWithExpiration").build()).build();

    private static final SdkField TYPE_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("Type")
            .getter(getter(CreateFleetRequest::typeAsString))
            .setter(setter(Builder::type))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type")
                    .unmarshallLocationName("Type").build()).build();

    private static final SdkField VALID_FROM_FIELD = SdkField
            . builder(MarshallingType.INSTANT)
            .memberName("ValidFrom")
            .getter(getter(CreateFleetRequest::validFrom))
            .setter(setter(Builder::validFrom))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ValidFrom")
                    .unmarshallLocationName("ValidFrom").build()).build();

    private static final SdkField VALID_UNTIL_FIELD = SdkField
            . builder(MarshallingType.INSTANT)
            .memberName("ValidUntil")
            .getter(getter(CreateFleetRequest::validUntil))
            .setter(setter(Builder::validUntil))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ValidUntil")
                    .unmarshallLocationName("ValidUntil").build()).build();

    private static final SdkField REPLACE_UNHEALTHY_INSTANCES_FIELD = SdkField
            . builder(MarshallingType.BOOLEAN)
            .memberName("ReplaceUnhealthyInstances")
            .getter(getter(CreateFleetRequest::replaceUnhealthyInstances))
            .setter(setter(Builder::replaceUnhealthyInstances))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplaceUnhealthyInstances")
                    .unmarshallLocationName("ReplaceUnhealthyInstances").build()).build();

    private static final SdkField> TAG_SPECIFICATIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("TagSpecifications")
            .getter(getter(CreateFleetRequest::tagSpecifications))
            .setter(setter(Builder::tagSpecifications))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TagSpecification")
                    .unmarshallLocationName("TagSpecification").build(),
                    ListTrait
                            .builder()
                            .memberLocationName("item")
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(TagSpecification::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("Item").unmarshallLocationName("item").build()).build())
                            .build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CLIENT_TOKEN_FIELD,
            SPOT_OPTIONS_FIELD, ON_DEMAND_OPTIONS_FIELD, EXCESS_CAPACITY_TERMINATION_POLICY_FIELD, LAUNCH_TEMPLATE_CONFIGS_FIELD,
            TARGET_CAPACITY_SPECIFICATION_FIELD, TERMINATE_INSTANCES_WITH_EXPIRATION_FIELD, TYPE_FIELD, VALID_FROM_FIELD,
            VALID_UNTIL_FIELD, REPLACE_UNHEALTHY_INSTANCES_FIELD, TAG_SPECIFICATIONS_FIELD));

    private final String clientToken;

    private final SpotOptionsRequest spotOptions;

    private final OnDemandOptionsRequest onDemandOptions;

    private final String excessCapacityTerminationPolicy;

    private final List launchTemplateConfigs;

    private final TargetCapacitySpecificationRequest targetCapacitySpecification;

    private final Boolean terminateInstancesWithExpiration;

    private final String type;

    private final Instant validFrom;

    private final Instant validUntil;

    private final Boolean replaceUnhealthyInstances;

    private final List tagSpecifications;

    private CreateFleetRequest(BuilderImpl builder) {
        super(builder);
        this.clientToken = builder.clientToken;
        this.spotOptions = builder.spotOptions;
        this.onDemandOptions = builder.onDemandOptions;
        this.excessCapacityTerminationPolicy = builder.excessCapacityTerminationPolicy;
        this.launchTemplateConfigs = builder.launchTemplateConfigs;
        this.targetCapacitySpecification = builder.targetCapacitySpecification;
        this.terminateInstancesWithExpiration = builder.terminateInstancesWithExpiration;
        this.type = builder.type;
        this.validFrom = builder.validFrom;
        this.validUntil = builder.validUntil;
        this.replaceUnhealthyInstances = builder.replaceUnhealthyInstances;
        this.tagSpecifications = builder.tagSpecifications;
    }

    /**
     * 

* Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more * information, see Ensuring * Idempotency. *

* * @return Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more * information, see Ensuring * Idempotency. */ public String clientToken() { return clientToken; } /** *

* Describes the configuration of Spot Instances in an EC2 Fleet. *

* * @return Describes the configuration of Spot Instances in an EC2 Fleet. */ public SpotOptionsRequest spotOptions() { return spotOptions; } /** *

* Describes the configuration of On-Demand Instances in an EC2 Fleet. *

* * @return Describes the configuration of On-Demand Instances in an EC2 Fleet. */ public OnDemandOptionsRequest onDemandOptions() { return onDemandOptions; } /** *

* Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is * decreased below the current size of the EC2 Fleet. *

*

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

* * @return Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is * decreased below the current size of the EC2 Fleet. * @see FleetExcessCapacityTerminationPolicy */ public FleetExcessCapacityTerminationPolicy excessCapacityTerminationPolicy() { return FleetExcessCapacityTerminationPolicy.fromValue(excessCapacityTerminationPolicy); } /** *

* Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is * decreased below the current size of the EC2 Fleet. *

*

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

* * @return Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is * decreased below the current size of the EC2 Fleet. * @see FleetExcessCapacityTerminationPolicy */ 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 configuration for the EC2 Fleet. *

*

* 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 configuration for the EC2 Fleet. */ public List launchTemplateConfigs() { return launchTemplateConfigs; } /** *

* The number of units to request. *

* * @return The number of units to request. */ public TargetCapacitySpecificationRequest targetCapacitySpecification() { return targetCapacitySpecification; } /** *

* Indicates whether running instances should be terminated when the EC2 Fleet expires. *

* * @return Indicates whether running instances should be terminated when the EC2 Fleet expires. */ public Boolean terminateInstancesWithExpiration() { return terminateInstancesWithExpiration; } /** *

* The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired capacity, and * maintains it by replenishing interrupted Spot Instances (maintain). A value of instant * places a synchronous one-time request, and returns errors for any instances that could not be launched. A value * of request places an asynchronous one-time request without maintaining capacity or submitting * requests in alternative capacity pools if capacity is unavailable. For more information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. *

*

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

* * @return The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired * capacity, and maintains it by replenishing interrupted Spot Instances (maintain). A value of * instant places a synchronous one-time request, and returns errors for any instances that * could not be launched. A value of request places an asynchronous one-time request without * maintaining capacity or submitting requests in alternative capacity pools if capacity is unavailable. For * more information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. * @see FleetType */ public FleetType type() { return FleetType.fromValue(type); } /** *

* The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired capacity, and * maintains it by replenishing interrupted Spot Instances (maintain). A value of instant * places a synchronous one-time request, and returns errors for any instances that could not be launched. A value * of request places an asynchronous one-time request without maintaining capacity or submitting * requests in alternative capacity pools if capacity is unavailable. For more information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. *

*

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

* * @return The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired * capacity, and maintains it by replenishing interrupted Spot Instances (maintain). A value of * instant places a synchronous one-time request, and returns errors for any instances that * could not be launched. A value of request places an asynchronous one-time request without * maintaining capacity or submitting requests in alternative capacity pools if capacity is unavailable. For * more information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. * @see FleetType */ public String typeAsString() { return type; } /** *

* The start date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling the request * immediately. *

* * @return The start date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling the * request immediately. */ public Instant validFrom() { return validFrom; } /** *

* The end date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). At this point, no new EC2 Fleet requests are * placed or able to fulfill the request. If no value is specified, the request remains until you cancel it. *

* * @return The end date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). At this point, no new EC2 Fleet requests * are placed or able to fulfill the request. If no value is specified, the request remains until you cancel * it. */ public Instant validUntil() { return validUntil; } /** *

* Indicates whether EC2 Fleet should replace unhealthy instances. *

* * @return Indicates whether EC2 Fleet should replace unhealthy instances. */ public Boolean replaceUnhealthyInstances() { return replaceUnhealthyInstances; } /** * Returns true if the TagSpecifications 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 hasTagSpecifications() { return tagSpecifications != null && !(tagSpecifications instanceof SdkAutoConstructList); } /** *

* The key-value pair for tagging the EC2 Fleet request on creation. The value for ResourceType must be * fleet, otherwise the fleet request fails. To tag instances at launch, specify the tags in the launch * template. For information about tagging after launch, see Tagging Your * Resources. *

*

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

*

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

* * @return The key-value pair for tagging the EC2 Fleet request on creation. The value for ResourceType * must be fleet, otherwise the fleet request fails. To tag instances at launch, specify the * tags in the launch template. For information about tagging after launch, see Tagging Your * Resources. */ public List tagSpecifications() { return tagSpecifications; } @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(clientToken()); hashCode = 31 * hashCode + Objects.hashCode(spotOptions()); hashCode = 31 * hashCode + Objects.hashCode(onDemandOptions()); hashCode = 31 * hashCode + Objects.hashCode(excessCapacityTerminationPolicyAsString()); hashCode = 31 * hashCode + Objects.hashCode(launchTemplateConfigs()); hashCode = 31 * hashCode + Objects.hashCode(targetCapacitySpecification()); hashCode = 31 * hashCode + Objects.hashCode(terminateInstancesWithExpiration()); hashCode = 31 * hashCode + Objects.hashCode(typeAsString()); hashCode = 31 * hashCode + Objects.hashCode(validFrom()); hashCode = 31 * hashCode + Objects.hashCode(validUntil()); hashCode = 31 * hashCode + Objects.hashCode(replaceUnhealthyInstances()); hashCode = 31 * hashCode + Objects.hashCode(tagSpecifications()); 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 CreateFleetRequest)) { return false; } CreateFleetRequest other = (CreateFleetRequest) obj; return Objects.equals(clientToken(), other.clientToken()) && Objects.equals(spotOptions(), other.spotOptions()) && Objects.equals(onDemandOptions(), other.onDemandOptions()) && Objects.equals(excessCapacityTerminationPolicyAsString(), other.excessCapacityTerminationPolicyAsString()) && Objects.equals(launchTemplateConfigs(), other.launchTemplateConfigs()) && Objects.equals(targetCapacitySpecification(), other.targetCapacitySpecification()) && Objects.equals(terminateInstancesWithExpiration(), other.terminateInstancesWithExpiration()) && Objects.equals(typeAsString(), other.typeAsString()) && Objects.equals(validFrom(), other.validFrom()) && Objects.equals(validUntil(), other.validUntil()) && Objects.equals(replaceUnhealthyInstances(), other.replaceUnhealthyInstances()) && Objects.equals(tagSpecifications(), other.tagSpecifications()); } /** * 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("CreateFleetRequest").add("ClientToken", clientToken()).add("SpotOptions", spotOptions()) .add("OnDemandOptions", onDemandOptions()) .add("ExcessCapacityTerminationPolicy", excessCapacityTerminationPolicyAsString()) .add("LaunchTemplateConfigs", launchTemplateConfigs()) .add("TargetCapacitySpecification", targetCapacitySpecification()) .add("TerminateInstancesWithExpiration", terminateInstancesWithExpiration()).add("Type", typeAsString()) .add("ValidFrom", validFrom()).add("ValidUntil", validUntil()) .add("ReplaceUnhealthyInstances", replaceUnhealthyInstances()).add("TagSpecifications", tagSpecifications()) .build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ClientToken": return Optional.ofNullable(clazz.cast(clientToken())); case "SpotOptions": return Optional.ofNullable(clazz.cast(spotOptions())); case "OnDemandOptions": return Optional.ofNullable(clazz.cast(onDemandOptions())); case "ExcessCapacityTerminationPolicy": return Optional.ofNullable(clazz.cast(excessCapacityTerminationPolicyAsString())); case "LaunchTemplateConfigs": return Optional.ofNullable(clazz.cast(launchTemplateConfigs())); case "TargetCapacitySpecification": return Optional.ofNullable(clazz.cast(targetCapacitySpecification())); case "TerminateInstancesWithExpiration": return Optional.ofNullable(clazz.cast(terminateInstancesWithExpiration())); case "Type": return Optional.ofNullable(clazz.cast(typeAsString())); case "ValidFrom": return Optional.ofNullable(clazz.cast(validFrom())); case "ValidUntil": return Optional.ofNullable(clazz.cast(validUntil())); case "ReplaceUnhealthyInstances": return Optional.ofNullable(clazz.cast(replaceUnhealthyInstances())); case "TagSpecifications": return Optional.ofNullable(clazz.cast(tagSpecifications())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateFleetRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends Ec2Request.Builder, SdkPojo, CopyableBuilder { /** *

* Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more * information, see Ensuring * Idempotency. *

* * @param clientToken * Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more * information, see Ensuring * Idempotency. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientToken(String clientToken); /** *

* Describes the configuration of Spot Instances in an EC2 Fleet. *

* * @param spotOptions * Describes the configuration of Spot Instances in an EC2 Fleet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder spotOptions(SpotOptionsRequest spotOptions); /** *

* Describes the configuration of Spot Instances in an EC2 Fleet. *

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

* Describes the configuration of On-Demand Instances in an EC2 Fleet. *

* * @param onDemandOptions * Describes the configuration of On-Demand Instances in an EC2 Fleet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder onDemandOptions(OnDemandOptionsRequest onDemandOptions); /** *

* Describes the configuration of On-Demand Instances in an EC2 Fleet. *

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

* Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is * decreased below the current size of the EC2 Fleet. *

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

* Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is * decreased below the current size of the EC2 Fleet. *

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

* The configuration for the EC2 Fleet. *

* * @param launchTemplateConfigs * The configuration for the EC2 Fleet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder launchTemplateConfigs(Collection launchTemplateConfigs); /** *

* The configuration for the EC2 Fleet. *

* * @param launchTemplateConfigs * The configuration for the EC2 Fleet. * @return Returns a reference to this object so that method calls can be chained together. */ Builder launchTemplateConfigs(FleetLaunchTemplateConfigRequest... launchTemplateConfigs); /** *

* The configuration for the EC2 Fleet. *

* 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 number of units to request. *

* * @param targetCapacitySpecification * The number of units to request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder targetCapacitySpecification(TargetCapacitySpecificationRequest targetCapacitySpecification); /** *

* The number of units to request. *

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

* Indicates whether running instances should be terminated when the EC2 Fleet expires. *

* * @param terminateInstancesWithExpiration * Indicates whether running instances should be terminated when the EC2 Fleet expires. * @return Returns a reference to this object so that method calls can be chained together. */ Builder terminateInstancesWithExpiration(Boolean terminateInstancesWithExpiration); /** *

* The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired capacity, * and maintains it by replenishing interrupted Spot Instances (maintain). A value of * instant places a synchronous one-time request, and returns errors for any instances that could * not be launched. A value of request places an asynchronous one-time request without maintaining * capacity or submitting requests in alternative capacity pools if capacity is unavailable. For more * information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. *

* * @param type * The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired * capacity, and maintains it by replenishing interrupted Spot Instances (maintain). A value * of instant places a synchronous one-time request, and returns errors for any instances * that could not be launched. A value of request places an asynchronous one-time request * without maintaining capacity or submitting requests in alternative capacity pools if capacity is * unavailable. For more information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. * @see FleetType * @return Returns a reference to this object so that method calls can be chained together. * @see FleetType */ Builder type(String type); /** *

* The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired capacity, * and maintains it by replenishing interrupted Spot Instances (maintain). A value of * instant places a synchronous one-time request, and returns errors for any instances that could * not be launched. A value of request places an asynchronous one-time request without maintaining * capacity or submitting requests in alternative capacity pools if capacity is unavailable. For more * information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. *

* * @param type * The type of the request. By default, the EC2 Fleet places an asynchronous request for your desired * capacity, and maintains it by replenishing interrupted Spot Instances (maintain). A value * of instant places a synchronous one-time request, and returns errors for any instances * that could not be launched. A value of request places an asynchronous one-time request * without maintaining capacity or submitting requests in alternative capacity pools if capacity is * unavailable. For more information, see EC2 Fleet Request Types in the Amazon Elastic Compute Cloud User Guide. * @see FleetType * @return Returns a reference to this object so that method calls can be chained together. * @see FleetType */ Builder type(FleetType type); /** *

* The start date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling the * request immediately. *

* * @param validFrom * The start date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). The default is to start fulfilling * the request immediately. * @return Returns a reference to this object so that method calls can be chained together. */ Builder validFrom(Instant validFrom); /** *

* The end date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). At this point, no new EC2 Fleet requests are * placed or able to fulfill the request. If no value is specified, the request remains until you cancel it. *

* * @param validUntil * The end date and time of the request, in UTC format (for example, * YYYY-MM-DDTHH:MM:SSZ). At this point, no new EC2 Fleet * requests are placed or able to fulfill the request. If no value is specified, the request remains * until you cancel it. * @return Returns a reference to this object so that method calls can be chained together. */ Builder validUntil(Instant validUntil); /** *

* Indicates whether EC2 Fleet should replace unhealthy instances. *

* * @param replaceUnhealthyInstances * Indicates whether EC2 Fleet should replace unhealthy instances. * @return Returns a reference to this object so that method calls can be chained together. */ Builder replaceUnhealthyInstances(Boolean replaceUnhealthyInstances); /** *

* The key-value pair for tagging the EC2 Fleet request on creation. The value for ResourceType * must be fleet, otherwise the fleet request fails. To tag instances at launch, specify the tags * in the launch template. For information about tagging after launch, see Tagging Your * Resources. *

* * @param tagSpecifications * The key-value pair for tagging the EC2 Fleet request on creation. The value for * ResourceType must be fleet, otherwise the fleet request fails. To tag * instances at launch, specify the tags in the launch template. For information about tagging after launch, see Tagging Your * Resources. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tagSpecifications(Collection tagSpecifications); /** *

* The key-value pair for tagging the EC2 Fleet request on creation. The value for ResourceType * must be fleet, otherwise the fleet request fails. To tag instances at launch, specify the tags * in the launch template. For information about tagging after launch, see Tagging Your * Resources. *

* * @param tagSpecifications * The key-value pair for tagging the EC2 Fleet request on creation. The value for * ResourceType must be fleet, otherwise the fleet request fails. To tag * instances at launch, specify the tags in the launch template. For information about tagging after launch, see Tagging Your * Resources. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tagSpecifications(TagSpecification... tagSpecifications); /** *

* The key-value pair for tagging the EC2 Fleet request on creation. The value for ResourceType * must be fleet, otherwise the fleet request fails. To tag instances at launch, specify the tags * in the launch template. For information about tagging after launch, see Tagging Your * Resources. *

* 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 #tagSpecifications(List)}. * * @param tagSpecifications * 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 #tagSpecifications(List) */ Builder tagSpecifications(Consumer... tagSpecifications); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends Ec2Request.BuilderImpl implements Builder { private String clientToken; private SpotOptionsRequest spotOptions; private OnDemandOptionsRequest onDemandOptions; private String excessCapacityTerminationPolicy; private List launchTemplateConfigs = DefaultSdkAutoConstructList.getInstance(); private TargetCapacitySpecificationRequest targetCapacitySpecification; private Boolean terminateInstancesWithExpiration; private String type; private Instant validFrom; private Instant validUntil; private Boolean replaceUnhealthyInstances; private List tagSpecifications = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(CreateFleetRequest model) { super(model); clientToken(model.clientToken); spotOptions(model.spotOptions); onDemandOptions(model.onDemandOptions); excessCapacityTerminationPolicy(model.excessCapacityTerminationPolicy); launchTemplateConfigs(model.launchTemplateConfigs); targetCapacitySpecification(model.targetCapacitySpecification); terminateInstancesWithExpiration(model.terminateInstancesWithExpiration); type(model.type); validFrom(model.validFrom); validUntil(model.validUntil); replaceUnhealthyInstances(model.replaceUnhealthyInstances); tagSpecifications(model.tagSpecifications); } public final String getClientToken() { return clientToken; } @Override public final Builder clientToken(String clientToken) { this.clientToken = clientToken; return this; } public final void setClientToken(String clientToken) { this.clientToken = clientToken; } public final SpotOptionsRequest.Builder getSpotOptions() { return spotOptions != null ? spotOptions.toBuilder() : null; } @Override public final Builder spotOptions(SpotOptionsRequest spotOptions) { this.spotOptions = spotOptions; return this; } public final void setSpotOptions(SpotOptionsRequest.BuilderImpl spotOptions) { this.spotOptions = spotOptions != null ? spotOptions.build() : null; } public final OnDemandOptionsRequest.Builder getOnDemandOptions() { return onDemandOptions != null ? onDemandOptions.toBuilder() : null; } @Override public final Builder onDemandOptions(OnDemandOptionsRequest onDemandOptions) { this.onDemandOptions = onDemandOptions; return this; } public final void setOnDemandOptions(OnDemandOptionsRequest.BuilderImpl onDemandOptions) { this.onDemandOptions = onDemandOptions != null ? onDemandOptions.build() : null; } public final String getExcessCapacityTerminationPolicy() { return excessCapacityTerminationPolicy; } @Override public final Builder excessCapacityTerminationPolicy(String excessCapacityTerminationPolicy) { this.excessCapacityTerminationPolicy = excessCapacityTerminationPolicy; return this; } @Override public final Builder excessCapacityTerminationPolicy(FleetExcessCapacityTerminationPolicy 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(FleetLaunchTemplateConfigRequest::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder launchTemplateConfigs(Collection launchTemplateConfigs) { this.launchTemplateConfigs = FleetLaunchTemplateConfigListRequestCopier.copy(launchTemplateConfigs); return this; } @Override @SafeVarargs public final Builder launchTemplateConfigs(FleetLaunchTemplateConfigRequest... launchTemplateConfigs) { launchTemplateConfigs(Arrays.asList(launchTemplateConfigs)); return this; } @Override @SafeVarargs public final Builder launchTemplateConfigs(Consumer... launchTemplateConfigs) { launchTemplateConfigs(Stream.of(launchTemplateConfigs) .map(c -> FleetLaunchTemplateConfigRequest.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setLaunchTemplateConfigs(Collection launchTemplateConfigs) { this.launchTemplateConfigs = FleetLaunchTemplateConfigListRequestCopier.copyFromBuilder(launchTemplateConfigs); } public final TargetCapacitySpecificationRequest.Builder getTargetCapacitySpecification() { return targetCapacitySpecification != null ? targetCapacitySpecification.toBuilder() : null; } @Override public final Builder targetCapacitySpecification(TargetCapacitySpecificationRequest targetCapacitySpecification) { this.targetCapacitySpecification = targetCapacitySpecification; return this; } public final void setTargetCapacitySpecification( TargetCapacitySpecificationRequest.BuilderImpl targetCapacitySpecification) { this.targetCapacitySpecification = targetCapacitySpecification != null ? targetCapacitySpecification.build() : null; } public final Boolean getTerminateInstancesWithExpiration() { return terminateInstancesWithExpiration; } @Override public final Builder terminateInstancesWithExpiration(Boolean terminateInstancesWithExpiration) { this.terminateInstancesWithExpiration = terminateInstancesWithExpiration; return this; } public final void setTerminateInstancesWithExpiration(Boolean terminateInstancesWithExpiration) { this.terminateInstancesWithExpiration = terminateInstancesWithExpiration; } public final String getType() { return type; } @Override public final Builder type(String type) { this.type = type; return this; } @Override public final Builder type(FleetType type) { this.type(type == null ? null : type.toString()); return this; } public final void setType(String type) { this.type = type; } public final Instant getValidFrom() { return validFrom; } @Override public final Builder validFrom(Instant validFrom) { this.validFrom = validFrom; return this; } public final void setValidFrom(Instant validFrom) { this.validFrom = validFrom; } public final Instant getValidUntil() { return validUntil; } @Override public final Builder validUntil(Instant validUntil) { this.validUntil = validUntil; return this; } public final void setValidUntil(Instant validUntil) { this.validUntil = validUntil; } public final Boolean getReplaceUnhealthyInstances() { return replaceUnhealthyInstances; } @Override public final Builder replaceUnhealthyInstances(Boolean replaceUnhealthyInstances) { this.replaceUnhealthyInstances = replaceUnhealthyInstances; return this; } public final void setReplaceUnhealthyInstances(Boolean replaceUnhealthyInstances) { this.replaceUnhealthyInstances = replaceUnhealthyInstances; } public final Collection getTagSpecifications() { return tagSpecifications != null ? tagSpecifications.stream().map(TagSpecification::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder tagSpecifications(Collection tagSpecifications) { this.tagSpecifications = TagSpecificationListCopier.copy(tagSpecifications); return this; } @Override @SafeVarargs public final Builder tagSpecifications(TagSpecification... tagSpecifications) { tagSpecifications(Arrays.asList(tagSpecifications)); return this; } @Override @SafeVarargs public final Builder tagSpecifications(Consumer... tagSpecifications) { tagSpecifications(Stream.of(tagSpecifications).map(c -> TagSpecification.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setTagSpecifications(Collection tagSpecifications) { this.tagSpecifications = TagSpecificationListCopier.copyFromBuilder(tagSpecifications); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateFleetRequest build() { return new CreateFleetRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy