Module bucket (2.14.0rc1)

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.

LifecycleRuleAbortIncompleteMultipartUpload

LifecycleRuleAbortIncompleteMultipartUpload(**kw)

Map a rule aborting incomplete multipart uploads of matching items.

The "age" lifecycle condition is the only supported condition for this rule.

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,
    matches_prefix=None,
    matches_suffix=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_prefix list(str)

(Optional) Apply rule action to items which any prefix matches the beginning of the item name.

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

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

matches_suffix list(str)

(Optional) Apply rule action to items which any suffix matches the end of the item name.

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.