software.amazon.awssdk.services.ec2.model.NetworkInterfaceAttachment 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.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 software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes a network interface attachment.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class NetworkInterfaceAttachment implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ATTACH_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("AttachTime")
.getter(getter(NetworkInterfaceAttachment::attachTime))
.setter(setter(Builder::attachTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AttachTime")
.unmarshallLocationName("attachTime").build()).build();
private static final SdkField ATTACHMENT_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("AttachmentId")
.getter(getter(NetworkInterfaceAttachment::attachmentId))
.setter(setter(Builder::attachmentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AttachmentId")
.unmarshallLocationName("attachmentId").build()).build();
private static final SdkField DELETE_ON_TERMINATION_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.memberName("DeleteOnTermination")
.getter(getter(NetworkInterfaceAttachment::deleteOnTermination))
.setter(setter(Builder::deleteOnTermination))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeleteOnTermination")
.unmarshallLocationName("deleteOnTermination").build()).build();
private static final SdkField DEVICE_INDEX_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("DeviceIndex")
.getter(getter(NetworkInterfaceAttachment::deviceIndex))
.setter(setter(Builder::deviceIndex))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeviceIndex")
.unmarshallLocationName("deviceIndex").build()).build();
private static final SdkField NETWORK_CARD_INDEX_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("NetworkCardIndex")
.getter(getter(NetworkInterfaceAttachment::networkCardIndex))
.setter(setter(Builder::networkCardIndex))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NetworkCardIndex")
.unmarshallLocationName("networkCardIndex").build()).build();
private static final SdkField INSTANCE_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("InstanceId")
.getter(getter(NetworkInterfaceAttachment::instanceId))
.setter(setter(Builder::instanceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceId")
.unmarshallLocationName("instanceId").build()).build();
private static final SdkField INSTANCE_OWNER_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("InstanceOwnerId")
.getter(getter(NetworkInterfaceAttachment::instanceOwnerId))
.setter(setter(Builder::instanceOwnerId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceOwnerId")
.unmarshallLocationName("instanceOwnerId").build()).build();
private static final SdkField STATUS_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Status")
.getter(getter(NetworkInterfaceAttachment::statusAsString))
.setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status")
.unmarshallLocationName("status").build()).build();
private static final SdkField ENA_SRD_SPECIFICATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("EnaSrdSpecification")
.getter(getter(NetworkInterfaceAttachment::enaSrdSpecification))
.setter(setter(Builder::enaSrdSpecification))
.constructor(AttachmentEnaSrdSpecification::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnaSrdSpecification")
.unmarshallLocationName("enaSrdSpecification").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ATTACH_TIME_FIELD,
ATTACHMENT_ID_FIELD, DELETE_ON_TERMINATION_FIELD, DEVICE_INDEX_FIELD, NETWORK_CARD_INDEX_FIELD, INSTANCE_ID_FIELD,
INSTANCE_OWNER_ID_FIELD, STATUS_FIELD, ENA_SRD_SPECIFICATION_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("AttachTime", ATTACH_TIME_FIELD);
put("AttachmentId", ATTACHMENT_ID_FIELD);
put("DeleteOnTermination", DELETE_ON_TERMINATION_FIELD);
put("DeviceIndex", DEVICE_INDEX_FIELD);
put("NetworkCardIndex", NETWORK_CARD_INDEX_FIELD);
put("InstanceId", INSTANCE_ID_FIELD);
put("InstanceOwnerId", INSTANCE_OWNER_ID_FIELD);
put("Status", STATUS_FIELD);
put("EnaSrdSpecification", ENA_SRD_SPECIFICATION_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final Instant attachTime;
private final String attachmentId;
private final Boolean deleteOnTermination;
private final Integer deviceIndex;
private final Integer networkCardIndex;
private final String instanceId;
private final String instanceOwnerId;
private final String status;
private final AttachmentEnaSrdSpecification enaSrdSpecification;
private NetworkInterfaceAttachment(BuilderImpl builder) {
this.attachTime = builder.attachTime;
this.attachmentId = builder.attachmentId;
this.deleteOnTermination = builder.deleteOnTermination;
this.deviceIndex = builder.deviceIndex;
this.networkCardIndex = builder.networkCardIndex;
this.instanceId = builder.instanceId;
this.instanceOwnerId = builder.instanceOwnerId;
this.status = builder.status;
this.enaSrdSpecification = builder.enaSrdSpecification;
}
/**
*
* The timestamp indicating when the attachment initiated.
*
*
* @return The timestamp indicating when the attachment initiated.
*/
public final Instant attachTime() {
return attachTime;
}
/**
*
* The ID of the network interface attachment.
*
*
* @return The ID of the network interface attachment.
*/
public final String attachmentId() {
return attachmentId;
}
/**
*
* Indicates whether the network interface is deleted when the instance is terminated.
*
*
* @return Indicates whether the network interface is deleted when the instance is terminated.
*/
public final Boolean deleteOnTermination() {
return deleteOnTermination;
}
/**
*
* The device index of the network interface attachment on the instance.
*
*
* @return The device index of the network interface attachment on the instance.
*/
public final Integer deviceIndex() {
return deviceIndex;
}
/**
*
* The index of the network card.
*
*
* @return The index of the network card.
*/
public final Integer networkCardIndex() {
return networkCardIndex;
}
/**
*
* The ID of the instance.
*
*
* @return The ID of the instance.
*/
public final String instanceId() {
return instanceId;
}
/**
*
* The Amazon Web Services account ID of the owner of the instance.
*
*
* @return The Amazon Web Services account ID of the owner of the instance.
*/
public final String instanceOwnerId() {
return instanceOwnerId;
}
/**
*
* The attachment state.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AttachmentStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The attachment state.
* @see AttachmentStatus
*/
public final AttachmentStatus status() {
return AttachmentStatus.fromValue(status);
}
/**
*
* The attachment state.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AttachmentStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The attachment state.
* @see AttachmentStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* Configures ENA Express for the network interface that this action attaches to the instance.
*
*
* @return Configures ENA Express for the network interface that this action attaches to the instance.
*/
public final AttachmentEnaSrdSpecification enaSrdSpecification() {
return enaSrdSpecification;
}
@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(attachTime());
hashCode = 31 * hashCode + Objects.hashCode(attachmentId());
hashCode = 31 * hashCode + Objects.hashCode(deleteOnTermination());
hashCode = 31 * hashCode + Objects.hashCode(deviceIndex());
hashCode = 31 * hashCode + Objects.hashCode(networkCardIndex());
hashCode = 31 * hashCode + Objects.hashCode(instanceId());
hashCode = 31 * hashCode + Objects.hashCode(instanceOwnerId());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(enaSrdSpecification());
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 NetworkInterfaceAttachment)) {
return false;
}
NetworkInterfaceAttachment other = (NetworkInterfaceAttachment) obj;
return Objects.equals(attachTime(), other.attachTime()) && Objects.equals(attachmentId(), other.attachmentId())
&& Objects.equals(deleteOnTermination(), other.deleteOnTermination())
&& Objects.equals(deviceIndex(), other.deviceIndex())
&& Objects.equals(networkCardIndex(), other.networkCardIndex())
&& Objects.equals(instanceId(), other.instanceId()) && Objects.equals(instanceOwnerId(), other.instanceOwnerId())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(enaSrdSpecification(), other.enaSrdSpecification());
}
/**
* 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("NetworkInterfaceAttachment").add("AttachTime", attachTime()).add("AttachmentId", attachmentId())
.add("DeleteOnTermination", deleteOnTermination()).add("DeviceIndex", deviceIndex())
.add("NetworkCardIndex", networkCardIndex()).add("InstanceId", instanceId())
.add("InstanceOwnerId", instanceOwnerId()).add("Status", statusAsString())
.add("EnaSrdSpecification", enaSrdSpecification()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AttachTime":
return Optional.ofNullable(clazz.cast(attachTime()));
case "AttachmentId":
return Optional.ofNullable(clazz.cast(attachmentId()));
case "DeleteOnTermination":
return Optional.ofNullable(clazz.cast(deleteOnTermination()));
case "DeviceIndex":
return Optional.ofNullable(clazz.cast(deviceIndex()));
case "NetworkCardIndex":
return Optional.ofNullable(clazz.cast(networkCardIndex()));
case "InstanceId":
return Optional.ofNullable(clazz.cast(instanceId()));
case "InstanceOwnerId":
return Optional.ofNullable(clazz.cast(instanceOwnerId()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "EnaSrdSpecification":
return Optional.ofNullable(clazz.cast(enaSrdSpecification()));
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