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

GET Bucket notification

API Description

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

Method Definition

func (obsClient ObsClient) GetBucketNotification(bucketName string) (output *GetBucketNotificationOutput, err error)

Method Definition If a Signed URL Is Used

func (obsClient ObsClient) GetBucketNotificationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketNotificationOutput, err error)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

string

Mandatory

Bucket name

Returned Result

Field

Type

output

*GetBucketNotificationOutput

err

error

Sample Code

func main() {
       output, err := obsClient.GetBucketNotification("bucketname")
       for index, topicConfiguration := range output.TopicConfigurations {
              fmt.Printf("TopicConfiguration[%d]\n", index)
              fmt.Printf("ID:%s, Topic:%s, Events:%v\n", topicConfiguration.ID, topicConfiguration.Topic, topicConfiguration.Events)
       }
       if err == nil {
              fmt.Printf("RequestId:%s\n", output.RequestId)
       } else {
              if obsError, ok := err.(obs.ObsError); ok {
                     fmt.Println(obsError.Code)
                     fmt.Println(obsError.Message)
              } else {
                     fmt.Println(err)
              }
       }
}