All Products
Search
Document Center

Object Storage Service:Query the retention policy configured for a bucket

Last Updated:Aug 01, 2024

Queries the retention policy that is configured for a bucket.

Usage notes

  • To query the retention policy configured for a bucket, you must have the oss:GetBucketWorm permission. For more information, see Attach a custom policy to a RAM user.

  • OSS supports the Write Once Read Many (WORM) strategy that prevents an object from being deleted or overwritten for a specified period of time. You can configure a time-based retention policy for a bucket. A retention policy has a retention period that ranges from one day to 70 years.

  • After a retention policy configured for a bucket is locked, you can read objects from or upload objects to the bucket. However, the retention policy and objects in the bucket cannot be deleted within the retention period. You can delete objects in the bucket only after the retention period expires.

Command syntax

ossutil api get-bucket-worm --bucket value [flags]

Parameter

Type

Description

--bucket

string

The name of the bucket.

Note

For more information, see Command-line options.

Examples

  • Query the retention policy configured for the examplebucket bucket.

    ossutil api get-bucket-worm --bucket examplebucket
  • Query the retention policy configured for the examplebucket bucket and format the output in JSON.

    ossutil api get-bucket-worm --bucket examplebucket --output-format json
  • Query the retention policy configured for the examplebucket bucket and format the output in YAML.

    ossutil api get-bucket-worm --bucket examplebucket --output-format yaml