# Cloud KMS V1 Client - Class CryptoKeyVersionTemplate (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 CryptoKeyVersionTemplate.

A [CryptoKeyVersionTemplate](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersionTemplate)
specifies the properties to use when creating a new
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion), either manually
with
[CreateCryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.Client.KeyManagementServiceClient#_Google_Cloud_Kms_V1_Client_KeyManagementServiceClient__createCryptoKeyVersion__)
or automatically as a result of auto-rotation.

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

## Namespace

Google \\ Cloud \\ Kms \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ protection_level` | `int` [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) to use when creating a [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) based on this template. Immutable. Defaults to [SOFTWARE](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__SOFTWARE). |
| `↳ algorithm` | `int` Required. [Algorithm](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionAlgorithm) to use when creating a [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) based on this template. For backwards compatibility, GOOGLE_SYMMETRIC_ENCRYPTION is implied if both this field is omitted and [CryptoKey.purpose](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKey#_Google_Cloud_Kms_V1_CryptoKey__getPurpose__) is [ENCRYPT_DECRYPT](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKey.CryptoKeyPurpose#_Google_Cloud_Kms_V1_CryptoKey_CryptoKeyPurpose__ENCRYPT_DECRYPT). |

### getProtectionLevel

[ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) to use when creating
a [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) based on this
template. Immutable. Defaults to
[SOFTWARE](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__SOFTWARE).

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

### setProtectionLevel

[ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) to use when creating
a [CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) based on this
template. Immutable. Defaults to
[SOFTWARE](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__SOFTWARE).

| **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

Required.

[Algorithm](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionAlgorithm)
to use when creating a
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) based on this
template.
For backwards compatibility, GOOGLE_SYMMETRIC_ENCRYPTION is implied if both
this field is omitted and
[CryptoKey.purpose](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKey#_Google_Cloud_Kms_V1_CryptoKey__getPurpose__) is
[ENCRYPT_DECRYPT](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKey.CryptoKeyPurpose#_Google_Cloud_Kms_V1_CryptoKey_CryptoKeyPurpose__ENCRYPT_DECRYPT).

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

### setAlgorithm

Required.

[Algorithm](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion.CryptoKeyVersionAlgorithm)
to use when creating a
[CryptoKeyVersion](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKeyVersion) based on this
template.
For backwards compatibility, GOOGLE_SYMMETRIC_ENCRYPTION is implied if both
this field is omitted and
[CryptoKey.purpose](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKey#_Google_Cloud_Kms_V1_CryptoKey__getPurpose__) is
[ENCRYPT_DECRYPT](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.CryptoKey.CryptoKeyPurpose#_Google_Cloud_Kms_V1_CryptoKey_CryptoKeyPurpose__ENCRYPT_DECRYPT).

| **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` |   |