
software.amazon.awssdk.services.guardduty.model.NetworkInterface 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.guardduty.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;
/**
*
* Contains information about the elastic network interface of the EC2 instance.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class NetworkInterface implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField> IPV6_ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Ipv6Addresses")
.getter(getter(NetworkInterface::ipv6Addresses))
.setter(setter(Builder::ipv6Addresses))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ipv6Addresses").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField NETWORK_INTERFACE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("NetworkInterfaceId").getter(getter(NetworkInterface::networkInterfaceId))
.setter(setter(Builder::networkInterfaceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("networkInterfaceId").build())
.build();
private static final SdkField PRIVATE_DNS_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrivateDnsName").getter(getter(NetworkInterface::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(NetworkInterface::privateIpAddress))
.setter(setter(Builder::privateIpAddress))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("privateIpAddress").build()).build();
private static final SdkField> PRIVATE_IP_ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("PrivateIpAddresses")
.getter(getter(NetworkInterface::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(PrivateIpAddressDetails::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(NetworkInterface::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(NetworkInterface::publicIp)).setter(setter(Builder::publicIp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("publicIp").build()).build();
private static final SdkField> SECURITY_GROUPS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SecurityGroups")
.getter(getter(NetworkInterface::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(SecurityGroup::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField SUBNET_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SubnetId").getter(getter(NetworkInterface::subnetId)).setter(setter(Builder::subnetId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("subnetId").build()).build();
private static final SdkField VPC_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("VpcId")
.getter(getter(NetworkInterface::vpcId)).setter(setter(Builder::vpcId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("vpcId").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(IPV6_ADDRESSES_FIELD,
NETWORK_INTERFACE_ID_FIELD, PRIVATE_DNS_NAME_FIELD, PRIVATE_IP_ADDRESS_FIELD, PRIVATE_IP_ADDRESSES_FIELD,
PUBLIC_DNS_NAME_FIELD, PUBLIC_IP_FIELD, SECURITY_GROUPS_FIELD, SUBNET_ID_FIELD, VPC_ID_FIELD));
private static final long serialVersionUID = 1L;
private final List ipv6Addresses;
private final String networkInterfaceId;
private final String privateDnsName;
private final String privateIpAddress;
private final List privateIpAddresses;
private final String publicDnsName;
private final String publicIp;
private final List securityGroups;
private final String subnetId;
private final String vpcId;
private NetworkInterface(BuilderImpl builder) {
this.ipv6Addresses = builder.ipv6Addresses;
this.networkInterfaceId = builder.networkInterfaceId;
this.privateDnsName = builder.privateDnsName;
this.privateIpAddress = builder.privateIpAddress;
this.privateIpAddresses = builder.privateIpAddresses;
this.publicDnsName = builder.publicDnsName;
this.publicIp = builder.publicIp;
this.securityGroups = builder.securityGroups;
this.subnetId = builder.subnetId;
this.vpcId = builder.vpcId;
}
/**
* 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);
}
/**
*
* A list of IPv6 addresses for the EC2 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 #hasIpv6Addresses} method.
*
*
* @return A list of IPv6 addresses for the EC2 instance.
*/
public final List ipv6Addresses() {
return ipv6Addresses;
}
/**
*
* The ID of the network interface.
*
*
* @return The ID of the network interface.
*/
public final String networkInterfaceId() {
return networkInterfaceId;
}
/**
*
* The private DNS name of the EC2 instance.
*
*
* @return The private DNS name of the EC2 instance.
*/
public final String privateDnsName() {
return privateDnsName;
}
/**
*
* The private IP address of the EC2 instance.
*
*
* @return The private IP address of the EC2 instance.
*/
public final String privateIpAddress() {
return privateIpAddress;
}
/**
* 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);
}
/**
*
* Other private IP address information of the EC2 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 #hasPrivateIpAddresses} method.
*
*
* @return Other private IP address information of the EC2 instance.
*/
public final List privateIpAddresses() {
return privateIpAddresses;
}
/**
*
* The public DNS name of the EC2 instance.
*
*
* @return The public DNS name of the EC2 instance.
*/
public final String publicDnsName() {
return publicDnsName;
}
/**
*
* The public IP address of the EC2 instance.
*
*
* @return The public IP address of the EC2 instance.
*/
public final String publicIp() {
return publicIp;
}
/**
* 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);
}
/**
*
* The security groups associated with the EC2 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 #hasSecurityGroups} method.
*
*
* @return The security groups associated with the EC2 instance.
*/
public final List securityGroups() {
return securityGroups;
}
/**
*
* The subnet ID of the EC2 instance.
*
*
* @return The subnet ID of the EC2 instance.
*/
public final String subnetId() {
return subnetId;
}
/**
*
* The VPC ID of the EC2 instance.
*
*
* @return The VPC ID of the EC2 instance.
*/
public final String vpcId() {
return vpcId;
}
@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(hasIpv6Addresses() ? ipv6Addresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(networkInterfaceId());
hashCode = 31 * hashCode + Objects.hashCode(privateDnsName());
hashCode = 31 * hashCode + Objects.hashCode(privateIpAddress());
hashCode = 31 * hashCode + Objects.hashCode(hasPrivateIpAddresses() ? privateIpAddresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(publicDnsName());
hashCode = 31 * hashCode + Objects.hashCode(publicIp());
hashCode = 31 * hashCode + Objects.hashCode(hasSecurityGroups() ? securityGroups() : null);
hashCode = 31 * hashCode + Objects.hashCode(subnetId());
hashCode = 31 * hashCode + Objects.hashCode(vpcId());
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 NetworkInterface)) {
return false;
}
NetworkInterface other = (NetworkInterface) obj;
return hasIpv6Addresses() == other.hasIpv6Addresses() && Objects.equals(ipv6Addresses(), other.ipv6Addresses())
&& Objects.equals(networkInterfaceId(), other.networkInterfaceId())
&& Objects.equals(privateDnsName(), other.privateDnsName())
&& Objects.equals(privateIpAddress(), other.privateIpAddress())
&& hasPrivateIpAddresses() == other.hasPrivateIpAddresses()
&& Objects.equals(privateIpAddresses(), other.privateIpAddresses())
&& Objects.equals(publicDnsName(), other.publicDnsName()) && Objects.equals(publicIp(), other.publicIp())
&& hasSecurityGroups() == other.hasSecurityGroups() && Objects.equals(securityGroups(), other.securityGroups())
&& Objects.equals(subnetId(), other.subnetId()) && Objects.equals(vpcId(), other.vpcId());
}
/**
* 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("NetworkInterface").add("Ipv6Addresses", hasIpv6Addresses() ? ipv6Addresses() : null)
.add("NetworkInterfaceId", networkInterfaceId()).add("PrivateDnsName", privateDnsName())
.add("PrivateIpAddress", privateIpAddress())
.add("PrivateIpAddresses", hasPrivateIpAddresses() ? privateIpAddresses() : null)
.add("PublicDnsName", publicDnsName()).add("PublicIp", publicIp())
.add("SecurityGroups", hasSecurityGroups() ? securityGroups() : null).add("SubnetId", subnetId())
.add("VpcId", vpcId()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Ipv6Addresses":
return Optional.ofNullable(clazz.cast(ipv6Addresses()));
case "NetworkInterfaceId":
return Optional.ofNullable(clazz.cast(networkInterfaceId()));
case "PrivateDnsName":
return Optional.ofNullable(clazz.cast(privateDnsName()));
case "PrivateIpAddress":
return Optional.ofNullable(clazz.cast(privateIpAddress()));
case "PrivateIpAddresses":
return Optional.ofNullable(clazz.cast(privateIpAddresses()));
case "PublicDnsName":
return Optional.ofNullable(clazz.cast(publicDnsName()));
case "PublicIp":
return Optional.ofNullable(clazz.cast(publicIp()));
case "SecurityGroups":
return Optional.ofNullable(clazz.cast(securityGroups()));
case "SubnetId":
return Optional.ofNullable(clazz.cast(subnetId()));
case "VpcId":
return Optional.ofNullable(clazz.cast(vpcId()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function