Cross-region Replication

Last updated: 2020-03-20 09:37:18

PDF

Note

This document provides an overview of API on version control and sample SDK code.

API Operation name pedagogical operation
PUT Bucket versioning Setting Versioning Set Bucket's version control function
GET Bucket versioning Query version control Query Bucket's version control information

Setting Versioning

Function description

Set and specify Bucket's version control function (PUT Bucket versioning).

Method prototype

public Guzzle\Service\Resource\Model putBucketVersioning(array $args = array());

Request Sample

Turn on version control

try {
    $result = $cosClient->putBucketVersioning(array(
        'Bucket' => 'examplebucket-1250000000', 
        'Status' => 'Enabled'
    )); 
    print_r($result);
} catch (\Exception $e) {
    echo "$e\n";
}

Pause version control

try {
    $result = $cosClient->putBucketVersioning(array(
        'Bucket' => 'examplebucket-1250000000', 
        'Status' => 'Suspended'
    )); 
    print_r($result);
} catch (\Exception $e) {
    echo "$e\n";
}

Parameter description

Parameter name Type Description Required/Optional
Bucket String Bucket who turns on or pauses version control, format: BucketName-APPID Yes
Status String Version control policy. Available value is Suspended/Enabled. Yes

Query version control

Function description

Query the version control information (GET Bucket versioning) of the specified Bucket.

Method prototype

public Guzzle\Service\Resource\Model getBucketVersioning(array $args = array());

Request Sample

try {
    $result = $cosClient->getBucketVersioning(array(
        'Bucket' => 'examplebucket-1250000000', 
    )); 
    print_r($result);
} catch (\Exception $e) {
    echo "$e\n";
}

Parameter description

Parameter name Type Description Required/Optional
Bucket String Query version control Bucket, format: BucketName-APPID Yes

Return result description

Parameter name Type Description Parent node
Status String Version control policy, optional value is Suspended/Enabled or empty None