Skip to content
Start here

Lifecycle

Get Object Lifecycle Rules
r2.buckets.lifecycle.get(strbucket_name, LifecycleGetParams**kwargs) -> LifecycleGetResponse
GET/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle
Put Object Lifecycle Rules
r2.buckets.lifecycle.update(strbucket_name, LifecycleUpdateParams**kwargs) -> object
PUT/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle
ModelsExpand Collapse
class LifecycleGetResponse:
rules: Optional[List[Rule]]
id: str

Unique identifier for this rule.

conditions: RuleConditions

Conditions that apply to all transitions of this rule.

prefix: str

Transitions will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads.

enabled: bool

Whether or not this rule is in effect.

abort_multipart_uploads_transition: Optional[RuleAbortMultipartUploadsTransition]

Transition to abort ongoing multipart uploads.

condition: Optional[RuleAbortMultipartUploadsTransitionCondition]

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

max_age: int
type: Literal["Age"]
delete_objects_transition: Optional[RuleDeleteObjectsTransition]

Transition to delete objects.

condition: Optional[RuleDeleteObjectsTransitionCondition]

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

One of the following:
class RuleDeleteObjectsTransitionConditionR2LifecycleAgeCondition:

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

max_age: int
type: Literal["Age"]
class RuleDeleteObjectsTransitionConditionR2LifecycleDateCondition:

Condition for lifecycle transitions to apply on a specific date.

date: datetime
formatdate-time
type: Literal["Date"]
storage_class_transitions: Optional[List[RuleStorageClassTransition]]

Transitions to change the storage class of objects.

condition: RuleStorageClassTransitionCondition

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

One of the following:
class RuleStorageClassTransitionConditionR2LifecycleAgeCondition:

Condition for lifecycle transitions to apply after an object reaches an age in seconds.

max_age: int
type: Literal["Age"]
class RuleStorageClassTransitionConditionR2LifecycleDateCondition:

Condition for lifecycle transitions to apply on a specific date.

date: datetime
formatdate-time
type: Literal["Date"]
storage_class: Literal["InfrequentAccess"]