software.amazon.awssdk.services.s3.model.EncryptionConfiguration 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.s3.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;
/**
*
* Specifies encryption-related information for an Amazon S3 bucket that is a destination for replicated objects.
*
*
*
* If you're specifying a customer managed KMS key, we recommend using a fully qualified KMS key ARN. If you use a KMS
* key alias instead, then KMS resolves the key within the requester’s account. This behavior can result in data that's
* encrypted with a KMS key that belongs to the requester, and not the bucket owner.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class EncryptionConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField REPLICA_KMS_KEY_ID_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ReplicaKmsKeyID")
.getter(getter(EncryptionConfiguration::replicaKmsKeyID))
.setter(setter(Builder::replicaKmsKeyID))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaKmsKeyID")
.unmarshallLocationName("ReplicaKmsKeyID").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(REPLICA_KMS_KEY_ID_FIELD));
private static final long serialVersionUID = 1L;
private final String replicaKmsKeyID;
private EncryptionConfiguration(BuilderImpl builder) {
this.replicaKmsKeyID = builder.replicaKmsKeyID;
}
/**
*
* Specifies the ID (Key ARN or Alias ARN) of the customer managed Amazon Web Services KMS key stored in Amazon Web
* Services Key Management Service (KMS) for the destination bucket. Amazon S3 uses this key to encrypt replica
* objects. Amazon S3 only supports symmetric encryption KMS keys. For more information, see Asymmetric keys in Amazon
* Web Services KMS in the Amazon Web Services Key Management Service Developer Guide.
*
*
* @return Specifies the ID (Key ARN or Alias ARN) of the customer managed Amazon Web Services KMS key stored in
* Amazon Web Services Key Management Service (KMS) for the destination bucket. Amazon S3 uses this key to
* encrypt replica objects. Amazon S3 only supports symmetric encryption KMS keys. For more information, see
* Asymmetric keys
* in Amazon Web Services KMS in the Amazon Web Services Key Management Service Developer Guide.
*/
public final String replicaKmsKeyID() {
return replicaKmsKeyID;
}
@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(replicaKmsKeyID());
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 EncryptionConfiguration)) {
return false;
}
EncryptionConfiguration other = (EncryptionConfiguration) obj;
return Objects.equals(replicaKmsKeyID(), other.replicaKmsKeyID());
}
/**
* 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("EncryptionConfiguration").add("ReplicaKmsKeyID", replicaKmsKeyID()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ReplicaKmsKeyID":
return Optional.ofNullable(clazz.cast(replicaKmsKeyID()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function