1.62.2 (latest) 1.62.1 1.61.0 1.60.0 1.59.0 1.58.0 1.57.1 1.56.0 1.55.0 1.54.0 1.53.0 1.52.0 1.51.0 1.50.0 1.49.0 1.48.1 1.47.0 1.46.0 1.45.0 1.44.0 1.43.0 1.42.0 1.41.0 1.40.0 1.39.0 1.38.0 1.37.0 1.36.2 1.35.0 Reference documentation and code samples for the Cloud Storage API class Google::Cloud::Storage::HmacKey.

## HmacKey

Represents the metadata for an HMAC key, and also includes the key's
secret if returned by the [Project#create_hmac_key](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Project.md.txt#Google__Cloud__Storage__Project_create_hmac_key_instance_ "Google::Cloud::Storage::Project#create_hmac_key (method)") creation method.

## Inherits

- Object

## Example

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

service_account_email = "my_account@developer.gserviceaccount.com"
hmac_key = storage.create_hmac_key service_account_email
hmac_key.secret # ...

hmac_key = storage.hmac_key hmac_key.access_id
hmac_key.secret # nil

hmac_key.inactive!
hmac_key.delete
```

## Methods

### #access_id

```ruby
def access_id() -> String
```
The ID of the HMAC Key.
**Returns**

- (String)

### #active!

```ruby
def active!() -> Google::Cloud::Storage::HmacKey
```
Updates the state of the HMAC key to `ACTIVE`.
**Returns**

- ([Google::Cloud::Storage::HmacKey](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt)) --- Returns the HMAC key for method chaining.
**Example**

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

hmac_key = storage.hmac_keys.first

hmac_key.active!
hmac_key.state # "ACTIVE"
```

### #active?

```ruby
def active?() -> Boolean
```
Whether the state of the HMAC key is `ACTIVE`.
**Returns**

- (Boolean)

### #api_url

```ruby
def api_url() -> String
```
A URL that can be used to access the HMAC key using the REST API.
**Returns**

- (String)

### #created_at

```ruby
def created_at() -> String
```
Creation time of the HMAC key.
**Returns**

- (String)

### #delete

```ruby
def delete() -> Google::Cloud::Storage::HmacKey
```
**Alias Of** : [#delete!](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt#Google__Cloud__Storage__HmacKey_delete!_instance_) Deletes the HMAC key, and loads the new state of the HMAC key,
which will be `DELETED`.


<br />

The API call to delete the HMAC key may be retried under certain
conditions. See [Google::Cloud#storage](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud.md.txt#Google__Cloud_storage_instance_ "Google::Cloud#storage (method)") to control this behavior.
**Returns**

- ([Google::Cloud::Storage::HmacKey](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt)) --- Returns the HMAC key for method chaining.
**Example**

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

hmac_key = storage.hmac_keys.first

hmac_key.inactive!.delete!
```

### #delete!

```ruby
def delete!() -> Google::Cloud::Storage::HmacKey
```
**Aliases**

- [#delete](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt#Google__Cloud__Storage__HmacKey_delete_instance_)
Deletes the HMAC key, and loads the new state of the HMAC key,
which will be `DELETED`.


<br />

The API call to delete the HMAC key may be retried under certain
conditions. See [Google::Cloud#storage](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud.md.txt#Google__Cloud_storage_instance_ "Google::Cloud#storage (method)") to control this behavior.
**Returns**

- ([Google::Cloud::Storage::HmacKey](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt)) --- Returns the HMAC key for method chaining.
**Example**

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

hmac_key = storage.hmac_keys.first

hmac_key.inactive!.delete!
```

### #deleted?

```ruby
def deleted?() -> Boolean
```
Whether the state of the HMAC key is `DELETED`.
**Returns**

- (Boolean)

### #etag

```ruby
def etag() -> String
```
HTTP 1.1 Entity tag for the HMAC key.
**Returns**

- (String)

### #id

```ruby
def id() -> String
```
The ID of the HMAC key, including the Project ID and the Access ID.
**Returns**

- (String)

### #inactive!

```ruby
def inactive!() -> Google::Cloud::Storage::HmacKey
```
Updates the state of the HMAC key to `INACTIVE`.
**Returns**

- ([Google::Cloud::Storage::HmacKey](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt)) --- Returns the HMAC key for method chaining.
**Example**

```ruby
require "google/cloud/storage"

storage = Google::Cloud::Storage.new

hmac_key = storage.hmac_keys.first

hmac_key.inactive!
hmac_key.state # "INACTIVE"
```

### #inactive?

```ruby
def inactive?() -> Boolean
```
Whether the state of the HMAC key is `INACTIVE`.
**Returns**

- (Boolean)

### #project_id

```ruby
def project_id() -> String
```
Project ID owning the service account to which the key authenticates.
**Returns**

- (String)

### #refresh!

```ruby
def refresh!()
```
**Alias Of** : [#reload!](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt#Google__Cloud__Storage__HmacKey_reload!_instance_) Reloads the HMAC key with current data from the Storage service.

### #reload!

```ruby
def reload!()
```
**Aliases**

- [#refresh!](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-HmacKey.md.txt#Google__Cloud__Storage__HmacKey_refresh!_instance_)
Reloads the HMAC key with current data from the Storage service.

### #secret

```ruby
def secret() -> String, nil
```
HMAC secret key material, or `nil` if
the key was not returned by the [Project#create_hmac_key](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-storage/latest/Google-Cloud-Storage-Project.md.txt#Google__Cloud__Storage__Project_create_hmac_key_instance_ "Google::Cloud::Storage::Project#create_hmac_key (method)") creation
method.
**Returns**

- (String, nil) --- the current value of secret

### #service_account_email

```ruby
def service_account_email() -> String
```
The email address of the key's associated service account.
**Returns**

- (String)

### #state

```ruby
def state() -> String
```
The state of the key. Can be one of `ACTIVE`, `INACTIVE`, or
`DELETED`.
**Returns**

- (String)

### #updated_at

```ruby
def updated_at() -> String
```
Last modification time of the HMAC key metadata.
**Returns**

- (String)