software.amazon.awssdk.services.ec2.model.SpotFleetRequestConfig Maven / Gradle / Ivy
Show all versions of ec2 Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.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 extends Builder> 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