# R2 Data Catalog ## List R2 catalogs `client.R2DataCatalog.List(ctx, query) (*R2DataCatalogListResponse, error)` **get** `/accounts/{account_id}/r2-catalog` Returns a list of R2 buckets that have been enabled as Apache Iceberg catalogs for the specified account. Each catalog represents an R2 bucket configured to store Iceberg metadata and data files. ### Parameters - `query R2DataCatalogListParams` - `AccountID param.Field[string]` Use this to identify the account. ### Returns - `type R2DataCatalogListResponse struct{…}` Contains the list of catalogs. - `Warehouses []R2DataCatalogListResponseWarehouse` Lists catalogs in the account. - `ID string` Use this to uniquely identify the catalog. - `Bucket string` Specifies the associated R2 bucket name. - `Name string` Specifies the catalog name (generated from account and bucket name). - `Status R2DataCatalogListResponseWarehousesStatus` Indicates the status of the catalog. - `const R2DataCatalogListResponseWarehousesStatusActive R2DataCatalogListResponseWarehousesStatus = "active"` - `const R2DataCatalogListResponseWarehousesStatusInactive R2DataCatalogListResponseWarehousesStatus = "inactive"` - `CredentialStatus R2DataCatalogListResponseWarehousesCredentialStatus` Shows the credential configuration status. - `const R2DataCatalogListResponseWarehousesCredentialStatusPresent R2DataCatalogListResponseWarehousesCredentialStatus = "present"` - `const R2DataCatalogListResponseWarehousesCredentialStatusAbsent R2DataCatalogListResponseWarehousesCredentialStatus = "absent"` - `MaintenanceConfig R2DataCatalogListResponseWarehousesMaintenanceConfig` Configures maintenance for the catalog. - `Compaction R2DataCatalogListResponseWarehousesMaintenanceConfigCompaction` Configures compaction for catalog maintenance. - `State R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionState` Specifies the state of maintenance operations. - `const R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionStateEnabled R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionState = "enabled"` - `const R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionStateDisabled R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionState = "disabled"` - `TargetSizeMB R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB` Sets the target file size for compaction in megabytes. Defaults to "128". - `const R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB64 R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB = "64"` - `const R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB128 R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB = "128"` - `const R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB256 R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB = "256"` - `const R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB512 R2DataCatalogListResponseWarehousesMaintenanceConfigCompactionTargetSizeMB = "512"` - `SnapshotExpiration R2DataCatalogListResponseWarehousesMaintenanceConfigSnapshotExpiration` Configures snapshot expiration settings. - `MaxSnapshotAge string` Specifies the maximum age for snapshots. The system deletes snapshots older than this age. Format: where unit is d (days), h (hours), m (minutes), or s (seconds). Examples: "7d" (7 days), "48h" (48 hours), "2880m" (2,880 minutes). Defaults to "7d". - `MinSnapshotsToKeep int64` Specifies the minimum number of snapshots to retain. Defaults to 100. - `State R2DataCatalogListResponseWarehousesMaintenanceConfigSnapshotExpirationState` Specifies the state of maintenance operations. - `const R2DataCatalogListResponseWarehousesMaintenanceConfigSnapshotExpirationStateEnabled R2DataCatalogListResponseWarehousesMaintenanceConfigSnapshotExpirationState = "enabled"` - `const R2DataCatalogListResponseWarehousesMaintenanceConfigSnapshotExpirationStateDisabled R2DataCatalogListResponseWarehousesMaintenanceConfigSnapshotExpirationState = "disabled"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) r2DataCatalogs, err := client.R2DataCatalog.List(context.TODO(), r2_data_catalog.R2DataCatalogListParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", r2DataCatalogs.Warehouses) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "warehouses": [ { "bucket": "analytics-bucket", "id": "550e8400-e29b-41d4-a716-446655440000", "maintenance_config": { "compaction": { "state": "enabled", "target_size_mb": "128" }, "snapshot_expiration": { "max_snapshot_age": "7d", "min_snapshots_to_keep": 100, "state": "enabled" } }, "name": "account123_analytics-bucket", "status": "active" }, { "bucket": "logs-bucket", "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "maintenance_config": { "compaction": { "state": "disabled", "target_size_mb": "128" }, "snapshot_expiration": { "max_snapshot_age": "7d", "min_snapshots_to_keep": 100, "state": "disabled" } }, "name": "account123_logs-bucket", "status": "inactive" } ] }, "success": true } ``` ## Get R2 catalog details `client.R2DataCatalog.Get(ctx, bucketName, query) (*R2DataCatalogGetResponse, error)` **get** `/accounts/{account_id}/r2-catalog/{bucket_name}` Retrieve detailed information about a specific R2 catalog by bucket name. Returns catalog status, maintenance configuration, and credential status. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `query R2DataCatalogGetParams` - `AccountID param.Field[string]` Use this to identify the account. ### Returns - `type R2DataCatalogGetResponse struct{…}` Contains R2 Data Catalog information. - `ID string` Use this to uniquely identify the catalog. - `Bucket string` Specifies the associated R2 bucket name. - `Name string` Specifies the catalog name (generated from account and bucket name). - `Status R2DataCatalogGetResponseStatus` Indicates the status of the catalog. - `const R2DataCatalogGetResponseStatusActive R2DataCatalogGetResponseStatus = "active"` - `const R2DataCatalogGetResponseStatusInactive R2DataCatalogGetResponseStatus = "inactive"` - `CredentialStatus R2DataCatalogGetResponseCredentialStatus` Shows the credential configuration status. - `const R2DataCatalogGetResponseCredentialStatusPresent R2DataCatalogGetResponseCredentialStatus = "present"` - `const R2DataCatalogGetResponseCredentialStatusAbsent R2DataCatalogGetResponseCredentialStatus = "absent"` - `MaintenanceConfig R2DataCatalogGetResponseMaintenanceConfig` Configures maintenance for the catalog. - `Compaction R2DataCatalogGetResponseMaintenanceConfigCompaction` Configures compaction for catalog maintenance. - `State R2DataCatalogGetResponseMaintenanceConfigCompactionState` Specifies the state of maintenance operations. - `const R2DataCatalogGetResponseMaintenanceConfigCompactionStateEnabled R2DataCatalogGetResponseMaintenanceConfigCompactionState = "enabled"` - `const R2DataCatalogGetResponseMaintenanceConfigCompactionStateDisabled R2DataCatalogGetResponseMaintenanceConfigCompactionState = "disabled"` - `TargetSizeMB R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB` Sets the target file size for compaction in megabytes. Defaults to "128". - `const R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB64 R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB = "64"` - `const R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB128 R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB = "128"` - `const R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB256 R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB = "256"` - `const R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB512 R2DataCatalogGetResponseMaintenanceConfigCompactionTargetSizeMB = "512"` - `SnapshotExpiration R2DataCatalogGetResponseMaintenanceConfigSnapshotExpiration` Configures snapshot expiration settings. - `MaxSnapshotAge string` Specifies the maximum age for snapshots. The system deletes snapshots older than this age. Format: where unit is d (days), h (hours), m (minutes), or s (seconds). Examples: "7d" (7 days), "48h" (48 hours), "2880m" (2,880 minutes). Defaults to "7d". - `MinSnapshotsToKeep int64` Specifies the minimum number of snapshots to retain. Defaults to 100. - `State R2DataCatalogGetResponseMaintenanceConfigSnapshotExpirationState` Specifies the state of maintenance operations. - `const R2DataCatalogGetResponseMaintenanceConfigSnapshotExpirationStateEnabled R2DataCatalogGetResponseMaintenanceConfigSnapshotExpirationState = "enabled"` - `const R2DataCatalogGetResponseMaintenanceConfigSnapshotExpirationStateDisabled R2DataCatalogGetResponseMaintenanceConfigSnapshotExpirationState = "disabled"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) r2DataCatalog, err := client.R2DataCatalog.Get( context.TODO(), "my-data-bucket", r2_data_catalog.R2DataCatalogGetParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", r2DataCatalog.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "bucket": "analytics-bucket", "credential_status": "present", "id": "550e8400-e29b-41d4-a716-446655440000", "maintenance_config": { "compaction": { "state": "enabled", "target_size_mb": "128" }, "snapshot_expiration": { "max_snapshot_age": "7d", "min_snapshots_to_keep": 100, "state": "enabled" } }, "name": "account123_analytics-bucket", "status": "active" }, "success": true } ``` ## Enable R2 bucket as a catalog `client.R2DataCatalog.Enable(ctx, bucketName, body) (*R2DataCatalogEnableResponse, error)` **post** `/accounts/{account_id}/r2-catalog/{bucket_name}/enable` Enable an R2 bucket as an Apache Iceberg catalog. This operation creates the necessary catalog infrastructure and activates the bucket for storing Iceberg metadata and data files. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `body R2DataCatalogEnableParams` - `AccountID param.Field[string]` Use this to identify the account. ### Returns - `type R2DataCatalogEnableResponse struct{…}` Contains response from activating an R2 bucket as a catalog. - `ID string` Use this to uniquely identify the activated catalog. - `Name string` Specifies the name of the activated catalog. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.R2DataCatalog.Enable( context.TODO(), "my-data-bucket", r2_data_catalog.R2DataCatalogEnableParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.ID) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "account123_my-bucket" }, "success": true } ``` ## Disable R2 catalog `client.R2DataCatalog.Disable(ctx, bucketName, body) error` **post** `/accounts/{account_id}/r2-catalog/{bucket_name}/disable` Disable an R2 bucket as a catalog. This operation deactivates the catalog but preserves existing metadata and data files. The catalog can be re-enabled later. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `body R2DataCatalogDisableParams` - `AccountID param.Field[string]` Use this to identify the account. ### Example ```go package main import ( "context" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) err := client.R2DataCatalog.Disable( context.TODO(), "my-data-bucket", r2_data_catalog.R2DataCatalogDisableParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }, ) if err != nil { panic(err.Error()) } } ``` # Maintenance Configs ## Get catalog maintenance configuration `client.R2DataCatalog.MaintenanceConfigs.Get(ctx, bucketName, query) (*MaintenanceConfigGetResponse, error)` **get** `/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs` Retrieve the maintenance configuration for a specific catalog, including compaction settings and credential status. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `query MaintenanceConfigGetParams` - `AccountID param.Field[string]` Use this to identify the account. ### Returns - `type MaintenanceConfigGetResponse struct{…}` Contains maintenance configuration and credential status. - `CredentialStatus MaintenanceConfigGetResponseCredentialStatus` Shows the credential configuration status. - `const MaintenanceConfigGetResponseCredentialStatusPresent MaintenanceConfigGetResponseCredentialStatus = "present"` - `const MaintenanceConfigGetResponseCredentialStatusAbsent MaintenanceConfigGetResponseCredentialStatus = "absent"` - `MaintenanceConfig MaintenanceConfigGetResponseMaintenanceConfig` Configures maintenance for the catalog. - `Compaction MaintenanceConfigGetResponseMaintenanceConfigCompaction` Configures compaction for catalog maintenance. - `State MaintenanceConfigGetResponseMaintenanceConfigCompactionState` Specifies the state of maintenance operations. - `const MaintenanceConfigGetResponseMaintenanceConfigCompactionStateEnabled MaintenanceConfigGetResponseMaintenanceConfigCompactionState = "enabled"` - `const MaintenanceConfigGetResponseMaintenanceConfigCompactionStateDisabled MaintenanceConfigGetResponseMaintenanceConfigCompactionState = "disabled"` - `TargetSizeMB MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB` Sets the target file size for compaction in megabytes. Defaults to "128". - `const MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB64 MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "64"` - `const MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB128 MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "128"` - `const MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB256 MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "256"` - `const MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB512 MaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "512"` - `SnapshotExpiration MaintenanceConfigGetResponseMaintenanceConfigSnapshotExpiration` Configures snapshot expiration settings. - `MaxSnapshotAge string` Specifies the maximum age for snapshots. The system deletes snapshots older than this age. Format: where unit is d (days), h (hours), m (minutes), or s (seconds). Examples: "7d" (7 days), "48h" (48 hours), "2880m" (2,880 minutes). Defaults to "7d". - `MinSnapshotsToKeep int64` Specifies the minimum number of snapshots to retain. Defaults to 100. - `State MaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationState` Specifies the state of maintenance operations. - `const MaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationStateEnabled MaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationState = "enabled"` - `const MaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationStateDisabled MaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationState = "disabled"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) maintenanceConfig, err := client.R2DataCatalog.MaintenanceConfigs.Get( context.TODO(), "my-data-bucket", r2_data_catalog.MaintenanceConfigGetParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", maintenanceConfig.CredentialStatus) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "credential_status": "present", "maintenance_config": { "compaction": { "state": "enabled", "target_size_mb": "128" }, "snapshot_expiration": { "max_snapshot_age": "7d", "min_snapshots_to_keep": 100, "state": "enabled" } } }, "success": true } ``` ## Update catalog maintenance configuration `client.R2DataCatalog.MaintenanceConfigs.Update(ctx, bucketName, params) (*MaintenanceConfigUpdateResponse, error)` **post** `/accounts/{account_id}/r2-catalog/{bucket_name}/maintenance-configs` Update the maintenance configuration for a catalog. This allows you to enable or disable compaction and adjust target file sizes for optimization. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `params MaintenanceConfigUpdateParams` - `AccountID param.Field[string]` Path param: Use this to identify the account. - `Compaction param.Field[MaintenanceConfigUpdateParamsCompaction]` Body param: Updates compaction configuration (all fields optional). - `State MaintenanceConfigUpdateParamsCompactionState` Updates the state optionally. - `const MaintenanceConfigUpdateParamsCompactionStateEnabled MaintenanceConfigUpdateParamsCompactionState = "enabled"` - `const MaintenanceConfigUpdateParamsCompactionStateDisabled MaintenanceConfigUpdateParamsCompactionState = "disabled"` - `TargetSizeMB MaintenanceConfigUpdateParamsCompactionTargetSizeMB` Updates the target file size optionally. - `const MaintenanceConfigUpdateParamsCompactionTargetSizeMB64 MaintenanceConfigUpdateParamsCompactionTargetSizeMB = "64"` - `const MaintenanceConfigUpdateParamsCompactionTargetSizeMB128 MaintenanceConfigUpdateParamsCompactionTargetSizeMB = "128"` - `const MaintenanceConfigUpdateParamsCompactionTargetSizeMB256 MaintenanceConfigUpdateParamsCompactionTargetSizeMB = "256"` - `const MaintenanceConfigUpdateParamsCompactionTargetSizeMB512 MaintenanceConfigUpdateParamsCompactionTargetSizeMB = "512"` - `SnapshotExpiration param.Field[MaintenanceConfigUpdateParamsSnapshotExpiration]` Body param: Updates snapshot expiration configuration (all fields optional). - `MaxSnapshotAge string` Updates the maximum age for snapshots optionally. - `MinSnapshotsToKeep int64` Updates the minimum number of snapshots to retain optionally. - `State MaintenanceConfigUpdateParamsSnapshotExpirationState` Updates the state optionally. - `const MaintenanceConfigUpdateParamsSnapshotExpirationStateEnabled MaintenanceConfigUpdateParamsSnapshotExpirationState = "enabled"` - `const MaintenanceConfigUpdateParamsSnapshotExpirationStateDisabled MaintenanceConfigUpdateParamsSnapshotExpirationState = "disabled"` ### Returns - `type MaintenanceConfigUpdateResponse struct{…}` Configures maintenance for the catalog. - `Compaction MaintenanceConfigUpdateResponseCompaction` Configures compaction for catalog maintenance. - `State MaintenanceConfigUpdateResponseCompactionState` Specifies the state of maintenance operations. - `const MaintenanceConfigUpdateResponseCompactionStateEnabled MaintenanceConfigUpdateResponseCompactionState = "enabled"` - `const MaintenanceConfigUpdateResponseCompactionStateDisabled MaintenanceConfigUpdateResponseCompactionState = "disabled"` - `TargetSizeMB MaintenanceConfigUpdateResponseCompactionTargetSizeMB` Sets the target file size for compaction in megabytes. Defaults to "128". - `const MaintenanceConfigUpdateResponseCompactionTargetSizeMB64 MaintenanceConfigUpdateResponseCompactionTargetSizeMB = "64"` - `const MaintenanceConfigUpdateResponseCompactionTargetSizeMB128 MaintenanceConfigUpdateResponseCompactionTargetSizeMB = "128"` - `const MaintenanceConfigUpdateResponseCompactionTargetSizeMB256 MaintenanceConfigUpdateResponseCompactionTargetSizeMB = "256"` - `const MaintenanceConfigUpdateResponseCompactionTargetSizeMB512 MaintenanceConfigUpdateResponseCompactionTargetSizeMB = "512"` - `SnapshotExpiration MaintenanceConfigUpdateResponseSnapshotExpiration` Configures snapshot expiration settings. - `MaxSnapshotAge string` Specifies the maximum age for snapshots. The system deletes snapshots older than this age. Format: where unit is d (days), h (hours), m (minutes), or s (seconds). Examples: "7d" (7 days), "48h" (48 hours), "2880m" (2,880 minutes). Defaults to "7d". - `MinSnapshotsToKeep int64` Specifies the minimum number of snapshots to retain. Defaults to 100. - `State MaintenanceConfigUpdateResponseSnapshotExpirationState` Specifies the state of maintenance operations. - `const MaintenanceConfigUpdateResponseSnapshotExpirationStateEnabled MaintenanceConfigUpdateResponseSnapshotExpirationState = "enabled"` - `const MaintenanceConfigUpdateResponseSnapshotExpirationStateDisabled MaintenanceConfigUpdateResponseSnapshotExpirationState = "disabled"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) maintenanceConfig, err := client.R2DataCatalog.MaintenanceConfigs.Update( context.TODO(), "my-data-bucket", r2_data_catalog.MaintenanceConfigUpdateParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), Compaction: cloudflare.F(r2_data_catalog.MaintenanceConfigUpdateParamsCompaction{ State: cloudflare.F(r2_data_catalog.MaintenanceConfigUpdateParamsCompactionStateEnabled), TargetSizeMB: cloudflare.F(r2_data_catalog.MaintenanceConfigUpdateParamsCompactionTargetSizeMB256), }), SnapshotExpiration: cloudflare.F(r2_data_catalog.MaintenanceConfigUpdateParamsSnapshotExpiration{ MaxSnapshotAge: cloudflare.F("14d"), MinSnapshotsToKeep: cloudflare.F(int64(5)), State: cloudflare.F(r2_data_catalog.MaintenanceConfigUpdateParamsSnapshotExpirationStateEnabled), }), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", maintenanceConfig.Compaction) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "compaction": { "state": "enabled", "target_size_mb": "256" }, "snapshot_expiration": { "max_snapshot_age": "14d", "min_snapshots_to_keep": 5, "state": "enabled" } }, "success": true } ``` # Credentials ## Store catalog credentials `client.R2DataCatalog.Credentials.New(ctx, bucketName, params) (*CredentialNewResponse, error)` **post** `/accounts/{account_id}/r2-catalog/{bucket_name}/credential` Store authentication credentials for a catalog. These credentials are used to authenticate with R2 storage when performing catalog operations. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `params CredentialNewParams` - `AccountID param.Field[string]` Path param: Use this to identify the account. - `Token param.Field[string]` Body param: Provides the Cloudflare API token for accessing R2. ### Returns - `type CredentialNewResponse 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_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credential, err := client.R2DataCatalog.Credentials.New( context.TODO(), "my-data-bucket", r2_data_catalog.CredentialNewParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), Token: cloudflare.F("your-cloudflare-api-token-here"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credential) } ``` #### Response ```json { "errors": [], "messages": [], "result": null, "success": true } ``` # Namespaces ## List namespaces in catalog `client.R2DataCatalog.Namespaces.List(ctx, bucketName, params) (*NamespaceListResponse, error)` **get** `/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces` Returns a list of namespaces in the specified R2 catalog. Supports hierarchical filtering and pagination for efficient traversal of large namespace hierarchies. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `params NamespaceListParams` - `AccountID param.Field[string]` Path param: Use this to identify the account. - `PageSize param.Field[int64]` Query param: Maximum number of namespaces to return per page. Defaults to 100, maximum 1000. - `PageToken param.Field[string]` Query param: Opaque pagination token from a previous response. Use this to fetch the next page of results. - `Parent param.Field[string]` Query param: Parent namespace to filter by. Only returns direct children of this namespace. For nested namespaces, use %1F as separator (e.g., "bronze%1Fanalytics"). Omit this parameter to list top-level namespaces. - `ReturnDetails param.Field[bool]` Query param: Whether to include additional metadata (timestamps). When true, response includes created_at and updated_at arrays. - `ReturnUUIDs param.Field[bool]` Query param: Whether to include namespace UUIDs in the response. Set to true to receive the namespace_uuids array. ### Returns - `type NamespaceListResponse struct{…}` Contains the list of namespaces with optional pagination. - `Namespaces [][]string` Lists namespaces in the catalog. - `Details []NamespaceListResponseDetail` Contains detailed metadata for each namespace when return_details is true. Each object includes the namespace, UUID, and timestamps. - `Namespace []string` Specifies the hierarchical namespace parts as an array of strings. For example, ["bronze", "analytics"] represents the namespace "bronze.analytics". - `NamespaceUUID string` Contains the UUID that persists across renames. - `CreatedAt Time` Indicates the creation timestamp in ISO 8601 format. - `UpdatedAt Time` Shows the last update timestamp in ISO 8601 format. Null if never updated. - `NamespaceUUIDs []string` Contains UUIDs for each namespace when return_uuids is true. The order corresponds to the namespaces array. - `NextPageToken string` Use this opaque token to fetch the next page of results. A null or absent value indicates the last page. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) namespaces, err := client.R2DataCatalog.Namespaces.List( context.TODO(), "my-data-bucket", r2_data_catalog.NamespaceListParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", namespaces.NamespaceUUIDs) } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": { "namespaces": [ [ "bronze", "analytics" ] ], "details": [ { "namespace": [ "bronze", "analytics" ], "namespace_uuid": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "updated_at": "2019-12-27T18:11:19.117Z" } ], "namespace_uuids": [ "0199b999-6869-7383-bb1f-d30e059d5326", "0199b99b-2c88-73b3-8dbb-421e0e8f2757" ], "next_page_token": "MSYxNzU5NzU1NTc4NTA0MTk0JjAxOTliOTliLTJjODgtNzNiMy04ZGJiLTQyMWUwZThmMjc1Nw" } } ``` # Tables ## List tables in namespace `client.R2DataCatalog.Namespaces.Tables.List(ctx, bucketName, namespace, params) (*NamespaceTableListResponse, error)` **get** `/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables` Returns a list of tables in the specified namespace within an R2 catalog. Supports pagination for efficient traversal of large table collections. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `namespace string` - `params NamespaceTableListParams` - `AccountID param.Field[string]` Path param: Use this to identify the account. - `PageSize param.Field[int64]` Query param: Maximum number of tables to return per page. Defaults to 100, maximum 1000. - `PageToken param.Field[string]` Query param: Opaque pagination token from a previous response. Use this to fetch the next page of results. - `ReturnDetails param.Field[bool]` Query param: Whether to include additional metadata (timestamps, locations). When true, response includes created_at, updated_at, metadata_locations, and locations arrays. - `ReturnUUIDs param.Field[bool]` Query param: Whether to include table UUIDs in the response. Set to true to receive the table_uuids array. ### Returns - `type NamespaceTableListResponse struct{…}` Contains the list of tables with optional pagination. - `Identifiers []NamespaceTableListResponseIdentifier` Lists tables in the namespace. - `Name string` Specifies the table name. - `Namespace []string` Specifies the hierarchical namespace parts as an array of strings. For example, ["bronze", "analytics"] represents the namespace "bronze.analytics". - `Details []NamespaceTableListResponseDetail` Contains detailed metadata for each table when return_details is true. Each object includes identifier, UUID, timestamps, and locations. - `Identifier NamespaceTableListResponseDetailsIdentifier` Specifies a unique table identifier within a catalog. - `Name string` Specifies the table name. - `Namespace []string` Specifies the hierarchical namespace parts as an array of strings. For example, ["bronze", "analytics"] represents the namespace "bronze.analytics". - `TableUUID string` Contains the UUID that persists across renames. - `CreatedAt Time` Indicates the creation timestamp in ISO 8601 format. - `Location string` Specifies the base S3 URI for table storage location. - `MetadataLocation string` Contains the S3 URI to table metadata file. Null for staged tables. - `UpdatedAt Time` Shows the last update timestamp in ISO 8601 format. Null if never updated. - `NextPageToken string` Use this opaque token to fetch the next page of results. A null or absent value indicates the last page. - `TableUUIDs []string` Contains UUIDs for each table when return_uuids is true. The order corresponds to the identifiers array. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) tables, err := client.R2DataCatalog.Namespaces.Tables.List( context.TODO(), "my-data-bucket", "bronze", r2_data_catalog.NamespaceTableListParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", tables.Identifiers) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "details": [ { "created_at": "2025-10-07T10:00:00Z", "identifier": { "name": "events", "namespace": [ "bronze" ] }, "location": "s3://my-bucket/__r2_data_catalog/wh-id/table-id/", "metadata_location": "s3://my-bucket/__r2_data_catalog/wh-id/table-id/metadata/v1.metadata.json", "table_uuid": "0199b9a1-28a0-71e0-a73e-b0fc32c8468e", "updated_at": "2025-10-07T15:00:00Z" }, { "created_at": "2025-10-07T10:30:00Z", "identifier": { "name": "users", "namespace": [ "bronze" ] }, "location": "s3://my-bucket/__r2_data_catalog/wh-id/table-id-2/", "metadata_location": "s3://my-bucket/__r2_data_catalog/wh-id/table-id-2/metadata/v2.metadata.json", "table_uuid": "0199b9a1-3c74-7731-bf53-d8c67ead079d", "updated_at": "2025-10-07T16:00:00Z" } ], "identifiers": [ { "name": "events", "namespace": [ "bronze" ] }, { "name": "users", "namespace": [ "bronze" ] } ], "next_page_token": null, "table_uuids": [ "0199b9a1-28a0-71e0-a73e-b0fc32c8468e", "0199b9a1-3c74-7731-bf53-d8c67ead079d" ] }, "success": true } ``` # Maintenance Configs ## Get table maintenance configuration `client.R2DataCatalog.Namespaces.Tables.MaintenanceConfigs.Get(ctx, bucketName, namespace, tableName, query) (*NamespaceTableMaintenanceConfigGetResponse, error)` **get** `/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs` Retrieve the maintenance configuration for a specific table, including compaction settings. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `namespace string` - `tableName string` - `query NamespaceTableMaintenanceConfigGetParams` - `AccountID param.Field[string]` Use this to identify the account. ### Returns - `type NamespaceTableMaintenanceConfigGetResponse struct{…}` Contains table maintenance configuration. - `MaintenanceConfig NamespaceTableMaintenanceConfigGetResponseMaintenanceConfig` Configures maintenance for the table. - `Compaction NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompaction` Configures compaction settings for table optimization. - `State NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionState` Specifies the state of maintenance operations. - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionStateEnabled NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionState = "enabled"` - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionStateDisabled NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionState = "disabled"` - `TargetSizeMB NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB` Sets the target file size for compaction in megabytes. Defaults to "128". - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB64 NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "64"` - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB128 NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "128"` - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB256 NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "256"` - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB512 NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigCompactionTargetSizeMB = "512"` - `SnapshotExpiration NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigSnapshotExpiration` Configures snapshot expiration settings. - `MaxSnapshotAge string` Specifies the maximum age for snapshots. The system deletes snapshots older than this age. Format: where unit is d (days), h (hours), m (minutes), or s (seconds). Examples: "7d" (7 days), "48h" (48 hours), "2880m" (2,880 minutes). Defaults to "7d". - `MinSnapshotsToKeep int64` Specifies the minimum number of snapshots to retain. Defaults to 100. - `State NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationState` Specifies the state of maintenance operations. - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationStateEnabled NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationState = "enabled"` - `const NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationStateDisabled NamespaceTableMaintenanceConfigGetResponseMaintenanceConfigSnapshotExpirationState = "disabled"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) maintenanceConfig, err := client.R2DataCatalog.Namespaces.Tables.MaintenanceConfigs.Get( context.TODO(), "my-data-bucket", "my_namespace%1Fsub_namespace", "my_table", r2_data_catalog.NamespaceTableMaintenanceConfigGetParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", maintenanceConfig.MaintenanceConfig) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "maintenance_config": { "compaction": { "state": "enabled", "target_size_mb": "128" }, "snapshot_expiration": { "max_snapshot_age": "7d", "min_snapshots_to_keep": 100, "state": "enabled" } } }, "success": true } ``` ## Update table maintenance configuration `client.R2DataCatalog.Namespaces.Tables.MaintenanceConfigs.Update(ctx, bucketName, namespace, tableName, params) (*NamespaceTableMaintenanceConfigUpdateResponse, error)` **post** `/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces/{namespace}/tables/{table_name}/maintenance-configs` Update the maintenance configuration for a specific table. This allows you to enable or disable compaction and adjust target file sizes for optimization. ### Parameters - `bucketName string` Specifies the R2 bucket name. - `namespace string` - `tableName string` - `params NamespaceTableMaintenanceConfigUpdateParams` - `AccountID param.Field[string]` Path param: Use this to identify the account. - `Compaction param.Field[NamespaceTableMaintenanceConfigUpdateParamsCompaction]` Body param: Updates compaction configuration (all fields optional). - `State NamespaceTableMaintenanceConfigUpdateParamsCompactionState` Updates the state optionally. - `const NamespaceTableMaintenanceConfigUpdateParamsCompactionStateEnabled NamespaceTableMaintenanceConfigUpdateParamsCompactionState = "enabled"` - `const NamespaceTableMaintenanceConfigUpdateParamsCompactionStateDisabled NamespaceTableMaintenanceConfigUpdateParamsCompactionState = "disabled"` - `TargetSizeMB NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB` Updates the target file size optionally. - `const NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB64 NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB = "64"` - `const NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB128 NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB = "128"` - `const NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB256 NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB = "256"` - `const NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB512 NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB = "512"` - `SnapshotExpiration param.Field[NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpiration]` Body param: Updates snapshot expiration configuration (all fields optional). - `MaxSnapshotAge string` Updates the maximum age for snapshots optionally. - `MinSnapshotsToKeep int64` Updates the minimum number of snapshots to retain optionally. - `State NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpirationState` Updates the state optionally. - `const NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpirationStateEnabled NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpirationState = "enabled"` - `const NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpirationStateDisabled NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpirationState = "disabled"` ### Returns - `type NamespaceTableMaintenanceConfigUpdateResponse struct{…}` Configures maintenance for the table. - `Compaction NamespaceTableMaintenanceConfigUpdateResponseCompaction` Configures compaction settings for table optimization. - `State NamespaceTableMaintenanceConfigUpdateResponseCompactionState` Specifies the state of maintenance operations. - `const NamespaceTableMaintenanceConfigUpdateResponseCompactionStateEnabled NamespaceTableMaintenanceConfigUpdateResponseCompactionState = "enabled"` - `const NamespaceTableMaintenanceConfigUpdateResponseCompactionStateDisabled NamespaceTableMaintenanceConfigUpdateResponseCompactionState = "disabled"` - `TargetSizeMB NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB` Sets the target file size for compaction in megabytes. Defaults to "128". - `const NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB64 NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB = "64"` - `const NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB128 NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB = "128"` - `const NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB256 NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB = "256"` - `const NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB512 NamespaceTableMaintenanceConfigUpdateResponseCompactionTargetSizeMB = "512"` - `SnapshotExpiration NamespaceTableMaintenanceConfigUpdateResponseSnapshotExpiration` Configures snapshot expiration settings. - `MaxSnapshotAge string` Specifies the maximum age for snapshots. The system deletes snapshots older than this age. Format: where unit is d (days), h (hours), m (minutes), or s (seconds). Examples: "7d" (7 days), "48h" (48 hours), "2880m" (2,880 minutes). Defaults to "7d". - `MinSnapshotsToKeep int64` Specifies the minimum number of snapshots to retain. Defaults to 100. - `State NamespaceTableMaintenanceConfigUpdateResponseSnapshotExpirationState` Specifies the state of maintenance operations. - `const NamespaceTableMaintenanceConfigUpdateResponseSnapshotExpirationStateEnabled NamespaceTableMaintenanceConfigUpdateResponseSnapshotExpirationState = "enabled"` - `const NamespaceTableMaintenanceConfigUpdateResponseSnapshotExpirationStateDisabled NamespaceTableMaintenanceConfigUpdateResponseSnapshotExpirationState = "disabled"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/r2_data_catalog" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) maintenanceConfig, err := client.R2DataCatalog.Namespaces.Tables.MaintenanceConfigs.Update( context.TODO(), "my-data-bucket", "my_namespace%1Fsub_namespace", "my_table", r2_data_catalog.NamespaceTableMaintenanceConfigUpdateParams{ AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"), Compaction: cloudflare.F(r2_data_catalog.NamespaceTableMaintenanceConfigUpdateParamsCompaction{ State: cloudflare.F(r2_data_catalog.NamespaceTableMaintenanceConfigUpdateParamsCompactionStateEnabled), TargetSizeMB: cloudflare.F(r2_data_catalog.NamespaceTableMaintenanceConfigUpdateParamsCompactionTargetSizeMB256), }), SnapshotExpiration: cloudflare.F(r2_data_catalog.NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpiration{ MaxSnapshotAge: cloudflare.F("14d"), MinSnapshotsToKeep: cloudflare.F(int64(5)), State: cloudflare.F(r2_data_catalog.NamespaceTableMaintenanceConfigUpdateParamsSnapshotExpirationStateEnabled), }), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", maintenanceConfig.Compaction) } ``` #### Response ```json { "errors": [], "messages": [], "result": { "compaction": { "state": "enabled", "target_size_mb": "256" }, "snapshot_expiration": { "max_snapshot_age": "14d", "min_snapshots_to_keep": 5, "state": "enabled" } }, "success": true } ```