software.amazon.awssdk.services.kms.model.EnableKeyRotationRequest Maven / Gradle / Ivy
Show all versions of kms 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.kms.model;
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.awscore.AwsRequestOverrideConfiguration;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class EnableKeyRotationRequest extends KmsRequest implements
ToCopyableBuilder {
private static final SdkField KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("KeyId")
.getter(getter(EnableKeyRotationRequest::keyId)).setter(setter(Builder::keyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyId").build()).build();
private static final SdkField ROTATION_PERIOD_IN_DAYS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("RotationPeriodInDays").getter(getter(EnableKeyRotationRequest::rotationPeriodInDays))
.setter(setter(Builder::rotationPeriodInDays))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RotationPeriodInDays").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(KEY_ID_FIELD,
ROTATION_PERIOD_IN_DAYS_FIELD));
private final String keyId;
private final Integer rotationPeriodInDays;
private EnableKeyRotationRequest(BuilderImpl builder) {
super(builder);
this.keyId = builder.keyId;
this.rotationPeriodInDays = builder.rotationPeriodInDays;
}
/**
*
* Identifies a symmetric encryption KMS key. You cannot enable automatic rotation of asymmetric KMS keys,
* HMAC KMS keys, KMS keys with imported key material, or
* KMS keys in a custom key store.
* To enable or disable automatic rotation of a set of related multi-Region keys, set the property on the primary key.
*
*
* Specify the key ID or key ARN of the KMS key.
*
*
* For example:
*
*
* -
*
* Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
*
*
* -
*
* Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
*
*
*
*
* To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
*
*
* @return Identifies a symmetric encryption KMS key. You cannot enable automatic rotation of asymmetric KMS
* keys, HMAC KMS keys,
* KMS keys with imported key
* material, or KMS keys in a custom key
* store. To enable or disable automatic rotation of a set of related multi-Region keys, set the property on the primary key.
*
* Specify the key ID or key ARN of the KMS key.
*
*
* For example:
*
*
* -
*
* Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
*
*
* -
*
* Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
*
*
*
*
* To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
*/
public final String keyId() {
return keyId;
}
/**
*
* Use this parameter to specify a custom period of time between each rotation date. If no value is specified, the
* default value is 365 days.
*
*
* The rotation period defines the number of days after you enable automatic key rotation that KMS will rotate your
* key material, and the number of days between each automatic rotation thereafter.
*
*
* You can use the kms:RotationPeriodInDays
condition key to further constrain the values that principals can
* specify in the RotationPeriodInDays
parameter.
*
*
*
*
* @return Use this parameter to specify a custom period of time between each rotation date. If no value is
* specified, the default value is 365 days.
*
* The rotation period defines the number of days after you enable automatic key rotation that KMS will
* rotate your key material, and the number of days between each automatic rotation thereafter.
*
*
* You can use the kms:RotationPeriodInDays
condition key to further constrain the values that
* principals can specify in the RotationPeriodInDays
parameter.
*
*
*/
public final Integer rotationPeriodInDays() {
return rotationPeriodInDays;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(keyId());
hashCode = 31 * hashCode + Objects.hashCode(rotationPeriodInDays());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof EnableKeyRotationRequest)) {
return false;
}
EnableKeyRotationRequest other = (EnableKeyRotationRequest) obj;
return Objects.equals(keyId(), other.keyId()) && Objects.equals(rotationPeriodInDays(), other.rotationPeriodInDays());
}
/**
* 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("EnableKeyRotationRequest").add("KeyId", keyId())
.add("RotationPeriodInDays", rotationPeriodInDays()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "KeyId":
return Optional.ofNullable(clazz.cast(keyId()));
case "RotationPeriodInDays":
return Optional.ofNullable(clazz.cast(rotationPeriodInDays()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* Specify the key ID or key ARN of the KMS key.
*
*
* For example:
*
*
* -
*
* Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
*
*
* -
*
* Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
*
*
*
*
* To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder keyId(String keyId);
/**
*
* Use this parameter to specify a custom period of time between each rotation date. If no value is specified,
* the default value is 365 days.
*
*
* The rotation period defines the number of days after you enable automatic key rotation that KMS will rotate
* your key material, and the number of days between each automatic rotation thereafter.
*
*
* You can use the kms:RotationPeriodInDays
condition key to further constrain the values that principals
* can specify in the RotationPeriodInDays
parameter.
*
*
*
*
* @param rotationPeriodInDays
* Use this parameter to specify a custom period of time between each rotation date. If no value is
* specified, the default value is 365 days.
*
* The rotation period defines the number of days after you enable automatic key rotation that KMS will
* rotate your key material, and the number of days between each automatic rotation thereafter.
*
*
* You can use the kms:RotationPeriodInDays
condition key to further constrain the values that
* principals can specify in the RotationPeriodInDays
parameter.
*
*
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder rotationPeriodInDays(Integer rotationPeriodInDays);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends KmsRequest.BuilderImpl implements Builder {
private String keyId;
private Integer rotationPeriodInDays;
private BuilderImpl() {
}
private BuilderImpl(EnableKeyRotationRequest model) {
super(model);
keyId(model.keyId);
rotationPeriodInDays(model.rotationPeriodInDays);
}
public final String getKeyId() {
return keyId;
}
public final void setKeyId(String keyId) {
this.keyId = keyId;
}
@Override
public final Builder keyId(String keyId) {
this.keyId = keyId;
return this;
}
public final Integer getRotationPeriodInDays() {
return rotationPeriodInDays;
}
public final void setRotationPeriodInDays(Integer rotationPeriodInDays) {
this.rotationPeriodInDays = rotationPeriodInDays;
}
@Override
public final Builder rotationPeriodInDays(Integer rotationPeriodInDays) {
this.rotationPeriodInDays = rotationPeriodInDays;
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public EnableKeyRotationRequest build() {
return new EnableKeyRotationRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}