software.amazon.awssdk.services.securityhub.model.Severity 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.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The severity of the finding.
*
*
* The finding provider can provide the initial severity. The finding provider can only update the severity if it hasn't
* been updated using BatchUpdateFindings.
*
*
* The finding must have either Label or Normalized populated. If only one of these attributes
* is populated, then Security Hub automatically populates the other one. If neither attribute is populated, then the
* finding is invalid. Label is the preferred attribute.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Severity implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField PRODUCT_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("Product")
.getter(getter(Severity::product)).setter(setter(Builder::product))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Product").build()).build();
private static final SdkField LABEL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Label")
.getter(getter(Severity::labelAsString)).setter(setter(Builder::label))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Label").build()).build();
private static final SdkField NORMALIZED_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Normalized").getter(getter(Severity::normalized)).setter(setter(Builder::normalized))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Normalized").build()).build();
private static final SdkField ORIGINAL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Original").getter(getter(Severity::original)).setter(setter(Builder::original))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Original").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PRODUCT_FIELD, LABEL_FIELD,
NORMALIZED_FIELD, ORIGINAL_FIELD));
private static final long serialVersionUID = 1L;
private final Double product;
private final String label;
private final Integer normalized;
private final String original;
private Severity(BuilderImpl builder) {
this.product = builder.product;
this.label = builder.label;
this.normalized = builder.normalized;
this.original = builder.original;
}
/**
*
* Deprecated. This attribute isn't included in findings. Instead of providing Product, provide
* Original.
*
*
* The native severity as defined by the Amazon Web Services service or integrated partner product that generated
* the finding.
*
*
* @return Deprecated. This attribute isn't included in findings. Instead of providing Product, provide
* Original.
*
* The native severity as defined by the Amazon Web Services service or integrated partner product that
* generated the finding.
*/
public final Double product() {
return product;
}
/**
*
* The severity value of the finding. The allowed values are the following.
*
*
* -
*
* INFORMATIONAL - No issue was found.
*
*
* -
*
* LOW - The issue does not require action on its own.
*
*
* -
*
* MEDIUM - The issue must be addressed but not urgently.
*
*
* -
*
* HIGH - The issue must be addressed as a priority.
*
*
* -
*
* CRITICAL - The issue must be remediated immediately to avoid it escalating.
*
*
*
*
* If you provide Normalized and do not provide Label, then Label is set
* automatically as follows.
*
*
* -
*
* 0 - INFORMATIONAL
*
*
* -
*
* 1–39 - LOW
*
*
* -
*
* 40–69 - MEDIUM
*
*
* -
*
* 70–89 - HIGH
*
*
* -
*
* 90–100 - CRITICAL
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #label} will return
* {@link SeverityLabel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #labelAsString}.
*
*
* @return The severity value of the finding. The allowed values are the following.
*
* -
*
* INFORMATIONAL - No issue was found.
*
*
* -
*
* LOW - The issue does not require action on its own.
*
*
* -
*
* MEDIUM - The issue must be addressed but not urgently.
*
*
* -
*
* HIGH - The issue must be addressed as a priority.
*
*
* -
*
* CRITICAL - The issue must be remediated immediately to avoid it escalating.
*
*
*
*
* If you provide Normalized and do not provide Label, then Label is
* set automatically as follows.
*
*
* -
*
* 0 - INFORMATIONAL
*
*
* -
*
* 1–39 - LOW
*
*
* -
*
* 40–69 - MEDIUM
*
*
* -
*
* 70–89 - HIGH
*
*
* -
*
* 90–100 - CRITICAL
*
*
* @see SeverityLabel
*/
public final SeverityLabel label() {
return SeverityLabel.fromValue(label);
}
/**
*
* The severity value of the finding. The allowed values are the following.
*
*
* -
*
* INFORMATIONAL - No issue was found.
*
*
* -
*
* LOW - The issue does not require action on its own.
*
*
* -
*
* MEDIUM - The issue must be addressed but not urgently.
*
*
* -
*
* HIGH - The issue must be addressed as a priority.
*
*
* -
*
* CRITICAL - The issue must be remediated immediately to avoid it escalating.
*
*
*
*
* If you provide Normalized and do not provide Label, then Label is set
* automatically as follows.
*
*
* -
*
* 0 - INFORMATIONAL
*
*
* -
*
* 1–39 - LOW
*
*
* -
*
* 40–69 - MEDIUM
*
*
* -
*
* 70–89 - HIGH
*
*
* -
*
* 90–100 - CRITICAL
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #label} will return
* {@link SeverityLabel#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #labelAsString}.
*
*
* @return The severity value of the finding. The allowed values are the following.
*
* -
*
* INFORMATIONAL - No issue was found.
*
*
* -
*
* LOW - The issue does not require action on its own.
*
*
* -
*
* MEDIUM - The issue must be addressed but not urgently.
*
*
* -
*
* HIGH - The issue must be addressed as a priority.
*
*
* -
*
* CRITICAL - The issue must be remediated immediately to avoid it escalating.
*
*
*
*
* If you provide Normalized and do not provide Label, then Label is
* set automatically as follows.
*
*
* -
*
* 0 - INFORMATIONAL
*
*
* -
*
* 1–39 - LOW
*
*
* -
*
* 40–69 - MEDIUM
*
*
* -
*
* 70–89 - HIGH
*
*
* -
*
* 90–100 - CRITICAL
*
*
* @see SeverityLabel
*/
public final String labelAsString() {
return label;
}
/**
*
* Deprecated. The normalized severity of a finding. Instead of providing Normalized, provide
* Label.
*
*
* If you provide Label and do not provide Normalized, then Normalized is set
* automatically as follows.
*
*
* -
*
* INFORMATIONAL - 0
*
*
* -
*
* LOW - 1
*
*
* -
*
* MEDIUM - 40
*
*
* -
*
* HIGH - 70
*
*
* -
*
* CRITICAL - 90
*
*
*
*
* @return Deprecated. The normalized severity of a finding. Instead of providing Normalized, provide
* Label.
*
* If you provide Label and do not provide Normalized, then
* Normalized is set automatically as follows.
*
*
* -
*
* INFORMATIONAL - 0
*
*
* -
*
* LOW - 1
*
*
* -
*
* MEDIUM - 40
*
*
* -
*
* HIGH - 70
*
*
* -
*
* CRITICAL - 90
*
*
*/
public final Integer normalized() {
return normalized;
}
/**
*
* The native severity from the finding product that generated the finding.
*
*
* @return The native severity from the finding product that generated the finding.
*/
public final String original() {
return original;
}
@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(product());
hashCode = 31 * hashCode + Objects.hashCode(labelAsString());
hashCode = 31 * hashCode + Objects.hashCode(normalized());
hashCode = 31 * hashCode + Objects.hashCode(original());
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 Severity)) {
return false;
}
Severity other = (Severity) obj;
return Objects.equals(product(), other.product()) && Objects.equals(labelAsString(), other.labelAsString())
&& Objects.equals(normalized(), other.normalized()) && Objects.equals(original(), other.original());
}
/**
* 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("Severity").add("Product", product()).add("Label", labelAsString())
.add("Normalized", normalized()).add("Original", original()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Product":
return Optional.ofNullable(clazz.cast(product()));
case "Label":
return Optional.ofNullable(clazz.cast(labelAsString()));
case "Normalized":
return Optional.ofNullable(clazz.cast(normalized()));
case "Original":
return Optional.ofNullable(clazz.cast(original()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function