As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

HMAC Key Metadata

class google.cloud.storage.hmac_key.HMACKeyMetadata(client, access_id=None, project_id=None, user_project=None)[source]

Bases: object

Metadata about an HMAC service account key withn Cloud Storage.

Parameters
  • client (Client) – client associated with the key metadata.

  • access_id (str) – (Optional) Unique ID of an existing key.

  • project_id (str) – (Optional) Project ID of an existing key. Defaults to client’s project.

  • user_project (str) – (Optional) This parameter is currently ignored.

ACTIVE_STATE = 'ACTIVE'

Key is active, and may be used to sign requests.

DELETED_STATE = 'DELETED'

Key is deleted. It cannot be re-activated.

INACTIVE_STATE = 'INACTIVE'

Key is inactive, and may not be used to sign requests.

It can be re-activated via update().

property access_id

Access ID of the key.

Return type

str or None

Returns

unique identifier of the key within a project.

delete(timeout=60, retry=<google.api_core.retry.Retry object>)[source]

Delete the key from Cloud Storage.

Parameters
:raises NotFound:

if the key does not exist on the back-end.

property etag

ETag identifying the version of the key metadata.

Return type

str or None

Returns

ETag for the version of the key’s metadata.

exists(timeout=60, retry=<google.api_core.retry.Retry object>)[source]

Determine whether or not the key for this metadata exists.

Parameters
Return type

bool

Returns

True if the key exists in Cloud Storage.

property id

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

Return type

str or None

Returns

ID of the key.

property path

Resource path for the metadata’s key.

property project

Project ID associated with the key.

Return type

str or None

Returns

project identfier for the key.

reload(timeout=60, retry=<google.api_core.retry.Retry object>)[source]

Reload properties from Cloud Storage.

Parameters
:raises NotFound:

if the key does not exist on the back-end.

property service_account_email

Service account e-mail address associated with the key.

Return type

str or None

Returns

e-mail address for the service account which created the key.

property state

Get / set key’s state.

One of:
  • ACTIVE

  • INACTIVE

  • DELETED

Return type

str or None

Returns

key’s current state.

property time_created

Retrieve the timestamp at which the HMAC key was created.

Return type

datetime.datetime or NoneType

Returns

Datetime object parsed from RFC3339 valid timestamp, or None if the bucket’s resource has not been loaded from the server.

update(timeout=60, retry=<google.cloud.storage.retry.ConditionalRetryPolicy object>)[source]

Save writable properties to Cloud Storage.

Parameters
:raises NotFound:

if the key does not exist on the back-end.

property updated

Retrieve the timestamp at which the HMAC key was created.

Return type

datetime.datetime or NoneType

Returns

Datetime object parsed from RFC3339 valid timestamp, or None if the bucket’s resource has not been loaded from the server.

property user_project

Project ID to be billed for API requests made via this bucket.

This property is currently ignored by the server.

Return type

str