Module bucket (2.1.0)

Create / interact with Google Cloud Storage buckets.

Classes

Bucket

Bucket(client, name=None, user_project=None)

A class representing a Bucket on Cloud Storage.

Parameters
NameDescription
client Client

A client which holds credentials and project configuration for the bucket (which requires a project).

name str

The name of the bucket. Bucket names must start and end with a number or letter.

user_project str

(Optional) the project ID to be billed for API requests made via this instance.

IAMConfiguration

IAMConfiguration(bucket, public_access_prevention=<object object>, uniform_bucket_level_access_enabled=<object object>, uniform_bucket_level_access_locked_time=<object object>, bucket_policy_only_enabled=<object object>, bucket_policy_only_locked_time=<object object>)

Map a bucket's IAM configuration.

LifecycleRuleConditions

LifecycleRuleConditions(
    age=None,
    created_before=None,
    is_live=None,
    matches_storage_class=None,
    number_of_newer_versions=None,
    days_since_custom_time=None,
    custom_time_before=None,
    days_since_noncurrent_time=None,
    noncurrent_time_before=None,
    _factory=False,
)

Map a single lifecycle rule for a bucket.

See: https://cloud.google.com/storage/docs/lifecycle

Parameters
NameDescription
age int

(Optional) Apply rule action to items whose age, in days, exceeds this value.

created_before datetime.date

(Optional) Apply rule action to items created before this date.

is_live bool

(Optional) If true, apply rule action to non-versioned items, or to items with no newer versions. If false, apply rule action to versioned items with at least one newer version.

matches_storage_class list(str), one or more of Bucket.STORAGE_CLASSES.

(Optional) Apply rule action to items which whose storage class matches this value.

number_of_newer_versions int

(Optional) Apply rule action to versioned items having N newer versions.

days_since_custom_time int

(Optional) Apply rule action to items whose number of days elapsed since the custom timestamp. This condition is relevant only for versioned objects. The value of the field must be a non negative integer. If it's zero, the object version will become eligible for lifecycle action as soon as it becomes custom.

custom_time_before datetime.date

(Optional) Date object parsed from RFC3339 valid date, apply rule action to items whose custom time is before this date. This condition is relevant only for versioned objects, e.g., 2019-03-16.

days_since_noncurrent_time int

(Optional) Apply rule action to items whose number of days elapsed since the non current timestamp. This condition is relevant only for versioned objects. The value of the field must be a non negative integer. If it's zero, the object version will become eligible for lifecycle action as soon as it becomes non current.

noncurrent_time_before datetime.date

(Optional) Date object parsed from RFC3339 valid date, apply rule action to items whose non current time is before this date. This condition is relevant only for versioned objects, e.g, 2019-03-16.

Exceptions
TypeDescription
ValueErrorif no arguments are passed.

LifecycleRuleDelete

LifecycleRuleDelete(**kw)

Map a lifecycle rule deleting matching items.

LifecycleRuleSetStorageClass

LifecycleRuleSetStorageClass(storage_class, **kw)

Map a lifecycle rule updating storage class of matching items.

Parameter
NameDescription
storage_class str, one of Bucket.STORAGE_CLASSES.

new storage class to assign to matching items.