-
API Reference
- Overview
- Initialization
- Pre-defined Constants
-
Bucket-Related APIs
- Before You Start
- HEAD Bucket
- DELETE Bucket
- GET Objects
- GET Object versions
- List Multipart uploads
- Obtain Bucket Metadata
- GET Bucket location
- GET Bucket storageinfo
- PUT Bucket quota
- GET Bucket quota
- Set Bucket storagePolicy
- GET Bucket storagePolicy
- PUT Bucket acl
- GET Bucket acl
- PUT Bucket logging
- GET Bucket logging
- PUT Bucket policy
- GET Bucket policy
- DELETE Bucket policy
- PUT Bucket lifecycle
- GET Bucket lifecycle
- DELETE Bucket lifecycle
- PUT Bucket website
- GET Bucket website
- DELETE Bucket website
- PUT Bucket versioning
- GET Bucket versioning
- GET Bucket cors
- DELETE Bucket cors
- PUT Bucket tagging
- GET Bucket tagging
- DELETE Bucket tagging
- Object-Related APIs
- Other APIs
- Change History
- General Reference
Copied.
PUT Bucket lifecycle
API Description
You can use this API to set lifecycle rules for a bucket, so as to periodically transit storage classes of objects and delete objects in the bucket.
Method Definition
ObsClient.setBucketLifecycle
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
||
---|---|---|---|---|---|
Bucket |
String |
Mandatory |
Bucket name |
||
RequestDate |
String or Date |
Optional |
Request time When the parameter type is String, the value must comply with the ISO8601 or RFC822 standards. |
||
Rules |
Array |
Mandatory |
Lifecycle rules of the bucket |
||
Transitions |
Array |
Optional |
List of object transition policies |
||
StorageClass |
String |
Mandatory |
Storage class of the object after transition The Standard storage class is not supported. |
||
Date |
String |
Mandatory when Days is not set |
Date when an object will be transited The value must conform with the ISO8601 standards and must be at 00:00 (UTC time), for example, 2018-01-01T00:00:00Z. |
||
Days |
Number |
Mandatory when Date is not set |
Number of days after which an object will be transited since its creation. The value must be a positive integer. |
||
Expiration |
Object |
Optional |
Expiration time of an object |
||
Date |
String |
Mandatory when Days is not set |
Date when an object expires The value must conform with the ISO8601 standards and must be at 00:00 (UTC time), for example, 2018-01-01T00:00:00Z. |
||
Days |
Number |
Mandatory when Date is not set |
Number of days after which an object expires since its creation. The value must be a positive integer. |
||
ID |
String |
Optional |
Rule ID. It is a 1-255 character string. |
||
Prefix |
String |
Mandatory |
Object name prefix identifying one or more objects to which the rule applies. The value can be empty, indicating that the rule applies to all objects in the bucket. |
||
Status |
String |
Mandatory |
Whether this rule is enabled. Possible values are:
|
||
NoncurrentVersionTransitions |
Array |
Optional |
List of noncurrent object version transition policies |
||
StorageClass |
String |
Mandatory |
Storage class of the noncurrent object version after transition |
||
NoncurrentDays |
Number |
Mandatory |
Number of days after which an object will be transited since it becomes a noncurrent version. The parameter value must be a positive integer. |
||
NoncurrentVersionExpiration |
Object |
Optional |
Expiration time of a noncurrent object version |
||
NoncurrentDays |
Number |
Mandatory |
Number of days after which an object expires since it becomes a noncurrent version. The field value must be a positive integer. |
Transition, Expiration, NoncurrentVersionTransitions, and NoncurrentVersionExpiration cannot be all null.
Returned Result (InterfaceResult)
Field |
Type |
Description |
---|---|---|
RequestId |
String |
Request ID returned by the OBS server |
Sample Code
obsClient.setBucketLifecycle({
Bucket : 'bucketname',
Rules:[
{ID:'rule1',Prefix:'prefix1',Status:'Enabled',Expiration:{Days: 60}, NoncurrentVersionExpiration:{NoncurrentDays : 60}},
{ID:'rule2',Prefix:'prefix2',Status:'Enabled',Expiration:{Date: '2018-12-31T00:00:00Z'}}
]
},function (err, result) {
if(err){
console.error('Error-->' + err);
}else{
if(result.CommonMsg.Status < 300){
console.log('RequestId-->' + result.InterfaceResult.RequestId);
}else{
console.log('Code-->' + result.CommonMsg.Code);
console.log('Message-->' + result.CommonMsg.Message);
}
}
});
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot