
software.amazon.awssdk.services.emr.model.Instance 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.emr.model;
import java.io.Serializable;
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.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;
/**
*
* Represents an EC2 instance provisioned as part of cluster.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Instance implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Id")
.getter(getter(Instance::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField EC2_INSTANCE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Ec2InstanceId").getter(getter(Instance::ec2InstanceId)).setter(setter(Builder::ec2InstanceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Ec2InstanceId").build()).build();
private static final SdkField PUBLIC_DNS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PublicDnsName").getter(getter(Instance::publicDnsName)).setter(setter(Builder::publicDnsName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PublicDnsName").build()).build();
private static final SdkField PUBLIC_IP_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PublicIpAddress").getter(getter(Instance::publicIpAddress)).setter(setter(Builder::publicIpAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PublicIpAddress").build()).build();
private static final SdkField PRIVATE_DNS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrivateDnsName").getter(getter(Instance::privateDnsName)).setter(setter(Builder::privateDnsName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrivateDnsName").build()).build();
private static final SdkField PRIVATE_IP_ADDRESS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrivateIpAddress").getter(getter(Instance::privateIpAddress)).setter(setter(Builder::privateIpAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrivateIpAddress").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Status").getter(getter(Instance::status)).setter(setter(Builder::status))
.constructor(InstanceStatus::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField INSTANCE_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceGroupId").getter(getter(Instance::instanceGroupId)).setter(setter(Builder::instanceGroupId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceGroupId").build()).build();
private static final SdkField INSTANCE_FLEET_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceFleetId").getter(getter(Instance::instanceFleetId)).setter(setter(Builder::instanceFleetId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceFleetId").build()).build();
private static final SdkField MARKET_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Market")
.getter(getter(Instance::marketAsString)).setter(setter(Builder::market))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Market").build()).build();
private static final SdkField INSTANCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("InstanceType").getter(getter(Instance::instanceType)).setter(setter(Builder::instanceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceType").build()).build();
private static final SdkField> EBS_VOLUMES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("EbsVolumes")
.getter(getter(Instance::ebsVolumes))
.setter(setter(Builder::ebsVolumes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EbsVolumes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(EbsVolume::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD,
EC2_INSTANCE_ID_FIELD, PUBLIC_DNS_NAME_FIELD, PUBLIC_IP_ADDRESS_FIELD, PRIVATE_DNS_NAME_FIELD,
PRIVATE_IP_ADDRESS_FIELD, STATUS_FIELD, INSTANCE_GROUP_ID_FIELD, INSTANCE_FLEET_ID_FIELD, MARKET_FIELD,
INSTANCE_TYPE_FIELD, EBS_VOLUMES_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final String ec2InstanceId;
private final String publicDnsName;
private final String publicIpAddress;
private final String privateDnsName;
private final String privateIpAddress;
private final InstanceStatus status;
private final String instanceGroupId;
private final String instanceFleetId;
private final String market;
private final String instanceType;
private final List ebsVolumes;
private Instance(BuilderImpl builder) {
this.id = builder.id;
this.ec2InstanceId = builder.ec2InstanceId;
this.publicDnsName = builder.publicDnsName;
this.publicIpAddress = builder.publicIpAddress;
this.privateDnsName = builder.privateDnsName;
this.privateIpAddress = builder.privateIpAddress;
this.status = builder.status;
this.instanceGroupId = builder.instanceGroupId;
this.instanceFleetId = builder.instanceFleetId;
this.market = builder.market;
this.instanceType = builder.instanceType;
this.ebsVolumes = builder.ebsVolumes;
}
/**
*
* The unique identifier for the instance in Amazon EMR.
*
*
* @return The unique identifier for the instance in Amazon EMR.
*/
public final String id() {
return id;
}
/**
*
* The unique identifier of the instance in Amazon EC2.
*
*
* @return The unique identifier of the instance in Amazon EC2.
*/
public final String ec2InstanceId() {
return ec2InstanceId;
}
/**
*
* The public DNS name of the instance.
*
*
* @return The public DNS name of the instance.
*/
public final String publicDnsName() {
return publicDnsName;
}
/**
*
* The public IP address of the instance.
*
*
* @return The public IP address of the instance.
*/
public final String publicIpAddress() {
return publicIpAddress;
}
/**
*
* The private DNS name of the instance.
*
*
* @return The private DNS name of the instance.
*/
public final String privateDnsName() {
return privateDnsName;
}
/**
*
* The private IP address of the instance.
*
*
* @return The private IP address of the instance.
*/
public final String privateIpAddress() {
return privateIpAddress;
}
/**
*
* The current status of the instance.
*
*
* @return The current status of the instance.
*/
public final InstanceStatus status() {
return status;
}
/**
*
* The identifier of the instance group to which this instance belongs.
*
*
* @return The identifier of the instance group to which this instance belongs.
*/
public final String instanceGroupId() {
return instanceGroupId;
}
/**
*
* The unique identifier of the instance fleet to which an EC2 instance belongs.
*
*
* @return The unique identifier of the instance fleet to which an EC2 instance belongs.
*/
public final String instanceFleetId() {
return instanceFleetId;
}
/**
*
* The instance purchasing option. Valid values are ON_DEMAND
or SPOT
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #market} will
* return {@link MarketType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #marketAsString}.
*
*
* @return The instance purchasing option. Valid values are ON_DEMAND
or SPOT
.
* @see MarketType
*/
public final MarketType market() {
return MarketType.fromValue(market);
}
/**
*
* The instance purchasing option. Valid values are ON_DEMAND
or SPOT
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #market} will
* return {@link MarketType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #marketAsString}.
*
*
* @return The instance purchasing option. Valid values are ON_DEMAND
or SPOT
.
* @see MarketType
*/
public final String marketAsString() {
return market;
}
/**
*
* The EC2 instance type, for example m3.xlarge
.
*
*
* @return The EC2 instance type, for example m3.xlarge
.
*/
public final String instanceType() {
return instanceType;
}
/**
* For responses, this returns true if the service returned a value for the EbsVolumes 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 hasEbsVolumes() {
return ebsVolumes != null && !(ebsVolumes instanceof SdkAutoConstructList);
}
/**
*
* The list of Amazon EBS volumes that are attached to this instance.
*
*
* 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 #hasEbsVolumes} method.
*
*
* @return The list of Amazon EBS volumes that are attached to this instance.
*/
public final List ebsVolumes() {
return ebsVolumes;
}
@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(id());
hashCode = 31 * hashCode + Objects.hashCode(ec2InstanceId());
hashCode = 31 * hashCode + Objects.hashCode(publicDnsName());
hashCode = 31 * hashCode + Objects.hashCode(publicIpAddress());
hashCode = 31 * hashCode + Objects.hashCode(privateDnsName());
hashCode = 31 * hashCode + Objects.hashCode(privateIpAddress());
hashCode = 31 * hashCode + Objects.hashCode(status());
hashCode = 31 * hashCode + Objects.hashCode(instanceGroupId());
hashCode = 31 * hashCode + Objects.hashCode(instanceFleetId());
hashCode = 31 * hashCode + Objects.hashCode(marketAsString());
hashCode = 31 * hashCode + Objects.hashCode(instanceType());
hashCode = 31 * hashCode + Objects.hashCode(hasEbsVolumes() ? ebsVolumes() : 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 Instance)) {
return false;
}
Instance other = (Instance) obj;
return Objects.equals(id(), other.id()) && Objects.equals(ec2InstanceId(), other.ec2InstanceId())
&& Objects.equals(publicDnsName(), other.publicDnsName())
&& Objects.equals(publicIpAddress(), other.publicIpAddress())
&& Objects.equals(privateDnsName(), other.privateDnsName())
&& Objects.equals(privateIpAddress(), other.privateIpAddress()) && Objects.equals(status(), other.status())
&& Objects.equals(instanceGroupId(), other.instanceGroupId())
&& Objects.equals(instanceFleetId(), other.instanceFleetId())
&& Objects.equals(marketAsString(), other.marketAsString())
&& Objects.equals(instanceType(), other.instanceType()) && hasEbsVolumes() == other.hasEbsVolumes()
&& Objects.equals(ebsVolumes(), other.ebsVolumes());
}
/**
* 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("Instance").add("Id", id()).add("Ec2InstanceId", ec2InstanceId())
.add("PublicDnsName", publicDnsName()).add("PublicIpAddress", publicIpAddress())
.add("PrivateDnsName", privateDnsName()).add("PrivateIpAddress", privateIpAddress()).add("Status", status())
.add("InstanceGroupId", instanceGroupId()).add("InstanceFleetId", instanceFleetId())
.add("Market", marketAsString()).add("InstanceType", instanceType())
.add("EbsVolumes", hasEbsVolumes() ? ebsVolumes() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "Ec2InstanceId":
return Optional.ofNullable(clazz.cast(ec2InstanceId()));
case "PublicDnsName":
return Optional.ofNullable(clazz.cast(publicDnsName()));
case "PublicIpAddress":
return Optional.ofNullable(clazz.cast(publicIpAddress()));
case "PrivateDnsName":
return Optional.ofNullable(clazz.cast(privateDnsName()));
case "PrivateIpAddress":
return Optional.ofNullable(clazz.cast(privateIpAddress()));
case "Status":
return Optional.ofNullable(clazz.cast(status()));
case "InstanceGroupId":
return Optional.ofNullable(clazz.cast(instanceGroupId()));
case "InstanceFleetId":
return Optional.ofNullable(clazz.cast(instanceFleetId()));
case "Market":
return Optional.ofNullable(clazz.cast(marketAsString()));
case "InstanceType":
return Optional.ofNullable(clazz.cast(instanceType()));
case "EbsVolumes":
return Optional.ofNullable(clazz.cast(ebsVolumes()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function