libcloud.storage.drivers.google_storage module

class libcloud.storage.drivers.google_storage.ContainerPermissions[source]

Bases: object

NONE = 0
OWNER = 3
READER = 1
WRITER = 2
values = ['NONE', 'READER', 'WRITER', 'OWNER']
class libcloud.storage.drivers.google_storage.GCSResponse(response, connection)[source]

Bases: GoogleResponse

Parameters:
  • response (httplib.HTTPResponse) – HTTP response object. (optional)

  • connection (Connection) – Parent connection object.

class libcloud.storage.drivers.google_storage.GoogleStorageConnection(user_id, key, secure=True, auth_type=None, credential_file=None, **kwargs)[source]

Bases: ConnectionUserAndKey

Represents a single connection to the Google storage API endpoint.

This can either authenticate via the Google OAuth2 methods or via the S3 HMAC interoperability method.

Initialize user_id and key; set secure to an int based on passed value.

PROJECT_ID_HEADER = 'x-goog-project-id'
add_default_headers(headers)[source]

Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers

Should return a dictionary.

get_project()[source]
host: str = 'storage.googleapis.com'
pre_connect_hook(params, headers)[source]

A hook which is called before connecting to the remote server. This hook can perform a final manipulation on the params, headers and url parameters.

Parameters:
  • params (dict) – Request parameters.

  • headers (dict) – Request headers.

rawResponseCls

alias of S3RawResponse

responseCls

alias of S3Response

class libcloud.storage.drivers.google_storage.GoogleStorageDriver(key, secret=None, project=None, **kwargs)[source]

Bases: BaseS3StorageDriver

Driver for Google Cloud Storage.

Can authenticate via standard Google Cloud methods (Service Accounts, Installed App credentials, and GCE instance service accounts)

Examples:

Service Accounts:

driver = GoogleStorageDriver(key=client_email, secret=private_key, ...)

Installed Application:

driver = GoogleStorageDriver(key=client_id, secret=client_secret, ...)

From GCE instance:

driver = GoogleStorageDriver(key=foo, secret=bar, ...)

Can also authenticate via Google Cloud Storage’s S3 HMAC interoperability API. S3 user keys are 20 alphanumeric characters, starting with GOOG.

Example:

driver = GoogleStorageDriver(key='GOOG0123456789ABCXYZ',
                             secret=key_secret)
Parameters:
  • key (str) – API key or username to be used (required)

  • secret (str) – Secret password to be used (required)

  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.

  • host (str) – Override hostname used for connections.

  • port (int) – Override port used for connections.

  • api_version (str) – Optional API version. Only used by drivers which support multiple API versions.

  • region (str) – Optional driver region. Only used by drivers which support multiple regions.

Return type:

None

connectionCls

alias of GoogleStorageConnection

ex_delete_permissions(container_name, object_name=None, entity=None)[source]

Delete permissions for an ACL entity on a container or object.

Parameters:
  • container_name (str) – The container name.

  • object_name (str) – The object name. Optional. Not providing an object will delete a container permission.

  • entity (str or None) – The entity to whose permission will be deleted. Optional. If not provided, the role will be applied to the authenticated user, if using an OAuth2 authentication scheme.

ex_get_permissions(container_name, object_name=None)[source]

Return the permissions for the currently authenticated user.

Parameters:
  • container_name (str) – The container name.

  • object_name (str or None) – The object name. Optional. Not providing an object will return only container permissions.

Returns:

A tuple of container and object permissions.

Return type:

tuple of (int, int or None) from ContainerPermissions and ObjectPermissions, respectively.

ex_set_permissions(container_name, object_name=None, entity=None, role=None)[source]

Set the permissions for an ACL entity on a container or an object.

Parameters:
  • container_name (str) – The container name.

  • object_name (str) – The object name. Optional. Not providing an object will apply the acl to the container.

  • entity (str) – The entity to which apply the role. Optional. If not provided, the role will be applied to the authenticated user, if using an OAuth2 authentication scheme.

  • role (int from ContainerPermissions or ObjectPermissions or str.) – The permission/role to set on the entity.

Raises:

ValueError – If no entity was given, but was required. Or if the role isn’t valid for the bucket or object.

hash_type: str = 'md5'
http_vendor_prefix = 'x-goog'
jsonConnectionCls

alias of GoogleStorageJSONConnection

name: str = 'Google Cloud Storage'
namespace = 'http://doc.s3.amazonaws.com/2006-03-01'
supports_chunked_encoding: bool = False
supports_s3_multipart_upload = False
website = 'http://cloud.google.com/storage'
class libcloud.storage.drivers.google_storage.GoogleStorageJSONConnection(user_id, key, secure=True, auth_type=None, credential_file=None, **kwargs)[source]

Bases: GoogleStorageConnection

Represents a single connection to the Google storage JSON API endpoint.

This can either authenticate via the Google OAuth2 methods or via the S3 HMAC interoperability method.

Initialize user_id and key; set secure to an int based on passed value.

add_default_headers(headers)[source]

Adds default headers (such as Authorization, X-Foo-Bar) to the passed headers

Should return a dictionary.

host: str = 'www.googleapis.com'
rawResponseCls = None
responseCls

alias of GCSResponse

class libcloud.storage.drivers.google_storage.ObjectPermissions[source]

Bases: object

NONE = 0
OWNER = 2
READER = 1
values = ['NONE', 'READER', 'OWNER']