All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.kms.model.KeyMetadata Maven / Gradle / Ivy

/*
 * Copyright 2014-2019 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.io.Serializable;
import java.time.Instant;
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;

/**
 * 

* Contains metadata about a customer master key (CMK). *

*

* This data type is used as a response element for the CreateKey and DescribeKey operations. *

*/ @Generated("software.amazon.awssdk:codegen") public final class KeyMetadata implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField AWS_ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::awsAccountId)).setter(setter(Builder::awsAccountId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AWSAccountId").build()).build(); private static final SdkField KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::keyId)).setter(setter(Builder::keyId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyId").build()).build(); private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::arn)).setter(setter(Builder::arn)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build(); private static final SdkField CREATION_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT) .getter(getter(KeyMetadata::creationDate)).setter(setter(Builder::creationDate)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreationDate").build()).build(); private static final SdkField ENABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .getter(getter(KeyMetadata::enabled)).setter(setter(Builder::enabled)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Enabled").build()).build(); private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::description)).setter(setter(Builder::description)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build(); private static final SdkField KEY_USAGE_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::keyUsageAsString)).setter(setter(Builder::keyUsage)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyUsage").build()).build(); private static final SdkField KEY_STATE_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::keyStateAsString)).setter(setter(Builder::keyState)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyState").build()).build(); private static final SdkField DELETION_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT) .getter(getter(KeyMetadata::deletionDate)).setter(setter(Builder::deletionDate)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeletionDate").build()).build(); private static final SdkField VALID_TO_FIELD = SdkField. builder(MarshallingType.INSTANT) .getter(getter(KeyMetadata::validTo)).setter(setter(Builder::validTo)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ValidTo").build()).build(); private static final SdkField ORIGIN_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::originAsString)).setter(setter(Builder::origin)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Origin").build()).build(); private static final SdkField CUSTOM_KEY_STORE_ID_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::customKeyStoreId)).setter(setter(Builder::customKeyStoreId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CustomKeyStoreId").build()).build(); private static final SdkField CLOUD_HSM_CLUSTER_ID_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::cloudHsmClusterId)).setter(setter(Builder::cloudHsmClusterId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CloudHsmClusterId").build()).build(); private static final SdkField EXPIRATION_MODEL_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::expirationModelAsString)).setter(setter(Builder::expirationModel)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExpirationModel").build()).build(); private static final SdkField KEY_MANAGER_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(KeyMetadata::keyManagerAsString)).setter(setter(Builder::keyManager)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyManager").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AWS_ACCOUNT_ID_FIELD, KEY_ID_FIELD, ARN_FIELD, CREATION_DATE_FIELD, ENABLED_FIELD, DESCRIPTION_FIELD, KEY_USAGE_FIELD, KEY_STATE_FIELD, DELETION_DATE_FIELD, VALID_TO_FIELD, ORIGIN_FIELD, CUSTOM_KEY_STORE_ID_FIELD, CLOUD_HSM_CLUSTER_ID_FIELD, EXPIRATION_MODEL_FIELD, KEY_MANAGER_FIELD)); private static final long serialVersionUID = 1L; private final String awsAccountId; private final String keyId; private final String arn; private final Instant creationDate; private final Boolean enabled; private final String description; private final String keyUsage; private final String keyState; private final Instant deletionDate; private final Instant validTo; private final String origin; private final String customKeyStoreId; private final String cloudHsmClusterId; private final String expirationModel; private final String keyManager; private KeyMetadata(BuilderImpl builder) { this.awsAccountId = builder.awsAccountId; this.keyId = builder.keyId; this.arn = builder.arn; this.creationDate = builder.creationDate; this.enabled = builder.enabled; this.description = builder.description; this.keyUsage = builder.keyUsage; this.keyState = builder.keyState; this.deletionDate = builder.deletionDate; this.validTo = builder.validTo; this.origin = builder.origin; this.customKeyStoreId = builder.customKeyStoreId; this.cloudHsmClusterId = builder.cloudHsmClusterId; this.expirationModel = builder.expirationModel; this.keyManager = builder.keyManager; } /** *

* The twelve-digit account ID of the AWS account that owns the CMK. *

* * @return The twelve-digit account ID of the AWS account that owns the CMK. */ public String awsAccountId() { return awsAccountId; } /** *

* The globally unique identifier for the CMK. *

* * @return The globally unique identifier for the CMK. */ public String keyId() { return keyId; } /** *

* The Amazon Resource Name (ARN) of the CMK. For examples, see AWS Key * Management Service (AWS KMS) in the Example ARNs section of the AWS General Reference. *

* * @return The Amazon Resource Name (ARN) of the CMK. For examples, see AWS Key * Management Service (AWS KMS) in the Example ARNs section of the AWS General Reference. */ public String arn() { return arn; } /** *

* The date and time when the CMK was created. *

* * @return The date and time when the CMK was created. */ public Instant creationDate() { return creationDate; } /** *

* Specifies whether the CMK is enabled. When KeyState is Enabled this value is true, * otherwise it is false. *

* * @return Specifies whether the CMK is enabled. When KeyState is Enabled this value is * true, otherwise it is false. */ public Boolean enabled() { return enabled; } /** *

* The description of the CMK. *

* * @return The description of the CMK. */ public String description() { return description; } /** *

* The cryptographic operations for which you can use the CMK. The only valid value is ENCRYPT_DECRYPT, * which means you can use the CMK to encrypt and decrypt data. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #keyUsage} will * return {@link KeyUsageType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #keyUsageAsString}. *

* * @return The cryptographic operations for which you can use the CMK. The only valid value is * ENCRYPT_DECRYPT, which means you can use the CMK to encrypt and decrypt data. * @see KeyUsageType */ public KeyUsageType keyUsage() { return KeyUsageType.fromValue(keyUsage); } /** *

* The cryptographic operations for which you can use the CMK. The only valid value is ENCRYPT_DECRYPT, * which means you can use the CMK to encrypt and decrypt data. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #keyUsage} will * return {@link KeyUsageType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #keyUsageAsString}. *

* * @return The cryptographic operations for which you can use the CMK. The only valid value is * ENCRYPT_DECRYPT, which means you can use the CMK to encrypt and decrypt data. * @see KeyUsageType */ public String keyUsageAsString() { return keyUsage; } /** *

* The state of the CMK. *

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the Use of a * Customer Master Key in the AWS Key Management Service Developer Guide. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #keyState} will * return {@link KeyState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #keyStateAsString}. *

* * @return The state of the CMK.

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the Use * of a Customer Master Key in the AWS Key Management Service Developer Guide. * @see KeyState */ public KeyState keyState() { return KeyState.fromValue(keyState); } /** *

* The state of the CMK. *

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the Use of a * Customer Master Key in the AWS Key Management Service Developer Guide. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #keyState} will * return {@link KeyState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #keyStateAsString}. *

* * @return The state of the CMK.

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the Use * of a Customer Master Key in the AWS Key Management Service Developer Guide. * @see KeyState */ public String keyStateAsString() { return keyState; } /** *

* The date and time after which AWS KMS deletes the CMK. This value is present only when KeyState is * PendingDeletion. *

* * @return The date and time after which AWS KMS deletes the CMK. This value is present only when * KeyState is PendingDeletion. */ public Instant deletionDate() { return deletionDate; } /** *

* The time at which the imported key material expires. When the key material expires, AWS KMS deletes the key * material and the CMK becomes unusable. This value is present only for CMKs whose Origin is * EXTERNAL and whose ExpirationModel is KEY_MATERIAL_EXPIRES, otherwise this * value is omitted. *

* * @return The time at which the imported key material expires. When the key material expires, AWS KMS deletes the * key material and the CMK becomes unusable. This value is present only for CMKs whose Origin * is EXTERNAL and whose ExpirationModel is KEY_MATERIAL_EXPIRES, * otherwise this value is omitted. */ public Instant validTo() { return validTo; } /** *

* The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key material. * When this value is EXTERNAL, the key material was imported from your existing key management * infrastructure or the CMK lacks key material. When this value is AWS_CLOUDHSM, the key material was * created in the AWS CloudHSM cluster associated with a custom key store. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #origin} will * return {@link OriginType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #originAsString}. *

* * @return The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key * material. When this value is EXTERNAL, the key material was imported from your existing key * management infrastructure or the CMK lacks key material. When this value is AWS_CLOUDHSM, * the key material was created in the AWS CloudHSM cluster associated with a custom key store. * @see OriginType */ public OriginType origin() { return OriginType.fromValue(origin); } /** *

* The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key material. * When this value is EXTERNAL, the key material was imported from your existing key management * infrastructure or the CMK lacks key material. When this value is AWS_CLOUDHSM, the key material was * created in the AWS CloudHSM cluster associated with a custom key store. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #origin} will * return {@link OriginType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #originAsString}. *

* * @return The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key * material. When this value is EXTERNAL, the key material was imported from your existing key * management infrastructure or the CMK lacks key material. When this value is AWS_CLOUDHSM, * the key material was created in the AWS CloudHSM cluster associated with a custom key store. * @see OriginType */ public String originAsString() { return origin; } /** *

* A unique identifier for the custom key store * that contains the CMK. This value is present only when the CMK is created in a custom key store. *

* * @return A unique identifier for the custom key * store that contains the CMK. This value is present only when the CMK is created in a custom key * store. */ public String customKeyStoreId() { return customKeyStoreId; } /** *

* The cluster ID of the AWS CloudHSM cluster that contains the key material for the CMK. When you create a CMK in a * custom key * store, AWS KMS creates the key material for the CMK in the associated AWS CloudHSM cluster. This value is * present only when the CMK is created in a custom key store. *

* * @return The cluster ID of the AWS CloudHSM cluster that contains the key material for the CMK. When you create a * CMK in a custom key * store, AWS KMS creates the key material for the CMK in the associated AWS CloudHSM cluster. This * value is present only when the CMK is created in a custom key store. */ public String cloudHsmClusterId() { return cloudHsmClusterId; } /** *

* Specifies whether the CMK's key material expires. This value is present only when Origin is * EXTERNAL, otherwise this value is omitted. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #expirationModel} * will return {@link ExpirationModelType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is * available from {@link #expirationModelAsString}. *

* * @return Specifies whether the CMK's key material expires. This value is present only when Origin is * EXTERNAL, otherwise this value is omitted. * @see ExpirationModelType */ public ExpirationModelType expirationModel() { return ExpirationModelType.fromValue(expirationModel); } /** *

* Specifies whether the CMK's key material expires. This value is present only when Origin is * EXTERNAL, otherwise this value is omitted. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #expirationModel} * will return {@link ExpirationModelType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is * available from {@link #expirationModelAsString}. *

* * @return Specifies whether the CMK's key material expires. This value is present only when Origin is * EXTERNAL, otherwise this value is omitted. * @see ExpirationModelType */ public String expirationModelAsString() { return expirationModel; } /** *

* The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more information * about the difference, see Customer Master Keys * in the AWS Key Management Service Developer Guide. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #keyManager} will * return {@link KeyManagerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #keyManagerAsString}. *

* * @return The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more * information about the difference, see Customer Master * Keys in the AWS Key Management Service Developer Guide. * @see KeyManagerType */ public KeyManagerType keyManager() { return KeyManagerType.fromValue(keyManager); } /** *

* The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more information * about the difference, see Customer Master Keys * in the AWS Key Management Service Developer Guide. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #keyManager} will * return {@link KeyManagerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #keyManagerAsString}. *

* * @return The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more * information about the difference, see Customer Master * Keys in the AWS Key Management Service Developer Guide. * @see KeyManagerType */ public String keyManagerAsString() { return keyManager; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(awsAccountId()); hashCode = 31 * hashCode + Objects.hashCode(keyId()); hashCode = 31 * hashCode + Objects.hashCode(arn()); hashCode = 31 * hashCode + Objects.hashCode(creationDate()); hashCode = 31 * hashCode + Objects.hashCode(enabled()); hashCode = 31 * hashCode + Objects.hashCode(description()); hashCode = 31 * hashCode + Objects.hashCode(keyUsageAsString()); hashCode = 31 * hashCode + Objects.hashCode(keyStateAsString()); hashCode = 31 * hashCode + Objects.hashCode(deletionDate()); hashCode = 31 * hashCode + Objects.hashCode(validTo()); hashCode = 31 * hashCode + Objects.hashCode(originAsString()); hashCode = 31 * hashCode + Objects.hashCode(customKeyStoreId()); hashCode = 31 * hashCode + Objects.hashCode(cloudHsmClusterId()); hashCode = 31 * hashCode + Objects.hashCode(expirationModelAsString()); hashCode = 31 * hashCode + Objects.hashCode(keyManagerAsString()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof KeyMetadata)) { return false; } KeyMetadata other = (KeyMetadata) obj; return Objects.equals(awsAccountId(), other.awsAccountId()) && Objects.equals(keyId(), other.keyId()) && Objects.equals(arn(), other.arn()) && Objects.equals(creationDate(), other.creationDate()) && Objects.equals(enabled(), other.enabled()) && Objects.equals(description(), other.description()) && Objects.equals(keyUsageAsString(), other.keyUsageAsString()) && Objects.equals(keyStateAsString(), other.keyStateAsString()) && Objects.equals(deletionDate(), other.deletionDate()) && Objects.equals(validTo(), other.validTo()) && Objects.equals(originAsString(), other.originAsString()) && Objects.equals(customKeyStoreId(), other.customKeyStoreId()) && Objects.equals(cloudHsmClusterId(), other.cloudHsmClusterId()) && Objects.equals(expirationModelAsString(), other.expirationModelAsString()) && Objects.equals(keyManagerAsString(), other.keyManagerAsString()); } /** * 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 String toString() { return ToString.builder("KeyMetadata").add("AWSAccountId", awsAccountId()).add("KeyId", keyId()).add("Arn", arn()) .add("CreationDate", creationDate()).add("Enabled", enabled()).add("Description", description()) .add("KeyUsage", keyUsageAsString()).add("KeyState", keyStateAsString()).add("DeletionDate", deletionDate()) .add("ValidTo", validTo()).add("Origin", originAsString()).add("CustomKeyStoreId", customKeyStoreId()) .add("CloudHsmClusterId", cloudHsmClusterId()).add("ExpirationModel", expirationModelAsString()) .add("KeyManager", keyManagerAsString()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "AWSAccountId": return Optional.ofNullable(clazz.cast(awsAccountId())); case "KeyId": return Optional.ofNullable(clazz.cast(keyId())); case "Arn": return Optional.ofNullable(clazz.cast(arn())); case "CreationDate": return Optional.ofNullable(clazz.cast(creationDate())); case "Enabled": return Optional.ofNullable(clazz.cast(enabled())); case "Description": return Optional.ofNullable(clazz.cast(description())); case "KeyUsage": return Optional.ofNullable(clazz.cast(keyUsageAsString())); case "KeyState": return Optional.ofNullable(clazz.cast(keyStateAsString())); case "DeletionDate": return Optional.ofNullable(clazz.cast(deletionDate())); case "ValidTo": return Optional.ofNullable(clazz.cast(validTo())); case "Origin": return Optional.ofNullable(clazz.cast(originAsString())); case "CustomKeyStoreId": return Optional.ofNullable(clazz.cast(customKeyStoreId())); case "CloudHsmClusterId": return Optional.ofNullable(clazz.cast(cloudHsmClusterId())); case "ExpirationModel": return Optional.ofNullable(clazz.cast(expirationModelAsString())); case "KeyManager": return Optional.ofNullable(clazz.cast(keyManagerAsString())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((KeyMetadata) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The twelve-digit account ID of the AWS account that owns the CMK. *

* * @param awsAccountId * The twelve-digit account ID of the AWS account that owns the CMK. * @return Returns a reference to this object so that method calls can be chained together. */ Builder awsAccountId(String awsAccountId); /** *

* The globally unique identifier for the CMK. *

* * @param keyId * The globally unique identifier for the CMK. * @return Returns a reference to this object so that method calls can be chained together. */ Builder keyId(String keyId); /** *

* The Amazon Resource Name (ARN) of the CMK. For examples, see AWS Key * Management Service (AWS KMS) in the Example ARNs section of the AWS General Reference. *

* * @param arn * The Amazon Resource Name (ARN) of the CMK. For examples, see AWS * Key Management Service (AWS KMS) in the Example ARNs section of the AWS General Reference. * @return Returns a reference to this object so that method calls can be chained together. */ Builder arn(String arn); /** *

* The date and time when the CMK was created. *

* * @param creationDate * The date and time when the CMK was created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder creationDate(Instant creationDate); /** *

* Specifies whether the CMK is enabled. When KeyState is Enabled this value is true, * otherwise it is false. *

* * @param enabled * Specifies whether the CMK is enabled. When KeyState is Enabled this value is * true, otherwise it is false. * @return Returns a reference to this object so that method calls can be chained together. */ Builder enabled(Boolean enabled); /** *

* The description of the CMK. *

* * @param description * The description of the CMK. * @return Returns a reference to this object so that method calls can be chained together. */ Builder description(String description); /** *

* The cryptographic operations for which you can use the CMK. The only valid value is * ENCRYPT_DECRYPT, which means you can use the CMK to encrypt and decrypt data. *

* * @param keyUsage * The cryptographic operations for which you can use the CMK. The only valid value is * ENCRYPT_DECRYPT, which means you can use the CMK to encrypt and decrypt data. * @see KeyUsageType * @return Returns a reference to this object so that method calls can be chained together. * @see KeyUsageType */ Builder keyUsage(String keyUsage); /** *

* The cryptographic operations for which you can use the CMK. The only valid value is * ENCRYPT_DECRYPT, which means you can use the CMK to encrypt and decrypt data. *

* * @param keyUsage * The cryptographic operations for which you can use the CMK. The only valid value is * ENCRYPT_DECRYPT, which means you can use the CMK to encrypt and decrypt data. * @see KeyUsageType * @return Returns a reference to this object so that method calls can be chained together. * @see KeyUsageType */ Builder keyUsage(KeyUsageType keyUsage); /** *

* The state of the CMK. *

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the Use of * a Customer Master Key in the AWS Key Management Service Developer Guide. *

* * @param keyState * The state of the CMK.

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the * Use of a Customer Master Key in the AWS Key Management Service Developer Guide. * @see KeyState * @return Returns a reference to this object so that method calls can be chained together. * @see KeyState */ Builder keyState(String keyState); /** *

* The state of the CMK. *

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the Use of * a Customer Master Key in the AWS Key Management Service Developer Guide. *

* * @param keyState * The state of the CMK.

*

* For more information about how key state affects the use of a CMK, see How Key State Affects the * Use of a Customer Master Key in the AWS Key Management Service Developer Guide. * @see KeyState * @return Returns a reference to this object so that method calls can be chained together. * @see KeyState */ Builder keyState(KeyState keyState); /** *

* The date and time after which AWS KMS deletes the CMK. This value is present only when KeyState * is PendingDeletion. *

* * @param deletionDate * The date and time after which AWS KMS deletes the CMK. This value is present only when * KeyState is PendingDeletion. * @return Returns a reference to this object so that method calls can be chained together. */ Builder deletionDate(Instant deletionDate); /** *

* The time at which the imported key material expires. When the key material expires, AWS KMS deletes the key * material and the CMK becomes unusable. This value is present only for CMKs whose Origin is * EXTERNAL and whose ExpirationModel is KEY_MATERIAL_EXPIRES, otherwise * this value is omitted. *

* * @param validTo * The time at which the imported key material expires. When the key material expires, AWS KMS deletes * the key material and the CMK becomes unusable. This value is present only for CMKs whose * Origin is EXTERNAL and whose ExpirationModel is * KEY_MATERIAL_EXPIRES, otherwise this value is omitted. * @return Returns a reference to this object so that method calls can be chained together. */ Builder validTo(Instant validTo); /** *

* The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key * material. When this value is EXTERNAL, the key material was imported from your existing key * management infrastructure or the CMK lacks key material. When this value is AWS_CLOUDHSM, the * key material was created in the AWS CloudHSM cluster associated with a custom key store. *

* * @param origin * The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key * material. When this value is EXTERNAL, the key material was imported from your existing * key management infrastructure or the CMK lacks key material. When this value is * AWS_CLOUDHSM, the key material was created in the AWS CloudHSM cluster associated with a * custom key store. * @see OriginType * @return Returns a reference to this object so that method calls can be chained together. * @see OriginType */ Builder origin(String origin); /** *

* The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key * material. When this value is EXTERNAL, the key material was imported from your existing key * management infrastructure or the CMK lacks key material. When this value is AWS_CLOUDHSM, the * key material was created in the AWS CloudHSM cluster associated with a custom key store. *

* * @param origin * The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key * material. When this value is EXTERNAL, the key material was imported from your existing * key management infrastructure or the CMK lacks key material. When this value is * AWS_CLOUDHSM, the key material was created in the AWS CloudHSM cluster associated with a * custom key store. * @see OriginType * @return Returns a reference to this object so that method calls can be chained together. * @see OriginType */ Builder origin(OriginType origin); /** *

* A unique identifier for the custom key * store that contains the CMK. This value is present only when the CMK is created in a custom key store. *

* * @param customKeyStoreId * A unique identifier for the custom key * store that contains the CMK. This value is present only when the CMK is created in a custom key * store. * @return Returns a reference to this object so that method calls can be chained together. */ Builder customKeyStoreId(String customKeyStoreId); /** *

* The cluster ID of the AWS CloudHSM cluster that contains the key material for the CMK. When you create a CMK * in a custom * key store, AWS KMS creates the key material for the CMK in the associated AWS CloudHSM cluster. This * value is present only when the CMK is created in a custom key store. *

* * @param cloudHsmClusterId * The cluster ID of the AWS CloudHSM cluster that contains the key material for the CMK. When you create * a CMK in a custom key * store, AWS KMS creates the key material for the CMK in the associated AWS CloudHSM cluster. This * value is present only when the CMK is created in a custom key store. * @return Returns a reference to this object so that method calls can be chained together. */ Builder cloudHsmClusterId(String cloudHsmClusterId); /** *

* Specifies whether the CMK's key material expires. This value is present only when Origin is * EXTERNAL, otherwise this value is omitted. *

* * @param expirationModel * Specifies whether the CMK's key material expires. This value is present only when Origin * is EXTERNAL, otherwise this value is omitted. * @see ExpirationModelType * @return Returns a reference to this object so that method calls can be chained together. * @see ExpirationModelType */ Builder expirationModel(String expirationModel); /** *

* Specifies whether the CMK's key material expires. This value is present only when Origin is * EXTERNAL, otherwise this value is omitted. *

* * @param expirationModel * Specifies whether the CMK's key material expires. This value is present only when Origin * is EXTERNAL, otherwise this value is omitted. * @see ExpirationModelType * @return Returns a reference to this object so that method calls can be chained together. * @see ExpirationModelType */ Builder expirationModel(ExpirationModelType expirationModel); /** *

* The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more * information about the difference, see Customer Master * Keys in the AWS Key Management Service Developer Guide. *

* * @param keyManager * The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more * information about the difference, see Customer Master * Keys in the AWS Key Management Service Developer Guide. * @see KeyManagerType * @return Returns a reference to this object so that method calls can be chained together. * @see KeyManagerType */ Builder keyManager(String keyManager); /** *

* The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more * information about the difference, see Customer Master * Keys in the AWS Key Management Service Developer Guide. *

* * @param keyManager * The manager of the CMK. CMKs in your AWS account are either customer managed or AWS managed. For more * information about the difference, see Customer Master * Keys in the AWS Key Management Service Developer Guide. * @see KeyManagerType * @return Returns a reference to this object so that method calls can be chained together. * @see KeyManagerType */ Builder keyManager(KeyManagerType keyManager); } static final class BuilderImpl implements Builder { private String awsAccountId; private String keyId; private String arn; private Instant creationDate; private Boolean enabled; private String description; private String keyUsage; private String keyState; private Instant deletionDate; private Instant validTo; private String origin; private String customKeyStoreId; private String cloudHsmClusterId; private String expirationModel; private String keyManager; private BuilderImpl() { } private BuilderImpl(KeyMetadata model) { awsAccountId(model.awsAccountId); keyId(model.keyId); arn(model.arn); creationDate(model.creationDate); enabled(model.enabled); description(model.description); keyUsage(model.keyUsage); keyState(model.keyState); deletionDate(model.deletionDate); validTo(model.validTo); origin(model.origin); customKeyStoreId(model.customKeyStoreId); cloudHsmClusterId(model.cloudHsmClusterId); expirationModel(model.expirationModel); keyManager(model.keyManager); } public final String getAwsAccountId() { return awsAccountId; } @Override public final Builder awsAccountId(String awsAccountId) { this.awsAccountId = awsAccountId; return this; } public final void setAwsAccountId(String awsAccountId) { this.awsAccountId = awsAccountId; } public final String getKeyId() { return keyId; } @Override public final Builder keyId(String keyId) { this.keyId = keyId; return this; } public final void setKeyId(String keyId) { this.keyId = keyId; } public final String getArn() { return arn; } @Override public final Builder arn(String arn) { this.arn = arn; return this; } public final void setArn(String arn) { this.arn = arn; } public final Instant getCreationDate() { return creationDate; } @Override public final Builder creationDate(Instant creationDate) { this.creationDate = creationDate; return this; } public final void setCreationDate(Instant creationDate) { this.creationDate = creationDate; } public final Boolean getEnabled() { return enabled; } @Override public final Builder enabled(Boolean enabled) { this.enabled = enabled; return this; } public final void setEnabled(Boolean enabled) { this.enabled = enabled; } public final String getDescription() { return description; } @Override public final Builder description(String description) { this.description = description; return this; } public final void setDescription(String description) { this.description = description; } public final String getKeyUsageAsString() { return keyUsage; } @Override public final Builder keyUsage(String keyUsage) { this.keyUsage = keyUsage; return this; } @Override public final Builder keyUsage(KeyUsageType keyUsage) { this.keyUsage(keyUsage.toString()); return this; } public final void setKeyUsage(String keyUsage) { this.keyUsage = keyUsage; } public final String getKeyStateAsString() { return keyState; } @Override public final Builder keyState(String keyState) { this.keyState = keyState; return this; } @Override public final Builder keyState(KeyState keyState) { this.keyState(keyState.toString()); return this; } public final void setKeyState(String keyState) { this.keyState = keyState; } public final Instant getDeletionDate() { return deletionDate; } @Override public final Builder deletionDate(Instant deletionDate) { this.deletionDate = deletionDate; return this; } public final void setDeletionDate(Instant deletionDate) { this.deletionDate = deletionDate; } public final Instant getValidTo() { return validTo; } @Override public final Builder validTo(Instant validTo) { this.validTo = validTo; return this; } public final void setValidTo(Instant validTo) { this.validTo = validTo; } public final String getOriginAsString() { return origin; } @Override public final Builder origin(String origin) { this.origin = origin; return this; } @Override public final Builder origin(OriginType origin) { this.origin(origin.toString()); return this; } public final void setOrigin(String origin) { this.origin = origin; } public final String getCustomKeyStoreId() { return customKeyStoreId; } @Override public final Builder customKeyStoreId(String customKeyStoreId) { this.customKeyStoreId = customKeyStoreId; return this; } public final void setCustomKeyStoreId(String customKeyStoreId) { this.customKeyStoreId = customKeyStoreId; } public final String getCloudHsmClusterId() { return cloudHsmClusterId; } @Override public final Builder cloudHsmClusterId(String cloudHsmClusterId) { this.cloudHsmClusterId = cloudHsmClusterId; return this; } public final void setCloudHsmClusterId(String cloudHsmClusterId) { this.cloudHsmClusterId = cloudHsmClusterId; } public final String getExpirationModelAsString() { return expirationModel; } @Override public final Builder expirationModel(String expirationModel) { this.expirationModel = expirationModel; return this; } @Override public final Builder expirationModel(ExpirationModelType expirationModel) { this.expirationModel(expirationModel.toString()); return this; } public final void setExpirationModel(String expirationModel) { this.expirationModel = expirationModel; } public final String getKeyManagerAsString() { return keyManager; } @Override public final Builder keyManager(String keyManager) { this.keyManager = keyManager; return this; } @Override public final Builder keyManager(KeyManagerType keyManager) { this.keyManager(keyManager.toString()); return this; } public final void setKeyManager(String keyManager) { this.keyManager = keyManager; } @Override public KeyMetadata build() { return new KeyMetadata(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy