Skip to main content

locks

Creates, updates, deletes, gets or lists a locks resource.

Overview

Namelocks
TypeResource
Idcloudflare.r2.locks

Fields

The following fields are returned by SELECT queries:

Success Response.

NameDatatypeDescription
idstringUnique identifier for this rule. (example: Lock all objects for 24 hours)
conditionobjectCondition to apply a lock rule to an object for how long in seconds.
enabledbooleanWhether or not this rule is in effect.
prefixstringRule 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.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectbucket_name, account_idcf-r2-jurisdictionGet lock rules for a bucket.
updateexecbucket_name, account_idcf-r2-jurisdictionSet lock 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.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
bucket_namestringThe R2 bucket name.
cf-r2-jurisdictionstring

SELECT examples

Get lock rules for a bucket.

SELECT
id,
condition,
enabled,
prefix
FROM cloudflare.r2.locks
WHERE bucket_name = '{{ bucket_name }}' -- required
AND account_id = '{{ account_id }}' -- required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction }}'
;

Lifecycle Methods

Set lock rules for a bucket.

EXEC cloudflare.r2.locks.update
@bucket_name='{{ bucket_name }}' --required,
@account_id='{{ account_id }}' --required,
@cf-r2-jurisdiction='{{ cf-r2-jurisdiction }}'
@@json=
'{
"rules": "{{ rules }}"
}'
;