-
API Reference
- Overview
- Initialization
- Predefined Constants
-
Bucket-Related APIs
- PUT Bucket
- GET Buckets
- 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
- PUT Bucket cors
- GET Bucket cors
- DELETE Bucket cors
- PUT Bucket tagging
- GET Bucket tagging
- DELETE Bucket tagging
- Objects-Related APIs
- Other APIs
- Change History
- General Reference
Copied.
GET Bucket lifecycle
API Description
You can use this API to obtain the lifecycle rules of a bucket.
Method Definition
1. ObsClient->getBucketLifecycle(array $parameter) 2. ObsClient->getBucketLifecycleAsync(array $parameter, callable $callback)
Request Parameter
Field |
Type |
Optional or Mandatory |
Description |
---|---|---|---|
Bucket |
string |
Mandatory |
Bucket name |
Returned Result
Field |
Type |
Description |
||
---|---|---|---|---|
HttpStatusCode |
integer |
HTTP status code |
||
Reason |
string |
Reason description |
||
RequestId |
string |
Request ID returned by the OBS server |
||
Rules |
indexed array |
Lifecycle rules of the bucket |
||
Transitions |
indexed 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 |
associative array |
Expiration time of an object |
||
Date |
string |
Date when an object expires |
||
Days |
integer |
Number of days after which an object expires since its creation |
||
ID |
string |
Rule ID |
||
Prefix |
string |
Object name prefix identifying one or more objects to which the rule applies |
||
Status |
string |
Whether the rule is enabled |
||
NoncurrentVersionTransitions |
indexed 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 |
associative array |
Expiration time of a noncurrent object version |
||
NoncurrentDays |
integer |
Number of days after which an object expires since it becomes a noncurrent version |
Sample Code
try{ $resp = $obsClient -> getBucketLifecycle([ 'Bucket' => 'bucketname' ]); printf("RequestId:%s\n", $resp['RequestId']); foreach ($resp['Rules'] as $index => $rule){ printf("Rules[%d]\n", $index + 1); printf("ID:%s\n", $rule['ID']); printf("Prefix:%s\n", $rule['Prefix']); printf("Status:%s\n", $rule['Status']); printf("Expiration[Days]:%s\n", $rule['Expiration']['Days']); printf("Expiration[Date]:%s\n", $rule['Expiration']['Date']); printf("NoncurrentVersionExpiration[NoncurrentDays]:%s\n", $rule['NoncurrentVersionExpiration']['NoncurrentDays']); } }catch (Obs\Common\ObsException $obsException){ printf("ExceptionCode:%s\n", $obsException->getExceptionCode()); printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage()); }
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