Cross-region replication

Last updated: 2023-09-20 12:28:04

Feature Overview

This document provides an overview of APIs and SDK code samples for cross-region replication.
API
Operation
Description
Setting cross-region replication
Sets cross-region replication rules for a bucket
Querying Cross-Region Replication
Queries the cross-region replication rules of a bucket
Deleting cross-region replication
Deletes the cross-region replication rules of a bucket

Setting cross-region replication

Note

This API (PUT Bucket replication) is used to set cross-region replication rules for a bucket.
Note
The bucket must have versioning enabled to use the cross-region replication feature.

Sample Request

cos.putBucketReplication({
Bucket: 'examplebucket-1250000000', /* Required */
Region: 'COS_REGION', /* The region where the bucket is located, required field */
ReplicationConfiguration: { /* Required */
Role: "qcs::cam::uin/100000000001:uin/100000000001",
Rules: [{
ID: "1",
Status: "Enabled",
Prefix: "sync/",
Destination: {
Bucket: "qcs::cos:ap-beijing::destinationbucket-1250000000",
StorageClass: "Standard",
}
}]
}
}, function(err, data) {
console.log(err || data);
});

Description

Parameter name
Description
Local Disk Types
Required
Bucket
Source bucket in the format of BucketName-APPID
String
Required
Region
Bucket region. For the enumerated values, see Regions and Access Endpoints.
String
Required
ReplicationConfiguration
Defines cross-region replication rules
Object
Required
- Role
Replication process with which role identity
Format: qcs::cam::uin/100000000001:uin/100000000011
In this example, 100000000001 is the root account, and 100000000011 is the sub-account.
Object
Not required
- Rules
List of specific replication rules
ObjectArray
Required
- - ID
Identifies the ID of a specific rule
String
Not required
- - Status
Rule status identifier. Enumerated values: Enabled, Disabled.
String
Required
- - Prefix
Prefix matching policy. Policies cannot overlap; otherwise, an error will be returned. To match the root directory, leave this parameter empty.
String
Not required
- - Destination
Destination bucket information
Object
Required
- - - Bucket
Destination bucket name
Format: qcs::cos:<Region>::<BucketName-APPID>
For example: qcs::cos:ap-beijing::destinationbucket-1250000000
Object
Required
- - - StorageClass
Storage class after the replication; enumerated values: STANDARD, STANDARD_IA. Default value: STANDARD
Object
Not required

Callback function description

function(err, data) { ... }
Parameter name
Description
Local Disk Types
err
Returns a network or service error when the request fails. If the request is successful, this is empty. For more information, see Error Codes
Object
- statusCode
HTTP status code, such as 200, 403, and 404
Number
- headers
Returned headers
Object
data
Object returned when the request is successful. If the request fails, this parameter is empty.
Object
- statusCode
HTTP status code, such as 200, 403, and 404
Number
- headers
Returned headers
Object

Querying Cross-Region Replication

Note

This API (GET Bucket replication) is used to query the cross-region replication rules of a specified bucket.

Sample Request

cos.getBucketReplication({
Bucket: 'examplebucket-1250000000', /* Required */
Region: 'COS_REGION', /* The region where the bucket is located, required field */
}, function(err, data) {
console.log(err || data);
});

Sample response

{
"ReplicationConfiguration": {
"Role": "qcs::cam::uin/100000000001:uin/100000000001",
"Rules": {
"ID": "1",
"Status": "Enabled",
"Prefix": "sync/",
"Destination": {
"Bucket": "qcs::cos:ap-beijing::destinationbucket-1250000000",
"StorageClass": "Standard"
}
}
},
"statusCode": 200,
"headers": {}
}

Description

Parameter name
Description
Local Disk Types
Required
Bucket
Bucket for which cross-region replication is queried in the format of BucketName-APPID
String
Required
Region
Bucket region. For the enumerated values, see Regions and Access Endpoints.
String
Required

Callback function description

function(err, data) { ... }
Parameter name
Description
Local Disk Types
err
Returns a network or service error when the request fails. If the request is successful, this is empty. For more information, see Error Codes
Object
data
Object returned when the request is successful. If the request fails, this parameter is empty.
Object
- ReplicationConfiguration
Cross-region replication rules
Object
- - Role
Replication process with which role identity
Format: qcs::cam::uin/100000000001:uin/100000000011
In this example, 100000000001 is the root account, and 100000000011 is the sub-account.
Object
- - Rules
List of specific replication rules
ObjectArray
- - - ID
Identifies the ID of a specific rule
String
- - - Status
Rule status identifier. Enumerated values: Enabled, Disabled.
String
- - - Prefix
Prefix matching policy. Policies cannot overlap; otherwise, an error will be returned. To match the root directory, leave this parameter empty.
String
- - - Destination
Destination bucket information
Object
- - - - Bucket
Destination bucket name
Format: qcs::cos:<Region>::<BucketName-APPID>
For example: qcs::cos:ap-beijing::destinationbucket-1250000000
Object
- - - - StorageClass
Storage class after the replication; enumerated values: STANDARD, STANDARD_IA. Default value: STANDARD
Object

Deleting cross-region replication

Note

This API (DELETE Bucket replication) is used to delete the cross-region replication rules of a bucket.

Sample Request

cos.deleteBucketReplication({
Bucket: 'examplebucket-1250000000', /* Required */
Region: 'COS_REGION', /* The region where the bucket is located, required field */
}, function(err, data) {
console.log(err || data);
});

Description

Parameter name
Description
Local Disk Types
Required
Bucket
Bucket for which cross-region replication is deleted in the format of BucketName-APPID
String
Required
Region
Bucket region. For the enumerated values, see Regions and Access Endpoints.
String
Required

Callback function description

function(err, data) { ... }
Parameter
ParameterDescription
Local Disk Types
err
Returns a network or service error when the request fails. If the request is successful, this is empty. For more information, see Error Codes
Object
- statusCode
HTTP status code, such as 200, 403, and 404
Number
- headers
Returned headers
Object
data
Object returned when the request is successful. If the request fails, this parameter is empty.
Object
- statusCode
HTTP status code, such as 200, 403, and 404
Number
- headers
Returned headers
Object