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());
} Last Article: PUT Bucket lifecycle
Next Article: DELETE Bucket lifecycle
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.