gcs_client.project module

class gcs_client.project.Project(project_id, credentials=None, retry_params=None)[source]

Bases: gcs_client.base.Listable

GCS Project Object representation.

Initialize a Project object.

Parameters:
  • project_id (String) – Project id as listed in Google’s project management https://console.developers.google.com/project.
  • credentials (gcs_client.Credentials) – A credentials object to authorize the connection.
  • retry_params (RetryParams or NoneType) – Retry configuration used for communications with GCS. If None is passed default retries will be used.
create_bucket(*args, **kwargs)[source]

Create a new bucket in the project.

Google Cloud Storage uses a flat namespace, so you can’t create a bucket with a name that is already in use.

For more information, see Bucket Naming Guidelines: https://cloud.google.com/storage/docs/bucket-naming#requirements

The authenticated user in credentials must be a member of the project’s team as an editor or owner.

Parameters:
  • name (String) – The name of the bucket.
  • location (String) – The location of the bucket. Object data for objects in the bucket resides in physical storage within this region. Defaults to US. See the developer’s guide for the authoritative list: https://cloud.google.com/storage/docs/bucket-locations
  • storage_class (String) – The bucket’s storage class. This defines how objects in the bucket are stored and determines the SLA and the cost of storage. Value must be one of gcs_client.constants.STORAGE_*, and they include STANDARD, NEARLINE and DURABLE_REDUCED_AVAILABILITY. Defaults to gcs_client.constants.STORAGE_NEARLINE.
  • predefined_acl (String) – Apply a predefined set of access controls to this bucket. Acceptable values from gcs_client.ACL_* are ACL_AUTH_READ, ACL_PRIVATE, ACL_PROJECT_PRIVATE, ACL_PUBLIC_R, and ACL_PUBLIC_RW
  • predefined_default_obj_acl (String) – Apply a predefined set of default object access controls to this bucket. Acceptable values from gcs_client.constants.ACL_* are ACL_AUTH_READ, ACL_OWNER_FULL, ACL_OWNER_READ, ACL_PRIVATE, ACL_PROJECT_PRIVATE, and ACL_PUBLIC_R
  • projection (String) –

    Set of properties to return. Defaults to PROJECTION_SIMPLE. Acceptable values from gcs_client.constants are:

    • PROJECTION_FULL (‘full’): Include all properties.
    • PROJECTION_SIMPLE (‘noAcl’): Omit the acl property.
Returns:

A new Bucket instance

Return type:

gcs_client.Bucket

exists(*args, **kwargs)

Check if exists in GCS server.

list(fields=None, maxResults=None, projection=None, prefix=None, pageToken=None)[source]

Retrieves a list of buckets for a given project.

The authenticated user in credentials must be a member of the project’s team.

Bucket list operations are eventually consistent. This means that if you create a bucket and then immediately perform a list operation, the newly-created bucket will be immediately available for use, but the bucket might not immediately appear in the returned list of buckets.

Parameters:
  • fields (list of strings) – Limit retrieved data for each bucket to these fields.
  • maxResults (Unsigned integer) – Maximum number of buckets to return.
  • projection (String) –

    Set of properties to return. Defaults to noAcl. Acceptable values are:

    “full”: Include all properties. “noAcl”: Omit the acl property.
  • prefix (String) – Filter results to buckets whose names begin with this prefix.
  • pageToken (String) – A previously-returned page token representing part of the larger set of results to view. The pageToken is an encoded field representing the name and generation of the last bucket in the returned list. In a subsequent request using the pageToken, items that come after the pageToken are shown (up to maxResults). Bucket list operations are eventually consistent. In addition, if you start a listing and then create a new bucket before using a pageToken to continue listing, you will not see the new bucket in subsequent listing results if it is in part of the bucket namespace already listed.
Returns:

List of buckets that match the criteria.

Return type:

List of gcs_client.Bucket.

credentials

Credentials used to connect to GCS server.

default_bucket_name

Bucket name of the default bucket for the project.

retry_params

Get retry configuration used by this instance for accessing GCS.