# Cloud KMS V1 Client - Class CryptoKeyVersion (2.9.0)

2.9.0 (latest) 2.8.0 2.7.0 2.6.0 2.5.2 2.4.0 2.3.1 2.2.0 2.1.6 2.0.0 1.23.0 1.22.1 1.21.4 1.20.3 1.19.0 1.18.1 1.17.0 1.16.4 1.15.3 Reference documentation and code samples for the Cloud KMS V1 Client class CryptoKeyVersion.

A [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) represents an
individual cryptographic key, and the associated key material.

An
[ENABLED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__ENABLED)
version can be used for cryptographic operations.
For security reasons, the raw cryptographic key material represented by a
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) can never be viewed
or exported. It can only be used to encrypt, decrypt, or sign data when an
authorized user or application invokes Cloud KMS.

Generated from protobuf message `google.cloud.kms.v1.CryptoKeyVersion`

## Namespace

Google \\ Cloud \\ Kms \\ V1

## Methods

### __construct

Constructor.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `data` | `mixed` |

### getName

Output only. The resource name for this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) in the format
`projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Output only. The resource name for this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) in the format
`projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getState

The current state of the
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [CryptoKeyVersionState](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState). |

### setState

The current state of the
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [CryptoKeyVersionState](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getProtectionLevel

Output only. The [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel)
describing how crypto operations are performed with this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel). |

### setProtectionLevel

Output only. The [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel)
describing how crypto operations are performed with this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getAlgorithm

Output only. The
[CryptoKeyVersionAlgorithm](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionAlgorithm)
that this [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)
supports.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [CryptoKeyVersionAlgorithm](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionAlgorithm). |

### setAlgorithm

Output only. The
[CryptoKeyVersionAlgorithm](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionAlgorithm)
that this [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)
supports.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [CryptoKeyVersionAlgorithm](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionAlgorithm). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getAttestation

Output only. Statement that was generated and signed by the HSM at key
creation time. Use this statement to verify attributes of the key as stored
on the HSM, independently of Google. Only provided for key versions with
[protection_level](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getProtectionLevel__)
[HSM](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__HSM).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.KeyOperationAttestation|null` |   |

### hasAttestation

### clearAttestation

### setAttestation

Output only. Statement that was generated and signed by the HSM at key
creation time. Use this statement to verify attributes of the key as stored
on the HSM, independently of Google. Only provided for key versions with
[protection_level](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getProtectionLevel__)
[HSM](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__HSM).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.KeyOperationAttestation` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCreateTime

Output only. The time at which this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) was created.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasCreateTime

### clearCreateTime

### setCreateTime

Output only. The time at which this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) was created.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getGenerateTime

Output only. The time this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)'s key material was
generated.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasGenerateTime

### clearGenerateTime

### setGenerateTime

Output only. The time this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)'s key material was
generated.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDestroyTime

Output only. The time this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)'s key material is
scheduled for destruction. Only present if
[state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[DESTROY_SCHEDULED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__DESTROY_SCHEDULED).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasDestroyTime

### clearDestroyTime

### setDestroyTime

Output only. The time this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)'s key material is
scheduled for destruction. Only present if
[state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[DESTROY_SCHEDULED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__DESTROY_SCHEDULED).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDestroyEventTime

Output only. The time this CryptoKeyVersion's key material was
destroyed. Only present if
[state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[DESTROYED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__DESTROYED).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasDestroyEventTime

### clearDestroyEventTime

### setDestroyEventTime

Output only. The time this CryptoKeyVersion's key material was
destroyed. Only present if
[state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[DESTROYED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__DESTROYED).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getImportJob

Output only. The name of the [ImportJob](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ImportJob)
used in the most recent import of this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion). Only present if
the underlying key material was imported.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setImportJob

Output only. The name of the [ImportJob](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ImportJob)
used in the most recent import of this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion). Only present if
the underlying key material was imported.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getImportTime

Output only. The time at which this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)'s key material was
most recently imported.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasImportTime

### clearImportTime

### setImportTime

Output only. The time at which this
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion)'s key material was
most recently imported.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getImportFailureReason

Output only. The root cause of the most recent import failure. Only present
if [state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[IMPORT_FAILED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__IMPORT_FAILED).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setImportFailureReason

Output only. The root cause of the most recent import failure. Only present
if [state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[IMPORT_FAILED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__IMPORT_FAILED).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getGenerationFailureReason

Output only. The root cause of the most recent generation failure. Only
present if [state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[GENERATION_FAILED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__GENERATION_FAILED).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setGenerationFailureReason

Output only. The root cause of the most recent generation failure. Only
present if [state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[GENERATION_FAILED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__GENERATION_FAILED).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getExternalDestructionFailureReason

Output only. The root cause of the most recent external destruction
failure. Only present if
[state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[EXTERNAL_DESTRUCTION_FAILED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__EXTERNAL_DESTRUCTION_FAILED).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setExternalDestructionFailureReason

Output only. The root cause of the most recent external destruction
failure. Only present if
[state](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion#_Google_Cloud_Kms_V1_CryptoKeyVersion__getState__) is
[EXTERNAL_DESTRUCTION_FAILED](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionState#_Google_Cloud_Kms_V1_CryptoKeyVersion_CryptoKeyVersionState__EXTERNAL_DESTRUCTION_FAILED).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getExternalProtectionLevelOptions

ExternalProtectionLevelOptions stores a group of additional fields for
configuring a [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) that
are specific to the
[EXTERNAL](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__EXTERNAL) protection level
and [EXTERNAL_VPC](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__EXTERNAL_VPC)
protection levels.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ExternalProtectionLevelOptions|null` |   |

### hasExternalProtectionLevelOptions

### clearExternalProtectionLevelOptions

### setExternalProtectionLevelOptions

ExternalProtectionLevelOptions stores a group of additional fields for
configuring a [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) that
are specific to the
[EXTERNAL](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__EXTERNAL) protection level
and [EXTERNAL_VPC](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__EXTERNAL_VPC)
protection levels.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ExternalProtectionLevelOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getReimportEligible

Output only. Whether or not this key version is eligible for reimport, by
being specified as a target in
[ImportCryptoKeyVersionRequest.crypto_key_version](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ImportCryptoKeyVersionRequest#_Google_Cloud_Kms_V1_ImportCryptoKeyVersionRequest__getCryptoKeyVersion__).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### setReimportEligible

Output only. Whether or not this key version is eligible for reimport, by
being specified as a target in
[ImportCryptoKeyVersionRequest.crypto_key_version](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ImportCryptoKeyVersionRequest#_Google_Cloud_Kms_V1_ImportCryptoKeyVersionRequest__getCryptoKeyVersion__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |