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

software.amazon.awssdk.services.ec2.model.SpotFleetRequestConfig Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon EC2 module holds the client classes that are used for communicating with Amazon EC2 Service

There is a newer version: 2.29.15
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.ec2.model;

import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.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;

/**
 * 

* Describes a Spot Fleet request. *

*/ @Generated("software.amazon.awssdk:codegen") public final class SpotFleetRequestConfig implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ACTIVITY_STATUS_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("ActivityStatus") .getter(getter(SpotFleetRequestConfig::activityStatusAsString)) .setter(setter(Builder::activityStatus)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActivityStatus") .unmarshallLocationName("activityStatus").build()).build(); private static final SdkField CREATE_TIME_FIELD = SdkField . builder(MarshallingType.INSTANT) .memberName("CreateTime") .getter(getter(SpotFleetRequestConfig::createTime)) .setter(setter(Builder::createTime)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreateTime") .unmarshallLocationName("createTime").build()).build(); private static final SdkField SPOT_FLEET_REQUEST_CONFIG_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("SpotFleetRequestConfig") .getter(getter(SpotFleetRequestConfig::spotFleetRequestConfig)) .setter(setter(Builder::spotFleetRequestConfig)) .constructor(SpotFleetRequestConfigData::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SpotFleetRequestConfig") .unmarshallLocationName("spotFleetRequestConfig").build()).build(); private static final SdkField SPOT_FLEET_REQUEST_ID_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("SpotFleetRequestId") .getter(getter(SpotFleetRequestConfig::spotFleetRequestId)) .setter(setter(Builder::spotFleetRequestId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SpotFleetRequestId") .unmarshallLocationName("spotFleetRequestId").build()).build(); private static final SdkField SPOT_FLEET_REQUEST_STATE_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("SpotFleetRequestState") .getter(getter(SpotFleetRequestConfig::spotFleetRequestStateAsString)) .setter(setter(Builder::spotFleetRequestState)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SpotFleetRequestState") .unmarshallLocationName("spotFleetRequestState").build()).build(); private static final SdkField> TAGS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Tags") .getter(getter(SpotFleetRequestConfig::tags)) .setter(setter(Builder::tags)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TagSet") .unmarshallLocationName("tagSet").build(), ListTrait .builder() .memberLocationName("item") .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Tag::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(ACTIVITY_STATUS_FIELD, CREATE_TIME_FIELD, SPOT_FLEET_REQUEST_CONFIG_FIELD, SPOT_FLEET_REQUEST_ID_FIELD, SPOT_FLEET_REQUEST_STATE_FIELD, TAGS_FIELD)); private static final Map> SDK_NAME_TO_FIELD = Collections .unmodifiableMap(new HashMap>() { { put("ActivityStatus", ACTIVITY_STATUS_FIELD); put("CreateTime", CREATE_TIME_FIELD); put("SpotFleetRequestConfig", SPOT_FLEET_REQUEST_CONFIG_FIELD); put("SpotFleetRequestId", SPOT_FLEET_REQUEST_ID_FIELD); put("SpotFleetRequestState", SPOT_FLEET_REQUEST_STATE_FIELD); put("TagSet", TAGS_FIELD); } }); private static final long serialVersionUID = 1L; private final String activityStatus; private final Instant createTime; private final SpotFleetRequestConfigData spotFleetRequestConfig; private final String spotFleetRequestId; private final String spotFleetRequestState; private final List tags; private SpotFleetRequestConfig(BuilderImpl builder) { this.activityStatus = builder.activityStatus; this.createTime = builder.createTime; this.spotFleetRequestConfig = builder.spotFleetRequestConfig; this.spotFleetRequestId = builder.spotFleetRequestId; this.spotFleetRequestState = builder.spotFleetRequestState; this.tags = builder.tags; } /** *

* The progress of the Spot Fleet request. If there is an error, the status is error. After all * requests are placed, the status is pending_fulfillment. If the size of the fleet is equal to or * greater than its target capacity, the status is fulfilled. If the size of the fleet is decreased, * the status is pending_termination while Spot Instances are terminating. *

*

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

* * @return The progress of the Spot Fleet request. If there is an error, the status is error. After all * requests are placed, the status is pending_fulfillment. If the size of the fleet is equal to * or greater than its target capacity, the status is fulfilled. If the size of the fleet is * decreased, the status is pending_termination while Spot Instances are terminating. * @see ActivityStatus */ public final ActivityStatus activityStatus() { return ActivityStatus.fromValue(activityStatus); } /** *

* The progress of the Spot Fleet request. If there is an error, the status is error. After all * requests are placed, the status is pending_fulfillment. If the size of the fleet is equal to or * greater than its target capacity, the status is fulfilled. If the size of the fleet is decreased, * the status is pending_termination while Spot Instances are terminating. *

*

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

* * @return The progress of the Spot Fleet request. If there is an error, the status is error. After all * requests are placed, the status is pending_fulfillment. If the size of the fleet is equal to * or greater than its target capacity, the status is fulfilled. If the size of the fleet is * decreased, the status is pending_termination while Spot Instances are terminating. * @see ActivityStatus */ public final String activityStatusAsString() { return activityStatus; } /** *

* The creation date and time of the request. *

* * @return The creation date and time of the request. */ public final Instant createTime() { return createTime; } /** *

* The configuration of the Spot Fleet request. *

* * @return The configuration of the Spot Fleet request. */ public final SpotFleetRequestConfigData spotFleetRequestConfig() { return spotFleetRequestConfig; } /** *

* The ID of the Spot Fleet request. *

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

* The state of the Spot Fleet request. *

*

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

* * @return The state of the Spot Fleet request. * @see BatchState */ public final BatchState spotFleetRequestState() { return BatchState.fromValue(spotFleetRequestState); } /** *

* The state of the Spot Fleet request. *

*

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

* * @return The state of the Spot Fleet request. * @see BatchState */ public final String spotFleetRequestStateAsString() { return spotFleetRequestState; } /** * For responses, this returns true if the service returned a value for the Tags 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 hasTags() { return tags != null && !(tags instanceof SdkAutoConstructList); } /** *

* The tags for a Spot Fleet resource. *

*

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

* * @return The tags for a Spot Fleet resource. */ public final List tags() { return tags; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(activityStatusAsString()); hashCode = 31 * hashCode + Objects.hashCode(createTime()); hashCode = 31 * hashCode + Objects.hashCode(spotFleetRequestConfig()); hashCode = 31 * hashCode + Objects.hashCode(spotFleetRequestId()); hashCode = 31 * hashCode + Objects.hashCode(spotFleetRequestStateAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof SpotFleetRequestConfig)) { return false; } SpotFleetRequestConfig other = (SpotFleetRequestConfig) obj; return Objects.equals(activityStatusAsString(), other.activityStatusAsString()) && Objects.equals(createTime(), other.createTime()) && Objects.equals(spotFleetRequestConfig(), other.spotFleetRequestConfig()) && Objects.equals(spotFleetRequestId(), other.spotFleetRequestId()) && Objects.equals(spotFleetRequestStateAsString(), other.spotFleetRequestStateAsString()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()); } /** * 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("SpotFleetRequestConfig").add("ActivityStatus", activityStatusAsString()) .add("CreateTime", createTime()).add("SpotFleetRequestConfig", spotFleetRequestConfig()) .add("SpotFleetRequestId", spotFleetRequestId()).add("SpotFleetRequestState", spotFleetRequestStateAsString()) .add("Tags", hasTags() ? tags() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ActivityStatus": return Optional.ofNullable(clazz.cast(activityStatusAsString())); case "CreateTime": return Optional.ofNullable(clazz.cast(createTime())); case "SpotFleetRequestConfig": return Optional.ofNullable(clazz.cast(spotFleetRequestConfig())); case "SpotFleetRequestId": return Optional.ofNullable(clazz.cast(spotFleetRequestId())); case "SpotFleetRequestState": return Optional.ofNullable(clazz.cast(spotFleetRequestStateAsString())); case "Tags": return Optional.ofNullable(clazz.cast(tags())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Function getter(Function g) { return obj -> g.apply((SpotFleetRequestConfig) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The progress of the Spot Fleet request. If there is an error, the status is error. After all * requests are placed, the status is pending_fulfillment. If the size of the fleet is equal to or * greater than its target capacity, the status is fulfilled. If the size of the fleet is * decreased, the status is pending_termination while Spot Instances are terminating. *

* * @param activityStatus * The progress of the Spot Fleet request. If there is an error, the status is error. After * all requests are placed, the status is pending_fulfillment. If the size of the fleet is * equal to or greater than its target capacity, the status is fulfilled. If the size of the * fleet is decreased, the status is pending_termination while Spot Instances are * terminating. * @see ActivityStatus * @return Returns a reference to this object so that method calls can be chained together. * @see ActivityStatus */ Builder activityStatus(String activityStatus); /** *

* The progress of the Spot Fleet request. If there is an error, the status is error. After all * requests are placed, the status is pending_fulfillment. If the size of the fleet is equal to or * greater than its target capacity, the status is fulfilled. If the size of the fleet is * decreased, the status is pending_termination while Spot Instances are terminating. *

* * @param activityStatus * The progress of the Spot Fleet request. If there is an error, the status is error. After * all requests are placed, the status is pending_fulfillment. If the size of the fleet is * equal to or greater than its target capacity, the status is fulfilled. If the size of the * fleet is decreased, the status is pending_termination while Spot Instances are * terminating. * @see ActivityStatus * @return Returns a reference to this object so that method calls can be chained together. * @see ActivityStatus */ Builder activityStatus(ActivityStatus activityStatus); /** *

* The creation date and time of the request. *

* * @param createTime * The creation date and time of the request. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createTime(Instant createTime); /** *

* The configuration of the Spot Fleet request. *

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

* The configuration of the Spot Fleet request. *

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

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

* 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 state of the Spot Fleet request. *

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

* The state of the Spot Fleet request. *

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

* The tags for a Spot Fleet resource. *

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

* The tags for a Spot Fleet resource. *

* * @param tags * The tags for a Spot Fleet resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

* The tags for a Spot Fleet resource. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.ec2.model.Tag.Builder} avoiding the need to create one manually via * {@link software.amazon.awssdk.services.ec2.model.Tag#builder()}. * *

* When the {@link Consumer} completes, {@link software.amazon.awssdk.services.ec2.model.Tag.Builder#build()} is * called immediately and its result is passed to {@link #tags(List)}. * * @param tags * a consumer that will call methods on {@link software.amazon.awssdk.services.ec2.model.Tag.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tags(java.util.Collection) */ Builder tags(Consumer... tags); } static final class BuilderImpl implements Builder { private String activityStatus; private Instant createTime; private SpotFleetRequestConfigData spotFleetRequestConfig; private String spotFleetRequestId; private String spotFleetRequestState; private List tags = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(SpotFleetRequestConfig model) { activityStatus(model.activityStatus); createTime(model.createTime); spotFleetRequestConfig(model.spotFleetRequestConfig); spotFleetRequestId(model.spotFleetRequestId); spotFleetRequestState(model.spotFleetRequestState); tags(model.tags); } public final String getActivityStatus() { return activityStatus; } public final void setActivityStatus(String activityStatus) { this.activityStatus = activityStatus; } @Override public final Builder activityStatus(String activityStatus) { this.activityStatus = activityStatus; return this; } @Override public final Builder activityStatus(ActivityStatus activityStatus) { this.activityStatus(activityStatus == null ? null : activityStatus.toString()); return this; } public final Instant getCreateTime() { return createTime; } public final void setCreateTime(Instant createTime) { this.createTime = createTime; } @Override public final Builder createTime(Instant createTime) { this.createTime = createTime; return this; } public final SpotFleetRequestConfigData.Builder getSpotFleetRequestConfig() { return spotFleetRequestConfig != null ? spotFleetRequestConfig.toBuilder() : null; } public final void setSpotFleetRequestConfig(SpotFleetRequestConfigData.BuilderImpl spotFleetRequestConfig) { this.spotFleetRequestConfig = spotFleetRequestConfig != null ? spotFleetRequestConfig.build() : null; } @Override public final Builder spotFleetRequestConfig(SpotFleetRequestConfigData spotFleetRequestConfig) { this.spotFleetRequestConfig = spotFleetRequestConfig; return this; } public final String getSpotFleetRequestId() { return spotFleetRequestId; } public final void setSpotFleetRequestId(String spotFleetRequestId) { this.spotFleetRequestId = spotFleetRequestId; } @Override public final Builder spotFleetRequestId(String spotFleetRequestId) { this.spotFleetRequestId = spotFleetRequestId; return this; } public final String getSpotFleetRequestState() { return spotFleetRequestState; } public final void setSpotFleetRequestState(String spotFleetRequestState) { this.spotFleetRequestState = spotFleetRequestState; } @Override public final Builder spotFleetRequestState(String spotFleetRequestState) { this.spotFleetRequestState = spotFleetRequestState; return this; } @Override public final Builder spotFleetRequestState(BatchState spotFleetRequestState) { this.spotFleetRequestState(spotFleetRequestState == null ? null : spotFleetRequestState.toString()); return this; } public final List getTags() { List result = TagListCopier.copyToBuilder(this.tags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTags(Collection tags) { this.tags = TagListCopier.copyFromBuilder(tags); } @Override public final Builder tags(Collection tags) { this.tags = TagListCopier.copy(tags); return this; } @Override @SafeVarargs public final Builder tags(Tag... tags) { tags(Arrays.asList(tags)); return this; } @Override @SafeVarargs public final Builder tags(Consumer... tags) { tags(Stream.of(tags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public SpotFleetRequestConfig build() { return new SpotFleetRequestConfig(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy