Send feedback
Module bucket (3.3.1)
Stay organized with collections
Save and categorize content based on your preferences.
Version latestkeyboard_arrow_down
Create / interact with Google Cloud Storage buckets.
Classes
Bucket ( client , name = None , user_project = None , generation = None )
A class representing a Bucket on Cloud Storage.
Parameters
Name
Description
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.
generation
int
(Optional) If present, selects a specific revision of this bucket.
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 ( ** kw )
Map a rule aborting incomplete multipart uploads of matching items.
The "age" lifecycle condition is the only supported condition for this rule.
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 ,
)
Parameters
Name
Description
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
Type
Description
ValueError
if no arguments are passed.
LifecycleRuleDelete ( ** kw )
Map a lifecycle rule deleting matching items.
LifecycleRuleSetStorageClass ( storage_class , ** kw )
Map a lifecycle rule updating storage class of matching items.
Parameter
Name
Description
storage_class
str, one of Bucket.STORAGE_CLASSES
.
new storage class to assign to matching items.
SoftDeletePolicy ( bucket , ** kw )
Parameters
Name
Description
bucket
Bucket
Bucket for which this instance is the policy.
retention_duration_seconds
int
(Optional) The period of time in seconds that soft-deleted objects in the bucket will be retained and cannot be permanently deleted.
effective_time
datetime.datetime
(Optional) When the bucket's soft delete policy is effective. This value should normally only be set by the back-end API.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Module bucket (3.3.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.3.0 (latest)](/python/docs/reference/storage/latest/google.cloud.storage.bucket)\n- [3.2.0](/python/docs/reference/storage/3.2.0/google.cloud.storage.bucket)\n- [3.1.1](/python/docs/reference/storage/3.1.1/google.cloud.storage.bucket)\n- [3.0.0](/python/docs/reference/storage/3.0.0/google.cloud.storage.bucket)\n- [2.19.0](/python/docs/reference/storage/2.19.0/google.cloud.storage.bucket)\n- [2.17.0](/python/docs/reference/storage/2.17.0/google.cloud.storage.bucket)\n- [2.16.0](/python/docs/reference/storage/2.16.0/google.cloud.storage.bucket)\n- [2.15.0](/python/docs/reference/storage/2.15.0/google.cloud.storage.bucket)\n- [2.14.0](/python/docs/reference/storage/2.14.0/google.cloud.storage.bucket)\n- [2.13.0](/python/docs/reference/storage/2.13.0/google.cloud.storage.bucket)\n- [2.12.0](/python/docs/reference/storage/2.12.0/google.cloud.storage.bucket)\n- [2.11.0](/python/docs/reference/storage/2.11.0/google.cloud.storage.bucket)\n- [2.10.0](/python/docs/reference/storage/2.10.0/google.cloud.storage.bucket)\n- [2.9.0](/python/docs/reference/storage/2.9.0/google.cloud.storage.bucket)\n- [2.8.0](/python/docs/reference/storage/2.8.0/google.cloud.storage.bucket)\n- [2.7.0](/python/docs/reference/storage/2.7.0/google.cloud.storage.bucket)\n- [2.6.0](/python/docs/reference/storage/2.6.0/google.cloud.storage.bucket)\n- [2.5.0](/python/docs/reference/storage/2.5.0/google.cloud.storage.bucket)\n- [2.4.0](/python/docs/reference/storage/2.4.0/google.cloud.storage.bucket)\n- [2.3.0](/python/docs/reference/storage/2.3.0/google.cloud.storage.bucket)\n- [2.2.1](/python/docs/reference/storage/2.2.1/google.cloud.storage.bucket)\n- [2.1.0](/python/docs/reference/storage/2.1.0/google.cloud.storage.bucket)\n- [2.0.0](/python/docs/reference/storage/2.0.0/google.cloud.storage.bucket)\n- [1.44.0](/python/docs/reference/storage/1.44.0/google.cloud.storage.bucket)\n- [1.43.0](/python/docs/reference/storage/1.43.0/google.cloud.storage.bucket)\n- [1.42.3](/python/docs/reference/storage/1.42.3/google.cloud.storage.bucket)\n- [1.41.1](/python/docs/reference/storage/1.41.1/google.cloud.storage.bucket)\n- [1.40.0](/python/docs/reference/storage/1.40.0/google.cloud.storage.bucket)\n- [1.39.0](/python/docs/reference/storage/1.39.0/google.cloud.storage.bucket)\n- [1.38.0](/python/docs/reference/storage/1.38.0/google.cloud.storage.bucket)\n- [1.37.1](/python/docs/reference/storage/1.37.1/google.cloud.storage.bucket)\n- [1.36.2](/python/docs/reference/storage/1.36.2/google.cloud.storage.bucket)\n- [1.35.1](/python/docs/reference/storage/1.35.1/google.cloud.storage.bucket)\n- [1.34.0](/python/docs/reference/storage/1.34.0/google.cloud.storage.bucket)\n- [1.33.0](/python/docs/reference/storage/1.33.0/google.cloud.storage.bucket)\n- [1.32.0](/python/docs/reference/storage/1.32.0/google.cloud.storage.bucket)\n- [1.31.2](/python/docs/reference/storage/1.31.2/google.cloud.storage.bucket)\n- [1.30.0](/python/docs/reference/storage/1.30.0/google.cloud.storage.bucket)\n- [1.29.0](/python/docs/reference/storage/1.29.0/google.cloud.storage.bucket)\n- [1.28.1](/python/docs/reference/storage/1.28.1/google.cloud.storage.bucket)\n- [1.27.0](/python/docs/reference/storage/1.27.0/google.cloud.storage.bucket)\n- [1.26.0](/python/docs/reference/storage/1.26.0/google.cloud.storage.bucket)\n- [1.25.0](/python/docs/reference/storage/1.25.0/google.cloud.storage.bucket)\n- [1.24.1](/python/docs/reference/storage/1.24.1/google.cloud.storage.bucket)\n- [1.23.0](/python/docs/reference/storage/1.23.0/google.cloud.storage.bucket)\n- [1.22.0](/python/docs/reference/storage/1.22.0/google.cloud.storage.bucket)\n- [1.21.0](/python/docs/reference/storage/1.21.0/google.cloud.storage.bucket)\n- [1.20.0](/python/docs/reference/storage/1.20.0/google.cloud.storage.bucket)\n- [1.19.0](/python/docs/reference/storage/1.19.0/google.cloud.storage.bucket)\n- [1.18.0](/python/docs/reference/storage/1.18.0/google.cloud.storage.bucket)\n- [1.17.0](/python/docs/reference/storage/1.17.0/google.cloud.storage.bucket) \nCreate / interact with Google Cloud Storage buckets.\n\nClasses\n-------\n\n### [Bucket](/python/docs/reference/storage/latest/google.cloud.storage.bucket.Bucket)\n\n Bucket(client, name=None, user_project=None, generation=None)\n\nA class representing a Bucket on Cloud Storage.\n\n### [IAMConfiguration](/python/docs/reference/storage/latest/google.cloud.storage.bucket.IAMConfiguration)\n\n IAMConfiguration(bucket, public_access_prevention=\u003cobject object\u003e, uniform_bucket_level_access_enabled=\u003cobject object\u003e, uniform_bucket_level_access_locked_time=\u003cobject object\u003e, bucket_policy_only_enabled=\u003cobject object\u003e, bucket_policy_only_locked_time=\u003cobject object\u003e)\n\nMap a bucket's IAM configuration.\n\n### [LifecycleRuleAbortIncompleteMultipartUpload](/python/docs/reference/storage/latest/google.cloud.storage.bucket.LifecycleRuleAbortIncompleteMultipartUpload)\n\n LifecycleRuleAbortIncompleteMultipartUpload(**kw)\n\nMap a rule aborting incomplete multipart uploads of matching items.\n\nThe \"age\" lifecycle condition is the only supported condition for this rule.\n\n### [LifecycleRuleConditions](/python/docs/reference/storage/latest/google.cloud.storage.bucket.LifecycleRuleConditions)\n\n LifecycleRuleConditions(\n age=None,\n created_before=None,\n is_live=None,\n matches_storage_class=None,\n number_of_newer_versions=None,\n days_since_custom_time=None,\n custom_time_before=None,\n days_since_noncurrent_time=None,\n noncurrent_time_before=None,\n matches_prefix=None,\n matches_suffix=None,\n _factory=False,\n )\n\nMap a single lifecycle rule for a bucket.\n\nSee: \u003chttps://cloud.google.com/storage/docs/lifecycle\u003e\n\n### [LifecycleRuleDelete](/python/docs/reference/storage/latest/google.cloud.storage.bucket.LifecycleRuleDelete)\n\n LifecycleRuleDelete(**kw)\n\nMap a lifecycle rule deleting matching items.\n\n### [LifecycleRuleSetStorageClass](/python/docs/reference/storage/latest/google.cloud.storage.bucket.LifecycleRuleSetStorageClass)\n\n LifecycleRuleSetStorageClass(storage_class, **kw)\n\nMap a lifecycle rule updating storage class of matching items.\n\n### [SoftDeletePolicy](/python/docs/reference/storage/latest/google.cloud.storage.bucket.SoftDeletePolicy)\n\n SoftDeletePolicy(bucket, **kw)\n\nMap a bucket's soft delete policy.\n\nSee \u003chttps://cloud.google.com/storage/docs/soft-delete\u003e"]]