software.amazon.awssdk.services.fms.model.ViolationDetail Maven / Gradle / Ivy
Show all versions of fms Show documentation
/*
* 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.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.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 AWS Firewall Manager policy and AWS 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 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 AWS Firewall Manager policy that the violation details were requested for.
*
*
* @return The ID of the AWS Firewall Manager policy that the violation details were requested for.
*/
public String policyId() {
return policyId;
}
/**
*
* The AWS account that the violation details were requested for.
*
*
* @return The AWS account that the violation details were requested for.
*/
public 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 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 String resourceType() {
return resourceType;
}
/**
* Returns true if the ResourceViolations property was specified by the sender (it may be empty), or false if the
* sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public 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.
*
*
* You can use {@link #hasResourceViolations()} to see if a value was sent in this field.
*
*
* @return List of violations for the requested resource.
*/
public List resourceViolations() {
return resourceViolations;
}
/**
* Returns true if the ResourceTags property was specified by the sender (it may be empty), or false if the sender
* did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public 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.
*
*
* You can use {@link #hasResourceTags()} to see if a value was sent in this field.
*
*
* @return The ResourceTag
objects associated with the resource.
*/
public List resourceTags() {
return resourceTags;
}
/**
*
* Brief description for the requested resource.
*
*
* @return Brief description for the requested resource.
*/
public String resourceDescription() {
return resourceDescription;
}
@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 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 boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public 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 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 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 List> sdkFields() {
return SDK_FIELDS;
}
private static Function