Updated on 2022-02-10 GMT+08:00

GET Bucket policy

API Description

You can use this API to obtain the bucket policy.

Method Definition

1. ObsClient->getBucketPolicy(array $parameter)
2. ObsClient->getBucketPolicyAsync(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

Policy

string

Policy information in JSON format

Sample Code

try{
       $resp = $obsClient -> getBucketPolicy([
              'Bucket' => 'bucketname'
       ]);
       printf("RequestId:%s\n", $resp['RequestId']);
       printf("Policy:%s\n", $resp['Policy']);
}catch (Obs\Common\ObsException $obsException){
       printf("ExceptionCode:%s\n", $obsException->getExceptionCode());              
       printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
}