software.amazon.awssdk.services.securityhub.model.AwsEc2NetworkInterfaceDetails 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.securityhub.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;
/**
*
* Details about the network interface
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AwsEc2NetworkInterfaceDetails implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ATTACHMENT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Attachment")
.getter(getter(AwsEc2NetworkInterfaceDetails::attachment)).setter(setter(Builder::attachment))
.constructor(AwsEc2NetworkInterfaceAttachment::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Attachment").build()).build();
private static final SdkField NETWORK_INTERFACE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NetworkInterfaceId").getter(getter(AwsEc2NetworkInterfaceDetails::networkInterfaceId))
.setter(setter(Builder::networkInterfaceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NetworkInterfaceId").build())
.build();
private static final SdkField> SECURITY_GROUPS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SecurityGroups")
.getter(getter(AwsEc2NetworkInterfaceDetails::securityGroups))
.setter(setter(Builder::securityGroups))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecurityGroups").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AwsEc2NetworkInterfaceSecurityGroup::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField SOURCE_DEST_CHECK_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("SourceDestCheck").getter(getter(AwsEc2NetworkInterfaceDetails::sourceDestCheck))
.setter(setter(Builder::sourceDestCheck))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceDestCheck").build()).build();
private static final SdkField> IP_V6_ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("IpV6Addresses")
.getter(getter(AwsEc2NetworkInterfaceDetails::ipV6Addresses))
.setter(setter(Builder::ipV6Addresses))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IpV6Addresses").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AwsEc2NetworkInterfaceIpV6AddressDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> PRIVATE_IP_ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("PrivateIpAddresses")
.getter(getter(AwsEc2NetworkInterfaceDetails::privateIpAddresses))
.setter(setter(Builder::privateIpAddresses))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrivateIpAddresses").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AwsEc2NetworkInterfacePrivateIpAddressDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField PUBLIC_DNS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PublicDnsName").getter(getter(AwsEc2NetworkInterfaceDetails::publicDnsName))
.setter(setter(Builder::publicDnsName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PublicDnsName").build()).build();
private static final SdkField PUBLIC_IP_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PublicIp").getter(getter(AwsEc2NetworkInterfaceDetails::publicIp)).setter(setter(Builder::publicIp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PublicIp").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ATTACHMENT_FIELD,
NETWORK_INTERFACE_ID_FIELD, SECURITY_GROUPS_FIELD, SOURCE_DEST_CHECK_FIELD, IP_V6_ADDRESSES_FIELD,
PRIVATE_IP_ADDRESSES_FIELD, PUBLIC_DNS_NAME_FIELD, PUBLIC_IP_FIELD));
private static final long serialVersionUID = 1L;
private final AwsEc2NetworkInterfaceAttachment attachment;
private final String networkInterfaceId;
private final List securityGroups;
private final Boolean sourceDestCheck;
private final List ipV6Addresses;
private final List privateIpAddresses;
private final String publicDnsName;
private final String publicIp;
private AwsEc2NetworkInterfaceDetails(BuilderImpl builder) {
this.attachment = builder.attachment;
this.networkInterfaceId = builder.networkInterfaceId;
this.securityGroups = builder.securityGroups;
this.sourceDestCheck = builder.sourceDestCheck;
this.ipV6Addresses = builder.ipV6Addresses;
this.privateIpAddresses = builder.privateIpAddresses;
this.publicDnsName = builder.publicDnsName;
this.publicIp = builder.publicIp;
}
/**
*
* The network interface attachment.
*
*
* @return The network interface attachment.
*/
public final AwsEc2NetworkInterfaceAttachment attachment() {
return attachment;
}
/**
*
* The ID of the network interface.
*
*
* @return The ID of the network interface.
*/
public final String networkInterfaceId() {
return networkInterfaceId;
}
/**
* For responses, this returns true if the service returned a value for the SecurityGroups 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 hasSecurityGroups() {
return securityGroups != null && !(securityGroups instanceof SdkAutoConstructList);
}
/**
*
* Security groups for the network interface.
*
*
* 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 #hasSecurityGroups} method.
*
*
* @return Security groups for the network interface.
*/
public final List securityGroups() {
return securityGroups;
}
/**
*
* Indicates whether traffic to or from the instance is validated.
*
*
* @return Indicates whether traffic to or from the instance is validated.
*/
public final Boolean sourceDestCheck() {
return sourceDestCheck;
}
/**
* For responses, this returns true if the service returned a value for the IpV6Addresses 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 hasIpV6Addresses() {
return ipV6Addresses != null && !(ipV6Addresses instanceof SdkAutoConstructList);
}
/**
*
* The IPv6 addresses associated with the network interface.
*
*
* 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 #hasIpV6Addresses} method.
*
*
* @return The IPv6 addresses associated with the network interface.
*/
public final List ipV6Addresses() {
return ipV6Addresses;
}
/**
* For responses, this returns true if the service returned a value for the PrivateIpAddresses 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 hasPrivateIpAddresses() {
return privateIpAddresses != null && !(privateIpAddresses instanceof SdkAutoConstructList);
}
/**
*
* The private IPv4 addresses associated with the network interface.
*
*
* 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 #hasPrivateIpAddresses} method.
*
*
* @return The private IPv4 addresses associated with the network interface.
*/
public final List privateIpAddresses() {
return privateIpAddresses;
}
/**
*
* The public DNS name of the network interface.
*
*
* @return The public DNS name of the network interface.
*/
public final String publicDnsName() {
return publicDnsName;
}
/**
*
* The address of the Elastic IP address bound to the network interface.
*
*
* @return The address of the Elastic IP address bound to the network interface.
*/
public final String publicIp() {
return publicIp;
}
@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(attachment());
hashCode = 31 * hashCode + Objects.hashCode(networkInterfaceId());
hashCode = 31 * hashCode + Objects.hashCode(hasSecurityGroups() ? securityGroups() : null);
hashCode = 31 * hashCode + Objects.hashCode(sourceDestCheck());
hashCode = 31 * hashCode + Objects.hashCode(hasIpV6Addresses() ? ipV6Addresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasPrivateIpAddresses() ? privateIpAddresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(publicDnsName());
hashCode = 31 * hashCode + Objects.hashCode(publicIp());
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 AwsEc2NetworkInterfaceDetails)) {
return false;
}
AwsEc2NetworkInterfaceDetails other = (AwsEc2NetworkInterfaceDetails) obj;
return Objects.equals(attachment(), other.attachment())
&& Objects.equals(networkInterfaceId(), other.networkInterfaceId())
&& hasSecurityGroups() == other.hasSecurityGroups() && Objects.equals(securityGroups(), other.securityGroups())
&& Objects.equals(sourceDestCheck(), other.sourceDestCheck()) && hasIpV6Addresses() == other.hasIpV6Addresses()
&& Objects.equals(ipV6Addresses(), other.ipV6Addresses())
&& hasPrivateIpAddresses() == other.hasPrivateIpAddresses()
&& Objects.equals(privateIpAddresses(), other.privateIpAddresses())
&& Objects.equals(publicDnsName(), other.publicDnsName()) && Objects.equals(publicIp(), other.publicIp());
}
/**
* 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("AwsEc2NetworkInterfaceDetails").add("Attachment", attachment())
.add("NetworkInterfaceId", networkInterfaceId())
.add("SecurityGroups", hasSecurityGroups() ? securityGroups() : null).add("SourceDestCheck", sourceDestCheck())
.add("IpV6Addresses", hasIpV6Addresses() ? ipV6Addresses() : null)
.add("PrivateIpAddresses", hasPrivateIpAddresses() ? privateIpAddresses() : null)
.add("PublicDnsName", publicDnsName()).add("PublicIp", publicIp()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Attachment":
return Optional.ofNullable(clazz.cast(attachment()));
case "NetworkInterfaceId":
return Optional.ofNullable(clazz.cast(networkInterfaceId()));
case "SecurityGroups":
return Optional.ofNullable(clazz.cast(securityGroups()));
case "SourceDestCheck":
return Optional.ofNullable(clazz.cast(sourceDestCheck()));
case "IpV6Addresses":
return Optional.ofNullable(clazz.cast(ipV6Addresses()));
case "PrivateIpAddresses":
return Optional.ofNullable(clazz.cast(privateIpAddresses()));
case "PublicDnsName":
return Optional.ofNullable(clazz.cast(publicDnsName()));
case "PublicIp":
return Optional.ofNullable(clazz.cast(publicIp()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function