Class: Google::Cloud::Storage::HmacKey

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/storage/hmac_key.rb,
lib/google/cloud/storage/hmac_key/list.rb

Overview

HmacKey

Represents the metadata for an HMAC key, and also includes the key's secret if returned by the Project#create_hmac_key creation method.

Examples:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

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

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

hmac_key.inactive!
hmac_key.delete

See Also:

Defined Under Namespace

Classes: List

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#secretString? (readonly)

HMAC secret key material, or nil if the key was not returned by the Project#create_hmac_key creation method.

Returns:

  • (String, nil)

    the current value of secret



49
50
51
# File 'lib/google/cloud/storage/hmac_key.rb', line 49

def secret
  @secret
end

Instance Method Details

#access_idString

The ID of the HMAC Key.

Returns:

  • (String)


79
80
81
# File 'lib/google/cloud/storage/hmac_key.rb', line 79

def access_id
  @gapi.access_id
end

#active!Google::Cloud::Storage::HmacKey

Updates the state of the HMAC key to ACTIVE.

Examples:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

hmac_key = storage.hmac_keys.first

hmac_key.active!
hmac_key.state # "ACTIVE"

Returns:



181
182
183
184
# File 'lib/google/cloud/storage/hmac_key.rb', line 181

def active!
  put_gapi! "ACTIVE"
  self
end

#active?Boolean

Whether the state of the HMAC key is ACTIVE.

Returns:

  • (Boolean)


161
162
163
# File 'lib/google/cloud/storage/hmac_key.rb', line 161

def active?
  state == "ACTIVE"
end

#api_urlString

A URL that can be used to access the HMAC key using the REST API.

Returns:

  • (String)


88
89
90
# File 'lib/google/cloud/storage/hmac_key.rb', line 88

def api_url
  @gapi.self_link
end

#created_atString

Creation time of the HMAC key.

Returns:

  • (String)


97
98
99
# File 'lib/google/cloud/storage/hmac_key.rb', line 97

def created_at
  @gapi.time_created
end

#delete!Google::Cloud::Storage::HmacKey Also known as: delete

Deletes the HMAC key, and loads the new state of the HMAC key, which will be DELETED.

The API call to delete the HMAC key may be retried under certain conditions. See Google::Cloud#storage to control this behavior.

Examples:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

hmac_key = storage.hmac_keys.first

hmac_key.inactive!.delete!

Returns:



244
245
246
247
248
249
250
251
252
# File 'lib/google/cloud/storage/hmac_key.rb', line 244

def delete!
  ensure_service!
  @service.delete_hmac_key access_id,
                           project_id: project_id,
                           user_project: @user_project
  @gapi = @service.get_hmac_key access_id, project_id: project_id,
                                           user_project: @user_project
  self
end

#deleted?Boolean

Whether the state of the HMAC key is DELETED.

Returns:

  • (Boolean)


221
222
223
# File 'lib/google/cloud/storage/hmac_key.rb', line 221

def deleted?
  state == "DELETED"
end

#etagString

HTTP 1.1 Entity tag for the HMAC key.

Returns:

  • (String)


106
107
108
# File 'lib/google/cloud/storage/hmac_key.rb', line 106

def etag
  @gapi.etag
end

#idString

The ID of the HMAC key, including the Project ID and the Access ID.

Returns:

  • (String)


115
116
117
# File 'lib/google/cloud/storage/hmac_key.rb', line 115

def id
  @gapi.id
end

#inactive!Google::Cloud::Storage::HmacKey

Updates the state of the HMAC key to INACTIVE.

Examples:

require "google/cloud/storage"

storage = Google::Cloud::Storage.new

hmac_key = storage.hmac_keys.first

hmac_key.inactive!
hmac_key.state # "INACTIVE"

Returns:



211
212
213
214
# File 'lib/google/cloud/storage/hmac_key.rb', line 211

def inactive!
  put_gapi! "INACTIVE"
  self
end

#inactive?Boolean

Whether the state of the HMAC key is INACTIVE.

Returns:

  • (Boolean)


191
192
193
# File 'lib/google/cloud/storage/hmac_key.rb', line 191

def inactive?
  state == "INACTIVE"
end

#project_idString

Project ID owning the service account to which the key authenticates.

Returns:

  • (String)


124
125
126
# File 'lib/google/cloud/storage/hmac_key.rb', line 124

def project_id
  @gapi.project_id
end

#reload!Object Also known as: refresh!

Reloads the HMAC key with current data from the Storage service.



258
259
260
261
262
263
# File 'lib/google/cloud/storage/hmac_key.rb', line 258

def reload!
  ensure_service!
  @gapi = service.get_hmac_key access_id, project_id: project_id,
                                          user_project: user_project
  self
end

#service_account_emailString

The email address of the key's associated service account.

Returns:

  • (String)


133
134
135
# File 'lib/google/cloud/storage/hmac_key.rb', line 133

def 
  @gapi.
end

#stateString

The state of the key. Can be one of ACTIVE, INACTIVE, or DELETED.

Returns:

  • (String)


143
144
145
# File 'lib/google/cloud/storage/hmac_key.rb', line 143

def state
  @gapi.state
end

#updated_atString

Last modification time of the HMAC key metadata.

Returns:

  • (String)


152
153
154
# File 'lib/google/cloud/storage/hmac_key.rb', line 152

def updated_at
  @gapi.updated
end