# R2 # Buckets ## List Buckets `client.R2.Buckets.List(ctx, params) (*BucketListResponse, error)` **get** `/accounts/{account_id}/r2/buckets` Lists all R2 buckets on your account. ### Parameters - `params BucketListParams` - `AccountID param.Field[string]` Path param: Account ID. - `Cursor param.Field[string]` Query param: Pagination cursor received during the last List Buckets call. R2 buckets are paginated using cursors instead of page numbers. - `Direction param.Field[BucketListParamsDirection]` Query param: Direction to order buckets. - `const BucketListParamsDirectionAsc BucketListParamsDirection = "asc"` - `const BucketListParamsDirectionDesc BucketListParamsDirection = "desc"` - `NameContains param.Field[string]` Query param: Bucket names to filter by. Only buckets with this phrase in their name will be returned. - `Order param.Field[BucketListParamsOrder]` Query param: Field to order buckets by. - `const BucketListParamsOrderName BucketListParamsOrder = "name"` - `PerPage param.Field[float64]` Query param: Maximum number of buckets to return in a single call. - `StartAfter param.Field[string]` Query param: Bucket name to start searching after. Buckets are ordered lexicographically. - `Jurisdiction param.Field[BucketListParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketListParamsCfR2JurisdictionDefault BucketListParamsCfR2Jurisdiction = "default"` - `const BucketListParamsCfR2JurisdictionEu BucketListParamsCfR2Jurisdiction = "eu"` - `const BucketListParamsCfR2JurisdictionFedramp BucketListParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketListResponse struct{…}` - `Buckets []Bucket` - `CreationDate string` Creation timestamp. - `Jurisdiction BucketJurisdiction` Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketJurisdictionDefault BucketJurisdiction = "default"` - `const BucketJurisdictionEu BucketJurisdiction = "eu"` - `const BucketJurisdictionFedramp BucketJurisdiction = "fedramp"` - `Location BucketLocation` Location of the bucket. - `const BucketLocationApac BucketLocation = "apac"` - `const BucketLocationEeur BucketLocation = "eeur"` - `const BucketLocationEnam BucketLocation = "enam"` - `const BucketLocationWeur BucketLocation = "weur"` - `const BucketLocationWnam BucketLocation = "wnam"` - `const BucketLocationOc BucketLocation = "oc"` - `Name string` Name of the bucket. - `StorageClass BucketStorageClass` Storage class for newly uploaded objects, unless specified otherwise. - `const BucketStorageClassStandard BucketStorageClass = "Standard"` - `const BucketStorageClassInfrequentAccess BucketStorageClass = "InfrequentAccess"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) buckets, err := client.R2.Buckets.List(context.TODO(), r2.BucketListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", buckets.Buckets) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "buckets": [ { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" } ] }, "success": true, "result_info": { "cursor": "1-JTdCJTIydiUyMiUzQTElMkMlMjJzdGFydEFmdGVyJTIyJTNBJTIyZGF2aWRwdWJsaWMlMjIlN0Q=", "per_page": 20 } } ``` ## Get Bucket `client.R2.Buckets.Get(ctx, bucketName, params) (*Bucket, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}` Gets properties of an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketGetParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketGetParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketGetParamsCfR2JurisdictionDefault BucketGetParamsCfR2Jurisdiction = "default"` - `const BucketGetParamsCfR2JurisdictionEu BucketGetParamsCfR2Jurisdiction = "eu"` - `const BucketGetParamsCfR2JurisdictionFedramp BucketGetParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type Bucket struct{…}` A single R2 bucket. - `CreationDate string` Creation timestamp. - `Jurisdiction BucketJurisdiction` Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketJurisdictionDefault BucketJurisdiction = "default"` - `const BucketJurisdictionEu BucketJurisdiction = "eu"` - `const BucketJurisdictionFedramp BucketJurisdiction = "fedramp"` - `Location BucketLocation` Location of the bucket. - `const BucketLocationApac BucketLocation = "apac"` - `const BucketLocationEeur BucketLocation = "eeur"` - `const BucketLocationEnam BucketLocation = "enam"` - `const BucketLocationWeur BucketLocation = "weur"` - `const BucketLocationWnam BucketLocation = "wnam"` - `const BucketLocationOc BucketLocation = "oc"` - `Name string` Name of the bucket. - `StorageClass BucketStorageClass` Storage class for newly uploaded objects, unless specified otherwise. - `const BucketStorageClassStandard BucketStorageClass = "Standard"` - `const BucketStorageClassInfrequentAccess BucketStorageClass = "InfrequentAccess"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) bucket, err := client.R2.Buckets.Get( context.TODO(), "example-bucket", r2.BucketGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bucket.CreationDate) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" }, "success": true } ``` ## Create Bucket `client.R2.Buckets.New(ctx, params) (*Bucket, error)` **post** `/accounts/{account_id}/r2/buckets` Creates a new R2 bucket. ### Parameters - `params BucketNewParams` - `AccountID param.Field[string]` Path param: Account ID. - `Name param.Field[string]` Body param: Name of the bucket. - `LocationHint param.Field[BucketNewParamsLocationHint]` Body param: Location of the bucket. - `const BucketNewParamsLocationHintApac BucketNewParamsLocationHint = "apac"` - `const BucketNewParamsLocationHintEeur BucketNewParamsLocationHint = "eeur"` - `const BucketNewParamsLocationHintEnam BucketNewParamsLocationHint = "enam"` - `const BucketNewParamsLocationHintWeur BucketNewParamsLocationHint = "weur"` - `const BucketNewParamsLocationHintWnam BucketNewParamsLocationHint = "wnam"` - `const BucketNewParamsLocationHintOc BucketNewParamsLocationHint = "oc"` - `StorageClass param.Field[BucketNewParamsStorageClass]` Body param: Storage class for newly uploaded objects, unless specified otherwise. - `const BucketNewParamsStorageClassStandard BucketNewParamsStorageClass = "Standard"` - `const BucketNewParamsStorageClassInfrequentAccess BucketNewParamsStorageClass = "InfrequentAccess"` - `Jurisdiction param.Field[BucketNewParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketNewParamsCfR2JurisdictionDefault BucketNewParamsCfR2Jurisdiction = "default"` - `const BucketNewParamsCfR2JurisdictionEu BucketNewParamsCfR2Jurisdiction = "eu"` - `const BucketNewParamsCfR2JurisdictionFedramp BucketNewParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type Bucket struct{…}` A single R2 bucket. - `CreationDate string` Creation timestamp. - `Jurisdiction BucketJurisdiction` Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketJurisdictionDefault BucketJurisdiction = "default"` - `const BucketJurisdictionEu BucketJurisdiction = "eu"` - `const BucketJurisdictionFedramp BucketJurisdiction = "fedramp"` - `Location BucketLocation` Location of the bucket. - `const BucketLocationApac BucketLocation = "apac"` - `const BucketLocationEeur BucketLocation = "eeur"` - `const BucketLocationEnam BucketLocation = "enam"` - `const BucketLocationWeur BucketLocation = "weur"` - `const BucketLocationWnam BucketLocation = "wnam"` - `const BucketLocationOc BucketLocation = "oc"` - `Name string` Name of the bucket. - `StorageClass BucketStorageClass` Storage class for newly uploaded objects, unless specified otherwise. - `const BucketStorageClassStandard BucketStorageClass = "Standard"` - `const BucketStorageClassInfrequentAccess BucketStorageClass = "InfrequentAccess"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) bucket, err := client.R2.Buckets.New(context.TODO(), r2.BucketNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("example-bucket"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bucket.CreationDate) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" }, "success": true } ``` ## Patch Bucket `client.R2.Buckets.Edit(ctx, bucketName, params) (*Bucket, error)` **patch** `/accounts/{account_id}/r2/buckets/{bucket_name}` Updates properties of an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketEditParams` - `AccountID param.Field[string]` Path param: Account ID. - `StorageClass param.Field[BucketEditParamsCfR2StorageClass]` Header param: Storage class for newly uploaded objects, unless specified otherwise. - `const BucketEditParamsCfR2StorageClassStandard BucketEditParamsCfR2StorageClass = "Standard"` - `const BucketEditParamsCfR2StorageClassInfrequentAccess BucketEditParamsCfR2StorageClass = "InfrequentAccess"` - `Jurisdiction param.Field[BucketEditParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketEditParamsCfR2JurisdictionDefault BucketEditParamsCfR2Jurisdiction = "default"` - `const BucketEditParamsCfR2JurisdictionEu BucketEditParamsCfR2Jurisdiction = "eu"` - `const BucketEditParamsCfR2JurisdictionFedramp BucketEditParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type Bucket struct{…}` A single R2 bucket. - `CreationDate string` Creation timestamp. - `Jurisdiction BucketJurisdiction` Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketJurisdictionDefault BucketJurisdiction = "default"` - `const BucketJurisdictionEu BucketJurisdiction = "eu"` - `const BucketJurisdictionFedramp BucketJurisdiction = "fedramp"` - `Location BucketLocation` Location of the bucket. - `const BucketLocationApac BucketLocation = "apac"` - `const BucketLocationEeur BucketLocation = "eeur"` - `const BucketLocationEnam BucketLocation = "enam"` - `const BucketLocationWeur BucketLocation = "weur"` - `const BucketLocationWnam BucketLocation = "wnam"` - `const BucketLocationOc BucketLocation = "oc"` - `Name string` Name of the bucket. - `StorageClass BucketStorageClass` Storage class for newly uploaded objects, unless specified otherwise. - `const BucketStorageClassStandard BucketStorageClass = "Standard"` - `const BucketStorageClassInfrequentAccess BucketStorageClass = "InfrequentAccess"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) bucket, err := client.R2.Buckets.Edit( context.TODO(), "example-bucket", r2.BucketEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), StorageClass: cloudflare.F(r2.BucketEditParamsCfR2StorageClassStandard), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bucket.CreationDate) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "creation_date": "creation_date", "jurisdiction": "default", "location": "apac", "name": "example-bucket", "storage_class": "Standard" }, "success": true } ``` ## Delete Bucket `client.R2.Buckets.Delete(ctx, bucketName, params) (*BucketDeleteResponse, error)` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}` Deletes an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketDeleteParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketDeleteParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDeleteParamsCfR2JurisdictionDefault BucketDeleteParamsCfR2Jurisdiction = "default"` - `const BucketDeleteParamsCfR2JurisdictionEu BucketDeleteParamsCfR2Jurisdiction = "eu"` - `const BucketDeleteParamsCfR2JurisdictionFedramp BucketDeleteParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) bucket, err := client.R2.Buckets.Delete( context.TODO(), "example-bucket", r2.BucketDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", bucket) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Domain Types ### Bucket - `type Bucket struct{…}` A single R2 bucket. - `CreationDate string` Creation timestamp. - `Jurisdiction BucketJurisdiction` Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketJurisdictionDefault BucketJurisdiction = "default"` - `const BucketJurisdictionEu BucketJurisdiction = "eu"` - `const BucketJurisdictionFedramp BucketJurisdiction = "fedramp"` - `Location BucketLocation` Location of the bucket. - `const BucketLocationApac BucketLocation = "apac"` - `const BucketLocationEeur BucketLocation = "eeur"` - `const BucketLocationEnam BucketLocation = "enam"` - `const BucketLocationWeur BucketLocation = "weur"` - `const BucketLocationWnam BucketLocation = "wnam"` - `const BucketLocationOc BucketLocation = "oc"` - `Name string` Name of the bucket. - `StorageClass BucketStorageClass` Storage class for newly uploaded objects, unless specified otherwise. - `const BucketStorageClassStandard BucketStorageClass = "Standard"` - `const BucketStorageClassInfrequentAccess BucketStorageClass = "InfrequentAccess"` # Lifecycle ## Get Object Lifecycle Rules `client.R2.Buckets.Lifecycle.Get(ctx, bucketName, params) (*BucketLifecycleGetResponse, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle` Get object lifecycle rules for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketLifecycleGetParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketLifecycleGetParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketLifecycleGetParamsCfR2JurisdictionDefault BucketLifecycleGetParamsCfR2Jurisdiction = "default"` - `const BucketLifecycleGetParamsCfR2JurisdictionEu BucketLifecycleGetParamsCfR2Jurisdiction = "eu"` - `const BucketLifecycleGetParamsCfR2JurisdictionFedramp BucketLifecycleGetParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketLifecycleGetResponse struct{…}` - `Rules []BucketLifecycleGetResponseRule` - `ID string` Unique identifier for this rule. - `Conditions BucketLifecycleGetResponseRulesConditions` Conditions that apply to all transitions of this rule. - `Prefix string` 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. - `AbortMultipartUploadsTransition BucketLifecycleGetResponseRulesAbortMultipartUploadsTransition` Transition to abort ongoing multipart uploads. - `Condition BucketLifecycleGetResponseRulesAbortMultipartUploadsTransitionCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `MaxAge int64` - `Type BucketLifecycleGetResponseRulesAbortMultipartUploadsTransitionConditionType` - `const BucketLifecycleGetResponseRulesAbortMultipartUploadsTransitionConditionTypeAge BucketLifecycleGetResponseRulesAbortMultipartUploadsTransitionConditionType = "Age"` - `DeleteObjectsTransition BucketLifecycleGetResponseRulesDeleteObjectsTransition` Transition to delete objects. - `Condition BucketLifecycleGetResponseRulesDeleteObjectsTransitionCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `type BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleAgeCondition struct{…}` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `MaxAge int64` - `Type BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleAgeConditionType` - `const BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleAgeConditionTypeAge BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleAgeConditionType = "Age"` - `type BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleDateCondition struct{…}` Condition for lifecycle transitions to apply on a specific date. - `Date Time` - `Type BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleDateConditionType` - `const BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleDateConditionTypeDate BucketLifecycleGetResponseRulesDeleteObjectsTransitionConditionR2LifecycleDateConditionType = "Date"` - `StorageClassTransitions []BucketLifecycleGetResponseRulesStorageClassTransition` Transitions to change the storage class of objects. - `Condition BucketLifecycleGetResponseRulesStorageClassTransitionsCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `type BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleAgeCondition struct{…}` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `MaxAge int64` - `Type BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleAgeConditionType` - `const BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleAgeConditionTypeAge BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleAgeConditionType = "Age"` - `type BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleDateCondition struct{…}` Condition for lifecycle transitions to apply on a specific date. - `Date Time` - `Type BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleDateConditionType` - `const BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleDateConditionTypeDate BucketLifecycleGetResponseRulesStorageClassTransitionsConditionR2LifecycleDateConditionType = "Date"` - `StorageClass BucketLifecycleGetResponseRulesStorageClassTransitionsStorageClass` - `const BucketLifecycleGetResponseRulesStorageClassTransitionsStorageClassInfrequentAccess BucketLifecycleGetResponseRulesStorageClassTransitionsStorageClass = "InfrequentAccess"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) lifecycle, err := client.R2.Buckets.Lifecycle.Get( context.TODO(), "example-bucket", r2.BucketLifecycleGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lifecycle.Rules) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "rules": [ { "id": "Expire all objects older than 24 hours", "conditions": { "prefix": "prefix" }, "enabled": true, "abortMultipartUploadsTransition": { "condition": { "maxAge": 0, "type": "Age" } }, "deleteObjectsTransition": { "condition": { "maxAge": 0, "type": "Age" } }, "storageClassTransitions": [ { "condition": { "maxAge": 0, "type": "Age" }, "storageClass": "InfrequentAccess" } ] } ] }, "success": true } ``` ## Put Object Lifecycle Rules `client.R2.Buckets.Lifecycle.Update(ctx, bucketName, params) (*BucketLifecycleUpdateResponse, error)` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/lifecycle` Set the object lifecycle rules for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketLifecycleUpdateParams` - `AccountID param.Field[string]` Path param: Account ID. - `Rules param.Field[[]BucketLifecycleUpdateParamsRule]` Body param - `ID string` Unique identifier for this rule. - `Conditions BucketLifecycleUpdateParamsRulesConditions` Conditions that apply to all transitions of this rule. - `Prefix string` 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. - `AbortMultipartUploadsTransition BucketLifecycleUpdateParamsRulesAbortMultipartUploadsTransition` Transition to abort ongoing multipart uploads. - `Condition BucketLifecycleUpdateParamsRulesAbortMultipartUploadsTransitionCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `MaxAge int64` - `Type BucketLifecycleUpdateParamsRulesAbortMultipartUploadsTransitionConditionType` - `const BucketLifecycleUpdateParamsRulesAbortMultipartUploadsTransitionConditionTypeAge BucketLifecycleUpdateParamsRulesAbortMultipartUploadsTransitionConditionType = "Age"` - `DeleteObjectsTransition BucketLifecycleUpdateParamsRulesDeleteObjectsTransition` Transition to delete objects. - `Condition BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `type BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleAgeCondition struct{…}` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `MaxAge int64` - `Type BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleAgeConditionType` - `const BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleAgeConditionTypeAge BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleAgeConditionType = "Age"` - `type BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleDateCondition struct{…}` Condition for lifecycle transitions to apply on a specific date. - `Date Time` - `Type BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleDateConditionType` - `const BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleDateConditionTypeDate BucketLifecycleUpdateParamsRulesDeleteObjectsTransitionConditionR2LifecycleDateConditionType = "Date"` - `StorageClassTransitions []BucketLifecycleUpdateParamsRulesStorageClassTransition` Transitions to change the storage class of objects. - `Condition BucketLifecycleUpdateParamsRulesStorageClassTransitionsCondition` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `type BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleAgeCondition struct{…}` Condition for lifecycle transitions to apply after an object reaches an age in seconds. - `MaxAge int64` - `Type BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleAgeConditionType` - `const BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleAgeConditionTypeAge BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleAgeConditionType = "Age"` - `type BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleDateCondition struct{…}` Condition for lifecycle transitions to apply on a specific date. - `Date Time` - `Type BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleDateConditionType` - `const BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleDateConditionTypeDate BucketLifecycleUpdateParamsRulesStorageClassTransitionsConditionR2LifecycleDateConditionType = "Date"` - `StorageClass BucketLifecycleUpdateParamsRulesStorageClassTransitionsStorageClass` - `const BucketLifecycleUpdateParamsRulesStorageClassTransitionsStorageClassInfrequentAccess BucketLifecycleUpdateParamsRulesStorageClassTransitionsStorageClass = "InfrequentAccess"` - `Jurisdiction param.Field[BucketLifecycleUpdateParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketLifecycleUpdateParamsCfR2JurisdictionDefault BucketLifecycleUpdateParamsCfR2Jurisdiction = "default"` - `const BucketLifecycleUpdateParamsCfR2JurisdictionEu BucketLifecycleUpdateParamsCfR2Jurisdiction = "eu"` - `const BucketLifecycleUpdateParamsCfR2JurisdictionFedramp BucketLifecycleUpdateParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketLifecycleUpdateResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) lifecycle, err := client.R2.Buckets.Lifecycle.Update( context.TODO(), "example-bucket", r2.BucketLifecycleUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lifecycle) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` # CORS ## Get Bucket CORS Policy `client.R2.Buckets.CORS.Get(ctx, bucketName, params) (*BucketCORSGetResponse, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/cors` Get the CORS policy for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketCORSGetParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketCORSGetParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketCORSGetParamsCfR2JurisdictionDefault BucketCORSGetParamsCfR2Jurisdiction = "default"` - `const BucketCORSGetParamsCfR2JurisdictionEu BucketCORSGetParamsCfR2Jurisdiction = "eu"` - `const BucketCORSGetParamsCfR2JurisdictionFedramp BucketCORSGetParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketCORSGetResponse struct{…}` - `Rules []BucketCORSGetResponseRule` - `Allowed BucketCORSGetResponseRulesAllowed` Object specifying allowed origins, methods and headers for this CORS rule. - `Methods []BucketCORSGetResponseRulesAllowedMethod` Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser. - `const BucketCORSGetResponseRulesAllowedMethodGet BucketCORSGetResponseRulesAllowedMethod = "GET"` - `const BucketCORSGetResponseRulesAllowedMethodPut BucketCORSGetResponseRulesAllowedMethod = "PUT"` - `const BucketCORSGetResponseRulesAllowedMethodPost BucketCORSGetResponseRulesAllowedMethod = "POST"` - `const BucketCORSGetResponseRulesAllowedMethodDelete BucketCORSGetResponseRulesAllowedMethod = "DELETE"` - `const BucketCORSGetResponseRulesAllowedMethodHead BucketCORSGetResponseRulesAllowedMethod = "HEAD"` - `Origins []string` Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser. - `Headers []string` Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders. - `ID string` Identifier for this rule. - `ExposeHeaders []string` Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here. - `MaxAgeSeconds float64` Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cors, err := client.R2.Buckets.CORS.Get( context.TODO(), "example-bucket", r2.BucketCORSGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cors.Rules) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "rules": [ { "allowed": { "methods": [ "GET" ], "origins": [ "http://localhost:3000" ], "headers": [ "x-requested-by" ] }, "id": "Allow Local Development", "exposeHeaders": [ "Content-Encoding" ], "maxAgeSeconds": 3600 } ] }, "success": true } ``` ## Put Bucket CORS Policy `client.R2.Buckets.CORS.Update(ctx, bucketName, params) (*BucketCORSUpdateResponse, error)` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/cors` Set the CORS policy for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketCORSUpdateParams` - `AccountID param.Field[string]` Path param: Account ID. - `Rules param.Field[[]BucketCORSUpdateParamsRule]` Body param - `Allowed BucketCORSUpdateParamsRulesAllowed` Object specifying allowed origins, methods and headers for this CORS rule. - `Methods []BucketCORSUpdateParamsRulesAllowedMethod` Specifies the value for the Access-Control-Allow-Methods header R2 sets when requesting objects in a bucket from a browser. - `const BucketCORSUpdateParamsRulesAllowedMethodGet BucketCORSUpdateParamsRulesAllowedMethod = "GET"` - `const BucketCORSUpdateParamsRulesAllowedMethodPut BucketCORSUpdateParamsRulesAllowedMethod = "PUT"` - `const BucketCORSUpdateParamsRulesAllowedMethodPost BucketCORSUpdateParamsRulesAllowedMethod = "POST"` - `const BucketCORSUpdateParamsRulesAllowedMethodDelete BucketCORSUpdateParamsRulesAllowedMethod = "DELETE"` - `const BucketCORSUpdateParamsRulesAllowedMethodHead BucketCORSUpdateParamsRulesAllowedMethod = "HEAD"` - `Origins []string` Specifies the value for the Access-Control-Allow-Origin header R2 sets when requesting objects in a bucket from a browser. - `Headers []string` Specifies the value for the Access-Control-Allow-Headers header R2 sets when requesting objects in this bucket from a browser. Cross-origin requests that include custom headers (e.g. x-user-id) should specify these headers as AllowedHeaders. - `ID string` Identifier for this rule. - `ExposeHeaders []string` Specifies the headers that can be exposed back, and accessed by, the JavaScript making the cross-origin request. If you need to access headers beyond the safelisted response headers, such as Content-Encoding or cf-cache-status, you must specify it here. - `MaxAgeSeconds float64` Specifies the amount of time (in seconds) browsers are allowed to cache CORS preflight responses. Browsers may limit this to 2 hours or less, even if the maximum value (86400) is specified. - `Jurisdiction param.Field[BucketCORSUpdateParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketCORSUpdateParamsCfR2JurisdictionDefault BucketCORSUpdateParamsCfR2Jurisdiction = "default"` - `const BucketCORSUpdateParamsCfR2JurisdictionEu BucketCORSUpdateParamsCfR2Jurisdiction = "eu"` - `const BucketCORSUpdateParamsCfR2JurisdictionFedramp BucketCORSUpdateParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketCORSUpdateResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cors, err := client.R2.Buckets.CORS.Update( context.TODO(), "example-bucket", r2.BucketCORSUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cors) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Delete Bucket CORS Policy `client.R2.Buckets.CORS.Delete(ctx, bucketName, params) (*BucketCORSDeleteResponse, error)` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}/cors` Delete the CORS policy for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketCORSDeleteParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketCORSDeleteParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketCORSDeleteParamsCfR2JurisdictionDefault BucketCORSDeleteParamsCfR2Jurisdiction = "default"` - `const BucketCORSDeleteParamsCfR2JurisdictionEu BucketCORSDeleteParamsCfR2Jurisdiction = "eu"` - `const BucketCORSDeleteParamsCfR2JurisdictionFedramp BucketCORSDeleteParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketCORSDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cors, err := client.R2.Buckets.CORS.Delete( context.TODO(), "example-bucket", r2.BucketCORSDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cors) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` # Domains # Custom ## List Custom Domains of Bucket `client.R2.Buckets.Domains.Custom.List(ctx, bucketName, params) (*BucketDomainCustomListResponse, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom` Gets a list of all custom domains registered with an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketDomainCustomListParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketDomainCustomListParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDomainCustomListParamsCfR2JurisdictionDefault BucketDomainCustomListParamsCfR2Jurisdiction = "default"` - `const BucketDomainCustomListParamsCfR2JurisdictionEu BucketDomainCustomListParamsCfR2Jurisdiction = "eu"` - `const BucketDomainCustomListParamsCfR2JurisdictionFedramp BucketDomainCustomListParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDomainCustomListResponse struct{…}` - `Domains []BucketDomainCustomListResponseDomain` - `Domain string` Domain name of the custom domain to be added. - `Enabled bool` Whether this bucket is publicly accessible at the specified custom domain. - `Status BucketDomainCustomListResponseDomainsStatus` - `Ownership BucketDomainCustomListResponseDomainsStatusOwnership` Ownership status of the domain. - `const BucketDomainCustomListResponseDomainsStatusOwnershipPending BucketDomainCustomListResponseDomainsStatusOwnership = "pending"` - `const BucketDomainCustomListResponseDomainsStatusOwnershipActive BucketDomainCustomListResponseDomainsStatusOwnership = "active"` - `const BucketDomainCustomListResponseDomainsStatusOwnershipDeactivated BucketDomainCustomListResponseDomainsStatusOwnership = "deactivated"` - `const BucketDomainCustomListResponseDomainsStatusOwnershipBlocked BucketDomainCustomListResponseDomainsStatusOwnership = "blocked"` - `const BucketDomainCustomListResponseDomainsStatusOwnershipError BucketDomainCustomListResponseDomainsStatusOwnership = "error"` - `const BucketDomainCustomListResponseDomainsStatusOwnershipUnknown BucketDomainCustomListResponseDomainsStatusOwnership = "unknown"` - `SSL BucketDomainCustomListResponseDomainsStatusSSL` SSL certificate status. - `const BucketDomainCustomListResponseDomainsStatusSSLInitializing BucketDomainCustomListResponseDomainsStatusSSL = "initializing"` - `const BucketDomainCustomListResponseDomainsStatusSSLPending BucketDomainCustomListResponseDomainsStatusSSL = "pending"` - `const BucketDomainCustomListResponseDomainsStatusSSLActive BucketDomainCustomListResponseDomainsStatusSSL = "active"` - `const BucketDomainCustomListResponseDomainsStatusSSLDeactivated BucketDomainCustomListResponseDomainsStatusSSL = "deactivated"` - `const BucketDomainCustomListResponseDomainsStatusSSLError BucketDomainCustomListResponseDomainsStatusSSL = "error"` - `const BucketDomainCustomListResponseDomainsStatusSSLUnknown BucketDomainCustomListResponseDomainsStatusSSL = "unknown"` - `Ciphers []string` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `MinTLS BucketDomainCustomListResponseDomainsMinTLS` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `const BucketDomainCustomListResponseDomainsMinTLS1_0 BucketDomainCustomListResponseDomainsMinTLS = "1.0"` - `const BucketDomainCustomListResponseDomainsMinTLS1_1 BucketDomainCustomListResponseDomainsMinTLS = "1.1"` - `const BucketDomainCustomListResponseDomainsMinTLS1_2 BucketDomainCustomListResponseDomainsMinTLS = "1.2"` - `const BucketDomainCustomListResponseDomainsMinTLS1_3 BucketDomainCustomListResponseDomainsMinTLS = "1.3"` - `ZoneID string` Zone ID of the custom domain resides in. - `ZoneName string` Zone that the custom domain resides in. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) customs, err := client.R2.Buckets.Domains.Custom.List( context.TODO(), "example-bucket", r2.BucketDomainCustomListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", customs.Domains) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domains": [ { "domain": "prefix.example-domain.one.com", "enabled": false, "status": { "ownership": "deactivated", "ssl": "pending" }, "ciphers": [ "string" ], "minTLS": "1.0", "zoneId": "36ca64a6d92827b8a6b90be344bb1bfd", "zoneName": "example-domain.one.com" }, { "domain": "prefix.example-domain.two.com", "enabled": true, "status": { "ownership": "active", "ssl": "active" }, "ciphers": [ "string" ], "minTLS": "1.0", "zoneId": "d9d28585d5f8f5b0f857b055bf574f19", "zoneName": "zoneName" } ] }, "success": true } ``` ## Get Custom Domain Settings `client.R2.Buckets.Domains.Custom.Get(ctx, bucketName, domain, params) (*BucketDomainCustomGetResponse, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}` Get the configuration for a custom domain on an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `domain string` Name of the custom domain. - `params BucketDomainCustomGetParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketDomainCustomGetParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDomainCustomGetParamsCfR2JurisdictionDefault BucketDomainCustomGetParamsCfR2Jurisdiction = "default"` - `const BucketDomainCustomGetParamsCfR2JurisdictionEu BucketDomainCustomGetParamsCfR2Jurisdiction = "eu"` - `const BucketDomainCustomGetParamsCfR2JurisdictionFedramp BucketDomainCustomGetParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDomainCustomGetResponse struct{…}` - `Domain string` Domain name of the custom domain to be added. - `Enabled bool` Whether this bucket is publicly accessible at the specified custom domain. - `Status BucketDomainCustomGetResponseStatus` - `Ownership BucketDomainCustomGetResponseStatusOwnership` Ownership status of the domain. - `const BucketDomainCustomGetResponseStatusOwnershipPending BucketDomainCustomGetResponseStatusOwnership = "pending"` - `const BucketDomainCustomGetResponseStatusOwnershipActive BucketDomainCustomGetResponseStatusOwnership = "active"` - `const BucketDomainCustomGetResponseStatusOwnershipDeactivated BucketDomainCustomGetResponseStatusOwnership = "deactivated"` - `const BucketDomainCustomGetResponseStatusOwnershipBlocked BucketDomainCustomGetResponseStatusOwnership = "blocked"` - `const BucketDomainCustomGetResponseStatusOwnershipError BucketDomainCustomGetResponseStatusOwnership = "error"` - `const BucketDomainCustomGetResponseStatusOwnershipUnknown BucketDomainCustomGetResponseStatusOwnership = "unknown"` - `SSL BucketDomainCustomGetResponseStatusSSL` SSL certificate status. - `const BucketDomainCustomGetResponseStatusSSLInitializing BucketDomainCustomGetResponseStatusSSL = "initializing"` - `const BucketDomainCustomGetResponseStatusSSLPending BucketDomainCustomGetResponseStatusSSL = "pending"` - `const BucketDomainCustomGetResponseStatusSSLActive BucketDomainCustomGetResponseStatusSSL = "active"` - `const BucketDomainCustomGetResponseStatusSSLDeactivated BucketDomainCustomGetResponseStatusSSL = "deactivated"` - `const BucketDomainCustomGetResponseStatusSSLError BucketDomainCustomGetResponseStatusSSL = "error"` - `const BucketDomainCustomGetResponseStatusSSLUnknown BucketDomainCustomGetResponseStatusSSL = "unknown"` - `Ciphers []string` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `MinTLS BucketDomainCustomGetResponseMinTLS` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `const BucketDomainCustomGetResponseMinTLS1_0 BucketDomainCustomGetResponseMinTLS = "1.0"` - `const BucketDomainCustomGetResponseMinTLS1_1 BucketDomainCustomGetResponseMinTLS = "1.1"` - `const BucketDomainCustomGetResponseMinTLS1_2 BucketDomainCustomGetResponseMinTLS = "1.2"` - `const BucketDomainCustomGetResponseMinTLS1_3 BucketDomainCustomGetResponseMinTLS = "1.3"` - `ZoneID string` Zone ID of the custom domain resides in. - `ZoneName string` Zone that the custom domain resides in. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) custom, err := client.R2.Buckets.Domains.Custom.Get( context.TODO(), "example-bucket", "example-domain/custom-domain.com", r2.BucketDomainCustomGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", custom.Domain) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "prefix.example-domain.one.com", "enabled": false, "status": { "ownership": "deactivated", "ssl": "pending" }, "ciphers": [ "string" ], "minTLS": "1.0", "zoneId": "36ca64a6d92827b8a6b90be344bb1bfd", "zoneName": "example-domain.one.com" }, "success": true } ``` ## Attach Custom Domain To Bucket `client.R2.Buckets.Domains.Custom.New(ctx, bucketName, params) (*BucketDomainCustomNewResponse, error)` **post** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom` Register a new custom domain for an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketDomainCustomNewParams` - `AccountID param.Field[string]` Path param: Account ID. - `Domain param.Field[string]` Body param: Name of the custom domain to be added. - `Enabled param.Field[bool]` Body param: Whether to enable public bucket access at the custom domain. If undefined, the domain will be enabled. - `ZoneID param.Field[string]` Body param: Zone ID of the custom domain. - `Ciphers param.Field[[]string]` Body param: An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `MinTLS param.Field[BucketDomainCustomNewParamsMinTLS]` Body param: Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `const BucketDomainCustomNewParamsMinTLS1_0 BucketDomainCustomNewParamsMinTLS = "1.0"` - `const BucketDomainCustomNewParamsMinTLS1_1 BucketDomainCustomNewParamsMinTLS = "1.1"` - `const BucketDomainCustomNewParamsMinTLS1_2 BucketDomainCustomNewParamsMinTLS = "1.2"` - `const BucketDomainCustomNewParamsMinTLS1_3 BucketDomainCustomNewParamsMinTLS = "1.3"` - `Jurisdiction param.Field[BucketDomainCustomNewParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDomainCustomNewParamsCfR2JurisdictionDefault BucketDomainCustomNewParamsCfR2Jurisdiction = "default"` - `const BucketDomainCustomNewParamsCfR2JurisdictionEu BucketDomainCustomNewParamsCfR2Jurisdiction = "eu"` - `const BucketDomainCustomNewParamsCfR2JurisdictionFedramp BucketDomainCustomNewParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDomainCustomNewResponse struct{…}` - `Domain string` Domain name of the affected custom domain. - `Enabled bool` Whether this bucket is publicly accessible at the specified custom domain. - `Ciphers []string` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `MinTLS BucketDomainCustomNewResponseMinTLS` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `const BucketDomainCustomNewResponseMinTLS1_0 BucketDomainCustomNewResponseMinTLS = "1.0"` - `const BucketDomainCustomNewResponseMinTLS1_1 BucketDomainCustomNewResponseMinTLS = "1.1"` - `const BucketDomainCustomNewResponseMinTLS1_2 BucketDomainCustomNewResponseMinTLS = "1.2"` - `const BucketDomainCustomNewResponseMinTLS1_3 BucketDomainCustomNewResponseMinTLS = "1.3"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) custom, err := client.R2.Buckets.Domains.Custom.New( context.TODO(), "example-bucket", r2.BucketDomainCustomNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Domain: cloudflare.F("prefix.example-domain.com"), Enabled: cloudflare.F(true), ZoneID: cloudflare.F("36ca64a6d92827b8a6b90be344bb1bfd"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", custom.Domain) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "example-domain.com", "enabled": true, "ciphers": [ "string" ], "minTLS": "1.0" }, "success": true } ``` ## Configure Custom Domain Settings `client.R2.Buckets.Domains.Custom.Update(ctx, bucketName, domain, params) (*BucketDomainCustomUpdateResponse, error)` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}` Edit the configuration for a custom domain on an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `domain string` Name of the custom domain. - `params BucketDomainCustomUpdateParams` - `AccountID param.Field[string]` Path param: Account ID. - `Ciphers param.Field[[]string]` Body param: An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `Enabled param.Field[bool]` Body param: Whether to enable public bucket access at the specified custom domain. - `MinTLS param.Field[BucketDomainCustomUpdateParamsMinTLS]` Body param: Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to previous value. - `const BucketDomainCustomUpdateParamsMinTLS1_0 BucketDomainCustomUpdateParamsMinTLS = "1.0"` - `const BucketDomainCustomUpdateParamsMinTLS1_1 BucketDomainCustomUpdateParamsMinTLS = "1.1"` - `const BucketDomainCustomUpdateParamsMinTLS1_2 BucketDomainCustomUpdateParamsMinTLS = "1.2"` - `const BucketDomainCustomUpdateParamsMinTLS1_3 BucketDomainCustomUpdateParamsMinTLS = "1.3"` - `Jurisdiction param.Field[BucketDomainCustomUpdateParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDomainCustomUpdateParamsCfR2JurisdictionDefault BucketDomainCustomUpdateParamsCfR2Jurisdiction = "default"` - `const BucketDomainCustomUpdateParamsCfR2JurisdictionEu BucketDomainCustomUpdateParamsCfR2Jurisdiction = "eu"` - `const BucketDomainCustomUpdateParamsCfR2JurisdictionFedramp BucketDomainCustomUpdateParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDomainCustomUpdateResponse struct{…}` - `Domain string` Domain name of the affected custom domain. - `Ciphers []string` An allowlist of ciphers for TLS termination. These ciphers must be in the BoringSSL format. - `Enabled bool` Whether this bucket is publicly accessible at the specified custom domain. - `MinTLS BucketDomainCustomUpdateResponseMinTLS` Minimum TLS Version the custom domain will accept for incoming connections. If not set, defaults to 1.0. - `const BucketDomainCustomUpdateResponseMinTLS1_0 BucketDomainCustomUpdateResponseMinTLS = "1.0"` - `const BucketDomainCustomUpdateResponseMinTLS1_1 BucketDomainCustomUpdateResponseMinTLS = "1.1"` - `const BucketDomainCustomUpdateResponseMinTLS1_2 BucketDomainCustomUpdateResponseMinTLS = "1.2"` - `const BucketDomainCustomUpdateResponseMinTLS1_3 BucketDomainCustomUpdateResponseMinTLS = "1.3"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) custom, err := client.R2.Buckets.Domains.Custom.Update( context.TODO(), "example-bucket", "example-domain/custom-domain.com", r2.BucketDomainCustomUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", custom.Domain) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "example-domain.com", "ciphers": [ "string" ], "enabled": true, "minTLS": "1.0" }, "success": true } ``` ## Remove Custom Domain From Bucket `client.R2.Buckets.Domains.Custom.Delete(ctx, bucketName, domain, params) (*BucketDomainCustomDeleteResponse, error)` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/custom/{domain}` Remove custom domain registration from an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `domain string` Name of the custom domain. - `params BucketDomainCustomDeleteParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketDomainCustomDeleteParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDomainCustomDeleteParamsCfR2JurisdictionDefault BucketDomainCustomDeleteParamsCfR2Jurisdiction = "default"` - `const BucketDomainCustomDeleteParamsCfR2JurisdictionEu BucketDomainCustomDeleteParamsCfR2Jurisdiction = "eu"` - `const BucketDomainCustomDeleteParamsCfR2JurisdictionFedramp BucketDomainCustomDeleteParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDomainCustomDeleteResponse struct{…}` - `Domain string` Name of the removed custom domain. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) custom, err := client.R2.Buckets.Domains.Custom.Delete( context.TODO(), "example-bucket", "example-domain/custom-domain.com", r2.BucketDomainCustomDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", custom.Domain) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "domain": "example-domain/custom-domain.com" }, "success": true } ``` # Managed ## Get r2.dev Domain of Bucket `client.R2.Buckets.Domains.Managed.List(ctx, bucketName, params) (*BucketDomainManagedListResponse, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed` Gets state of public access over the bucket's R2-managed (r2.dev) domain. ### Parameters - `bucketName string` Name of the bucket. - `params BucketDomainManagedListParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketDomainManagedListParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDomainManagedListParamsCfR2JurisdictionDefault BucketDomainManagedListParamsCfR2Jurisdiction = "default"` - `const BucketDomainManagedListParamsCfR2JurisdictionEu BucketDomainManagedListParamsCfR2Jurisdiction = "eu"` - `const BucketDomainManagedListParamsCfR2JurisdictionFedramp BucketDomainManagedListParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDomainManagedListResponse struct{…}` - `BucketID string` Bucket ID. - `Domain string` Domain name of the bucket's r2.dev domain. - `Enabled bool` Whether this bucket is publicly accessible at the r2.dev domain. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) manageds, err := client.R2.Buckets.Domains.Managed.List( context.TODO(), "example-bucket", r2.BucketDomainManagedListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", manageds.BucketID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "bucketId": "0113a9e4549cf9b1ff1bf56e04da0cef", "domain": "pub-0113a9e4549cf9b1ff1bf56e04da0cef.r2.dev", "enabled": true }, "success": true } ``` ## Update r2.dev Domain of Bucket `client.R2.Buckets.Domains.Managed.Update(ctx, bucketName, params) (*BucketDomainManagedUpdateResponse, error)` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/domains/managed` Updates state of public access over the bucket's R2-managed (r2.dev) domain. ### Parameters - `bucketName string` Name of the bucket. - `params BucketDomainManagedUpdateParams` - `AccountID param.Field[string]` Path param: Account ID. - `Enabled param.Field[bool]` Body param: Whether to enable public bucket access at the r2.dev domain. - `Jurisdiction param.Field[BucketDomainManagedUpdateParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketDomainManagedUpdateParamsCfR2JurisdictionDefault BucketDomainManagedUpdateParamsCfR2Jurisdiction = "default"` - `const BucketDomainManagedUpdateParamsCfR2JurisdictionEu BucketDomainManagedUpdateParamsCfR2Jurisdiction = "eu"` - `const BucketDomainManagedUpdateParamsCfR2JurisdictionFedramp BucketDomainManagedUpdateParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketDomainManagedUpdateResponse struct{…}` - `BucketID string` Bucket ID. - `Domain string` Domain name of the bucket's r2.dev domain. - `Enabled bool` Whether this bucket is publicly accessible at the r2.dev domain. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) managed, err := client.R2.Buckets.Domains.Managed.Update( context.TODO(), "example-bucket", r2.BucketDomainManagedUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Enabled: cloudflare.F(true), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", managed.BucketID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "bucketId": "0113a9e4549cf9b1ff1bf56e04da0cef", "domain": "pub-0113a9e4549cf9b1ff1bf56e04da0cef.r2.dev", "enabled": true }, "success": true } ``` # Event Notifications ## List Event Notification Rules `client.R2.Buckets.EventNotifications.List(ctx, bucketName, params) (*BucketEventNotificationListResponse, error)` **get** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration` List all event notification rules for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketEventNotificationListParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketEventNotificationListParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketEventNotificationListParamsCfR2JurisdictionDefault BucketEventNotificationListParamsCfR2Jurisdiction = "default"` - `const BucketEventNotificationListParamsCfR2JurisdictionEu BucketEventNotificationListParamsCfR2Jurisdiction = "eu"` - `const BucketEventNotificationListParamsCfR2JurisdictionFedramp BucketEventNotificationListParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketEventNotificationListResponse struct{…}` - `BucketName string` Name of the bucket. - `Queues []BucketEventNotificationListResponseQueue` List of queues associated with the bucket. - `QueueID string` Queue ID. - `QueueName string` Name of the queue. - `Rules []BucketEventNotificationListResponseQueuesRule` - `Actions []BucketEventNotificationListResponseQueuesRulesAction` Array of R2 object actions that will trigger notifications. - `const BucketEventNotificationListResponseQueuesRulesActionPutObject BucketEventNotificationListResponseQueuesRulesAction = "PutObject"` - `const BucketEventNotificationListResponseQueuesRulesActionCopyObject BucketEventNotificationListResponseQueuesRulesAction = "CopyObject"` - `const BucketEventNotificationListResponseQueuesRulesActionDeleteObject BucketEventNotificationListResponseQueuesRulesAction = "DeleteObject"` - `const BucketEventNotificationListResponseQueuesRulesActionCompleteMultipartUpload BucketEventNotificationListResponseQueuesRulesAction = "CompleteMultipartUpload"` - `const BucketEventNotificationListResponseQueuesRulesActionLifecycleDeletion BucketEventNotificationListResponseQueuesRulesAction = "LifecycleDeletion"` - `CreatedAt string` Timestamp when the rule was created. - `Description string` A description that can be used to identify the event notification rule after creation. - `Prefix string` Notifications will be sent only for objects with this prefix. - `RuleID string` Rule ID. - `Suffix string` Notifications will be sent only for objects with this suffix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) eventNotifications, err := client.R2.Buckets.EventNotifications.List( context.TODO(), "example-bucket", r2.BucketEventNotificationListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", eventNotifications.BucketName) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "bucketName": "bucketName", "queues": [ { "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "queueName": "first-queue", "rules": [ { "actions": [ "PutObject", "CopyObject" ], "createdAt": "2024-09-19T21:54:48.405Z", "description": "Notifications from source bucket to queue", "prefix": "img/", "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "suffix": ".jpeg" } ] } ] }, "success": true } ``` ## Get Event Notification Rule `client.R2.Buckets.EventNotifications.Get(ctx, bucketName, queueID, params) (*BucketEventNotificationGetResponse, error)` **get** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Get a single event notification rule. ### Parameters - `bucketName string` Name of the bucket. - `queueID string` Queue ID. - `params BucketEventNotificationGetParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketEventNotificationGetParamsCfR2Jurisdiction]` Header param: The bucket jurisdiction. - `const BucketEventNotificationGetParamsCfR2JurisdictionDefault BucketEventNotificationGetParamsCfR2Jurisdiction = "default"` - `const BucketEventNotificationGetParamsCfR2JurisdictionEu BucketEventNotificationGetParamsCfR2Jurisdiction = "eu"` - `const BucketEventNotificationGetParamsCfR2JurisdictionFedramp BucketEventNotificationGetParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketEventNotificationGetResponse struct{…}` - `QueueID string` Queue ID. - `QueueName string` Name of the queue. - `Rules []BucketEventNotificationGetResponseRule` - `Actions []BucketEventNotificationGetResponseRulesAction` Array of R2 object actions that will trigger notifications. - `const BucketEventNotificationGetResponseRulesActionPutObject BucketEventNotificationGetResponseRulesAction = "PutObject"` - `const BucketEventNotificationGetResponseRulesActionCopyObject BucketEventNotificationGetResponseRulesAction = "CopyObject"` - `const BucketEventNotificationGetResponseRulesActionDeleteObject BucketEventNotificationGetResponseRulesAction = "DeleteObject"` - `const BucketEventNotificationGetResponseRulesActionCompleteMultipartUpload BucketEventNotificationGetResponseRulesAction = "CompleteMultipartUpload"` - `const BucketEventNotificationGetResponseRulesActionLifecycleDeletion BucketEventNotificationGetResponseRulesAction = "LifecycleDeletion"` - `CreatedAt string` Timestamp when the rule was created. - `Description string` A description that can be used to identify the event notification rule after creation. - `Prefix string` Notifications will be sent only for objects with this prefix. - `RuleID string` Rule ID. - `Suffix string` Notifications will be sent only for objects with this suffix. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) eventNotification, err := client.R2.Buckets.EventNotifications.Get( context.TODO(), "example-bucket", "queue_id", r2.BucketEventNotificationGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", eventNotification.QueueID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "queueId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "queueName": "first-queue", "rules": [ { "actions": [ "PutObject", "CopyObject" ], "createdAt": "2024-09-19T21:54:48.405Z", "description": "Notifications from source bucket to queue", "prefix": "img/", "ruleId": "11111aa1-11aa-111a-a1a1-a1a111a11a11", "suffix": ".jpeg" } ] }, "success": true } ``` ## Create Event Notification Rule `client.R2.Buckets.EventNotifications.Update(ctx, bucketName, queueID, params) (*BucketEventNotificationUpdateResponse, error)` **put** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Create event notification rule. ### Parameters - `bucketName string` Name of the bucket. - `queueID string` Queue ID. - `params BucketEventNotificationUpdateParams` - `AccountID param.Field[string]` Path param: Account ID. - `Rules param.Field[[]BucketEventNotificationUpdateParamsRule]` Body param: Array of rules to drive notifications. - `Actions []BucketEventNotificationUpdateParamsRulesAction` Array of R2 object actions that will trigger notifications. - `const BucketEventNotificationUpdateParamsRulesActionPutObject BucketEventNotificationUpdateParamsRulesAction = "PutObject"` - `const BucketEventNotificationUpdateParamsRulesActionCopyObject BucketEventNotificationUpdateParamsRulesAction = "CopyObject"` - `const BucketEventNotificationUpdateParamsRulesActionDeleteObject BucketEventNotificationUpdateParamsRulesAction = "DeleteObject"` - `const BucketEventNotificationUpdateParamsRulesActionCompleteMultipartUpload BucketEventNotificationUpdateParamsRulesAction = "CompleteMultipartUpload"` - `const BucketEventNotificationUpdateParamsRulesActionLifecycleDeletion BucketEventNotificationUpdateParamsRulesAction = "LifecycleDeletion"` - `Description string` A description that can be used to identify the event notification rule after creation. - `Prefix string` Notifications will be sent only for objects with this prefix. - `Suffix string` Notifications will be sent only for objects with this suffix. - `Jurisdiction param.Field[BucketEventNotificationUpdateParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketEventNotificationUpdateParamsCfR2JurisdictionDefault BucketEventNotificationUpdateParamsCfR2Jurisdiction = "default"` - `const BucketEventNotificationUpdateParamsCfR2JurisdictionEu BucketEventNotificationUpdateParamsCfR2Jurisdiction = "eu"` - `const BucketEventNotificationUpdateParamsCfR2JurisdictionFedramp BucketEventNotificationUpdateParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketEventNotificationUpdateResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) eventNotification, err := client.R2.Buckets.EventNotifications.Update( context.TODO(), "example-bucket", "queue_id", r2.BucketEventNotificationUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Rules: cloudflare.F([]r2.BucketEventNotificationUpdateParamsRule{r2.BucketEventNotificationUpdateParamsRule{ Actions: cloudflare.F([]r2.BucketEventNotificationUpdateParamsRulesAction{r2.BucketEventNotificationUpdateParamsRulesActionPutObject, r2.BucketEventNotificationUpdateParamsRulesActionCopyObject}), }}), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", eventNotification) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` ## Delete Event Notification Rules `client.R2.Buckets.EventNotifications.Delete(ctx, bucketName, queueID, params) (*BucketEventNotificationDeleteResponse, error)` **delete** `/accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}` Delete an event notification rule. **If no body is provided, all rules for specified queue will be deleted**. ### Parameters - `bucketName string` Name of the bucket. - `queueID string` Queue ID. - `params BucketEventNotificationDeleteParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketEventNotificationDeleteParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketEventNotificationDeleteParamsCfR2JurisdictionDefault BucketEventNotificationDeleteParamsCfR2Jurisdiction = "default"` - `const BucketEventNotificationDeleteParamsCfR2JurisdictionEu BucketEventNotificationDeleteParamsCfR2Jurisdiction = "eu"` - `const BucketEventNotificationDeleteParamsCfR2JurisdictionFedramp BucketEventNotificationDeleteParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketEventNotificationDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) eventNotification, err := client.R2.Buckets.EventNotifications.Delete( context.TODO(), "example-bucket", "queue_id", r2.BucketEventNotificationDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", eventNotification) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` # Locks ## Get Bucket Lock Rules `client.R2.Buckets.Locks.Get(ctx, bucketName, params) (*BucketLockGetResponse, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/lock` Get lock rules for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketLockGetParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketLockGetParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketLockGetParamsCfR2JurisdictionDefault BucketLockGetParamsCfR2Jurisdiction = "default"` - `const BucketLockGetParamsCfR2JurisdictionEu BucketLockGetParamsCfR2Jurisdiction = "eu"` - `const BucketLockGetParamsCfR2JurisdictionFedramp BucketLockGetParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketLockGetResponse struct{…}` - `Rules []BucketLockGetResponseRule` - `ID string` Unique identifier for this rule. - `Condition BucketLockGetResponseRulesCondition` Condition to apply a lock rule to an object for how long in seconds. - `type BucketLockGetResponseRulesConditionR2LockRuleAgeCondition struct{…}` Condition to apply a lock rule to an object for how long in seconds. - `MaxAgeSeconds int64` - `Type BucketLockGetResponseRulesConditionR2LockRuleAgeConditionType` - `const BucketLockGetResponseRulesConditionR2LockRuleAgeConditionTypeAge BucketLockGetResponseRulesConditionR2LockRuleAgeConditionType = "Age"` - `type BucketLockGetResponseRulesConditionR2LockRuleDateCondition struct{…}` Condition to apply a lock rule to an object until a specific date. - `Date Time` - `Type BucketLockGetResponseRulesConditionR2LockRuleDateConditionType` - `const BucketLockGetResponseRulesConditionR2LockRuleDateConditionTypeDate BucketLockGetResponseRulesConditionR2LockRuleDateConditionType = "Date"` - `type BucketLockGetResponseRulesConditionR2LockRuleIndefiniteCondition struct{…}` Condition to apply a lock rule indefinitely. - `Type BucketLockGetResponseRulesConditionR2LockRuleIndefiniteConditionType` - `const BucketLockGetResponseRulesConditionR2LockRuleIndefiniteConditionTypeIndefinite BucketLockGetResponseRulesConditionR2LockRuleIndefiniteConditionType = "Indefinite"` - `Enabled bool` Whether or not this rule is in effect. - `Prefix string` Rule 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. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) lock, err := client.R2.Buckets.Locks.Get( context.TODO(), "example-bucket", r2.BucketLockGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lock.Rules) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "rules": [ { "id": "Lock all objects for 24 hours", "condition": { "maxAgeSeconds": 100, "type": "Age" }, "enabled": true, "prefix": "prefix" } ] }, "success": true } ``` ## Put Bucket Lock Rules `client.R2.Buckets.Locks.Update(ctx, bucketName, params) (*BucketLockUpdateResponse, error)` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/lock` Set lock rules for a bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketLockUpdateParams` - `AccountID param.Field[string]` Path param: Account ID. - `Rules param.Field[[]BucketLockUpdateParamsRule]` Body param - `ID string` Unique identifier for this rule. - `Condition BucketLockUpdateParamsRulesCondition` Condition to apply a lock rule to an object for how long in seconds. - `type BucketLockUpdateParamsRulesConditionR2LockRuleAgeCondition struct{…}` Condition to apply a lock rule to an object for how long in seconds. - `MaxAgeSeconds int64` - `Type BucketLockUpdateParamsRulesConditionR2LockRuleAgeConditionType` - `const BucketLockUpdateParamsRulesConditionR2LockRuleAgeConditionTypeAge BucketLockUpdateParamsRulesConditionR2LockRuleAgeConditionType = "Age"` - `type BucketLockUpdateParamsRulesConditionR2LockRuleDateCondition struct{…}` Condition to apply a lock rule to an object until a specific date. - `Date Time` - `Type BucketLockUpdateParamsRulesConditionR2LockRuleDateConditionType` - `const BucketLockUpdateParamsRulesConditionR2LockRuleDateConditionTypeDate BucketLockUpdateParamsRulesConditionR2LockRuleDateConditionType = "Date"` - `type BucketLockUpdateParamsRulesConditionR2LockRuleIndefiniteCondition struct{…}` Condition to apply a lock rule indefinitely. - `Type BucketLockUpdateParamsRulesConditionR2LockRuleIndefiniteConditionType` - `const BucketLockUpdateParamsRulesConditionR2LockRuleIndefiniteConditionTypeIndefinite BucketLockUpdateParamsRulesConditionR2LockRuleIndefiniteConditionType = "Indefinite"` - `Enabled bool` Whether or not this rule is in effect. - `Prefix string` Rule 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. - `Jurisdiction param.Field[BucketLockUpdateParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketLockUpdateParamsCfR2JurisdictionDefault BucketLockUpdateParamsCfR2Jurisdiction = "default"` - `const BucketLockUpdateParamsCfR2JurisdictionEu BucketLockUpdateParamsCfR2Jurisdiction = "eu"` - `const BucketLockUpdateParamsCfR2JurisdictionFedramp BucketLockUpdateParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketLockUpdateResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) lock, err := client.R2.Buckets.Locks.Update( context.TODO(), "example-bucket", r2.BucketLockUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", lock) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": {}, "success": true } ``` # Metrics ## Get Account-Level Metrics `client.R2.Buckets.Metrics.List(ctx, query) (*BucketMetricListResponse, error)` **get** `/accounts/{account_id}/r2/metrics` Get Storage/Object Count Metrics across all buckets in your account. Note that Account-Level Metrics may not immediately reflect the latest data. ### Parameters - `query BucketMetricListParams` - `AccountID param.Field[string]` Account ID. ### Returns - `type BucketMetricListResponse struct{…}` Metrics based on the class they belong to. - `InfrequentAccess BucketMetricListResponseInfrequentAccess` Metrics based on what state they are in(uploaded or published). - `Published BucketMetricListResponseInfrequentAccessPublished` Metrics on number of objects/amount of storage used. - `MetadataSize float64` Amount of. - `Objects float64` Number of objects stored. - `PayloadSize float64` Amount of storage used by object data. - `Uploaded BucketMetricListResponseInfrequentAccessUploaded` Metrics on number of objects/amount of storage used. - `MetadataSize float64` Amount of. - `Objects float64` Number of objects stored. - `PayloadSize float64` Amount of storage used by object data. - `Standard BucketMetricListResponseStandard` Metrics based on what state they are in(uploaded or published). - `Published BucketMetricListResponseStandardPublished` Metrics on number of objects/amount of storage used. - `MetadataSize float64` Amount of. - `Objects float64` Number of objects stored. - `PayloadSize float64` Amount of storage used by object data. - `Uploaded BucketMetricListResponseStandardUploaded` Metrics on number of objects/amount of storage used. - `MetadataSize float64` Amount of. - `Objects float64` Number of objects stored. - `PayloadSize float64` Amount of storage used by object data. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) metrics, err := client.R2.Buckets.Metrics.List(context.TODO(), r2.BucketMetricListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", metrics.InfrequentAccess) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "infrequentAccess": { "published": { "metadataSize": 0, "objects": 0, "payloadSize": 0 }, "uploaded": { "metadataSize": 0, "objects": 0, "payloadSize": 0 } }, "standard": { "published": { "metadataSize": 0, "objects": 0, "payloadSize": 0 }, "uploaded": { "metadataSize": 0, "objects": 0, "payloadSize": 0 } } }, "success": true } ``` # Sippy ## Get Sippy Configuration `client.R2.Buckets.Sippy.Get(ctx, bucketName, params) (*Sippy, error)` **get** `/accounts/{account_id}/r2/buckets/{bucket_name}/sippy` Gets configuration for Sippy for an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketSippyGetParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketSippyGetParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketSippyGetParamsCfR2JurisdictionDefault BucketSippyGetParamsCfR2Jurisdiction = "default"` - `const BucketSippyGetParamsCfR2JurisdictionEu BucketSippyGetParamsCfR2Jurisdiction = "eu"` - `const BucketSippyGetParamsCfR2JurisdictionFedramp BucketSippyGetParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type Sippy struct{…}` - `Destination SippyDestination` Details about the configured destination bucket. - `AccessKeyID string` ID of the Cloudflare API token used when writing objects to this bucket. - `Account string` - `Bucket string` Name of the bucket on the provider. - `Provider Provider` - `const ProviderR2 Provider = "r2"` - `Enabled bool` State of Sippy for this bucket. - `Source SippySource` Details about the configured source bucket. - `Bucket string` Name of the bucket on the provider (AWS, GCS only). - `BucketURL string` S3-compatible URL (Generic S3-compatible providers only). - `Provider SippySourceProvider` - `const SippySourceProviderAws SippySourceProvider = "aws"` - `const SippySourceProviderGcs SippySourceProvider = "gcs"` - `const SippySourceProviderS3 SippySourceProvider = "s3"` - `Region string` Region where the bucket resides (AWS only). ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) sippy, err := client.R2.Buckets.Sippy.Get( context.TODO(), "example-bucket", r2.BucketSippyGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", sippy.Destination) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "destination": { "accessKeyId": "accessKeyId", "account": "account", "bucket": "bucket", "provider": "r2" }, "enabled": true, "source": { "bucket": "bucket", "bucketUrl": "bucketUrl", "provider": "aws", "region": "region" } }, "success": true } ``` ## Enable Sippy `client.R2.Buckets.Sippy.Update(ctx, bucketName, params) (*Sippy, error)` **put** `/accounts/{account_id}/r2/buckets/{bucket_name}/sippy` Sets configuration for Sippy for an existing R2 bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketSippyUpdateParams` - `AccountID param.Field[string]` Path param: Account ID. - `Destination param.Field[BucketSippyUpdateParamsR2EnableSippyAwsDestination]` Body param: R2 bucket to copy objects to. - `AccessKeyID string` ID of a Cloudflare API token. This is the value labelled "Access Key ID" when creating an API. token from the [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). Sippy will use this token when writing objects to R2, so it is best to scope this token to the bucket you're enabling Sippy for. - `Provider Provider` - `const ProviderR2 Provider = "r2"` - `SecretAccessKey string` Value of a Cloudflare API token. This is the value labelled "Secret Access Key" when creating an API. token from the [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). Sippy will use this token when writing objects to R2, so it is best to scope this token to the bucket you're enabling Sippy for. - `Source param.Field[BucketSippyUpdateParamsR2EnableSippyAwsSource]` Body param: AWS S3 bucket to copy objects from. - `AccessKeyID string` Access Key ID of an IAM credential (ideally scoped to a single S3 bucket). - `Bucket string` Name of the AWS S3 bucket. - `Provider BucketSippyUpdateParamsR2EnableSippyAwsSourceProvider` - `const BucketSippyUpdateParamsR2EnableSippyAwsSourceProviderAws BucketSippyUpdateParamsR2EnableSippyAwsSourceProvider = "aws"` - `Region string` Name of the AWS availability zone. - `SecretAccessKey string` Secret Access Key of an IAM credential (ideally scoped to a single S3 bucket). - `Jurisdiction param.Field[BucketSippyUpdateParamsR2EnableSippyAwsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketSippyUpdateParamsR2EnableSippyAwsCfR2JurisdictionDefault BucketSippyUpdateParamsR2EnableSippyAwsCfR2Jurisdiction = "default"` - `const BucketSippyUpdateParamsR2EnableSippyAwsCfR2JurisdictionEu BucketSippyUpdateParamsR2EnableSippyAwsCfR2Jurisdiction = "eu"` - `const BucketSippyUpdateParamsR2EnableSippyAwsCfR2JurisdictionFedramp BucketSippyUpdateParamsR2EnableSippyAwsCfR2Jurisdiction = "fedramp"` ### Returns - `type Sippy struct{…}` - `Destination SippyDestination` Details about the configured destination bucket. - `AccessKeyID string` ID of the Cloudflare API token used when writing objects to this bucket. - `Account string` - `Bucket string` Name of the bucket on the provider. - `Provider Provider` - `const ProviderR2 Provider = "r2"` - `Enabled bool` State of Sippy for this bucket. - `Source SippySource` Details about the configured source bucket. - `Bucket string` Name of the bucket on the provider (AWS, GCS only). - `BucketURL string` S3-compatible URL (Generic S3-compatible providers only). - `Provider SippySourceProvider` - `const SippySourceProviderAws SippySourceProvider = "aws"` - `const SippySourceProviderGcs SippySourceProvider = "gcs"` - `const SippySourceProviderS3 SippySourceProvider = "s3"` - `Region string` Region where the bucket resides (AWS only). ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) sippy, err := client.R2.Buckets.Sippy.Update( context.TODO(), "example-bucket", r2.BucketSippyUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: r2.BucketSippyUpdateParamsBodyR2EnableSippyAws{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", sippy.Destination) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "destination": { "accessKeyId": "accessKeyId", "account": "account", "bucket": "bucket", "provider": "r2" }, "enabled": true, "source": { "bucket": "bucket", "bucketUrl": "bucketUrl", "provider": "aws", "region": "region" } }, "success": true } ``` ## Disable Sippy `client.R2.Buckets.Sippy.Delete(ctx, bucketName, params) (*BucketSippyDeleteResponse, error)` **delete** `/accounts/{account_id}/r2/buckets/{bucket_name}/sippy` Disables Sippy on this bucket. ### Parameters - `bucketName string` Name of the bucket. - `params BucketSippyDeleteParams` - `AccountID param.Field[string]` Path param: Account ID. - `Jurisdiction param.Field[BucketSippyDeleteParamsCfR2Jurisdiction]` Header param: Jurisdiction where objects in this bucket are guaranteed to be stored. - `const BucketSippyDeleteParamsCfR2JurisdictionDefault BucketSippyDeleteParamsCfR2Jurisdiction = "default"` - `const BucketSippyDeleteParamsCfR2JurisdictionEu BucketSippyDeleteParamsCfR2Jurisdiction = "eu"` - `const BucketSippyDeleteParamsCfR2JurisdictionFedramp BucketSippyDeleteParamsCfR2Jurisdiction = "fedramp"` ### Returns - `type BucketSippyDeleteResponse struct{…}` - `Enabled BucketSippyDeleteResponseEnabled` - `const BucketSippyDeleteResponseEnabledFalse BucketSippyDeleteResponseEnabled = false` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) sippy, err := client.R2.Buckets.Sippy.Delete( context.TODO(), "example-bucket", r2.BucketSippyDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", sippy.Enabled) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "enabled": false }, "success": true } ``` ## Domain Types ### Provider - `type Provider string` - `const ProviderR2 Provider = "r2"` ### Sippy - `type Sippy struct{…}` - `Destination SippyDestination` Details about the configured destination bucket. - `AccessKeyID string` ID of the Cloudflare API token used when writing objects to this bucket. - `Account string` - `Bucket string` Name of the bucket on the provider. - `Provider Provider` - `const ProviderR2 Provider = "r2"` - `Enabled bool` State of Sippy for this bucket. - `Source SippySource` Details about the configured source bucket. - `Bucket string` Name of the bucket on the provider (AWS, GCS only). - `BucketURL string` S3-compatible URL (Generic S3-compatible providers only). - `Provider SippySourceProvider` - `const SippySourceProviderAws SippySourceProvider = "aws"` - `const SippySourceProviderGcs SippySourceProvider = "gcs"` - `const SippySourceProviderS3 SippySourceProvider = "s3"` - `Region string` Region where the bucket resides (AWS only). # Temporary Credentials ## Create Temporary Access Credentials `client.R2.TemporaryCredentials.New(ctx, params) (*TemporaryCredentialNewResponse, error)` **post** `/accounts/{account_id}/r2/temp-access-credentials` Creates temporary access credentials on a bucket that can be optionally scoped to prefixes or objects. ### Parameters - `params TemporaryCredentialNewParams` - `AccountID param.Field[string]` Path param: Account ID. - `TemporaryCredential param.Field[TemporaryCredential]` Body param ### Returns - `type TemporaryCredentialNewResponse struct{…}` - `AccessKeyID string` ID for new access key. - `SecretAccessKey string` Secret access key. - `SessionToken string` Security token. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) temporaryCredential, err := client.R2.TemporaryCredentials.New(context.TODO(), r2.TemporaryCredentialNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), TemporaryCredential: r2.TemporaryCredentialParam{ Bucket: cloudflare.F("example-bucket"), ParentAccessKeyID: cloudflare.F("example-access-key-id"), Permission: cloudflare.F(r2.TemporaryCredentialPermissionObjectReadWrite), TTLSeconds: cloudflare.F(3600.000000), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", temporaryCredential.AccessKeyID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "accessKeyId": "example-access-key-id", "secretAccessKey": "example-secret-key", "sessionToken": "example-session-token" }, "success": true } ``` ## Domain Types ### Temporary Credential - `type TemporaryCredential struct{…}` - `Bucket string` Name of the R2 bucket. - `ParentAccessKeyID string` The parent access key id to use for signing. - `Permission TemporaryCredentialPermission` Permissions allowed on the credentials. - `const TemporaryCredentialPermissionAdminReadWrite TemporaryCredentialPermission = "admin-read-write"` - `const TemporaryCredentialPermissionAdminReadOnly TemporaryCredentialPermission = "admin-read-only"` - `const TemporaryCredentialPermissionObjectReadWrite TemporaryCredentialPermission = "object-read-write"` - `const TemporaryCredentialPermissionObjectReadOnly TemporaryCredentialPermission = "object-read-only"` - `TTLSeconds float64` How long the credentials will live for in seconds. - `Objects []string` Optional object paths to scope the credentials to. - `Prefixes []string` Optional prefix paths to scope the credentials to. # Super Slurper # Jobs ## List jobs `client.R2.SuperSlurper.Jobs.List(ctx, params) (*SinglePage[SuperSlurperJobListResponse], error)` **get** `/accounts/{account_id}/slurper/jobs` Lists all R2 Super Slurper migration jobs for the account with their status. ### Parameters - `params SuperSlurperJobListParams` - `AccountID param.Field[string]` Path param - `Limit param.Field[int64]` Query param - `Offset param.Field[int64]` Query param ### Returns - `type SuperSlurperJobListResponse struct{…}` - `ID string` - `CreatedAt string` - `FinishedAt string` - `Overwrite bool` - `Source SuperSlurperJobListResponseSource` - `type SuperSlurperJobListResponseSourceS3SourceResponseSchema struct{…}` - `Bucket string` - `Endpoint string` - `Keys []string` - `PathPrefix string` - `Vendor SuperSlurperJobListResponseSourceS3SourceResponseSchemaVendor` - `const SuperSlurperJobListResponseSourceS3SourceResponseSchemaVendorS3 SuperSlurperJobListResponseSourceS3SourceResponseSchemaVendor = "s3"` - `type SuperSlurperJobListResponseSourceGcsSourceResponseSchema struct{…}` - `Bucket string` - `Keys []string` - `PathPrefix string` - `Vendor SuperSlurperJobListResponseSourceGcsSourceResponseSchemaVendor` - `const SuperSlurperJobListResponseSourceGcsSourceResponseSchemaVendorGcs SuperSlurperJobListResponseSourceGcsSourceResponseSchemaVendor = "gcs"` - `type SuperSlurperJobListResponseSourceR2SourceResponseSchema struct{…}` - `Bucket string` - `Jurisdiction SuperSlurperJobListResponseSourceR2SourceResponseSchemaJurisdiction` - `const SuperSlurperJobListResponseSourceR2SourceResponseSchemaJurisdictionDefault SuperSlurperJobListResponseSourceR2SourceResponseSchemaJurisdiction = "default"` - `const SuperSlurperJobListResponseSourceR2SourceResponseSchemaJurisdictionEu SuperSlurperJobListResponseSourceR2SourceResponseSchemaJurisdiction = "eu"` - `const SuperSlurperJobListResponseSourceR2SourceResponseSchemaJurisdictionFedramp SuperSlurperJobListResponseSourceR2SourceResponseSchemaJurisdiction = "fedramp"` - `Keys []string` - `PathPrefix string` - `Vendor Provider` - `const ProviderR2 Provider = "r2"` - `Status SuperSlurperJobListResponseStatus` - `const SuperSlurperJobListResponseStatusRunning SuperSlurperJobListResponseStatus = "running"` - `const SuperSlurperJobListResponseStatusPaused SuperSlurperJobListResponseStatus = "paused"` - `const SuperSlurperJobListResponseStatusAborted SuperSlurperJobListResponseStatus = "aborted"` - `const SuperSlurperJobListResponseStatusCompleted SuperSlurperJobListResponseStatus = "completed"` - `Target SuperSlurperJobListResponseTarget` - `Bucket string` - `Jurisdiction SuperSlurperJobListResponseTargetJurisdiction` - `const SuperSlurperJobListResponseTargetJurisdictionDefault SuperSlurperJobListResponseTargetJurisdiction = "default"` - `const SuperSlurperJobListResponseTargetJurisdictionEu SuperSlurperJobListResponseTargetJurisdiction = "eu"` - `const SuperSlurperJobListResponseTargetJurisdictionFedramp SuperSlurperJobListResponseTargetJurisdiction = "fedramp"` - `Vendor Provider` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.R2.SuperSlurper.Jobs.List(context.TODO(), r2.SuperSlurperJobListParams{ AccountID: cloudflare.F("account_id"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": [ { "id": "id", "createdAt": "createdAt", "finishedAt": "finishedAt", "overwrite": true, "source": { "bucket": "bucket", "endpoint": "endpoint", "keys": [ "string" ], "pathPrefix": "pathPrefix", "vendor": "s3" }, "status": "running", "target": { "bucket": "bucket", "jurisdiction": "default", "vendor": "r2" } } ], "success": true } ``` ## Get job details `client.R2.SuperSlurper.Jobs.Get(ctx, jobID, query) (*SuperSlurperJobGetResponse, error)` **get** `/accounts/{account_id}/slurper/jobs/{job_id}` Retrieves detailed status and configuration for a specific R2 Super Slurper migration job. ### Parameters - `jobID string` - `query SuperSlurperJobGetParams` - `AccountID param.Field[string]` ### Returns - `type SuperSlurperJobGetResponse struct{…}` - `ID string` - `CreatedAt string` - `FinishedAt string` - `Overwrite bool` - `Source SuperSlurperJobGetResponseSource` - `type SuperSlurperJobGetResponseSourceS3SourceResponseSchema struct{…}` - `Bucket string` - `Endpoint string` - `Keys []string` - `PathPrefix string` - `Vendor SuperSlurperJobGetResponseSourceS3SourceResponseSchemaVendor` - `const SuperSlurperJobGetResponseSourceS3SourceResponseSchemaVendorS3 SuperSlurperJobGetResponseSourceS3SourceResponseSchemaVendor = "s3"` - `type SuperSlurperJobGetResponseSourceGcsSourceResponseSchema struct{…}` - `Bucket string` - `Keys []string` - `PathPrefix string` - `Vendor SuperSlurperJobGetResponseSourceGcsSourceResponseSchemaVendor` - `const SuperSlurperJobGetResponseSourceGcsSourceResponseSchemaVendorGcs SuperSlurperJobGetResponseSourceGcsSourceResponseSchemaVendor = "gcs"` - `type SuperSlurperJobGetResponseSourceR2SourceResponseSchema struct{…}` - `Bucket string` - `Jurisdiction SuperSlurperJobGetResponseSourceR2SourceResponseSchemaJurisdiction` - `const SuperSlurperJobGetResponseSourceR2SourceResponseSchemaJurisdictionDefault SuperSlurperJobGetResponseSourceR2SourceResponseSchemaJurisdiction = "default"` - `const SuperSlurperJobGetResponseSourceR2SourceResponseSchemaJurisdictionEu SuperSlurperJobGetResponseSourceR2SourceResponseSchemaJurisdiction = "eu"` - `const SuperSlurperJobGetResponseSourceR2SourceResponseSchemaJurisdictionFedramp SuperSlurperJobGetResponseSourceR2SourceResponseSchemaJurisdiction = "fedramp"` - `Keys []string` - `PathPrefix string` - `Vendor Provider` - `const ProviderR2 Provider = "r2"` - `Status SuperSlurperJobGetResponseStatus` - `const SuperSlurperJobGetResponseStatusRunning SuperSlurperJobGetResponseStatus = "running"` - `const SuperSlurperJobGetResponseStatusPaused SuperSlurperJobGetResponseStatus = "paused"` - `const SuperSlurperJobGetResponseStatusAborted SuperSlurperJobGetResponseStatus = "aborted"` - `const SuperSlurperJobGetResponseStatusCompleted SuperSlurperJobGetResponseStatus = "completed"` - `Target SuperSlurperJobGetResponseTarget` - `Bucket string` - `Jurisdiction SuperSlurperJobGetResponseTargetJurisdiction` - `const SuperSlurperJobGetResponseTargetJurisdictionDefault SuperSlurperJobGetResponseTargetJurisdiction = "default"` - `const SuperSlurperJobGetResponseTargetJurisdictionEu SuperSlurperJobGetResponseTargetJurisdiction = "eu"` - `const SuperSlurperJobGetResponseTargetJurisdictionFedramp SuperSlurperJobGetResponseTargetJurisdiction = "fedramp"` - `Vendor Provider` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) job, err := client.R2.SuperSlurper.Jobs.Get( context.TODO(), "job_id", r2.SuperSlurperJobGetParams{ AccountID: cloudflare.F("account_id"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", job.ID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "id": "id", "createdAt": "createdAt", "finishedAt": "finishedAt", "overwrite": true, "source": { "bucket": "bucket", "endpoint": "endpoint", "keys": [ "string" ], "pathPrefix": "pathPrefix", "vendor": "s3" }, "status": "running", "target": { "bucket": "bucket", "jurisdiction": "default", "vendor": "r2" } }, "success": true } ``` ## Create a job `client.R2.SuperSlurper.Jobs.New(ctx, params) (*SuperSlurperJobNewResponse, error)` **post** `/accounts/{account_id}/slurper/jobs` Creates a new R2 Super Slurper migration job to transfer objects from a source bucket (e.g. S3, GCS, R2) to R2. ### Parameters - `params SuperSlurperJobNewParams` - `AccountID param.Field[string]` Path param - `Overwrite param.Field[bool]` Body param - `Source param.Field[SuperSlurperJobNewParamsSource]` Body param - `type SuperSlurperJobNewParamsSourceR2SlurperS3SourceSchema struct{…}` - `Bucket string` - `Secret SuperSlurperJobNewParamsSourceR2SlurperS3SourceSchemaSecret` - `AccessKeyID string` - `SecretAccessKey string` - `Vendor SuperSlurperJobNewParamsSourceR2SlurperS3SourceSchemaVendor` - `const SuperSlurperJobNewParamsSourceR2SlurperS3SourceSchemaVendorS3 SuperSlurperJobNewParamsSourceR2SlurperS3SourceSchemaVendor = "s3"` - `Endpoint string` - `Keys []string` - `PathPrefix string` - `Region string` - `type SuperSlurperJobNewParamsSourceR2SlurperGcsSourceSchema struct{…}` - `Bucket string` - `Secret SuperSlurperJobNewParamsSourceR2SlurperGcsSourceSchemaSecret` - `ClientEmail string` - `PrivateKey string` - `Vendor SuperSlurperJobNewParamsSourceR2SlurperGcsSourceSchemaVendor` - `const SuperSlurperJobNewParamsSourceR2SlurperGcsSourceSchemaVendorGcs SuperSlurperJobNewParamsSourceR2SlurperGcsSourceSchemaVendor = "gcs"` - `Keys []string` - `PathPrefix string` - `type SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchema struct{…}` - `Bucket string` - `Secret SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaSecret` - `AccessKeyID string` - `SecretAccessKey string` - `Vendor Provider` - `const ProviderR2 Provider = "r2"` - `Jurisdiction SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaJurisdiction` - `const SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaJurisdictionDefault SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaJurisdiction = "default"` - `const SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaJurisdictionEu SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaJurisdiction = "eu"` - `const SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaJurisdictionFedramp SuperSlurperJobNewParamsSourceR2SlurperR2SourceSchemaJurisdiction = "fedramp"` - `Keys []string` - `PathPrefix string` - `Target param.Field[SuperSlurperJobNewParamsTarget]` Body param - `Bucket string` - `Secret SuperSlurperJobNewParamsTargetSecret` - `AccessKeyID string` - `SecretAccessKey string` - `Vendor Provider` - `Jurisdiction SuperSlurperJobNewParamsTargetJurisdiction` - `const SuperSlurperJobNewParamsTargetJurisdictionDefault SuperSlurperJobNewParamsTargetJurisdiction = "default"` - `const SuperSlurperJobNewParamsTargetJurisdictionEu SuperSlurperJobNewParamsTargetJurisdiction = "eu"` - `const SuperSlurperJobNewParamsTargetJurisdictionFedramp SuperSlurperJobNewParamsTargetJurisdiction = "fedramp"` ### Returns - `type SuperSlurperJobNewResponse struct{…}` - `ID string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) job, err := client.R2.SuperSlurper.Jobs.New(context.TODO(), r2.SuperSlurperJobNewParams{ AccountID: cloudflare.F("account_id"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", job.ID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "id": "id" }, "success": true } ``` ## Abort all jobs `client.R2.SuperSlurper.Jobs.AbortAll(ctx, body) (*string, error)` **put** `/accounts/{account_id}/slurper/jobs/abortAll` Cancels all running R2 Super Slurper migration jobs for the account. Any objects in the middle of a transfer will finish, but no new objects will start transferring. ### Parameters - `body SuperSlurperJobAbortAllParams` - `AccountID param.Field[string]` ### Returns - `type SuperSlurperJobAbortAllResponseEnvelopeResult string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2.SuperSlurper.Jobs.AbortAll(context.TODO(), r2.SuperSlurperJobAbortAllParams{ AccountID: cloudflare.F("account_id"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` ## Abort a job `client.R2.SuperSlurper.Jobs.Abort(ctx, jobID, body) (*string, error)` **put** `/accounts/{account_id}/slurper/jobs/{job_id}/abort` Cancels a specific R2 Super Slurper migration job. Any objects in the middle of a transfer will finish, but no new objects will start transferring. ### Parameters - `jobID string` - `body SuperSlurperJobAbortParams` - `AccountID param.Field[string]` ### Returns - `type SuperSlurperJobAbortResponseEnvelopeResult string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2.SuperSlurper.Jobs.Abort( context.TODO(), "job_id", r2.SuperSlurperJobAbortParams{ AccountID: cloudflare.F("account_id"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` ## Pause a job `client.R2.SuperSlurper.Jobs.Pause(ctx, jobID, body) (*string, error)` **put** `/accounts/{account_id}/slurper/jobs/{job_id}/pause` Pauses a running R2 Super Slurper migration job. The job can be resumed later to continue transferring. ### Parameters - `jobID string` - `body SuperSlurperJobPauseParams` - `AccountID param.Field[string]` ### Returns - `type SuperSlurperJobPauseResponseEnvelopeResult string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2.SuperSlurper.Jobs.Pause( context.TODO(), "job_id", r2.SuperSlurperJobPauseParams{ AccountID: cloudflare.F("account_id"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` ## Get job progress `client.R2.SuperSlurper.Jobs.Progress(ctx, jobID, query) (*SuperSlurperJobProgressResponse, error)` **get** `/accounts/{account_id}/slurper/jobs/{job_id}/progress` Retrieves current progress metrics for an R2 Super Slurper migration job ### Parameters - `jobID string` - `query SuperSlurperJobProgressParams` - `AccountID param.Field[string]` ### Returns - `type SuperSlurperJobProgressResponse struct{…}` - `ID string` - `CreatedAt string` - `FailedObjects int64` - `Objects int64` - `SkippedObjects int64` - `Status SuperSlurperJobProgressResponseStatus` - `const SuperSlurperJobProgressResponseStatusRunning SuperSlurperJobProgressResponseStatus = "running"` - `const SuperSlurperJobProgressResponseStatusPaused SuperSlurperJobProgressResponseStatus = "paused"` - `const SuperSlurperJobProgressResponseStatusAborted SuperSlurperJobProgressResponseStatus = "aborted"` - `const SuperSlurperJobProgressResponseStatusCompleted SuperSlurperJobProgressResponseStatus = "completed"` - `TransferredObjects int64` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2.SuperSlurper.Jobs.Progress( context.TODO(), "job_id", r2.SuperSlurperJobProgressParams{ AccountID: cloudflare.F("account_id"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "id": "id", "createdAt": "createdAt", "failedObjects": 0, "objects": 0, "skippedObjects": 0, "status": "running", "transferredObjects": 0 }, "success": true } ``` ## Resume a job `client.R2.SuperSlurper.Jobs.Resume(ctx, jobID, body) (*string, error)` **put** `/accounts/{account_id}/slurper/jobs/{job_id}/resume` Resumes a paused R2 Super Slurper migration job, continuing the transfer from where it stopped. ### Parameters - `jobID string` - `body SuperSlurperJobResumeParams` - `AccountID param.Field[string]` ### Returns - `type SuperSlurperJobResumeResponseEnvelopeResult string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2.SuperSlurper.Jobs.Resume( context.TODO(), "job_id", r2.SuperSlurperJobResumeParams{ AccountID: cloudflare.F("account_id"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": "result", "success": true } ``` # Logs ## Get job logs `client.R2.SuperSlurper.Jobs.Logs.List(ctx, jobID, params) (*SinglePage[SuperSlurperJobLogListResponse], error)` **get** `/accounts/{account_id}/slurper/jobs/{job_id}/logs` Gets log entries for an R2 Super Slurper migration job, showing migration status changes, errors, etc. ### Parameters - `jobID string` - `params SuperSlurperJobLogListParams` - `AccountID param.Field[string]` Path param - `Limit param.Field[int64]` Query param - `Offset param.Field[int64]` Query param ### Returns - `type SuperSlurperJobLogListResponse struct{…}` - `CreatedAt string` - `Job string` - `LogType SuperSlurperJobLogListResponseLogType` - `const SuperSlurperJobLogListResponseLogTypeMigrationStart SuperSlurperJobLogListResponseLogType = "migrationStart"` - `const SuperSlurperJobLogListResponseLogTypeMigrationComplete SuperSlurperJobLogListResponseLogType = "migrationComplete"` - `const SuperSlurperJobLogListResponseLogTypeMigrationAbort SuperSlurperJobLogListResponseLogType = "migrationAbort"` - `const SuperSlurperJobLogListResponseLogTypeMigrationError SuperSlurperJobLogListResponseLogType = "migrationError"` - `const SuperSlurperJobLogListResponseLogTypeMigrationPause SuperSlurperJobLogListResponseLogType = "migrationPause"` - `const SuperSlurperJobLogListResponseLogTypeMigrationResume SuperSlurperJobLogListResponseLogType = "migrationResume"` - `const SuperSlurperJobLogListResponseLogTypeMigrationErrorFailedContinuation SuperSlurperJobLogListResponseLogType = "migrationErrorFailedContinuation"` - `const SuperSlurperJobLogListResponseLogTypeImportErrorRetryExhaustion SuperSlurperJobLogListResponseLogType = "importErrorRetryExhaustion"` - `const SuperSlurperJobLogListResponseLogTypeImportSkippedStorageClass SuperSlurperJobLogListResponseLogType = "importSkippedStorageClass"` - `const SuperSlurperJobLogListResponseLogTypeImportSkippedOversized SuperSlurperJobLogListResponseLogType = "importSkippedOversized"` - `const SuperSlurperJobLogListResponseLogTypeImportSkippedEmptyObject SuperSlurperJobLogListResponseLogType = "importSkippedEmptyObject"` - `const SuperSlurperJobLogListResponseLogTypeImportSkippedUnsupportedContentType SuperSlurperJobLogListResponseLogType = "importSkippedUnsupportedContentType"` - `const SuperSlurperJobLogListResponseLogTypeImportSkippedExcludedContentType SuperSlurperJobLogListResponseLogType = "importSkippedExcludedContentType"` - `const SuperSlurperJobLogListResponseLogTypeImportSkippedInvalidMedia SuperSlurperJobLogListResponseLogType = "importSkippedInvalidMedia"` - `const SuperSlurperJobLogListResponseLogTypeImportSkippedRequiresRetrieval SuperSlurperJobLogListResponseLogType = "importSkippedRequiresRetrieval"` - `Message string` - `ObjectKey string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.R2.SuperSlurper.Jobs.Logs.List( context.TODO(), "job_id", r2.SuperSlurperJobLogListParams{ AccountID: cloudflare.F("account_id"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": [ { "createdAt": "createdAt", "job": "job", "logType": "migrationStart", "message": "message", "objectKey": "objectKey" } ], "success": true } ``` # Connectivity Precheck ## Check source connectivity `client.R2.SuperSlurper.ConnectivityPrecheck.Source(ctx, params) (*SuperSlurperConnectivityPrecheckSourceResponse, error)` **put** `/accounts/{account_id}/slurper/source/connectivity-precheck` Check whether tokens are valid against the source bucket ### Parameters - `params SuperSlurperConnectivityPrecheckSourceParams` - `AccountID param.Field[string]` Path param - `Bucket param.Field[string]` Body param - `Secret param.Field[SuperSlurperConnectivityPrecheckSourceParamsR2SlurperS3SourceSchemaSecret]` Body param - `AccessKeyID string` - `SecretAccessKey string` - `Vendor param.Field[SuperSlurperConnectivityPrecheckSourceParamsR2SlurperS3SourceSchemaVendor]` Body param - `const SuperSlurperConnectivityPrecheckSourceParamsR2SlurperS3SourceSchemaVendorS3 SuperSlurperConnectivityPrecheckSourceParamsR2SlurperS3SourceSchemaVendor = "s3"` - `Endpoint param.Field[string]` Body param - `Keys param.Field[[]string]` Body param - `PathPrefix param.Field[string]` Body param - `Region param.Field[string]` Body param ### Returns - `type SuperSlurperConnectivityPrecheckSourceResponse struct{…}` - `ConnectivityStatus SuperSlurperConnectivityPrecheckSourceResponseConnectivityStatus` - `const SuperSlurperConnectivityPrecheckSourceResponseConnectivityStatusSuccess SuperSlurperConnectivityPrecheckSourceResponseConnectivityStatus = "success"` - `const SuperSlurperConnectivityPrecheckSourceResponseConnectivityStatusError SuperSlurperConnectivityPrecheckSourceResponseConnectivityStatus = "error"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2.SuperSlurper.ConnectivityPrecheck.Source(context.TODO(), r2.SuperSlurperConnectivityPrecheckSourceParams{ AccountID: cloudflare.F("account_id"), Body: r2.SuperSlurperConnectivityPrecheckSourceParamsBodyR2SlurperS3SourceSchema{ Bucket: cloudflare.F("bucket"), Secret: cloudflare.F(r2.SuperSlurperConnectivityPrecheckSourceParamsBodyR2SlurperS3SourceSchemaSecret{ AccessKeyID: cloudflare.F("accessKeyId"), SecretAccessKey: cloudflare.F("secretAccessKey"), }), Vendor: cloudflare.F(r2.SuperSlurperConnectivityPrecheckSourceParamsBodyR2SlurperS3SourceSchemaVendorS3), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ConnectivityStatus) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "connectivityStatus": "success" }, "success": true } ``` ## Check target connectivity `client.R2.SuperSlurper.ConnectivityPrecheck.Target(ctx, params) (*SuperSlurperConnectivityPrecheckTargetResponse, error)` **put** `/accounts/{account_id}/slurper/target/connectivity-precheck` Check whether tokens are valid against the target bucket ### Parameters - `params SuperSlurperConnectivityPrecheckTargetParams` - `AccountID param.Field[string]` Path param - `Bucket param.Field[string]` Body param - `Secret param.Field[SuperSlurperConnectivityPrecheckTargetParamsSecret]` Body param - `AccessKeyID string` - `SecretAccessKey string` - `Vendor param.Field[Provider]` Body param - `Jurisdiction param.Field[SuperSlurperConnectivityPrecheckTargetParamsJurisdiction]` Body param - `const SuperSlurperConnectivityPrecheckTargetParamsJurisdictionDefault SuperSlurperConnectivityPrecheckTargetParamsJurisdiction = "default"` - `const SuperSlurperConnectivityPrecheckTargetParamsJurisdictionEu SuperSlurperConnectivityPrecheckTargetParamsJurisdiction = "eu"` - `const SuperSlurperConnectivityPrecheckTargetParamsJurisdictionFedramp SuperSlurperConnectivityPrecheckTargetParamsJurisdiction = "fedramp"` ### Returns - `type SuperSlurperConnectivityPrecheckTargetResponse struct{…}` - `ConnectivityStatus SuperSlurperConnectivityPrecheckTargetResponseConnectivityStatus` - `const SuperSlurperConnectivityPrecheckTargetResponseConnectivityStatusSuccess SuperSlurperConnectivityPrecheckTargetResponseConnectivityStatus = "success"` - `const SuperSlurperConnectivityPrecheckTargetResponseConnectivityStatusError SuperSlurperConnectivityPrecheckTargetResponseConnectivityStatus = "error"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2.SuperSlurper.ConnectivityPrecheck.Target(context.TODO(), r2.SuperSlurperConnectivityPrecheckTargetParams{ AccountID: cloudflare.F("account_id"), Bucket: cloudflare.F("bucket"), Secret: cloudflare.F(r2.SuperSlurperConnectivityPrecheckTargetParamsSecret{ AccessKeyID: cloudflare.F("accessKeyId"), SecretAccessKey: cloudflare.F("secretAccessKey"), }), Vendor: cloudflare.F(r2.ProviderR2), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ConnectivityStatus) } ``` #### Response ```json { "errors": [ { "code": 7003, "message": "No route for the URI", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "result": { "connectivityStatus": "success" }, "success": true } ```