Skip to main content

buckets

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

Overview

Namebuckets
TypeResource
Idcloudflare.r2.buckets

Fields

The following fields are returned by SELECT queries:

Get Bucket response.

NameDatatypeDescription
namestringName of the bucket. (example: example-bucket)
creation_datestringCreation timestamp.
jurisdictionstringJurisdiction where objects in this bucket are guaranteed to be stored. (default, eu, fedramp) (default: default, x-stainless-param: jurisdiction)
locationstringLocation of the bucket. (apac, eeur, enam, weur, wnam, oc) (x-stainless-terraform-configurability: computed_optional)
storage_classstringStorage class for newly uploaded objects, unless specified otherwise. (Standard, InfrequentAccess) (default: Standard)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, bucket_namecf-r2-jurisdictionGets properties of an existing R2 bucket.
listselectaccount_idname_contains, start_after, per_page, order, direction, cursor, cf-r2-jurisdictionLists all R2 buckets on your account.
createinsertaccount_id, namecf-r2-jurisdictionCreates a new R2 bucket.
editupdateaccount_id, bucket_namecf-r2-jurisdiction, cf-r2-storage-classUpdates properties of an existing R2 bucket.
deletedeletebucket_name, account_idcf-r2-jurisdictionDeletes an existing R2 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
cf-r2-storage-classstring
cursorstring
directionstring
name_containsstring
orderstring
per_pagenumber
start_afterstring

SELECT examples

Gets properties of an existing R2 bucket.

SELECT
name,
creation_date,
jurisdiction,
location,
storage_class
FROM cloudflare.r2.buckets
WHERE account_id = '{{ account_id }}' -- required
AND bucket_name = '{{ bucket_name }}' -- required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction }}'
;

INSERT examples

Creates a new R2 bucket.

INSERT INTO cloudflare.r2.buckets (
locationHint,
name,
storageClass,
account_id,
cf-r2-jurisdiction
)
SELECT
'{{ locationHint }}',
'{{ name }}' /* required */,
'{{ storageClass }}',
'{{ account_id }}',
'{{ cf-r2-jurisdiction }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Updates properties of an existing R2 bucket.

UPDATE cloudflare.r2.buckets
SET
-- No updatable properties
WHERE
account_id = '{{ account_id }}' --required
AND bucket_name = '{{ bucket_name }}' --required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction}}'
AND cf-r2-storage-class = '{{ cf-r2-storage-class}}'
RETURNING
errors,
messages,
result,
success;

DELETE examples

Deletes an existing R2 bucket.

DELETE FROM cloudflare.r2.buckets
WHERE bucket_name = '{{ bucket_name }}' --required
AND account_id = '{{ account_id }}' --required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction }}'
;