Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.fms.model.PolicyComplianceDetail Maven / Gradle / Ivy
Go to download
The AWS Java SDK for FMS module holds the client classes that are used for
communicating with FMS.
/*
* 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.fms.model;
import java.io.Serializable;
import java.time.Instant;
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.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Describes the noncompliant resources in a member account for a specific Firewall Manager policy. A maximum of 100
* entries are displayed. If more than 100 resources are noncompliant, EvaluationLimitExceeded
is set to
* True
.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PolicyComplianceDetail implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField POLICY_OWNER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PolicyOwner").getter(getter(PolicyComplianceDetail::policyOwner)).setter(setter(Builder::policyOwner))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolicyOwner").build()).build();
private static final SdkField POLICY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PolicyId").getter(getter(PolicyComplianceDetail::policyId)).setter(setter(Builder::policyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolicyId").build()).build();
private static final SdkField MEMBER_ACCOUNT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("MemberAccount").getter(getter(PolicyComplianceDetail::memberAccount))
.setter(setter(Builder::memberAccount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberAccount").build()).build();
private static final SdkField> VIOLATORS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Violators")
.getter(getter(PolicyComplianceDetail::violators))
.setter(setter(Builder::violators))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Violators").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ComplianceViolator::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField EVALUATION_LIMIT_EXCEEDED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("EvaluationLimitExceeded").getter(getter(PolicyComplianceDetail::evaluationLimitExceeded))
.setter(setter(Builder::evaluationLimitExceeded))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EvaluationLimitExceeded").build())
.build();
private static final SdkField EXPIRED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("ExpiredAt").getter(getter(PolicyComplianceDetail::expiredAt)).setter(setter(Builder::expiredAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpiredAt").build()).build();
private static final SdkField> ISSUE_INFO_MAP_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("IssueInfoMap")
.getter(getter(PolicyComplianceDetail::issueInfoMapAsStrings))
.setter(setter(Builder::issueInfoMapWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IssueInfoMap").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(POLICY_OWNER_FIELD,
POLICY_ID_FIELD, MEMBER_ACCOUNT_FIELD, VIOLATORS_FIELD, EVALUATION_LIMIT_EXCEEDED_FIELD, EXPIRED_AT_FIELD,
ISSUE_INFO_MAP_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("PolicyOwner", POLICY_OWNER_FIELD);
put("PolicyId", POLICY_ID_FIELD);
put("MemberAccount", MEMBER_ACCOUNT_FIELD);
put("Violators", VIOLATORS_FIELD);
put("EvaluationLimitExceeded", EVALUATION_LIMIT_EXCEEDED_FIELD);
put("ExpiredAt", EXPIRED_AT_FIELD);
put("IssueInfoMap", ISSUE_INFO_MAP_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String policyOwner;
private final String policyId;
private final String memberAccount;
private final List violators;
private final Boolean evaluationLimitExceeded;
private final Instant expiredAt;
private final Map issueInfoMap;
private PolicyComplianceDetail(BuilderImpl builder) {
this.policyOwner = builder.policyOwner;
this.policyId = builder.policyId;
this.memberAccount = builder.memberAccount;
this.violators = builder.violators;
this.evaluationLimitExceeded = builder.evaluationLimitExceeded;
this.expiredAt = builder.expiredAt;
this.issueInfoMap = builder.issueInfoMap;
}
/**
*
* The Amazon Web Services account that created the Firewall Manager policy.
*
*
* @return The Amazon Web Services account that created the Firewall Manager policy.
*/
public final String policyOwner() {
return policyOwner;
}
/**
*
* The ID of the Firewall Manager policy.
*
*
* @return The ID of the Firewall Manager policy.
*/
public final String policyId() {
return policyId;
}
/**
*
* The Amazon Web Services account ID.
*
*
* @return The Amazon Web Services account ID.
*/
public final String memberAccount() {
return memberAccount;
}
/**
* For responses, this returns true if the service returned a value for the Violators 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 hasViolators() {
return violators != null && !(violators instanceof SdkAutoConstructList);
}
/**
*
* An array of resources that aren't protected by the WAF or Shield Advanced policy or that aren't in compliance
* with the security group policy.
*
*
* 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 #hasViolators} method.
*
*
* @return An array of resources that aren't protected by the WAF or Shield Advanced policy or that aren't in
* compliance with the security group policy.
*/
public final List violators() {
return violators;
}
/**
*
* Indicates if over 100 resources are noncompliant with the Firewall Manager policy.
*
*
* @return Indicates if over 100 resources are noncompliant with the Firewall Manager policy.
*/
public final Boolean evaluationLimitExceeded() {
return evaluationLimitExceeded;
}
/**
*
* A timestamp that indicates when the returned information should be considered out of date.
*
*
* @return A timestamp that indicates when the returned information should be considered out of date.
*/
public final Instant expiredAt() {
return expiredAt;
}
/**
*
* Details about problems with dependent services, such as WAF or Config, and the error message received that
* indicates the problem with the service.
*
*
* 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 #hasIssueInfoMap} method.
*
*
* @return Details about problems with dependent services, such as WAF or Config, and the error message received
* that indicates the problem with the service.
*/
public final Map issueInfoMap() {
return IssueInfoMapCopier.copyStringToEnum(issueInfoMap);
}
/**
* For responses, this returns true if the service returned a value for the IssueInfoMap 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 hasIssueInfoMap() {
return issueInfoMap != null && !(issueInfoMap instanceof SdkAutoConstructMap);
}
/**
*
* Details about problems with dependent services, such as WAF or Config, and the error message received that
* indicates the problem with the service.
*
*
* 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 #hasIssueInfoMap} method.
*
*
* @return Details about problems with dependent services, such as WAF or Config, and the error message received
* that indicates the problem with the service.
*/
public final Map issueInfoMapAsStrings() {
return issueInfoMap;
}
@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(policyOwner());
hashCode = 31 * hashCode + Objects.hashCode(policyId());
hashCode = 31 * hashCode + Objects.hashCode(memberAccount());
hashCode = 31 * hashCode + Objects.hashCode(hasViolators() ? violators() : null);
hashCode = 31 * hashCode + Objects.hashCode(evaluationLimitExceeded());
hashCode = 31 * hashCode + Objects.hashCode(expiredAt());
hashCode = 31 * hashCode + Objects.hashCode(hasIssueInfoMap() ? issueInfoMapAsStrings() : 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 PolicyComplianceDetail)) {
return false;
}
PolicyComplianceDetail other = (PolicyComplianceDetail) obj;
return Objects.equals(policyOwner(), other.policyOwner()) && Objects.equals(policyId(), other.policyId())
&& Objects.equals(memberAccount(), other.memberAccount()) && hasViolators() == other.hasViolators()
&& Objects.equals(violators(), other.violators())
&& Objects.equals(evaluationLimitExceeded(), other.evaluationLimitExceeded())
&& Objects.equals(expiredAt(), other.expiredAt()) && hasIssueInfoMap() == other.hasIssueInfoMap()
&& Objects.equals(issueInfoMapAsStrings(), other.issueInfoMapAsStrings());
}
/**
* 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("PolicyComplianceDetail").add("PolicyOwner", policyOwner()).add("PolicyId", policyId())
.add("MemberAccount", memberAccount()).add("Violators", hasViolators() ? violators() : null)
.add("EvaluationLimitExceeded", evaluationLimitExceeded()).add("ExpiredAt", expiredAt())
.add("IssueInfoMap", hasIssueInfoMap() ? issueInfoMapAsStrings() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PolicyOwner":
return Optional.ofNullable(clazz.cast(policyOwner()));
case "PolicyId":
return Optional.ofNullable(clazz.cast(policyId()));
case "MemberAccount":
return Optional.ofNullable(clazz.cast(memberAccount()));
case "Violators":
return Optional.ofNullable(clazz.cast(violators()));
case "EvaluationLimitExceeded":
return Optional.ofNullable(clazz.cast(evaluationLimitExceeded()));
case "ExpiredAt":
return Optional.ofNullable(clazz.cast(expiredAt()));
case "IssueInfoMap":
return Optional.ofNullable(clazz.cast(issueInfoMapAsStrings()));
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((PolicyComplianceDetail) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* The Amazon Web Services account that created the Firewall Manager policy.
*
*
* @param policyOwner
* The Amazon Web Services account that created the Firewall Manager policy.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder policyOwner(String policyOwner);
/**
*
* The ID of the Firewall Manager policy.
*
*
* @param policyId
* The ID of the Firewall Manager policy.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder policyId(String policyId);
/**
*
* The Amazon Web Services account ID.
*
*
* @param memberAccount
* The Amazon Web Services account ID.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder memberAccount(String memberAccount);
/**
*
* An array of resources that aren't protected by the WAF or Shield Advanced policy or that aren't in compliance
* with the security group policy.
*
*
* @param violators
* An array of resources that aren't protected by the WAF or Shield Advanced policy or that aren't in
* compliance with the security group policy.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder violators(Collection violators);
/**
*
* An array of resources that aren't protected by the WAF or Shield Advanced policy or that aren't in compliance
* with the security group policy.
*
*
* @param violators
* An array of resources that aren't protected by the WAF or Shield Advanced policy or that aren't in
* compliance with the security group policy.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder violators(ComplianceViolator... violators);
/**
*
* An array of resources that aren't protected by the WAF or Shield Advanced policy or that aren't in compliance
* with the security group policy.
*
* This is a convenience method that creates an instance of the
* {@link software.amazon.awssdk.services.fms.model.ComplianceViolator.Builder} avoiding the need to create one
* manually via {@link software.amazon.awssdk.services.fms.model.ComplianceViolator#builder()}.
*
*
* When the {@link Consumer} completes,
* {@link software.amazon.awssdk.services.fms.model.ComplianceViolator.Builder#build()} is called immediately
* and its result is passed to {@link #violators(List)}.
*
* @param violators
* a consumer that will call methods on
* {@link software.amazon.awssdk.services.fms.model.ComplianceViolator.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #violators(java.util.Collection)
*/
Builder violators(Consumer... violators);
/**
*
* Indicates if over 100 resources are noncompliant with the Firewall Manager policy.
*
*
* @param evaluationLimitExceeded
* Indicates if over 100 resources are noncompliant with the Firewall Manager policy.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder evaluationLimitExceeded(Boolean evaluationLimitExceeded);
/**
*
* A timestamp that indicates when the returned information should be considered out of date.
*
*
* @param expiredAt
* A timestamp that indicates when the returned information should be considered out of date.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder expiredAt(Instant expiredAt);
/**
*
* Details about problems with dependent services, such as WAF or Config, and the error message received that
* indicates the problem with the service.
*
*
* @param issueInfoMap
* Details about problems with dependent services, such as WAF or Config, and the error message received
* that indicates the problem with the service.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder issueInfoMapWithStrings(Map issueInfoMap);
/**
*
* Details about problems with dependent services, such as WAF or Config, and the error message received that
* indicates the problem with the service.
*
*
* @param issueInfoMap
* Details about problems with dependent services, such as WAF or Config, and the error message received
* that indicates the problem with the service.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder issueInfoMap(Map issueInfoMap);
}
static final class BuilderImpl implements Builder {
private String policyOwner;
private String policyId;
private String memberAccount;
private List violators = DefaultSdkAutoConstructList.getInstance();
private Boolean evaluationLimitExceeded;
private Instant expiredAt;
private Map issueInfoMap = DefaultSdkAutoConstructMap.getInstance();
private BuilderImpl() {
}
private BuilderImpl(PolicyComplianceDetail model) {
policyOwner(model.policyOwner);
policyId(model.policyId);
memberAccount(model.memberAccount);
violators(model.violators);
evaluationLimitExceeded(model.evaluationLimitExceeded);
expiredAt(model.expiredAt);
issueInfoMapWithStrings(model.issueInfoMap);
}
public final String getPolicyOwner() {
return policyOwner;
}
public final void setPolicyOwner(String policyOwner) {
this.policyOwner = policyOwner;
}
@Override
public final Builder policyOwner(String policyOwner) {
this.policyOwner = policyOwner;
return this;
}
public final String getPolicyId() {
return policyId;
}
public final void setPolicyId(String policyId) {
this.policyId = policyId;
}
@Override
public final Builder policyId(String policyId) {
this.policyId = policyId;
return this;
}
public final String getMemberAccount() {
return memberAccount;
}
public final void setMemberAccount(String memberAccount) {
this.memberAccount = memberAccount;
}
@Override
public final Builder memberAccount(String memberAccount) {
this.memberAccount = memberAccount;
return this;
}
public final List getViolators() {
List result = ComplianceViolatorsCopier.copyToBuilder(this.violators);
if (result instanceof SdkAutoConstructList) {
return null;
}
return result;
}
public final void setViolators(Collection violators) {
this.violators = ComplianceViolatorsCopier.copyFromBuilder(violators);
}
@Override
public final Builder violators(Collection violators) {
this.violators = ComplianceViolatorsCopier.copy(violators);
return this;
}
@Override
@SafeVarargs
public final Builder violators(ComplianceViolator... violators) {
violators(Arrays.asList(violators));
return this;
}
@Override
@SafeVarargs
public final Builder violators(Consumer... violators) {
violators(Stream.of(violators).map(c -> ComplianceViolator.builder().applyMutation(c).build())
.collect(Collectors.toList()));
return this;
}
public final Boolean getEvaluationLimitExceeded() {
return evaluationLimitExceeded;
}
public final void setEvaluationLimitExceeded(Boolean evaluationLimitExceeded) {
this.evaluationLimitExceeded = evaluationLimitExceeded;
}
@Override
public final Builder evaluationLimitExceeded(Boolean evaluationLimitExceeded) {
this.evaluationLimitExceeded = evaluationLimitExceeded;
return this;
}
public final Instant getExpiredAt() {
return expiredAt;
}
public final void setExpiredAt(Instant expiredAt) {
this.expiredAt = expiredAt;
}
@Override
public final Builder expiredAt(Instant expiredAt) {
this.expiredAt = expiredAt;
return this;
}
public final Map getIssueInfoMap() {
if (issueInfoMap instanceof SdkAutoConstructMap) {
return null;
}
return issueInfoMap;
}
public final void setIssueInfoMap(Map issueInfoMap) {
this.issueInfoMap = IssueInfoMapCopier.copy(issueInfoMap);
}
@Override
public final Builder issueInfoMapWithStrings(Map issueInfoMap) {
this.issueInfoMap = IssueInfoMapCopier.copy(issueInfoMap);
return this;
}
@Override
public final Builder issueInfoMap(Map issueInfoMap) {
this.issueInfoMap = IssueInfoMapCopier.copyEnumToString(issueInfoMap);
return this;
}
@Override
public PolicyComplianceDetail build() {
return new PolicyComplianceDetail(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
@Override
public Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
}
}