All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.inspector.model.AssetAttributes Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon Inspector Service module holds the client classes that are used for communicating with Amazon Inspector Service

There is a newer version: 2.29.39
Show newest version
/*
 * 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 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 getter(Function g) { return obj -> g.apply((AssetAttributes) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The schema version of this data type. *

* * @param schemaVersion * The schema version of this data type. * @return Returns a reference to this object so that method calls can be chained together. */ Builder schemaVersion(Integer schemaVersion); /** *

* The ID of the agent that is installed on the EC2 instance where the finding is generated. *

* * @param agentId * The ID of the agent that is installed on the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder agentId(String agentId); /** *

* The Auto Scaling group of the EC2 instance where the finding is generated. *

* * @param autoScalingGroup * The Auto Scaling group of the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder autoScalingGroup(String autoScalingGroup); /** *

* The ID of the Amazon Machine Image (AMI) that is installed on the EC2 instance where the finding is * generated. *

* * @param amiId * The ID of the Amazon Machine Image (AMI) that is installed on the EC2 instance where the finding is * generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder amiId(String amiId); /** *

* The hostname of the EC2 instance where the finding is generated. *

* * @param hostname * The hostname of the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder hostname(String hostname); /** *

* The list of IP v4 addresses of the EC2 instance where the finding is generated. *

* * @param ipv4Addresses * The list of IP v4 addresses of the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ipv4Addresses(Collection ipv4Addresses); /** *

* The list of IP v4 addresses of the EC2 instance where the finding is generated. *

* * @param ipv4Addresses * The list of IP v4 addresses of the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ipv4Addresses(String... ipv4Addresses); /** *

* The tags related to the EC2 instance where the finding is generated. *

* * @param tags * The tags related to the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Collection tags); /** *

* The tags related to the EC2 instance where the finding is generated. *

* * @param tags * The tags related to the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

* The tags related to the EC2 instance where the finding is generated. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.inspector.model.Tag.Builder} avoiding the need to create one manually * via {@link software.amazon.awssdk.services.inspector.model.Tag#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.inspector.model.Tag.Builder#build()} is called immediately and its * result is passed to {@link #tags(List)}. * * @param tags * a consumer that will call methods on * {@link software.amazon.awssdk.services.inspector.model.Tag.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tags(java.util.Collection) */ Builder tags(Consumer... tags); /** *

* An array of the network interfaces interacting with the EC2 instance where the finding is generated. *

* * @param networkInterfaces * An array of the network interfaces interacting with the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder networkInterfaces(Collection networkInterfaces); /** *

* An array of the network interfaces interacting with the EC2 instance where the finding is generated. *

* * @param networkInterfaces * An array of the network interfaces interacting with the EC2 instance where the finding is generated. * @return Returns a reference to this object so that method calls can be chained together. */ Builder networkInterfaces(NetworkInterface... networkInterfaces); /** *

* An array of the network interfaces interacting with the EC2 instance where the finding is generated. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.inspector.model.NetworkInterface.Builder} avoiding the need to create * one manually via {@link software.amazon.awssdk.services.inspector.model.NetworkInterface#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.inspector.model.NetworkInterface.Builder#build()} is called * immediately and its result is passed to {@link #networkInterfaces(List)}. * * @param networkInterfaces * a consumer that will call methods on * {@link software.amazon.awssdk.services.inspector.model.NetworkInterface.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #networkInterfaces(java.util.Collection) */ Builder networkInterfaces(Consumer... networkInterfaces); } static final class BuilderImpl implements Builder { private Integer schemaVersion; private String agentId; private String autoScalingGroup; private String amiId; private String hostname; private List ipv4Addresses = DefaultSdkAutoConstructList.getInstance(); private List tags = DefaultSdkAutoConstructList.getInstance(); private List networkInterfaces = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(AssetAttributes model) { schemaVersion(model.schemaVersion); agentId(model.agentId); autoScalingGroup(model.autoScalingGroup); amiId(model.amiId); hostname(model.hostname); ipv4Addresses(model.ipv4Addresses); tags(model.tags); networkInterfaces(model.networkInterfaces); } public final Integer getSchemaVersion() { return schemaVersion; } public final void setSchemaVersion(Integer schemaVersion) { this.schemaVersion = schemaVersion; } @Override public final Builder schemaVersion(Integer schemaVersion) { this.schemaVersion = schemaVersion; return this; } public final String getAgentId() { return agentId; } public final void setAgentId(String agentId) { this.agentId = agentId; } @Override public final Builder agentId(String agentId) { this.agentId = agentId; return this; } public final String getAutoScalingGroup() { return autoScalingGroup; } public final void setAutoScalingGroup(String autoScalingGroup) { this.autoScalingGroup = autoScalingGroup; } @Override public final Builder autoScalingGroup(String autoScalingGroup) { this.autoScalingGroup = autoScalingGroup; return this; } public final String getAmiId() { return amiId; } public final void setAmiId(String amiId) { this.amiId = amiId; } @Override public final Builder amiId(String amiId) { this.amiId = amiId; return this; } public final String getHostname() { return hostname; } public final void setHostname(String hostname) { this.hostname = hostname; } @Override public final Builder hostname(String hostname) { this.hostname = hostname; return this; } public final Collection getIpv4Addresses() { if (ipv4Addresses instanceof SdkAutoConstructList) { return null; } return ipv4Addresses; } public final void setIpv4Addresses(Collection ipv4Addresses) { this.ipv4Addresses = Ipv4AddressListCopier.copy(ipv4Addresses); } @Override public final Builder ipv4Addresses(Collection ipv4Addresses) { this.ipv4Addresses = Ipv4AddressListCopier.copy(ipv4Addresses); return this; } @Override @SafeVarargs public final Builder ipv4Addresses(String... ipv4Addresses) { ipv4Addresses(Arrays.asList(ipv4Addresses)); return this; } public final List getTags() { List result = TagsCopier.copyToBuilder(this.tags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTags(Collection tags) { this.tags = TagsCopier.copyFromBuilder(tags); } @Override public final Builder tags(Collection tags) { this.tags = TagsCopier.copy(tags); return this; } @Override @SafeVarargs public final Builder tags(Tag... tags) { tags(Arrays.asList(tags)); return this; } @Override @SafeVarargs public final Builder tags(Consumer... tags) { tags(Stream.of(tags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final List getNetworkInterfaces() { List result = NetworkInterfacesCopier.copyToBuilder(this.networkInterfaces); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setNetworkInterfaces(Collection networkInterfaces) { this.networkInterfaces = NetworkInterfacesCopier.copyFromBuilder(networkInterfaces); } @Override public final Builder networkInterfaces(Collection networkInterfaces) { this.networkInterfaces = NetworkInterfacesCopier.copy(networkInterfaces); return this; } @Override @SafeVarargs public final Builder networkInterfaces(NetworkInterface... networkInterfaces) { networkInterfaces(Arrays.asList(networkInterfaces)); return this; } @Override @SafeVarargs public final Builder networkInterfaces(Consumer... networkInterfaces) { networkInterfaces(Stream.of(networkInterfaces).map(c -> NetworkInterface.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public AssetAttributes build() { return new AssetAttributes(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy