software.amazon.awssdk.services.securityhub.model.AutomationRulesConfig 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.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.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;
/**
*
* Defines the configuration of an automation rule.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AutomationRulesConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField RULE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RuleArn").getter(getter(AutomationRulesConfig::ruleArn)).setter(setter(Builder::ruleArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleArn").build()).build();
private static final SdkField RULE_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RuleStatus").getter(getter(AutomationRulesConfig::ruleStatusAsString))
.setter(setter(Builder::ruleStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleStatus").build()).build();
private static final SdkField RULE_ORDER_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("RuleOrder").getter(getter(AutomationRulesConfig::ruleOrder)).setter(setter(Builder::ruleOrder))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleOrder").build()).build();
private static final SdkField RULE_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RuleName").getter(getter(AutomationRulesConfig::ruleName)).setter(setter(Builder::ruleName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RuleName").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(AutomationRulesConfig::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField IS_TERMINAL_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("IsTerminal").getter(getter(AutomationRulesConfig::isTerminal)).setter(setter(Builder::isTerminal))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IsTerminal").build()).build();
private static final SdkField CRITERIA_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Criteria")
.getter(getter(AutomationRulesConfig::criteria)).setter(setter(Builder::criteria))
.constructor(AutomationRulesFindingFilters::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Criteria").build()).build();
private static final SdkField> ACTIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Actions")
.getter(getter(AutomationRulesConfig::actions))
.setter(setter(Builder::actions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Actions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(AutomationRulesAction::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(AutomationRulesConfig::createdAt))
.setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField UPDATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("UpdatedAt")
.getter(getter(AutomationRulesConfig::updatedAt))
.setter(setter(Builder::updatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UpdatedAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField CREATED_BY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CreatedBy").getter(getter(AutomationRulesConfig::createdBy)).setter(setter(Builder::createdBy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedBy").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RULE_ARN_FIELD,
RULE_STATUS_FIELD, RULE_ORDER_FIELD, RULE_NAME_FIELD, DESCRIPTION_FIELD, IS_TERMINAL_FIELD, CRITERIA_FIELD,
ACTIONS_FIELD, CREATED_AT_FIELD, UPDATED_AT_FIELD, CREATED_BY_FIELD));
private static final long serialVersionUID = 1L;
private final String ruleArn;
private final String ruleStatus;
private final Integer ruleOrder;
private final String ruleName;
private final String description;
private final Boolean isTerminal;
private final AutomationRulesFindingFilters criteria;
private final List actions;
private final Instant createdAt;
private final Instant updatedAt;
private final String createdBy;
private AutomationRulesConfig(BuilderImpl builder) {
this.ruleArn = builder.ruleArn;
this.ruleStatus = builder.ruleStatus;
this.ruleOrder = builder.ruleOrder;
this.ruleName = builder.ruleName;
this.description = builder.description;
this.isTerminal = builder.isTerminal;
this.criteria = builder.criteria;
this.actions = builder.actions;
this.createdAt = builder.createdAt;
this.updatedAt = builder.updatedAt;
this.createdBy = builder.createdBy;
}
/**
*
* The Amazon Resource Name (ARN) of a rule.
*
*
* @return The Amazon Resource Name (ARN) of a rule.
*/
public final String ruleArn() {
return ruleArn;
}
/**
*
* Whether the rule is active after it is created. If this parameter is equal to ENABLED, Security Hub
* starts applying the rule to findings and finding updates after the rule is created.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #ruleStatus} will
* return {@link RuleStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #ruleStatusAsString}.
*
*
* @return Whether the rule is active after it is created. If this parameter is equal to ENABLED,
* Security Hub starts applying the rule to findings and finding updates after the rule is created.
* @see RuleStatus
*/
public final RuleStatus ruleStatus() {
return RuleStatus.fromValue(ruleStatus);
}
/**
*
* Whether the rule is active after it is created. If this parameter is equal to ENABLED, Security Hub
* starts applying the rule to findings and finding updates after the rule is created.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #ruleStatus} will
* return {@link RuleStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #ruleStatusAsString}.
*
*
* @return Whether the rule is active after it is created. If this parameter is equal to ENABLED,
* Security Hub starts applying the rule to findings and finding updates after the rule is created.
* @see RuleStatus
*/
public final String ruleStatusAsString() {
return ruleStatus;
}
/**
*
* An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings.
* Security Hub applies rules with lower values for this parameter first.
*
*
* @return An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to
* findings. Security Hub applies rules with lower values for this parameter first.
*/
public final Integer ruleOrder() {
return ruleOrder;
}
/**
*
* The name of the rule.
*
*
* @return The name of the rule.
*/
public final String ruleName() {
return ruleName;
}
/**
*
* A description of the rule.
*
*
* @return A description of the rule.
*/
public final String description() {
return description;
}
/**
*
* Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. This
* is useful when a finding matches the criteria for multiple rules, and each rule has different actions. If a rule
* is terminal, Security Hub applies the rule action to a finding that matches the rule criteria and doesn't
* evaluate other rules for the finding. By default, a rule isn't terminal.
*
*
* @return Specifies whether a rule is the last to be applied with respect to a finding that matches the rule
* criteria. This is useful when a finding matches the criteria for multiple rules, and each rule has
* different actions. If a rule is terminal, Security Hub applies the rule action to a finding that matches
* the rule criteria and doesn't evaluate other rules for the finding. By default, a rule isn't terminal.
*/
public final Boolean isTerminal() {
return isTerminal;
}
/**
*
* A set of Amazon Web
* Services Security Finding Format finding field attributes and corresponding expected values that Security Hub
* uses to filter findings. If a rule is enabled and a finding matches the conditions specified in this parameter,
* Security Hub applies the rule action to the finding.
*
*
* @return A set of Amazon
* Web Services Security Finding Format finding field attributes and corresponding expected values that
* Security Hub uses to filter findings. If a rule is enabled and a finding matches the conditions specified
* in this parameter, Security Hub applies the rule action to the finding.
*/
public final AutomationRulesFindingFilters criteria() {
return criteria;
}
/**
* For responses, this returns true if the service returned a value for the Actions 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 hasActions() {
return actions != null && !(actions instanceof SdkAutoConstructList);
}
/**
*
* One or more actions to update finding fields if a finding matches the defined criteria of the rule.
*
*
* 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 #hasActions} method.
*
*
* @return One or more actions to update finding fields if a finding matches the defined criteria of the rule.
*/
public final List actions() {
return actions;
}
/**
*
* A timestamp that indicates when the rule was created.
*
*
* Uses the date-time format specified in RFC
* 3339 section 5.6, Internet Date/Time Format. The value cannot contain spaces. For example,
* 2020-03-22T13:22:13.933Z.
*
*
* @return A timestamp that indicates when the rule was created.
*
* Uses the date-time format specified in RFC 3339 section 5.6, Internet Date/Time
* Format. The value cannot contain spaces. For example, 2020-03-22T13:22:13.933Z.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* A timestamp that indicates when the rule was most recently updated.
*
*
* Uses the date-time format specified in RFC
* 3339 section 5.6, Internet Date/Time Format. The value cannot contain spaces. For example,
* 2020-03-22T13:22:13.933Z.
*
*
* @return A timestamp that indicates when the rule was most recently updated.
*
* Uses the date-time format specified in RFC 3339 section 5.6, Internet Date/Time
* Format. The value cannot contain spaces. For example, 2020-03-22T13:22:13.933Z.
*/
public final Instant updatedAt() {
return updatedAt;
}
/**
*
* The principal that created a rule.
*
*
* @return The principal that created a rule.
*/
public final String createdBy() {
return createdBy;
}
@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(ruleArn());
hashCode = 31 * hashCode + Objects.hashCode(ruleStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(ruleOrder());
hashCode = 31 * hashCode + Objects.hashCode(ruleName());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(isTerminal());
hashCode = 31 * hashCode + Objects.hashCode(criteria());
hashCode = 31 * hashCode + Objects.hashCode(hasActions() ? actions() : null);
hashCode = 31 * hashCode + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(updatedAt());
hashCode = 31 * hashCode + Objects.hashCode(createdBy());
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 AutomationRulesConfig)) {
return false;
}
AutomationRulesConfig other = (AutomationRulesConfig) obj;
return Objects.equals(ruleArn(), other.ruleArn()) && Objects.equals(ruleStatusAsString(), other.ruleStatusAsString())
&& Objects.equals(ruleOrder(), other.ruleOrder()) && Objects.equals(ruleName(), other.ruleName())
&& Objects.equals(description(), other.description()) && Objects.equals(isTerminal(), other.isTerminal())
&& Objects.equals(criteria(), other.criteria()) && hasActions() == other.hasActions()
&& Objects.equals(actions(), other.actions()) && Objects.equals(createdAt(), other.createdAt())
&& Objects.equals(updatedAt(), other.updatedAt()) && Objects.equals(createdBy(), other.createdBy());
}
/**
* 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("AutomationRulesConfig").add("RuleArn", ruleArn()).add("RuleStatus", ruleStatusAsString())
.add("RuleOrder", ruleOrder()).add("RuleName", ruleName()).add("Description", description())
.add("IsTerminal", isTerminal()).add("Criteria", criteria()).add("Actions", hasActions() ? actions() : null)
.add("CreatedAt", createdAt()).add("UpdatedAt", updatedAt()).add("CreatedBy", createdBy()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "RuleArn":
return Optional.ofNullable(clazz.cast(ruleArn()));
case "RuleStatus":
return Optional.ofNullable(clazz.cast(ruleStatusAsString()));
case "RuleOrder":
return Optional.ofNullable(clazz.cast(ruleOrder()));
case "RuleName":
return Optional.ofNullable(clazz.cast(ruleName()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "IsTerminal":
return Optional.ofNullable(clazz.cast(isTerminal()));
case "Criteria":
return Optional.ofNullable(clazz.cast(criteria()));
case "Actions":
return Optional.ofNullable(clazz.cast(actions()));
case "CreatedAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "UpdatedAt":
return Optional.ofNullable(clazz.cast(updatedAt()));
case "CreatedBy":
return Optional.ofNullable(clazz.cast(createdBy()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function