This document provides an overview of APIs and SDK code samples related to versioning.
API | Operation Name | Operation Description |
---|---|---|
PUT Bucket versioning | Setting versioning | Sets the versioning feature of a bucket |
GET Bucket versioning | Querying versioning | Queries the versioning information of a bucket |
This API (PUT Bucket versioning) is used to set the versioning feature of a specified bucket.
public Guzzle\Service\Resource\Model putBucketVersioning(array $args = array());
Enable versioning
try {
$result = $cosClient->putBucketVersioning(array(
'Bucket' => 'examplebucket-1250000000', // Format: BucketName-APPID
'Status' => 'Enabled'
));
// Request succeeded
print_r($result);
} catch (\Exception $e) {
// Request failed
echo "$e\n";
}
Suspend versioning
try {
$result = $cosClient->putBucketVersioning(array(
'Bucket' => 'examplebucket-1250000000', // Format: BucketName-APPID
'Status' => 'Suspended'
));
// Request succeeded
print_r($result);
} catch (\Exception $e) {
// Request failed
echo "$e\n";
}
Parameter Name | Type | Description | Required |
---|---|---|---|
Bucket | String | Bucket for which to enable or suspend versioning in the format of BucketName-APPID |
Yes |
Status | String | Versioning policy. Valid values: Suspended, Enabled | Yes |
This API (GET Bucket versioning) is used to query the versioning information of a specified bucket.
public Guzzle\Service\Resource\Model getBucketVersioning(array $args = array());
try {
$result = $cosClient->getBucketVersioning(array(
'Bucket' => 'examplebucket-1250000000', // Format: BucketName-APPID
));
// Request succeeded
print_r($result);
} catch (\Exception $e) {
// Request failed
echo "$e\n";
}
Parameter Name | Type | Description | Required |
---|---|---|---|
Bucket | String | Bucket for which to query versioning in the format of BucketName-APPID |
Yes |
Parameter name | Type | Description | Parent Node |
---|---|---|---|
Status | String | Versioning policy. Valid values: Suspended, Enabled, null | None |
Was this page helpful?