• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Node.js SDK)
  4. Bucket-Related APIs
  5. GET Bucket lifecycle

GET Bucket lifecycle

API Description

You can use this API to obtain the lifecycle rules of a bucket.

Method Definition

ObsClient.getBucketLifecycleConfiguration(parameter, callback)

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

Returned Result (InterfaceResult)

Field

Type

Description

RequestId

String

Request ID returned by the OBS server

Rules

Array

Lifecycle rules of the bucket

  

Transitions

Array

List of object transition policies

  

StorageClass

String

Storage class of the object after transition

Date

String

Date when an object will be transited

Days

String

Number of days after which an object will be transited since its creation

  

Expiration

Object

Expiration time of an object

  

Date

String

Date when an object expires

Days

String

Number of days after which an object expires since its creation

ID

String

Rule ID

Prefix

String

Object name prefix. It identifies the objects to which the rule applies.

Status

String

Whether the rule is enabled

  

NoncurrentVersionTransitions

Array

List of noncurrent object version transition policies

  

StorageClass

String

Storage class of the noncurrent object version after transition

NoncurrentDays

String

Number of days after which an object will be transited since it becomes a noncurrent version

  

NoncurrentVersionExpiration

Object

Expiration time of a noncurrent object version

  

NoncurrentDays

String

Number of days after which an object expires since it becomes a noncurrent version.

Sample Code

obsClient.getBucketLifecycleConfiguration({
       Bucket : 'bucketname'
},(err, result) => {
       if(err){
              console.error('Error-->' + err);
       }else{
              if(result.CommonMsg.Status < 300){
                     console.log('RequestId-->' + result.InterfaceResult.RequestId);
                     for(let i=0;i<result.InterfaceResult.Rules.length;i++){
                           console.log('Rule[' + i + ']:');
                           console.log('ID-->' + result.InterfaceResult.Rules[i]['ID']);
                           console.log('Prefix-->' + result.InterfaceResult.Rules[i]['Prefix']);
                           console.log('Status-->' + result.InterfaceResult.Rules[i]['Status']);
                           console.log('Expiration[Date]-->' + result.InterfaceResult.Rules[i]['Expiration']['Date']);
                           console.log('Expiration[Days]-->' + result.InterfaceResult.Rules[i]['Expiration']['Days']);
                           console.log('NoncurrentVersionExpiration[NoncurrentDays]-->' + result.InterfaceResult.Rules[i]['NoncurrentVersionExpiration']['NoncurrentDays']);
                     }
              }else{
                     console.log('Code-->' + result.CommonMsg.Code);
                     console.log('Message-->' + result.CommonMsg.Message);
              }
       }
});