lifecycle
Creates, updates, deletes, gets or lists a lifecycle resource.
Overview
| Name | lifecycle |
| Type | Resource |
| Id | cloudflare.r2.lifecycle |
Fields
The following fields are returned by SELECT queries:
- list
Success Response.
| Name | Datatype | Description |
|---|---|---|
id | string | Unique identifier for this rule. (example: Expire all objects older than 24 hours) |
abortMultipartUploadsTransition | object | Transition to abort ongoing multipart uploads. |
conditions | object | Conditions that apply to all transitions of this rule. |
deleteObjectsTransition | object | Transition to delete objects. |
enabled | boolean | Whether or not this rule is in effect. |
storageClassTransitions | array | Transitions to change the storage class of objects. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | bucket_name, account_id | cf-r2-jurisdiction | Get object lifecycle rules for a bucket. |
update | replace | bucket_name, account_id | cf-r2-jurisdiction | Set the object lifecycle rules for a bucket. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
bucket_name | string | The R2 bucket name. |
cf-r2-jurisdiction | string |
SELECT examples
- list
Get object lifecycle rules for a bucket.
SELECT
id,
abortMultipartUploadsTransition,
conditions,
deleteObjectsTransition,
enabled,
storageClassTransitions
FROM cloudflare.r2.lifecycle
WHERE bucket_name = '{{ bucket_name }}' -- required
AND account_id = '{{ account_id }}' -- required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction }}'
;
REPLACE examples
- update
Set the object lifecycle rules for a bucket.
REPLACE cloudflare.r2.lifecycle
SET
rules = '{{ rules }}'
WHERE
bucket_name = '{{ bucket_name }}' --required
AND account_id = '{{ account_id }}' --required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction}}'
RETURNING
errors,
messages,
result,
success;