
software.amazon.awssdk.services.guardduty.model.Resource 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.guardduty.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;
/**
*
* Contains information about the Amazon Web Services resource associated with the activity that prompted GuardDuty to
* generate a finding.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Resource implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ACCESS_KEY_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("AccessKeyDetails")
.getter(getter(Resource::accessKeyDetails)).setter(setter(Builder::accessKeyDetails))
.constructor(AccessKeyDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("accessKeyDetails").build()).build();
private static final SdkField> S3_BUCKET_DETAILS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("S3BucketDetails")
.getter(getter(Resource::s3BucketDetails))
.setter(setter(Builder::s3BucketDetails))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("s3BucketDetails").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(S3BucketDetail::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField INSTANCE_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("InstanceDetails")
.getter(getter(Resource::instanceDetails)).setter(setter(Builder::instanceDetails))
.constructor(InstanceDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("instanceDetails").build()).build();
private static final SdkField EKS_CLUSTER_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("EksClusterDetails")
.getter(getter(Resource::eksClusterDetails)).setter(setter(Builder::eksClusterDetails))
.constructor(EksClusterDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("eksClusterDetails").build()).build();
private static final SdkField KUBERNETES_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("KubernetesDetails")
.getter(getter(Resource::kubernetesDetails)).setter(setter(Builder::kubernetesDetails))
.constructor(KubernetesDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("kubernetesDetails").build()).build();
private static final SdkField RESOURCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ResourceType").getter(getter(Resource::resourceType)).setter(setter(Builder::resourceType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resourceType").build()).build();
private static final SdkField EBS_VOLUME_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("EbsVolumeDetails")
.getter(getter(Resource::ebsVolumeDetails)).setter(setter(Builder::ebsVolumeDetails))
.constructor(EbsVolumeDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ebsVolumeDetails").build()).build();
private static final SdkField ECS_CLUSTER_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("EcsClusterDetails")
.getter(getter(Resource::ecsClusterDetails)).setter(setter(Builder::ecsClusterDetails))
.constructor(EcsClusterDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ecsClusterDetails").build()).build();
private static final SdkField CONTAINER_DETAILS_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("ContainerDetails").getter(getter(Resource::containerDetails)).setter(setter(Builder::containerDetails))
.constructor(Container::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("containerDetails").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ACCESS_KEY_DETAILS_FIELD,
S3_BUCKET_DETAILS_FIELD, INSTANCE_DETAILS_FIELD, EKS_CLUSTER_DETAILS_FIELD, KUBERNETES_DETAILS_FIELD,
RESOURCE_TYPE_FIELD, EBS_VOLUME_DETAILS_FIELD, ECS_CLUSTER_DETAILS_FIELD, CONTAINER_DETAILS_FIELD));
private static final long serialVersionUID = 1L;
private final AccessKeyDetails accessKeyDetails;
private final List s3BucketDetails;
private final InstanceDetails instanceDetails;
private final EksClusterDetails eksClusterDetails;
private final KubernetesDetails kubernetesDetails;
private final String resourceType;
private final EbsVolumeDetails ebsVolumeDetails;
private final EcsClusterDetails ecsClusterDetails;
private final Container containerDetails;
private Resource(BuilderImpl builder) {
this.accessKeyDetails = builder.accessKeyDetails;
this.s3BucketDetails = builder.s3BucketDetails;
this.instanceDetails = builder.instanceDetails;
this.eksClusterDetails = builder.eksClusterDetails;
this.kubernetesDetails = builder.kubernetesDetails;
this.resourceType = builder.resourceType;
this.ebsVolumeDetails = builder.ebsVolumeDetails;
this.ecsClusterDetails = builder.ecsClusterDetails;
this.containerDetails = builder.containerDetails;
}
/**
*
* The IAM access key details (IAM user information) of a user that engaged in the activity that prompted GuardDuty
* to generate a finding.
*
*
* @return The IAM access key details (IAM user information) of a user that engaged in the activity that prompted
* GuardDuty to generate a finding.
*/
public final AccessKeyDetails accessKeyDetails() {
return accessKeyDetails;
}
/**
* For responses, this returns true if the service returned a value for the S3BucketDetails 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 hasS3BucketDetails() {
return s3BucketDetails != null && !(s3BucketDetails instanceof SdkAutoConstructList);
}
/**
*
* Contains information on the S3 bucket.
*
*
* 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 #hasS3BucketDetails} method.
*
*
* @return Contains information on the S3 bucket.
*/
public final List s3BucketDetails() {
return s3BucketDetails;
}
/**
*
* The information about the EC2 instance associated with the activity that prompted GuardDuty to generate a
* finding.
*
*
* @return The information about the EC2 instance associated with the activity that prompted GuardDuty to generate a
* finding.
*/
public final InstanceDetails instanceDetails() {
return instanceDetails;
}
/**
*
* Details about the EKS cluster involved in a Kubernetes finding.
*
*
* @return Details about the EKS cluster involved in a Kubernetes finding.
*/
public final EksClusterDetails eksClusterDetails() {
return eksClusterDetails;
}
/**
*
* Details about the Kubernetes user and workload involved in a Kubernetes finding.
*
*
* @return Details about the Kubernetes user and workload involved in a Kubernetes finding.
*/
public final KubernetesDetails kubernetesDetails() {
return kubernetesDetails;
}
/**
*
* The type of Amazon Web Services resource.
*
*
* @return The type of Amazon Web Services resource.
*/
public final String resourceType() {
return resourceType;
}
/**
*
* Contains list of scanned and skipped EBS volumes with details.
*
*
* @return Contains list of scanned and skipped EBS volumes with details.
*/
public final EbsVolumeDetails ebsVolumeDetails() {
return ebsVolumeDetails;
}
/**
*
* Contains information about the details of the ECS Cluster.
*
*
* @return Contains information about the details of the ECS Cluster.
*/
public final EcsClusterDetails ecsClusterDetails() {
return ecsClusterDetails;
}
/**
* Returns the value of the ContainerDetails property for this object.
*
* @return The value of the ContainerDetails property for this object.
*/
public final Container containerDetails() {
return containerDetails;
}
@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(accessKeyDetails());
hashCode = 31 * hashCode + Objects.hashCode(hasS3BucketDetails() ? s3BucketDetails() : null);
hashCode = 31 * hashCode + Objects.hashCode(instanceDetails());
hashCode = 31 * hashCode + Objects.hashCode(eksClusterDetails());
hashCode = 31 * hashCode + Objects.hashCode(kubernetesDetails());
hashCode = 31 * hashCode + Objects.hashCode(resourceType());
hashCode = 31 * hashCode + Objects.hashCode(ebsVolumeDetails());
hashCode = 31 * hashCode + Objects.hashCode(ecsClusterDetails());
hashCode = 31 * hashCode + Objects.hashCode(containerDetails());
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 Resource)) {
return false;
}
Resource other = (Resource) obj;
return Objects.equals(accessKeyDetails(), other.accessKeyDetails()) && hasS3BucketDetails() == other.hasS3BucketDetails()
&& Objects.equals(s3BucketDetails(), other.s3BucketDetails())
&& Objects.equals(instanceDetails(), other.instanceDetails())
&& Objects.equals(eksClusterDetails(), other.eksClusterDetails())
&& Objects.equals(kubernetesDetails(), other.kubernetesDetails())
&& Objects.equals(resourceType(), other.resourceType())
&& Objects.equals(ebsVolumeDetails(), other.ebsVolumeDetails())
&& Objects.equals(ecsClusterDetails(), other.ecsClusterDetails())
&& Objects.equals(containerDetails(), other.containerDetails());
}
/**
* 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("Resource").add("AccessKeyDetails", accessKeyDetails())
.add("S3BucketDetails", hasS3BucketDetails() ? s3BucketDetails() : null)
.add("InstanceDetails", instanceDetails()).add("EksClusterDetails", eksClusterDetails())
.add("KubernetesDetails", kubernetesDetails()).add("ResourceType", resourceType())
.add("EbsVolumeDetails", ebsVolumeDetails()).add("EcsClusterDetails", ecsClusterDetails())
.add("ContainerDetails", containerDetails()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AccessKeyDetails":
return Optional.ofNullable(clazz.cast(accessKeyDetails()));
case "S3BucketDetails":
return Optional.ofNullable(clazz.cast(s3BucketDetails()));
case "InstanceDetails":
return Optional.ofNullable(clazz.cast(instanceDetails()));
case "EksClusterDetails":
return Optional.ofNullable(clazz.cast(eksClusterDetails()));
case "KubernetesDetails":
return Optional.ofNullable(clazz.cast(kubernetesDetails()));
case "ResourceType":
return Optional.ofNullable(clazz.cast(resourceType()));
case "EbsVolumeDetails":
return Optional.ofNullable(clazz.cast(ebsVolumeDetails()));
case "EcsClusterDetails":
return Optional.ofNullable(clazz.cast(ecsClusterDetails()));
case "ContainerDetails":
return Optional.ofNullable(clazz.cast(containerDetails()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function