Configures versioning for a bucket.
Usage notes
Before you configure the versioning state for a bucket, you must have the PutBucketVersioning permission.
A bucket can be in one of the following versioning states: disabled, enabled, or suspended. By default, versioning is disabled for a bucket.
If versioning is enabled for a bucket, OSS generates unique version IDs for all objects that are added to the bucket. In this case, OSS stores multiple versions of the objects.
If versioning is suspended for a bucket, OSS generates the version ID null for all objects that are added to the bucket. In this case, OSS does not store new versions for objects that are deleted or overwritten.
For more information about versioning, see Overview.
Command syntax
ossutil api put-bucket-versioning --bucket value --versioning-configuration value [flags]
Parameter | Type | Description |
--bucket | string | The name of the bucket. |
--versioning-configuration | string | The container that stores the versioning configurations. |
The put-bucket-versioning command is the equivalent of the PutBucketVersioning operation. For more information about the API operation, see PutBucketVersioning.
--versioning-configuration
The --versioning-configuration option supports XML and JSON formats:
XML format:
<VersioningConfiguration> <Status>string</Status> </VersioningConfiguration>
JSON format:
{ "Status": "string" }
For more information, see Command-line options.
Examples
Configure versioning for a bucket named examplebucket.
Use an XML configuration file (versioning-configuration.xml in this example)
<?xml version="1.0" encoding="UTF-8"?> <VersioningConfiguration> <Status>Enabled</Status> </VersioningConfiguration>
Sample command:
ossutil api put-bucket-versioning --bucket examplebucket --versioning-configuration file://versioning-configuration.xml
Use a JSON configuration file (versioning-configuration.json in this example)
{ "Status": "Enabled" }
Sample command:
ossutil api put-bucket-versioning --bucket examplebucket --versioning-configuration file://versioning-configuration.json
Use JSON parameters in the command line
ossutil api put-bucket-versioning --bucket examplebucket --versioning-configuration "{\"Status\":\"Enabled\"}"