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

Request message for
[KeyManagementService.GenerateRandomBytes](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.Client.KeyManagementServiceClient#_Google_Cloud_Kms_V1_Client_KeyManagementServiceClient__generateRandomBytes__).

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

## Namespace

Google \\ Cloud \\ Kms \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ location` | `string` The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1". |
| `↳ length_bytes` | `int` The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes. |
| `↳ protection_level` | `int` The [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) to use when generating the random data. Currently, only [HSM](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__HSM) protection level is supported. |

### getLocation

The project-specific location in which to generate random bytes.

For example, "projects/my-project/locations/us-central1".

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

### setLocation

The project-specific location in which to generate random bytes.

For example, "projects/my-project/locations/us-central1".

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

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

### getLengthBytes

The length in bytes of the amount of randomness to retrieve. Minimum 8
bytes, maximum 1024 bytes.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### setLengthBytes

The length in bytes of the amount of randomness to retrieve. Minimum 8
bytes, maximum 1024 bytes.

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

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

### getProtectionLevel

The [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) to use when
generating the random data. Currently, only
[HSM](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__HSM) protection level is
supported.

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

### setProtectionLevel

The [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) to use when
generating the random data. Currently, only
[HSM](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__HSM) protection level is
supported.

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

### static::build

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `location` | `string` The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1". |
| `lengthBytes` | `int` The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes. |
| `protectionLevel` | `int` The [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) to use when generating the random data. Currently, only [HSM](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel#_Google_Cloud_Kms_V1_ProtectionLevel__HSM) protection level is supported. For allowed values, use constants defined on [ProtectionLevel](https://docs.cloud.google.com/php/docs/reference/cloud-kms/latest/V1.ProtectionLevel) |

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