/* * Copyright 2010-2023 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 com.amazonaws.services.kms.model; import java.io.Serializable; import com.amazonaws.AmazonWebServiceRequest; /** *

* Provides detailed information about a KMS key. You can run * DescribeKey on a customer managed key or an Amazon Web Services managed key. *

*

* This detailed information includes the key ARN, creation date (and deletion * date, if applicable), the key state, and the origin and expiration date (if * any) of the key material. It includes fields, like KeySpec, that * help you distinguish different types of KMS keys. It also displays the key * usage (encryption, signing, or generating and verifying MACs) and the * algorithms that the KMS key supports. *

*

* For multi-Region * keys, DescribeKey displays the primary key and all related * replica keys. For KMS keys in CloudHSM key * stores, it includes information about the key store, such as the key * store ID and the CloudHSM cluster ID. For KMS keys in external key * stores, it includes the custom key store ID and the ID of the external * key. *

*

* DescribeKey does not return the following information: *

* *

* In general, DescribeKey is a non-mutating operation. It returns * data about KMS keys, but doesn't change them. However, Amazon Web Services * services use DescribeKey to create Amazon Web Services managed keys from a predefined Amazon Web * Services alias with no key ID. *

*

* Cross-account use: Yes. To perform this operation with a KMS key in a * different Amazon Web Services account, specify the key ARN or alias ARN in * the value of the KeyId parameter. *

*

* Required permissions: kms:DescribeKey (key policy) *

*

* Related operations: *

* */ public class DescribeKeyRequest extends AmazonWebServiceRequest implements Serializable { /** *

* Describes the specified KMS key. *

*

* If you specify a predefined Amazon Web Services alias (an Amazon Web * Services alias with no key ID), KMS associates the alias with an Amazon Web Services managed key and returns its KeyId * and Arn in the response. *

*

* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. * When using an alias name, prefix it with "alias/". To * specify a KMS key in a different Amazon Web Services account, you must * use the key ARN or alias ARN. *

*

* For example: *

* *

* To get the key ID and key ARN for a KMS key, use ListKeys or * DescribeKey. To get the alias name and alias ARN, use * ListAliases. *

*

* Constraints:
* Length: 1 - 2048
*/ private String keyId; /** *

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *

*/ private java.util.List grantTokens = new java.util.ArrayList(); /** *

* Describes the specified KMS key. *

*

* If you specify a predefined Amazon Web Services alias (an Amazon Web * Services alias with no key ID), KMS associates the alias with an Amazon Web Services managed key and returns its KeyId * and Arn in the response. *

*

* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. * When using an alias name, prefix it with "alias/". To * specify a KMS key in a different Amazon Web Services account, you must * use the key ARN or alias ARN. *

*

* For example: *

* *

* To get the key ID and key ARN for a KMS key, use ListKeys or * DescribeKey. To get the alias name and alias ARN, use * ListAliases. *

*

* Constraints:
* Length: 1 - 2048
* * @return

* Describes the specified KMS key. *

*

* If you specify a predefined Amazon Web Services alias (an Amazon * Web Services alias with no key ID), KMS associates the alias with * an Amazon Web Services managed key and returns its * KeyId and Arn in the response. *

*

* To specify a KMS key, use its key ID, key ARN, alias name, or * alias ARN. When using an alias name, prefix it with * "alias/". To specify a KMS key in a different Amazon * Web Services account, you must use the key ARN or alias ARN. *

*

* For example: *

* *

* To get the key ID and key ARN for a KMS key, use ListKeys * or DescribeKey. To get the alias name and alias ARN, use * ListAliases. *

*/ public String getKeyId() { return keyId; } /** *

* Describes the specified KMS key. *

*

* If you specify a predefined Amazon Web Services alias (an Amazon Web * Services alias with no key ID), KMS associates the alias with an Amazon Web Services managed key and returns its KeyId * and Arn in the response. *

*

* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. * When using an alias name, prefix it with "alias/". To * specify a KMS key in a different Amazon Web Services account, you must * use the key ARN or alias ARN. *

*

* For example: *

* *

* To get the key ID and key ARN for a KMS key, use ListKeys or * DescribeKey. To get the alias name and alias ARN, use * ListAliases. *

*

* Constraints:
* Length: 1 - 2048
* * @param keyId

* Describes the specified KMS key. *

*

* If you specify a predefined Amazon Web Services alias (an * Amazon Web Services alias with no key ID), KMS associates the * alias with an Amazon Web Services managed key and returns its * KeyId and Arn in the response. *

*

* To specify a KMS key, use its key ID, key ARN, alias name, or * alias ARN. When using an alias name, prefix it with * "alias/". To specify a KMS key in a different * Amazon Web Services account, you must use the key ARN or alias * ARN. *

*

* For example: *

* *

* To get the key ID and key ARN for a KMS key, use * ListKeys or DescribeKey. To get the alias name * and alias ARN, use ListAliases. *

*/ public void setKeyId(String keyId) { this.keyId = keyId; } /** *

* Describes the specified KMS key. *

*

* If you specify a predefined Amazon Web Services alias (an Amazon Web * Services alias with no key ID), KMS associates the alias with an Amazon Web Services managed key and returns its KeyId * and Arn in the response. *

*

* To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. * When using an alias name, prefix it with "alias/". To * specify a KMS key in a different Amazon Web Services account, you must * use the key ARN or alias ARN. *

*

* For example: *

* *

* To get the key ID and key ARN for a KMS key, use ListKeys or * DescribeKey. To get the alias name and alias ARN, use * ListAliases. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 1 - 2048
* * @param keyId

* Describes the specified KMS key. *

*

* If you specify a predefined Amazon Web Services alias (an * Amazon Web Services alias with no key ID), KMS associates the * alias with an Amazon Web Services managed key and returns its * KeyId and Arn in the response. *

*

* To specify a KMS key, use its key ID, key ARN, alias name, or * alias ARN. When using an alias name, prefix it with * "alias/". To specify a KMS key in a different * Amazon Web Services account, you must use the key ARN or alias * ARN. *

*

* For example: *

* *

* To get the key ID and key ARN for a KMS key, use * ListKeys or DescribeKey. To get the alias name * and alias ARN, use ListAliases. *

* @return A reference to this updated object so that method calls can be * chained together. */ public DescribeKeyRequest withKeyId(String keyId) { this.keyId = keyId; return this; } /** *

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *

* * @return

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *

*/ public java.util.List getGrantTokens() { return grantTokens; } /** *

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *

* * @param grantTokens

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *

*/ public void setGrantTokens(java.util.Collection grantTokens) { if (grantTokens == null) { this.grantTokens = null; return; } this.grantTokens = new java.util.ArrayList(grantTokens); } /** *

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param grantTokens

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *

* @return A reference to this updated object so that method calls can be * chained together. */ public DescribeKeyRequest withGrantTokens(String... grantTokens) { if (getGrantTokens() == null) { this.grantTokens = new java.util.ArrayList(grantTokens.length); } for (String value : grantTokens) { this.grantTokens.add(value); } return this; } /** *

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation comes from * a new grant that has not yet achieved eventual consistency. For * more information, see Grant token and Using a grant token in the Key Management Service Developer * Guide. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param grantTokens

* A list of grant tokens. *

*

* Use a grant token when your permission to call this operation * comes from a new grant that has not yet achieved eventual * consistency. For more information, see Grant token and Using a grant token in the Key Management Service * Developer Guide. *

* @return A reference to this updated object so that method calls can be * chained together. */ public DescribeKeyRequest withGrantTokens(java.util.Collection grantTokens) { setGrantTokens(grantTokens); return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getKeyId() != null) sb.append("KeyId: " + getKeyId() + ","); if (getGrantTokens() != null) sb.append("GrantTokens: " + getGrantTokens()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getKeyId() == null) ? 0 : getKeyId().hashCode()); hashCode = prime * hashCode + ((getGrantTokens() == null) ? 0 : getGrantTokens().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeKeyRequest == false) return false; DescribeKeyRequest other = (DescribeKeyRequest) obj; if (other.getKeyId() == null ^ this.getKeyId() == null) return false; if (other.getKeyId() != null && other.getKeyId().equals(this.getKeyId()) == false) return false; if (other.getGrantTokens() == null ^ this.getGrantTokens() == null) return false; if (other.getGrantTokens() != null && other.getGrantTokens().equals(this.getGrantTokens()) == false) return false; return true; } }