software.amazon.awssdk.services.cloudfront.model.ResponseHeadersPolicyConfig Maven / Gradle / Ivy
Show all versions of cloudfront 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.cloudfront.model;
import java.io.Serializable;
import java.util.Arrays;
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 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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A response headers policy configuration.
*
*
* A response headers policy configuration contains metadata about the response headers policy, and configurations for
* sets of HTTP response headers.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ResponseHeadersPolicyConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField COMMENT_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Comment")
.getter(getter(ResponseHeadersPolicyConfig::comment))
.setter(setter(Builder::comment))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Comment")
.unmarshallLocationName("Comment").build()).build();
private static final SdkField NAME_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Name")
.getter(getter(ResponseHeadersPolicyConfig::name))
.setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name")
.unmarshallLocationName("Name").build()).build();
private static final SdkField CORS_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("CorsConfig")
.getter(getter(ResponseHeadersPolicyConfig::corsConfig))
.setter(setter(Builder::corsConfig))
.constructor(ResponseHeadersPolicyCorsConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CorsConfig")
.unmarshallLocationName("CorsConfig").build()).build();
private static final SdkField SECURITY_HEADERS_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("SecurityHeadersConfig")
.getter(getter(ResponseHeadersPolicyConfig::securityHeadersConfig))
.setter(setter(Builder::securityHeadersConfig))
.constructor(ResponseHeadersPolicySecurityHeadersConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecurityHeadersConfig")
.unmarshallLocationName("SecurityHeadersConfig").build()).build();
private static final SdkField SERVER_TIMING_HEADERS_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("ServerTimingHeadersConfig")
.getter(getter(ResponseHeadersPolicyConfig::serverTimingHeadersConfig))
.setter(setter(Builder::serverTimingHeadersConfig))
.constructor(ResponseHeadersPolicyServerTimingHeadersConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ServerTimingHeadersConfig")
.unmarshallLocationName("ServerTimingHeadersConfig").build()).build();
private static final SdkField CUSTOM_HEADERS_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("CustomHeadersConfig")
.getter(getter(ResponseHeadersPolicyConfig::customHeadersConfig))
.setter(setter(Builder::customHeadersConfig))
.constructor(ResponseHeadersPolicyCustomHeadersConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomHeadersConfig")
.unmarshallLocationName("CustomHeadersConfig").build()).build();
private static final SdkField REMOVE_HEADERS_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("RemoveHeadersConfig")
.getter(getter(ResponseHeadersPolicyConfig::removeHeadersConfig))
.setter(setter(Builder::removeHeadersConfig))
.constructor(ResponseHeadersPolicyRemoveHeadersConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RemoveHeadersConfig")
.unmarshallLocationName("RemoveHeadersConfig").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(COMMENT_FIELD, NAME_FIELD,
CORS_CONFIG_FIELD, SECURITY_HEADERS_CONFIG_FIELD, SERVER_TIMING_HEADERS_CONFIG_FIELD, CUSTOM_HEADERS_CONFIG_FIELD,
REMOVE_HEADERS_CONFIG_FIELD));
private static final long serialVersionUID = 1L;
private final String comment;
private final String name;
private final ResponseHeadersPolicyCorsConfig corsConfig;
private final ResponseHeadersPolicySecurityHeadersConfig securityHeadersConfig;
private final ResponseHeadersPolicyServerTimingHeadersConfig serverTimingHeadersConfig;
private final ResponseHeadersPolicyCustomHeadersConfig customHeadersConfig;
private final ResponseHeadersPolicyRemoveHeadersConfig removeHeadersConfig;
private ResponseHeadersPolicyConfig(BuilderImpl builder) {
this.comment = builder.comment;
this.name = builder.name;
this.corsConfig = builder.corsConfig;
this.securityHeadersConfig = builder.securityHeadersConfig;
this.serverTimingHeadersConfig = builder.serverTimingHeadersConfig;
this.customHeadersConfig = builder.customHeadersConfig;
this.removeHeadersConfig = builder.removeHeadersConfig;
}
/**
*
* A comment to describe the response headers policy.
*
*
* The comment cannot be longer than 128 characters.
*
*
* @return A comment to describe the response headers policy.
*
* The comment cannot be longer than 128 characters.
*/
public final String comment() {
return comment;
}
/**
*
* A name to identify the response headers policy.
*
*
* The name must be unique for response headers policies in this Amazon Web Services account.
*
*
* @return A name to identify the response headers policy.
*
* The name must be unique for response headers policies in this Amazon Web Services account.
*/
public final String name() {
return name;
}
/**
*
* A configuration for a set of HTTP response headers that are used for cross-origin resource sharing (CORS).
*
*
* @return A configuration for a set of HTTP response headers that are used for cross-origin resource sharing
* (CORS).
*/
public final ResponseHeadersPolicyCorsConfig corsConfig() {
return corsConfig;
}
/**
*
* A configuration for a set of security-related HTTP response headers.
*
*
* @return A configuration for a set of security-related HTTP response headers.
*/
public final ResponseHeadersPolicySecurityHeadersConfig securityHeadersConfig() {
return securityHeadersConfig;
}
/**
*
* A configuration for enabling the Server-Timing
header in HTTP responses sent from CloudFront.
*
*
* @return A configuration for enabling the Server-Timing
header in HTTP responses sent from
* CloudFront.
*/
public final ResponseHeadersPolicyServerTimingHeadersConfig serverTimingHeadersConfig() {
return serverTimingHeadersConfig;
}
/**
*
* A configuration for a set of custom HTTP response headers.
*
*
* @return A configuration for a set of custom HTTP response headers.
*/
public final ResponseHeadersPolicyCustomHeadersConfig customHeadersConfig() {
return customHeadersConfig;
}
/**
*
* A configuration for a set of HTTP headers to remove from the HTTP response.
*
*
* @return A configuration for a set of HTTP headers to remove from the HTTP response.
*/
public final ResponseHeadersPolicyRemoveHeadersConfig removeHeadersConfig() {
return removeHeadersConfig;
}
@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(comment());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(corsConfig());
hashCode = 31 * hashCode + Objects.hashCode(securityHeadersConfig());
hashCode = 31 * hashCode + Objects.hashCode(serverTimingHeadersConfig());
hashCode = 31 * hashCode + Objects.hashCode(customHeadersConfig());
hashCode = 31 * hashCode + Objects.hashCode(removeHeadersConfig());
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 ResponseHeadersPolicyConfig)) {
return false;
}
ResponseHeadersPolicyConfig other = (ResponseHeadersPolicyConfig) obj;
return Objects.equals(comment(), other.comment()) && Objects.equals(name(), other.name())
&& Objects.equals(corsConfig(), other.corsConfig())
&& Objects.equals(securityHeadersConfig(), other.securityHeadersConfig())
&& Objects.equals(serverTimingHeadersConfig(), other.serverTimingHeadersConfig())
&& Objects.equals(customHeadersConfig(), other.customHeadersConfig())
&& Objects.equals(removeHeadersConfig(), other.removeHeadersConfig());
}
/**
* 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("ResponseHeadersPolicyConfig").add("Comment", comment()).add("Name", name())
.add("CorsConfig", corsConfig()).add("SecurityHeadersConfig", securityHeadersConfig())
.add("ServerTimingHeadersConfig", serverTimingHeadersConfig()).add("CustomHeadersConfig", customHeadersConfig())
.add("RemoveHeadersConfig", removeHeadersConfig()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Comment":
return Optional.ofNullable(clazz.cast(comment()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "CorsConfig":
return Optional.ofNullable(clazz.cast(corsConfig()));
case "SecurityHeadersConfig":
return Optional.ofNullable(clazz.cast(securityHeadersConfig()));
case "ServerTimingHeadersConfig":
return Optional.ofNullable(clazz.cast(serverTimingHeadersConfig()));
case "CustomHeadersConfig":
return Optional.ofNullable(clazz.cast(customHeadersConfig()));
case "RemoveHeadersConfig":
return Optional.ofNullable(clazz.cast(removeHeadersConfig()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function