
software.amazon.awssdk.services.inspector.model.Finding 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.inspector.model;
import java.io.Serializable;
import java.time.Instant;
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 an Amazon Inspector finding. This data type is used as the response element in the
* DescribeFindings action.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Finding implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("arn")
.getter(getter(Finding::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField SCHEMA_VERSION_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("schemaVersion").getter(getter(Finding::schemaVersion)).setter(setter(Builder::schemaVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("schemaVersion").build()).build();
private static final SdkField SERVICE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("service")
.getter(getter(Finding::service)).setter(setter(Builder::service))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("service").build()).build();
private static final SdkField SERVICE_ATTRIBUTES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("serviceAttributes")
.getter(getter(Finding::serviceAttributes)).setter(setter(Builder::serviceAttributes))
.constructor(InspectorServiceAttributes::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("serviceAttributes").build()).build();
private static final SdkField ASSET_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("assetType").getter(getter(Finding::assetTypeAsString)).setter(setter(Builder::assetType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("assetType").build()).build();
private static final SdkField ASSET_ATTRIBUTES_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("assetAttributes")
.getter(getter(Finding::assetAttributes)).setter(setter(Builder::assetAttributes))
.constructor(AssetAttributes::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("assetAttributes").build()).build();
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(Finding::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build();
private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("title")
.getter(getter(Finding::title)).setter(setter(Builder::title))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("title").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(Finding::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField RECOMMENDATION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("recommendation").getter(getter(Finding::recommendation)).setter(setter(Builder::recommendation))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("recommendation").build()).build();
private static final SdkField SEVERITY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("severity").getter(getter(Finding::severityAsString)).setter(setter(Builder::severity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("severity").build()).build();
private static final SdkField NUMERIC_SEVERITY_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("numericSeverity").getter(getter(Finding::numericSeverity)).setter(setter(Builder::numericSeverity))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("numericSeverity").build()).build();
private static final SdkField CONFIDENCE_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("confidence").getter(getter(Finding::confidence)).setter(setter(Builder::confidence))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("confidence").build()).build();
private static final SdkField INDICATOR_OF_COMPROMISE_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("indicatorOfCompromise").getter(getter(Finding::indicatorOfCompromise))
.setter(setter(Builder::indicatorOfCompromise))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("indicatorOfCompromise").build())
.build();
private static final SdkField> ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("attributes")
.getter(getter(Finding::attributes))
.setter(setter(Builder::attributes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("attributes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Attribute::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> USER_ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("userAttributes")
.getter(getter(Finding::userAttributes))
.setter(setter(Builder::userAttributes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("userAttributes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Attribute::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CREATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("createdAt").getter(getter(Finding::createdAt)).setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdAt").build()).build();
private static final SdkField UPDATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("updatedAt").getter(getter(Finding::updatedAt)).setter(setter(Builder::updatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("updatedAt").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARN_FIELD,
SCHEMA_VERSION_FIELD, SERVICE_FIELD, SERVICE_ATTRIBUTES_FIELD, ASSET_TYPE_FIELD, ASSET_ATTRIBUTES_FIELD, ID_FIELD,
TITLE_FIELD, DESCRIPTION_FIELD, RECOMMENDATION_FIELD, SEVERITY_FIELD, NUMERIC_SEVERITY_FIELD, CONFIDENCE_FIELD,
INDICATOR_OF_COMPROMISE_FIELD, ATTRIBUTES_FIELD, USER_ATTRIBUTES_FIELD, CREATED_AT_FIELD, UPDATED_AT_FIELD));
private static final long serialVersionUID = 1L;
private final String arn;
private final Integer schemaVersion;
private final String service;
private final InspectorServiceAttributes serviceAttributes;
private final String assetType;
private final AssetAttributes assetAttributes;
private final String id;
private final String title;
private final String description;
private final String recommendation;
private final String severity;
private final Double numericSeverity;
private final Integer confidence;
private final Boolean indicatorOfCompromise;
private final List attributes;
private final List userAttributes;
private final Instant createdAt;
private final Instant updatedAt;
private Finding(BuilderImpl builder) {
this.arn = builder.arn;
this.schemaVersion = builder.schemaVersion;
this.service = builder.service;
this.serviceAttributes = builder.serviceAttributes;
this.assetType = builder.assetType;
this.assetAttributes = builder.assetAttributes;
this.id = builder.id;
this.title = builder.title;
this.description = builder.description;
this.recommendation = builder.recommendation;
this.severity = builder.severity;
this.numericSeverity = builder.numericSeverity;
this.confidence = builder.confidence;
this.indicatorOfCompromise = builder.indicatorOfCompromise;
this.attributes = builder.attributes;
this.userAttributes = builder.userAttributes;
this.createdAt = builder.createdAt;
this.updatedAt = builder.updatedAt;
}
/**
*
* The ARN that specifies the finding.
*
*
* @return The ARN that specifies the finding.
*/
public final String arn() {
return arn;
}
/**
*
* The schema version of this data type.
*
*
* @return The schema version of this data type.
*/
public final Integer schemaVersion() {
return schemaVersion;
}
/**
*
* The data element is set to "Inspector".
*
*
* @return The data element is set to "Inspector".
*/
public final String service() {
return service;
}
/**
*
* This data type is used in the Finding data type.
*
*
* @return This data type is used in the Finding data type.
*/
public final InspectorServiceAttributes serviceAttributes() {
return serviceAttributes;
}
/**
*
* The type of the host from which the finding is generated.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #assetType} will
* return {@link AssetType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #assetTypeAsString}.
*
*
* @return The type of the host from which the finding is generated.
* @see AssetType
*/
public final AssetType assetType() {
return AssetType.fromValue(assetType);
}
/**
*
* The type of the host from which the finding is generated.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #assetType} will
* return {@link AssetType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #assetTypeAsString}.
*
*
* @return The type of the host from which the finding is generated.
* @see AssetType
*/
public final String assetTypeAsString() {
return assetType;
}
/**
*
* A collection of attributes of the host from which the finding is generated.
*
*
* @return A collection of attributes of the host from which the finding is generated.
*/
public final AssetAttributes assetAttributes() {
return assetAttributes;
}
/**
*
* The ID of the finding.
*
*
* @return The ID of the finding.
*/
public final String id() {
return id;
}
/**
*
* The name of the finding.
*
*
* @return The name of the finding.
*/
public final String title() {
return title;
}
/**
*
* The description of the finding.
*
*
* @return The description of the finding.
*/
public final String description() {
return description;
}
/**
*
* The recommendation for the finding.
*
*
* @return The recommendation for the finding.
*/
public final String recommendation() {
return recommendation;
}
/**
*
* The finding severity. Values can be set to High, Medium, Low, and Informational.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link Severity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The finding severity. Values can be set to High, Medium, Low, and Informational.
* @see Severity
*/
public final Severity severity() {
return Severity.fromValue(severity);
}
/**
*
* The finding severity. Values can be set to High, Medium, Low, and Informational.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severity} will
* return {@link Severity#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #severityAsString}.
*
*
* @return The finding severity. Values can be set to High, Medium, Low, and Informational.
* @see Severity
*/
public final String severityAsString() {
return severity;
}
/**
*
* The numeric value of the finding severity.
*
*
* @return The numeric value of the finding severity.
*/
public final Double numericSeverity() {
return numericSeverity;
}
/**
*
* This data element is currently not used.
*
*
* @return This data element is currently not used.
*/
public final Integer confidence() {
return confidence;
}
/**
*
* This data element is currently not used.
*
*
* @return This data element is currently not used.
*/
public final Boolean indicatorOfCompromise() {
return indicatorOfCompromise;
}
/**
* For responses, this returns true if the service returned a value for the Attributes 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 hasAttributes() {
return attributes != null && !(attributes instanceof SdkAutoConstructList);
}
/**
*
* The system-defined attributes for the finding.
*
*
* 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 #hasAttributes} method.
*
*
* @return The system-defined attributes for the finding.
*/
public final List attributes() {
return attributes;
}
/**
* For responses, this returns true if the service returned a value for the UserAttributes 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 hasUserAttributes() {
return userAttributes != null && !(userAttributes instanceof SdkAutoConstructList);
}
/**
*
* The user-defined attributes that are assigned to the finding.
*
*
* 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 #hasUserAttributes} method.
*
*
* @return The user-defined attributes that are assigned to the finding.
*/
public final List userAttributes() {
return userAttributes;
}
/**
*
* The time when the finding was generated.
*
*
* @return The time when the finding was generated.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* The time when AddAttributesToFindings is called.
*
*
* @return The time when AddAttributesToFindings is called.
*/
public final Instant updatedAt() {
return updatedAt;
}
@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(arn());
hashCode = 31 * hashCode + Objects.hashCode(schemaVersion());
hashCode = 31 * hashCode + Objects.hashCode(service());
hashCode = 31 * hashCode + Objects.hashCode(serviceAttributes());
hashCode = 31 * hashCode + Objects.hashCode(assetTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(assetAttributes());
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(title());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(recommendation());
hashCode = 31 * hashCode + Objects.hashCode(severityAsString());
hashCode = 31 * hashCode + Objects.hashCode(numericSeverity());
hashCode = 31 * hashCode + Objects.hashCode(confidence());
hashCode = 31 * hashCode + Objects.hashCode(indicatorOfCompromise());
hashCode = 31 * hashCode + Objects.hashCode(hasAttributes() ? attributes() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasUserAttributes() ? userAttributes() : null);
hashCode = 31 * hashCode + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(updatedAt());
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 Finding)) {
return false;
}
Finding other = (Finding) obj;
return Objects.equals(arn(), other.arn()) && Objects.equals(schemaVersion(), other.schemaVersion())
&& Objects.equals(service(), other.service()) && Objects.equals(serviceAttributes(), other.serviceAttributes())
&& Objects.equals(assetTypeAsString(), other.assetTypeAsString())
&& Objects.equals(assetAttributes(), other.assetAttributes()) && Objects.equals(id(), other.id())
&& Objects.equals(title(), other.title()) && Objects.equals(description(), other.description())
&& Objects.equals(recommendation(), other.recommendation())
&& Objects.equals(severityAsString(), other.severityAsString())
&& Objects.equals(numericSeverity(), other.numericSeverity()) && Objects.equals(confidence(), other.confidence())
&& Objects.equals(indicatorOfCompromise(), other.indicatorOfCompromise())
&& hasAttributes() == other.hasAttributes() && Objects.equals(attributes(), other.attributes())
&& hasUserAttributes() == other.hasUserAttributes() && Objects.equals(userAttributes(), other.userAttributes())
&& Objects.equals(createdAt(), other.createdAt()) && Objects.equals(updatedAt(), other.updatedAt());
}
/**
* 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("Finding").add("Arn", arn()).add("SchemaVersion", schemaVersion()).add("Service", service())
.add("ServiceAttributes", serviceAttributes()).add("AssetType", assetTypeAsString())
.add("AssetAttributes", assetAttributes()).add("Id", id()).add("Title", title())
.add("Description", description()).add("Recommendation", recommendation()).add("Severity", severityAsString())
.add("NumericSeverity", numericSeverity()).add("Confidence", confidence())
.add("IndicatorOfCompromise", indicatorOfCompromise()).add("Attributes", hasAttributes() ? attributes() : null)
.add("UserAttributes", hasUserAttributes() ? userAttributes() : null).add("CreatedAt", createdAt())
.add("UpdatedAt", updatedAt()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "arn":
return Optional.ofNullable(clazz.cast(arn()));
case "schemaVersion":
return Optional.ofNullable(clazz.cast(schemaVersion()));
case "service":
return Optional.ofNullable(clazz.cast(service()));
case "serviceAttributes":
return Optional.ofNullable(clazz.cast(serviceAttributes()));
case "assetType":
return Optional.ofNullable(clazz.cast(assetTypeAsString()));
case "assetAttributes":
return Optional.ofNullable(clazz.cast(assetAttributes()));
case "id":
return Optional.ofNullable(clazz.cast(id()));
case "title":
return Optional.ofNullable(clazz.cast(title()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "recommendation":
return Optional.ofNullable(clazz.cast(recommendation()));
case "severity":
return Optional.ofNullable(clazz.cast(severityAsString()));
case "numericSeverity":
return Optional.ofNullable(clazz.cast(numericSeverity()));
case "confidence":
return Optional.ofNullable(clazz.cast(confidence()));
case "indicatorOfCompromise":
return Optional.ofNullable(clazz.cast(indicatorOfCompromise()));
case "attributes":
return Optional.ofNullable(clazz.cast(attributes()));
case "userAttributes":
return Optional.ofNullable(clazz.cast(userAttributes()));
case "createdAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "updatedAt":
return Optional.ofNullable(clazz.cast(updatedAt()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function