OBS PHP SDK
OBS PHP SDK
链接复制成功!
设置桶日志管理配置
功能说明
设置桶的访问日志配置。
方法定义
1. ObsClient->setBucketLogging(array $parameter)
2. ObsClient->setBucketLoggingAsync(array $parameter, callable $callback)
请求参数
字段名 |
类型 |
约束 |
说明 |
|||
---|---|---|---|---|---|---|
Bucket |
string |
必选 |
桶名。 |
|||
Agency |
string |
如果是设置桶日志配置则必选 |
委托名。 |
|||
LoggingEnabled |
associative array |
可选 |
日志配置信息。 |
|||
TargetBucket |
string |
必选 |
生成日志的目标桶。 |
|||
TargetPrefix |
string |
必选 |
在目标桶中生成日志对象的对象名前缀。 |
|||
TargetGrants |
indexed array |
可选 |
被授权用户权限信息列表。 |
|||
Grantee |
associative array |
可选 |
被授权用户。 |
|||
Type |
string |
必选 |
被授权的用户类型。 |
|||
ID |
string |
如果Type为“CanonicalUser”则必选,否则必须为空 |
被授权用户的DomainId。 |
|||
URI |
string |
如果Type为“Group”则必选,否则必须为空 |
被授权的用户组。 |
|||
Permission |
string |
可选 |
被授予的权限。 |
返回结果
字段名 |
类型 |
说明 |
---|---|---|
HttpStatusCode |
integer |
HTTP状态码。 |
Reason |
string |
HTTP文本描述。 |
RequestId |
string |
OBS服务端返回的请求ID。 |
代码样例
try{
$resp = $obsClient -> setBucketLogging([
'Bucket' => 'bucketname',
'LoggingEnabled' => [
'TargetBucket' => 'targetbucketname',
'TargetPrefix' => 'prefix',
'TargetGrants' => [
['Grantee' => ['Type' => 'Group', 'URI' => ObsClient::GroupAuthenticatedUsers], 'Permission' => ObsClient::PermissionWriteAcp],
['Grantee' => ['Type' => 'Group', 'URI' => ObsClient::GroupAuthenticatedUsers], 'Permission' => ObsClient::PermissionRead]
]
]
]);
printf("RequestId:%s\n", $resp['RequestId']);
}catch (Obs\Common\ObsException $obsException){
printf("ExceptionCode:%s\n", $obsException->getExceptionCode());
printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
}
父主题: 桶相关接口