All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.fms.model.ViolationDetail Maven / Gradle / Ivy

Go to download

The AWS Java SDK for FMS module holds the client classes that are used for communicating with FMS.

There is a newer version: 2.29.15
Show newest version
/*
 * 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.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.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;

/**
 * 

* Violations for a resource based on the specified Firewall Manager policy and Amazon Web Services account. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ViolationDetail implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField POLICY_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("PolicyId").getter(getter(ViolationDetail::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(ViolationDetail::memberAccount)).setter(setter(Builder::memberAccount)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MemberAccount").build()).build(); private static final SdkField RESOURCE_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ResourceId").getter(getter(ViolationDetail::resourceId)).setter(setter(Builder::resourceId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceId").build()).build(); private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ResourceType").getter(getter(ViolationDetail::resourceType)).setter(setter(Builder::resourceType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceType").build()).build(); private static final SdkField> RESOURCE_VIOLATIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("ResourceViolations") .getter(getter(ViolationDetail::resourceViolations)) .setter(setter(Builder::resourceViolations)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceViolations").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(ResourceViolation::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField> RESOURCE_TAGS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("ResourceTags") .getter(getter(ViolationDetail::resourceTags)) .setter(setter(Builder::resourceTags)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceTags").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Tag::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField RESOURCE_DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ResourceDescription").getter(getter(ViolationDetail::resourceDescription)) .setter(setter(Builder::resourceDescription)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceDescription").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(POLICY_ID_FIELD, MEMBER_ACCOUNT_FIELD, RESOURCE_ID_FIELD, RESOURCE_TYPE_FIELD, RESOURCE_VIOLATIONS_FIELD, RESOURCE_TAGS_FIELD, RESOURCE_DESCRIPTION_FIELD)); private static final Map> SDK_NAME_TO_FIELD = Collections .unmodifiableMap(new HashMap>() { { put("PolicyId", POLICY_ID_FIELD); put("MemberAccount", MEMBER_ACCOUNT_FIELD); put("ResourceId", RESOURCE_ID_FIELD); put("ResourceType", RESOURCE_TYPE_FIELD); put("ResourceViolations", RESOURCE_VIOLATIONS_FIELD); put("ResourceTags", RESOURCE_TAGS_FIELD); put("ResourceDescription", RESOURCE_DESCRIPTION_FIELD); } }); private static final long serialVersionUID = 1L; private final String policyId; private final String memberAccount; private final String resourceId; private final String resourceType; private final List resourceViolations; private final List resourceTags; private final String resourceDescription; private ViolationDetail(BuilderImpl builder) { this.policyId = builder.policyId; this.memberAccount = builder.memberAccount; this.resourceId = builder.resourceId; this.resourceType = builder.resourceType; this.resourceViolations = builder.resourceViolations; this.resourceTags = builder.resourceTags; this.resourceDescription = builder.resourceDescription; } /** *

* The ID of the Firewall Manager policy that the violation details were requested for. *

* * @return The ID of the Firewall Manager policy that the violation details were requested for. */ public final String policyId() { return policyId; } /** *

* The Amazon Web Services account that the violation details were requested for. *

* * @return The Amazon Web Services account that the violation details were requested for. */ public final String memberAccount() { return memberAccount; } /** *

* The resource ID that the violation details were requested for. *

* * @return The resource ID that the violation details were requested for. */ public final String resourceId() { return resourceId; } /** *

* The resource type that the violation details were requested for. *

* * @return The resource type that the violation details were requested for. */ public final String resourceType() { return resourceType; } /** * For responses, this returns true if the service returned a value for the ResourceViolations 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 hasResourceViolations() { return resourceViolations != null && !(resourceViolations instanceof SdkAutoConstructList); } /** *

* List of violations for the requested resource. *

*

* 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 #hasResourceViolations} method. *

* * @return List of violations for the requested resource. */ public final List resourceViolations() { return resourceViolations; } /** * For responses, this returns true if the service returned a value for the ResourceTags 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 hasResourceTags() { return resourceTags != null && !(resourceTags instanceof SdkAutoConstructList); } /** *

* The ResourceTag objects associated with the resource. *

*

* 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 #hasResourceTags} method. *

* * @return The ResourceTag objects associated with the resource. */ public final List resourceTags() { return resourceTags; } /** *

* Brief description for the requested resource. *

* * @return Brief description for the requested resource. */ public final String resourceDescription() { return resourceDescription; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(policyId()); hashCode = 31 * hashCode + Objects.hashCode(memberAccount()); hashCode = 31 * hashCode + Objects.hashCode(resourceId()); hashCode = 31 * hashCode + Objects.hashCode(resourceType()); hashCode = 31 * hashCode + Objects.hashCode(hasResourceViolations() ? resourceViolations() : null); hashCode = 31 * hashCode + Objects.hashCode(hasResourceTags() ? resourceTags() : null); hashCode = 31 * hashCode + Objects.hashCode(resourceDescription()); 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 ViolationDetail)) { return false; } ViolationDetail other = (ViolationDetail) obj; return Objects.equals(policyId(), other.policyId()) && Objects.equals(memberAccount(), other.memberAccount()) && Objects.equals(resourceId(), other.resourceId()) && Objects.equals(resourceType(), other.resourceType()) && hasResourceViolations() == other.hasResourceViolations() && Objects.equals(resourceViolations(), other.resourceViolations()) && hasResourceTags() == other.hasResourceTags() && Objects.equals(resourceTags(), other.resourceTags()) && Objects.equals(resourceDescription(), other.resourceDescription()); } /** * 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("ViolationDetail").add("PolicyId", policyId()).add("MemberAccount", memberAccount()) .add("ResourceId", resourceId()).add("ResourceType", resourceType()) .add("ResourceViolations", hasResourceViolations() ? resourceViolations() : null) .add("ResourceTags", hasResourceTags() ? resourceTags() : null).add("ResourceDescription", resourceDescription()) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "PolicyId": return Optional.ofNullable(clazz.cast(policyId())); case "MemberAccount": return Optional.ofNullable(clazz.cast(memberAccount())); case "ResourceId": return Optional.ofNullable(clazz.cast(resourceId())); case "ResourceType": return Optional.ofNullable(clazz.cast(resourceType())); case "ResourceViolations": return Optional.ofNullable(clazz.cast(resourceViolations())); case "ResourceTags": return Optional.ofNullable(clazz.cast(resourceTags())); case "ResourceDescription": return Optional.ofNullable(clazz.cast(resourceDescription())); 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((ViolationDetail) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The ID of the Firewall Manager policy that the violation details were requested for. *

* * @param policyId * The ID of the Firewall Manager policy that the violation details were requested for. * @return Returns a reference to this object so that method calls can be chained together. */ Builder policyId(String policyId); /** *

* The Amazon Web Services account that the violation details were requested for. *

* * @param memberAccount * The Amazon Web Services account that the violation details were requested for. * @return Returns a reference to this object so that method calls can be chained together. */ Builder memberAccount(String memberAccount); /** *

* The resource ID that the violation details were requested for. *

* * @param resourceId * The resource ID that the violation details were requested for. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceId(String resourceId); /** *

* The resource type that the violation details were requested for. *

* * @param resourceType * The resource type that the violation details were requested for. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceType(String resourceType); /** *

* List of violations for the requested resource. *

* * @param resourceViolations * List of violations for the requested resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceViolations(Collection resourceViolations); /** *

* List of violations for the requested resource. *

* * @param resourceViolations * List of violations for the requested resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceViolations(ResourceViolation... resourceViolations); /** *

* List of violations for the requested resource. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.fms.model.ResourceViolation.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.fms.model.ResourceViolation#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.fms.model.ResourceViolation.Builder#build()} is called immediately and * its result is passed to {@link #resourceViolations(List)}. * * @param resourceViolations * a consumer that will call methods on * {@link software.amazon.awssdk.services.fms.model.ResourceViolation.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #resourceViolations(java.util.Collection) */ Builder resourceViolations(Consumer... resourceViolations); /** *

* The ResourceTag objects associated with the resource. *

* * @param resourceTags * The ResourceTag objects associated with the resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceTags(Collection resourceTags); /** *

* The ResourceTag objects associated with the resource. *

* * @param resourceTags * The ResourceTag objects associated with the resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceTags(Tag... resourceTags); /** *

* The ResourceTag objects associated with the resource. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.fms.model.Tag.Builder} avoiding the need to create one manually via * {@link software.amazon.awssdk.services.fms.model.Tag#builder()}. * *

* When the {@link Consumer} completes, {@link software.amazon.awssdk.services.fms.model.Tag.Builder#build()} is * called immediately and its result is passed to {@link #resourceTags(List)}. * * @param resourceTags * a consumer that will call methods on {@link software.amazon.awssdk.services.fms.model.Tag.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #resourceTags(java.util.Collection) */ Builder resourceTags(Consumer... resourceTags); /** *

* Brief description for the requested resource. *

* * @param resourceDescription * Brief description for the requested resource. * @return Returns a reference to this object so that method calls can be chained together. */ Builder resourceDescription(String resourceDescription); } static final class BuilderImpl implements Builder { private String policyId; private String memberAccount; private String resourceId; private String resourceType; private List resourceViolations = DefaultSdkAutoConstructList.getInstance(); private List resourceTags = DefaultSdkAutoConstructList.getInstance(); private String resourceDescription; private BuilderImpl() { } private BuilderImpl(ViolationDetail model) { policyId(model.policyId); memberAccount(model.memberAccount); resourceId(model.resourceId); resourceType(model.resourceType); resourceViolations(model.resourceViolations); resourceTags(model.resourceTags); resourceDescription(model.resourceDescription); } 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 String getResourceId() { return resourceId; } public final void setResourceId(String resourceId) { this.resourceId = resourceId; } @Override public final Builder resourceId(String resourceId) { this.resourceId = resourceId; return this; } public final String getResourceType() { return resourceType; } public final void setResourceType(String resourceType) { this.resourceType = resourceType; } @Override public final Builder resourceType(String resourceType) { this.resourceType = resourceType; return this; } public final List getResourceViolations() { List result = ResourceViolationsCopier.copyToBuilder(this.resourceViolations); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setResourceViolations(Collection resourceViolations) { this.resourceViolations = ResourceViolationsCopier.copyFromBuilder(resourceViolations); } @Override public final Builder resourceViolations(Collection resourceViolations) { this.resourceViolations = ResourceViolationsCopier.copy(resourceViolations); return this; } @Override @SafeVarargs public final Builder resourceViolations(ResourceViolation... resourceViolations) { resourceViolations(Arrays.asList(resourceViolations)); return this; } @Override @SafeVarargs public final Builder resourceViolations(Consumer... resourceViolations) { resourceViolations(Stream.of(resourceViolations).map(c -> ResourceViolation.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getResourceTags() { List result = TagListCopier.copyToBuilder(this.resourceTags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setResourceTags(Collection resourceTags) { this.resourceTags = TagListCopier.copyFromBuilder(resourceTags); } @Override public final Builder resourceTags(Collection resourceTags) { this.resourceTags = TagListCopier.copy(resourceTags); return this; } @Override @SafeVarargs public final Builder resourceTags(Tag... resourceTags) { resourceTags(Arrays.asList(resourceTags)); return this; } @Override @SafeVarargs public final Builder resourceTags(Consumer... resourceTags) { resourceTags(Stream.of(resourceTags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final String getResourceDescription() { return resourceDescription; } public final void setResourceDescription(String resourceDescription) { this.resourceDescription = resourceDescription; } @Override public final Builder resourceDescription(String resourceDescription) { this.resourceDescription = resourceDescription; return this; } @Override public ViolationDetail build() { return new ViolationDetail(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy