• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (PHP SDK)
  4. Bucket-Related APIs
  5. GET Bucket notification

GET Bucket notification

API Description

You can use this API to obtain the event notification settings of a bucket.

Method Definition

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

TopicConfigurations

indexed array

Event notification setting list of the bucket

  

ID

string

Event notification setting ID

Topic

string

URN of the event notification topic. After detecting a specific event in the bucket, OBS sends a message to the topic.

Event

indexed array of strings

Type of events that need to be notified

Filter

indexed array

List of filtering rules

  

Name

string

Prefix or suffix of object names for filtering

Value

string

Keyword of object names for filtering objects by prefix or suffix

Sample Code

try{
       $resp = $obsClient -> getBucketNotification([
              'Bucket' => 'bucketname'
       ]);
       printf("RequestId:%s\n", $resp['RequestId']);
 foreach ( $resp ['TopicConfigurations'] as $index => $topicConfiguration ) {
           printf ( "TopicConfigurations[%d]\n", $index + 1 );
           printf ( "ID:%s\n", $topicConfiguration ['ID'] );
           printf ( "Topic:%s\n", $topicConfiguration ['Topic'] );
           printf ( "Event:%s\n", print_r ( $topicConfiguration ['Event'], true ) );
 foreach ( $topicConfiguration ['Filter'] as $index => $filter ) {
                  printf ( "Filter[%d]", $index + 1 );
                  printf ( "Name:%s\n", $filter ['Name'] );
                  printf ( "Value:%s\n", $filter ['Value'] );
           }
       }
}catch (Obs\Common\ObsException $obsException){
       printf("ExceptionCode:%s\n", $obsException->getExceptionCode());              
       printf("ExceptionMessage:%s\n", $obsException->getExceptionMessage());
}