Obtaining the Lifecycle Configuration Information of a Bucket
API Description
You can use this API to obtain the lifecycle configuration information of a bucket.
Method Definition
ObsClient.getBucketLifecycle(bucketName)
Request Parameters
|
Field |
Type |
Optional or Mandatory |
Description |
|---|---|---|---|
|
bucketName |
str |
Mandatory |
Bucket name |
Returned Result
|
Type |
Description |
|---|---|
|
SDK common result object |
|
GetResult.body Type |
Description |
|---|---|
|
Response result of the request for obtaining the lifecycle configuration information of a bucket |
Sample Code
try:
resp = obsClient.getBucketLifecycle('bucketname')
if resp.status < 300:
print('requestId:', resp.requestId)
index = 1
for rule in resp.body.lifecycleConfig.rule:
print('rule [' + str(index) + ']')
print('id:', rule.id)
print('prefix:', rule.prefix)
print('status:', rule.status)
if rule.expiration:
print('days:' , rule.expiration.days)
print('date:' , rule.expiration.date)
if rule.noncurrentVersionExpiration:
print('noncurrentDays:' , rule.noncurrentVersionExpiration.noncurrentDays)
index += 1
else:
print('errorCode:', resp.errorCode)
print('errorMessage:', resp.errorMessage)
except:
import traceback
print(traceback.format_exc())
Last Article: Configuring a Lifecycle Rule for a Bucket
Next Article: Deleting Lifecycle Rules of a Bucket
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.