software.amazon.awssdk.services.waf.model.LoggingConfiguration Maven / Gradle / Ivy
Show all versions of waf 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.waf.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;
/**
*
*
* This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the
* developer guide.
*
*
* For the latest version of AWS WAF, use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the
* latest version, AWS WAF has a single set of endpoints for regional and global use.
*
*
*
* The Amazon Kinesis Data Firehose, RedactedFields
information, and the web ACL Amazon Resource Name
* (ARN).
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LoggingConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField RESOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ResourceArn").getter(getter(LoggingConfiguration::resourceArn)).setter(setter(Builder::resourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceArn").build()).build();
private static final SdkField> LOG_DESTINATION_CONFIGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("LogDestinationConfigs")
.getter(getter(LoggingConfiguration::logDestinationConfigs))
.setter(setter(Builder::logDestinationConfigs))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LogDestinationConfigs").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> REDACTED_FIELDS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RedactedFields")
.getter(getter(LoggingConfiguration::redactedFields))
.setter(setter(Builder::redactedFields))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RedactedFields").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(FieldToMatch::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RESOURCE_ARN_FIELD,
LOG_DESTINATION_CONFIGS_FIELD, REDACTED_FIELDS_FIELD));
private static final long serialVersionUID = 1L;
private final String resourceArn;
private final List logDestinationConfigs;
private final List redactedFields;
private LoggingConfiguration(BuilderImpl builder) {
this.resourceArn = builder.resourceArn;
this.logDestinationConfigs = builder.logDestinationConfigs;
this.redactedFields = builder.redactedFields;
}
/**
*
* The Amazon Resource Name (ARN) of the web ACL that you want to associate with LogDestinationConfigs
.
*
*
* @return The Amazon Resource Name (ARN) of the web ACL that you want to associate with
* LogDestinationConfigs
.
*/
public final String resourceArn() {
return resourceArn;
}
/**
* For responses, this returns true if the service returned a value for the LogDestinationConfigs 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 hasLogDestinationConfigs() {
return logDestinationConfigs != null && !(logDestinationConfigs instanceof SdkAutoConstructList);
}
/**
*
* An array of Amazon Kinesis Data Firehose ARNs.
*
*
* 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 #hasLogDestinationConfigs} method.
*
*
* @return An array of Amazon Kinesis Data Firehose ARNs.
*/
public final List logDestinationConfigs() {
return logDestinationConfigs;
}
/**
* For responses, this returns true if the service returned a value for the RedactedFields 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 hasRedactedFields() {
return redactedFields != null && !(redactedFields instanceof SdkAutoConstructList);
}
/**
*
* The parts of the request that you want redacted from the logs. For example, if you redact the cookie field, the
* cookie field in the firehose will be xxx
.
*
*
* 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 #hasRedactedFields} method.
*
*
* @return The parts of the request that you want redacted from the logs. For example, if you redact the cookie
* field, the cookie field in the firehose will be xxx
.
*/
public final List redactedFields() {
return redactedFields;
}
@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(resourceArn());
hashCode = 31 * hashCode + Objects.hashCode(hasLogDestinationConfigs() ? logDestinationConfigs() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasRedactedFields() ? redactedFields() : 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 LoggingConfiguration)) {
return false;
}
LoggingConfiguration other = (LoggingConfiguration) obj;
return Objects.equals(resourceArn(), other.resourceArn())
&& hasLogDestinationConfigs() == other.hasLogDestinationConfigs()
&& Objects.equals(logDestinationConfigs(), other.logDestinationConfigs())
&& hasRedactedFields() == other.hasRedactedFields() && Objects.equals(redactedFields(), other.redactedFields());
}
/**
* 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("LoggingConfiguration").add("ResourceArn", resourceArn())
.add("LogDestinationConfigs", hasLogDestinationConfigs() ? logDestinationConfigs() : null)
.add("RedactedFields", hasRedactedFields() ? redactedFields() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ResourceArn":
return Optional.ofNullable(clazz.cast(resourceArn()));
case "LogDestinationConfigs":
return Optional.ofNullable(clazz.cast(logDestinationConfigs()));
case "RedactedFields":
return Optional.ofNullable(clazz.cast(redactedFields()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function