Configures versioning for a bucket.
Usage notes
-
You must have the PutBucketVersioning permission.
-
A bucket has one of three versioning states: disabled (default), enabled, or suspended.
-
When enabled, OSS assigns unique version IDs to all objects added to the bucket and retains multiple versions.
-
When suspended, OSS assigns version ID null to new objects and does not retain versions for deleted or overwritten objects.
For more information about versioning, see Versioning.
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\"}"