
# 获取桶列表
#### 功能说明
查询桶列表，返回结果按照桶名字典顺序排列。
#### 方法定义
```
1. ObsClient->listBuckets(array $parameter)
2. ObsClient->listBucketsAsync(array $parameter, callable $callback)
```
#### 请求参数
| **字段名**       | **类型**  | **约束** | **说明**        |
|:---|:---|:---|:---|
| QueryLocation | boolean | 可选     | 是否同时查询桶的区域位置。 |
   
#### 返回结果
| **字段名**         || **类型**            | **说明**         |
|:--|---|:---|:---|
| HttpStatusCode  || integer           | HTTP状态码。       |
| Reason          || string            | HTTP文本描述。      |
| RequestId       || string            | OBS服务端返回的请求ID。 |
| Buckets         || indexed array     | 桶列表。           |
| - | Name         | string            | 桶名。            |
| - | CreationDate | string            | 桶的创建时间。        |
| - | Location     | string            | 桶的区域位置。        |
| Owner           || associative array | 桶的所有者。         |
| - | ID           | string            | 桶所有者的DomainId。 |
   
#### 代码样例
```
try{
       $resp = $obsClient -> listBuckets([
             'QueryLocation' => true
       ]);
       printf("RequestId:%s\n", $resp['RequestId']);
       printf("Owner[ID]:%s\n", $resp['Owner']['ID']);
       
       foreach ($resp['Buckets'] as $index => $bucket){
              printf("Buckets[%d]\n", $index + 1);
              printf("Name:%s\n", $bucket['Name']);
              printf("CreationDate:%s\n", $bucket['CreationDate']);
              printf("Location:%s\n", $bucket['Location']);
       }
}catch (Obs\Common\ObsException $obsException){
       printf("ExceptionCode:%s\n", $obsException->getExceptionCode());              
       printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
}
```
