software.amazon.awssdk.services.cloudfront.model.OriginAccessControlConfig 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.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 CloudFront origin access control configuration.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class OriginAccessControlConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Name")
.getter(getter(OriginAccessControlConfig::name))
.setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name")
.unmarshallLocationName("Name").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Description")
.getter(getter(OriginAccessControlConfig::description))
.setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description")
.unmarshallLocationName("Description").build()).build();
private static final SdkField SIGNING_PROTOCOL_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("SigningProtocol")
.getter(getter(OriginAccessControlConfig::signingProtocolAsString))
.setter(setter(Builder::signingProtocol))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SigningProtocol")
.unmarshallLocationName("SigningProtocol").build()).build();
private static final SdkField SIGNING_BEHAVIOR_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("SigningBehavior")
.getter(getter(OriginAccessControlConfig::signingBehaviorAsString))
.setter(setter(Builder::signingBehavior))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SigningBehavior")
.unmarshallLocationName("SigningBehavior").build()).build();
private static final SdkField ORIGIN_ACCESS_CONTROL_ORIGIN_TYPE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("OriginAccessControlOriginType")
.getter(getter(OriginAccessControlConfig::originAccessControlOriginTypeAsString))
.setter(setter(Builder::originAccessControlOriginType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("OriginAccessControlOriginType")
.unmarshallLocationName("OriginAccessControlOriginType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, DESCRIPTION_FIELD,
SIGNING_PROTOCOL_FIELD, SIGNING_BEHAVIOR_FIELD, ORIGIN_ACCESS_CONTROL_ORIGIN_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String description;
private final String signingProtocol;
private final String signingBehavior;
private final String originAccessControlOriginType;
private OriginAccessControlConfig(BuilderImpl builder) {
this.name = builder.name;
this.description = builder.description;
this.signingProtocol = builder.signingProtocol;
this.signingBehavior = builder.signingBehavior;
this.originAccessControlOriginType = builder.originAccessControlOriginType;
}
/**
*
* A name to identify the origin access control.
*
*
* @return A name to identify the origin access control.
*/
public final String name() {
return name;
}
/**
*
* A description of the origin access control.
*
*
* @return A description of the origin access control.
*/
public final String description() {
return description;
}
/**
*
* The signing protocol of the origin access control, which determines how CloudFront signs (authenticates)
* requests. The only valid value is sigv4
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #signingProtocol}
* will return {@link OriginAccessControlSigningProtocols#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #signingProtocolAsString}.
*
*
* @return The signing protocol of the origin access control, which determines how CloudFront signs (authenticates)
* requests. The only valid value is sigv4
.
* @see OriginAccessControlSigningProtocols
*/
public final OriginAccessControlSigningProtocols signingProtocol() {
return OriginAccessControlSigningProtocols.fromValue(signingProtocol);
}
/**
*
* The signing protocol of the origin access control, which determines how CloudFront signs (authenticates)
* requests. The only valid value is sigv4
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #signingProtocol}
* will return {@link OriginAccessControlSigningProtocols#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #signingProtocolAsString}.
*
*
* @return The signing protocol of the origin access control, which determines how CloudFront signs (authenticates)
* requests. The only valid value is sigv4
.
* @see OriginAccessControlSigningProtocols
*/
public final String signingProtocolAsString() {
return signingProtocol;
}
/**
*
* Specifies which requests CloudFront signs (adds authentication information to). Specify always
for
* the most common use case. For more information, see origin access control advanced settings in the Amazon CloudFront Developer Guide.
*
*
* This field can have one of the following values:
*
*
* -
*
* always
– CloudFront signs all origin requests, overwriting the Authorization
header
* from the viewer request if one exists.
*
*
* -
*
* never
– CloudFront doesn't sign any origin requests. This value turns off origin access control for
* all origins in all distributions that use this origin access control.
*
*
* -
*
* no-override
– If the viewer request doesn't contain the Authorization
header, then
* CloudFront signs the origin request. If the viewer request contains the Authorization
header, then
* CloudFront doesn't sign the origin request and instead passes along the Authorization
header from
* the viewer request. WARNING: To pass along the Authorization
header from the viewer request, you
* must add the Authorization
header to a cache
* policy for all cache behaviors that use origins associated with this origin access control.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #signingBehavior}
* will return {@link OriginAccessControlSigningBehaviors#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #signingBehaviorAsString}.
*
*
* @return Specifies which requests CloudFront signs (adds authentication information to). Specify
* always
for the most common use case. For more information, see origin access control advanced settings in the Amazon CloudFront Developer Guide.
*
* This field can have one of the following values:
*
*
* -
*
* always
– CloudFront signs all origin requests, overwriting the Authorization
* header from the viewer request if one exists.
*
*
* -
*
* never
– CloudFront doesn't sign any origin requests. This value turns off origin access
* control for all origins in all distributions that use this origin access control.
*
*
* -
*
* no-override
– If the viewer request doesn't contain the Authorization
header,
* then CloudFront signs the origin request. If the viewer request contains the Authorization
* header, then CloudFront doesn't sign the origin request and instead passes along the
* Authorization
header from the viewer request. WARNING: To pass along the
* Authorization
header from the viewer request, you must add the
* Authorization
header to a cache policy for all cache behaviors that use origins associated with this origin access
* control.
*
*
* @see OriginAccessControlSigningBehaviors
*/
public final OriginAccessControlSigningBehaviors signingBehavior() {
return OriginAccessControlSigningBehaviors.fromValue(signingBehavior);
}
/**
*
* Specifies which requests CloudFront signs (adds authentication information to). Specify always
for
* the most common use case. For more information, see origin access control advanced settings in the Amazon CloudFront Developer Guide.
*
*
* This field can have one of the following values:
*
*
* -
*
* always
– CloudFront signs all origin requests, overwriting the Authorization
header
* from the viewer request if one exists.
*
*
* -
*
* never
– CloudFront doesn't sign any origin requests. This value turns off origin access control for
* all origins in all distributions that use this origin access control.
*
*
* -
*
* no-override
– If the viewer request doesn't contain the Authorization
header, then
* CloudFront signs the origin request. If the viewer request contains the Authorization
header, then
* CloudFront doesn't sign the origin request and instead passes along the Authorization
header from
* the viewer request. WARNING: To pass along the Authorization
header from the viewer request, you
* must add the Authorization
header to a cache
* policy for all cache behaviors that use origins associated with this origin access control.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #signingBehavior}
* will return {@link OriginAccessControlSigningBehaviors#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #signingBehaviorAsString}.
*
*
* @return Specifies which requests CloudFront signs (adds authentication information to). Specify
* always
for the most common use case. For more information, see origin access control advanced settings in the Amazon CloudFront Developer Guide.
*
* This field can have one of the following values:
*
*
* -
*
* always
– CloudFront signs all origin requests, overwriting the Authorization
* header from the viewer request if one exists.
*
*
* -
*
* never
– CloudFront doesn't sign any origin requests. This value turns off origin access
* control for all origins in all distributions that use this origin access control.
*
*
* -
*
* no-override
– If the viewer request doesn't contain the Authorization
header,
* then CloudFront signs the origin request. If the viewer request contains the Authorization
* header, then CloudFront doesn't sign the origin request and instead passes along the
* Authorization
header from the viewer request. WARNING: To pass along the
* Authorization
header from the viewer request, you must add the
* Authorization
header to a cache policy for all cache behaviors that use origins associated with this origin access
* control.
*
*
* @see OriginAccessControlSigningBehaviors
*/
public final String signingBehaviorAsString() {
return signingBehavior;
}
/**
*
* The type of origin that this origin access control is for.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #originAccessControlOriginType} will return {@link OriginAccessControlOriginTypes#UNKNOWN_TO_SDK_VERSION}.
* The raw value returned by the service is available from {@link #originAccessControlOriginTypeAsString}.
*
*
* @return The type of origin that this origin access control is for.
* @see OriginAccessControlOriginTypes
*/
public final OriginAccessControlOriginTypes originAccessControlOriginType() {
return OriginAccessControlOriginTypes.fromValue(originAccessControlOriginType);
}
/**
*
* The type of origin that this origin access control is for.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #originAccessControlOriginType} will return {@link OriginAccessControlOriginTypes#UNKNOWN_TO_SDK_VERSION}.
* The raw value returned by the service is available from {@link #originAccessControlOriginTypeAsString}.
*
*
* @return The type of origin that this origin access control is for.
* @see OriginAccessControlOriginTypes
*/
public final String originAccessControlOriginTypeAsString() {
return originAccessControlOriginType;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(signingProtocolAsString());
hashCode = 31 * hashCode + Objects.hashCode(signingBehaviorAsString());
hashCode = 31 * hashCode + Objects.hashCode(originAccessControlOriginTypeAsString());
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 OriginAccessControlConfig)) {
return false;
}
OriginAccessControlConfig other = (OriginAccessControlConfig) obj;
return Objects.equals(name(), other.name()) && Objects.equals(description(), other.description())
&& Objects.equals(signingProtocolAsString(), other.signingProtocolAsString())
&& Objects.equals(signingBehaviorAsString(), other.signingBehaviorAsString())
&& Objects.equals(originAccessControlOriginTypeAsString(), other.originAccessControlOriginTypeAsString());
}
/**
* 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("OriginAccessControlConfig").add("Name", name()).add("Description", description())
.add("SigningProtocol", signingProtocolAsString()).add("SigningBehavior", signingBehaviorAsString())
.add("OriginAccessControlOriginType", originAccessControlOriginTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "SigningProtocol":
return Optional.ofNullable(clazz.cast(signingProtocolAsString()));
case "SigningBehavior":
return Optional.ofNullable(clazz.cast(signingBehaviorAsString()));
case "OriginAccessControlOriginType":
return Optional.ofNullable(clazz.cast(originAccessControlOriginTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function