
software.amazon.awssdk.services.securityhub.model.StandardsControl 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.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.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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.TimestampFormatTrait;
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;
/**
*
* Details for an individual security standard control.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class StandardsControl implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField STANDARDS_CONTROL_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StandardsControlArn").getter(getter(StandardsControl::standardsControlArn))
.setter(setter(Builder::standardsControlArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StandardsControlArn").build())
.build();
private static final SdkField CONTROL_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ControlStatus").getter(getter(StandardsControl::controlStatusAsString))
.setter(setter(Builder::controlStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ControlStatus").build()).build();
private static final SdkField DISABLED_REASON_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DisabledReason").getter(getter(StandardsControl::disabledReason))
.setter(setter(Builder::disabledReason))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DisabledReason").build()).build();
private static final SdkField CONTROL_STATUS_UPDATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("ControlStatusUpdatedAt")
.getter(getter(StandardsControl::controlStatusUpdatedAt))
.setter(setter(Builder::controlStatusUpdatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ControlStatusUpdatedAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField CONTROL_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ControlId").getter(getter(StandardsControl::controlId)).setter(setter(Builder::controlId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ControlId").build()).build();
private static final SdkField TITLE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Title")
.getter(getter(StandardsControl::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(StandardsControl::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField REMEDIATION_URL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RemediationUrl").getter(getter(StandardsControl::remediationUrl))
.setter(setter(Builder::remediationUrl))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RemediationUrl").build()).build();
private static final SdkField SEVERITY_RATING_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SeverityRating").getter(getter(StandardsControl::severityRatingAsString))
.setter(setter(Builder::severityRating))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SeverityRating").build()).build();
private static final SdkField> RELATED_REQUIREMENTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RelatedRequirements")
.getter(getter(StandardsControl::relatedRequirements))
.setter(setter(Builder::relatedRequirements))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RelatedRequirements").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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STANDARDS_CONTROL_ARN_FIELD,
CONTROL_STATUS_FIELD, DISABLED_REASON_FIELD, CONTROL_STATUS_UPDATED_AT_FIELD, CONTROL_ID_FIELD, TITLE_FIELD,
DESCRIPTION_FIELD, REMEDIATION_URL_FIELD, SEVERITY_RATING_FIELD, RELATED_REQUIREMENTS_FIELD));
private static final long serialVersionUID = 1L;
private final String standardsControlArn;
private final String controlStatus;
private final String disabledReason;
private final Instant controlStatusUpdatedAt;
private final String controlId;
private final String title;
private final String description;
private final String remediationUrl;
private final String severityRating;
private final List relatedRequirements;
private StandardsControl(BuilderImpl builder) {
this.standardsControlArn = builder.standardsControlArn;
this.controlStatus = builder.controlStatus;
this.disabledReason = builder.disabledReason;
this.controlStatusUpdatedAt = builder.controlStatusUpdatedAt;
this.controlId = builder.controlId;
this.title = builder.title;
this.description = builder.description;
this.remediationUrl = builder.remediationUrl;
this.severityRating = builder.severityRating;
this.relatedRequirements = builder.relatedRequirements;
}
/**
*
* The ARN of the security standard control.
*
*
* @return The ARN of the security standard control.
*/
public final String standardsControlArn() {
return standardsControlArn;
}
/**
*
* The current status of the security standard control. Indicates whether the control is enabled or disabled.
* Security Hub does not check against disabled controls.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #controlStatus}
* will return {@link ControlStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #controlStatusAsString}.
*
*
* @return The current status of the security standard control. Indicates whether the control is enabled or
* disabled. Security Hub does not check against disabled controls.
* @see ControlStatus
*/
public final ControlStatus controlStatus() {
return ControlStatus.fromValue(controlStatus);
}
/**
*
* The current status of the security standard control. Indicates whether the control is enabled or disabled.
* Security Hub does not check against disabled controls.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #controlStatus}
* will return {@link ControlStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #controlStatusAsString}.
*
*
* @return The current status of the security standard control. Indicates whether the control is enabled or
* disabled. Security Hub does not check against disabled controls.
* @see ControlStatus
*/
public final String controlStatusAsString() {
return controlStatus;
}
/**
*
* The reason provided for the most recent change in status for the control.
*
*
* @return The reason provided for the most recent change in status for the control.
*/
public final String disabledReason() {
return disabledReason;
}
/**
*
* The date and time that the status of the security standard control was most recently updated.
*
*
* @return The date and time that the status of the security standard control was most recently updated.
*/
public final Instant controlStatusUpdatedAt() {
return controlStatusUpdatedAt;
}
/**
*
* The identifier of the security standard control.
*
*
* @return The identifier of the security standard control.
*/
public final String controlId() {
return controlId;
}
/**
*
* The title of the security standard control.
*
*
* @return The title of the security standard control.
*/
public final String title() {
return title;
}
/**
*
* The longer description of the security standard control. Provides information about what the control is checking
* for.
*
*
* @return The longer description of the security standard control. Provides information about what the control is
* checking for.
*/
public final String description() {
return description;
}
/**
*
* A link to remediation information for the control in the Security Hub user documentation.
*
*
* @return A link to remediation information for the control in the Security Hub user documentation.
*/
public final String remediationUrl() {
return remediationUrl;
}
/**
*
* The severity of findings generated from this security standard control.
*
*
* The finding severity is based on an assessment of how easy it would be to compromise Amazon Web Services
* resources if the issue is detected.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severityRating}
* will return {@link SeverityRating#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #severityRatingAsString}.
*
*
* @return The severity of findings generated from this security standard control.
*
* The finding severity is based on an assessment of how easy it would be to compromise Amazon Web Services
* resources if the issue is detected.
* @see SeverityRating
*/
public final SeverityRating severityRating() {
return SeverityRating.fromValue(severityRating);
}
/**
*
* The severity of findings generated from this security standard control.
*
*
* The finding severity is based on an assessment of how easy it would be to compromise Amazon Web Services
* resources if the issue is detected.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #severityRating}
* will return {@link SeverityRating#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #severityRatingAsString}.
*
*
* @return The severity of findings generated from this security standard control.
*
* The finding severity is based on an assessment of how easy it would be to compromise Amazon Web Services
* resources if the issue is detected.
* @see SeverityRating
*/
public final String severityRatingAsString() {
return severityRating;
}
/**
* For responses, this returns true if the service returned a value for the RelatedRequirements 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 hasRelatedRequirements() {
return relatedRequirements != null && !(relatedRequirements instanceof SdkAutoConstructList);
}
/**
*
* The list of requirements that are related to this control.
*
*
* 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 #hasRelatedRequirements} method.
*
*
* @return The list of requirements that are related to this control.
*/
public final List relatedRequirements() {
return relatedRequirements;
}
@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(standardsControlArn());
hashCode = 31 * hashCode + Objects.hashCode(controlStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(disabledReason());
hashCode = 31 * hashCode + Objects.hashCode(controlStatusUpdatedAt());
hashCode = 31 * hashCode + Objects.hashCode(controlId());
hashCode = 31 * hashCode + Objects.hashCode(title());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(remediationUrl());
hashCode = 31 * hashCode + Objects.hashCode(severityRatingAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasRelatedRequirements() ? relatedRequirements() : 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 StandardsControl)) {
return false;
}
StandardsControl other = (StandardsControl) obj;
return Objects.equals(standardsControlArn(), other.standardsControlArn())
&& Objects.equals(controlStatusAsString(), other.controlStatusAsString())
&& Objects.equals(disabledReason(), other.disabledReason())
&& Objects.equals(controlStatusUpdatedAt(), other.controlStatusUpdatedAt())
&& Objects.equals(controlId(), other.controlId()) && Objects.equals(title(), other.title())
&& Objects.equals(description(), other.description()) && Objects.equals(remediationUrl(), other.remediationUrl())
&& Objects.equals(severityRatingAsString(), other.severityRatingAsString())
&& hasRelatedRequirements() == other.hasRelatedRequirements()
&& Objects.equals(relatedRequirements(), other.relatedRequirements());
}
/**
* 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("StandardsControl").add("StandardsControlArn", standardsControlArn())
.add("ControlStatus", controlStatusAsString()).add("DisabledReason", disabledReason())
.add("ControlStatusUpdatedAt", controlStatusUpdatedAt()).add("ControlId", controlId()).add("Title", title())
.add("Description", description()).add("RemediationUrl", remediationUrl())
.add("SeverityRating", severityRatingAsString())
.add("RelatedRequirements", hasRelatedRequirements() ? relatedRequirements() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "StandardsControlArn":
return Optional.ofNullable(clazz.cast(standardsControlArn()));
case "ControlStatus":
return Optional.ofNullable(clazz.cast(controlStatusAsString()));
case "DisabledReason":
return Optional.ofNullable(clazz.cast(disabledReason()));
case "ControlStatusUpdatedAt":
return Optional.ofNullable(clazz.cast(controlStatusUpdatedAt()));
case "ControlId":
return Optional.ofNullable(clazz.cast(controlId()));
case "Title":
return Optional.ofNullable(clazz.cast(title()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "RemediationUrl":
return Optional.ofNullable(clazz.cast(remediationUrl()));
case "SeverityRating":
return Optional.ofNullable(clazz.cast(severityRatingAsString()));
case "RelatedRequirements":
return Optional.ofNullable(clazz.cast(relatedRequirements()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function