# Cloud Storage Client - Class HmacKey (2.3.0)

2.3.0 (latest) 2.2.0 2.1.0 2.0.0 1.51.0 1.50.0 1.49.2 1.48.7 1.47.0 1.46.0 1.45.0 1.44.0 1.43.1 1.42.1 1.41.4 1.37.0 1.36.1 1.35.0 1.34.0 1.33.4 1.32.0 1.31.2 1.30.3 Reference documentation and code samples for the Cloud Storage Client class HmacKey.

Represents a Service Account HMAC key.

Example:

    use Google\Cloud\Storage\StorageClient;

    $storage = new StorageClient();
    $hmacKey = $storage->hmacKey($accessId);

## Namespace

Google \\ Cloud \\ Storage

## Methods

### __construct

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `connection` | `Connection\ConnectionInterface` A connection to Cloud Storage. This object is created by StorageClient, and should not be instantiated outside of this client. |
| `projectId` | `string` The current project ID. |
| `accessId` | `string` The key identifier. |
| `info` | `array|null` The key metadata. |

### accessId

Get the HMAC Key Access ID.

Example:

    $accessId = $hmacKey->accessId();

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

### reload

Fetch the key metadata from Cloud Storage.

Example:

    $keyMetadata = $hmacKey->reload();

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` Configuration Options |
| `↳ userProject` | `string` If set, this is the ID of the project which will be billed for the request. **NOTE**: This option is currently ignored by Cloud Storage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### info

Get the HMAC Key Metadata.

If the metadata is not already available, it will be requested from Cloud
Storage.

Example:

    $keyMetadata = $hmacKey->info();

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` Configuration Options |
| `↳ userProject` | `string` If set, this is the ID of the project which will be billed for the request. **NOTE**: This option is currently ignored by Cloud Storage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### update

Update the HMAC Key state.

Example:

    $hmacKey->update('INACTIVE');

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `state` | `string` The key state. Either `ACTIVE` or `INACTIVE`. |
| `options` | `array` Configuration Options |
| `↳ userProject` | `string` If set, this is the ID of the project which will be billed for the request. **NOTE**: This option is currently ignored by Cloud Storage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### delete

Delete the HMAC Key.

Key state must be set to `INACTIVE` prior to deletion. See
[HmacKey::update()](https://docs.cloud.google.com/php/docs/reference/cloud-storage/latest/HmacKey#_Google_Cloud_Storage_HmacKey__update__) for details.

Example:

    $hmacKey->delete();

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` Configuration Options |
| `↳ userProject` | `string` If set, this is the ID of the project which will be billed for the request. **NOTE**: This option is currently ignored by Cloud Storage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `void` |   |