Help Center> Object Storage Service> SDK Reference> Python> Bucket-Related APIs> Obtaining the Event Notification Settings of a Bucket

Obtaining the Event Notification Settings of a Bucket

API Description

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

Method Definition

ObsClient.getBucketNotification(bucketName)

Request Parameters

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

Returned Results

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

Notification

Bucket event notification settings

Sample Code

try:
    resp = obsClient.getBucketNotification('bucketname') 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        for topicConfiguration in resp.body.topicConfigurations:
            print('id:', topicConfiguration.id)
            print('topic:', topicConfiguration.topic)
            print('events:', topicConfiguration.events)
            index = 1
            for rule in topicConfiguration.filterRules:
                print('rule [' + str(index) + ']')
                print('name:', rule.name)
                print('value:', rule.value)

        for functionGraphConfiguration in resp.body.functionGraphConfigurations:
            print('id:', functionGraphConfiguration.id)
            print('functionGraph:', functionGraphConfiguration.functionGraph)
            print('events:', functionGraphConfiguration.events)
            index = 1
            for rule in functionGraphConfiguration.filterRules:
                print('rule [' + str(index) + ']')
                print('name:', rule.name)
                print('value:', rule.value)

    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())