software.amazon.awssdk.services.inspector.model.AssetAttributes Maven / Gradle / Ivy
Show all versions of inspector 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.inspector.model;
import java.io.Serializable;
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;
/**
*
* A collection of attributes of the host from which the finding is generated.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AssetAttributes implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField SCHEMA_VERSION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("schemaVersion").getter(getter(AssetAttributes::schemaVersion)).setter(setter(Builder::schemaVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("schemaVersion").build()).build();
private static final SdkField AGENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("agentId").getter(getter(AssetAttributes::agentId)).setter(setter(Builder::agentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("agentId").build()).build();
private static final SdkField AUTO_SCALING_GROUP_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("autoScalingGroup").getter(getter(AssetAttributes::autoScalingGroup))
.setter(setter(Builder::autoScalingGroup))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("autoScalingGroup").build()).build();
private static final SdkField AMI_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("amiId")
.getter(getter(AssetAttributes::amiId)).setter(setter(Builder::amiId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("amiId").build()).build();
private static final SdkField HOSTNAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("hostname").getter(getter(AssetAttributes::hostname)).setter(setter(Builder::hostname))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("hostname").build()).build();
private static final SdkField> IPV4_ADDRESSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ipv4Addresses")
.getter(getter(AssetAttributes::ipv4Addresses))
.setter(setter(Builder::ipv4Addresses))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ipv4Addresses").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> TAGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("tags")
.getter(getter(AssetAttributes::tags))
.setter(setter(Builder::tags))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("tags").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Tag::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> NETWORK_INTERFACES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("networkInterfaces")
.getter(getter(AssetAttributes::networkInterfaces))
.setter(setter(Builder::networkInterfaces))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("networkInterfaces").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(NetworkInterface::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SCHEMA_VERSION_FIELD,
AGENT_ID_FIELD, AUTO_SCALING_GROUP_FIELD, AMI_ID_FIELD, HOSTNAME_FIELD, IPV4_ADDRESSES_FIELD, TAGS_FIELD,
NETWORK_INTERFACES_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("schemaVersion", SCHEMA_VERSION_FIELD);
put("agentId", AGENT_ID_FIELD);
put("autoScalingGroup", AUTO_SCALING_GROUP_FIELD);
put("amiId", AMI_ID_FIELD);
put("hostname", HOSTNAME_FIELD);
put("ipv4Addresses", IPV4_ADDRESSES_FIELD);
put("tags", TAGS_FIELD);
put("networkInterfaces", NETWORK_INTERFACES_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final Integer schemaVersion;
private final String agentId;
private final String autoScalingGroup;
private final String amiId;
private final String hostname;
private final List ipv4Addresses;
private final List tags;
private final List networkInterfaces;
private AssetAttributes(BuilderImpl builder) {
this.schemaVersion = builder.schemaVersion;
this.agentId = builder.agentId;
this.autoScalingGroup = builder.autoScalingGroup;
this.amiId = builder.amiId;
this.hostname = builder.hostname;
this.ipv4Addresses = builder.ipv4Addresses;
this.tags = builder.tags;
this.networkInterfaces = builder.networkInterfaces;
}
/**
*
* The schema version of this data type.
*
*
* @return The schema version of this data type.
*/
public final Integer schemaVersion() {
return schemaVersion;
}
/**
*
* The ID of the agent that is installed on the EC2 instance where the finding is generated.
*
*
* @return The ID of the agent that is installed on the EC2 instance where the finding is generated.
*/
public final String agentId() {
return agentId;
}
/**
*
* The Auto Scaling group of the EC2 instance where the finding is generated.
*
*
* @return The Auto Scaling group of the EC2 instance where the finding is generated.
*/
public final String autoScalingGroup() {
return autoScalingGroup;
}
/**
*
* The ID of the Amazon Machine Image (AMI) that is installed on the EC2 instance where the finding is generated.
*
*
* @return The ID of the Amazon Machine Image (AMI) that is installed on the EC2 instance where the finding is
* generated.
*/
public final String amiId() {
return amiId;
}
/**
*
* The hostname of the EC2 instance where the finding is generated.
*
*
* @return The hostname of the EC2 instance where the finding is generated.
*/
public final String hostname() {
return hostname;
}
/**
* For responses, this returns true if the service returned a value for the Ipv4Addresses 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 hasIpv4Addresses() {
return ipv4Addresses != null && !(ipv4Addresses instanceof SdkAutoConstructList);
}
/**
*
* The list of IP v4 addresses of the EC2 instance where the finding is generated.
*
*
* 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 #hasIpv4Addresses} method.
*
*
* @return The list of IP v4 addresses of the EC2 instance where the finding is generated.
*/
public final List ipv4Addresses() {
return ipv4Addresses;
}
/**
* 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 related to the EC2 instance where the finding is generated.
*
*
* 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 related to the EC2 instance where the finding is generated.
*/
public final List tags() {
return tags;
}
/**
* For responses, this returns true if the service returned a value for the NetworkInterfaces 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 hasNetworkInterfaces() {
return networkInterfaces != null && !(networkInterfaces instanceof SdkAutoConstructList);
}
/**
*
* An array of the network interfaces interacting with the EC2 instance where the finding is generated.
*
*
* 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 #hasNetworkInterfaces} method.
*
*
* @return An array of the network interfaces interacting with the EC2 instance where the finding is generated.
*/
public final List networkInterfaces() {
return networkInterfaces;
}
@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(schemaVersion());
hashCode = 31 * hashCode + Objects.hashCode(agentId());
hashCode = 31 * hashCode + Objects.hashCode(autoScalingGroup());
hashCode = 31 * hashCode + Objects.hashCode(amiId());
hashCode = 31 * hashCode + Objects.hashCode(hostname());
hashCode = 31 * hashCode + Objects.hashCode(hasIpv4Addresses() ? ipv4Addresses() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasNetworkInterfaces() ? networkInterfaces() : 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 AssetAttributes)) {
return false;
}
AssetAttributes other = (AssetAttributes) obj;
return Objects.equals(schemaVersion(), other.schemaVersion()) && Objects.equals(agentId(), other.agentId())
&& Objects.equals(autoScalingGroup(), other.autoScalingGroup()) && Objects.equals(amiId(), other.amiId())
&& Objects.equals(hostname(), other.hostname()) && hasIpv4Addresses() == other.hasIpv4Addresses()
&& Objects.equals(ipv4Addresses(), other.ipv4Addresses()) && hasTags() == other.hasTags()
&& Objects.equals(tags(), other.tags()) && hasNetworkInterfaces() == other.hasNetworkInterfaces()
&& Objects.equals(networkInterfaces(), other.networkInterfaces());
}
/**
* 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("AssetAttributes").add("SchemaVersion", schemaVersion()).add("AgentId", agentId())
.add("AutoScalingGroup", autoScalingGroup()).add("AmiId", amiId()).add("Hostname", hostname())
.add("Ipv4Addresses", hasIpv4Addresses() ? ipv4Addresses() : null).add("Tags", hasTags() ? tags() : null)
.add("NetworkInterfaces", hasNetworkInterfaces() ? networkInterfaces() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "schemaVersion":
return Optional.ofNullable(clazz.cast(schemaVersion()));
case "agentId":
return Optional.ofNullable(clazz.cast(agentId()));
case "autoScalingGroup":
return Optional.ofNullable(clazz.cast(autoScalingGroup()));
case "amiId":
return Optional.ofNullable(clazz.cast(amiId()));
case "hostname":
return Optional.ofNullable(clazz.cast(hostname()));
case "ipv4Addresses":
return Optional.ofNullable(clazz.cast(ipv4Addresses()));
case "tags":
return Optional.ofNullable(clazz.cast(tags()));
case "networkInterfaces":
return Optional.ofNullable(clazz.cast(networkInterfaces()));
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