设置桶的事件通知配置
更新时间: 2019-03-13 10:29
功能说明
设置桶的事件通知配置,桶上所发生的指定操作,都能及时得到通知。
方法定义
- func (obsClient ObsClient) SetBucketNotification(input *SetBucketNotificationInput) (output *BaseModel, err error)
使用带授权信息URL的方法定义
- func (obsClient ObsClient) SetBucketNotificationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error)
请求参数
参数名 | 类型 | 约束 |
---|---|---|
input | *SetBucketNotificationInput | 必选 |
返回结果
参数名 | 类型 |
---|---|
output | *BaseModel |
err | error |
代码样例
- func main() {
- input := &obs.SetBucketNotificationInput{}
- input.Bucket = "bucketname"
- var topicConfigurations [1]obs.TopicConfiguration
- topicConfigurations[0] = obs.TopicConfiguration{}
- topicConfigurations[0].ID = "001"
- topicConfigurations[0].Topic = "topic"
- topicConfigurations[0].Events = []obs.EventType{obs.ObjectCreatedAll}
- var filterRules [2]obs.FilterRule
- filterRules[0] = obs.FilterRule{Name: "prefix", Value: "smn"}
- filterRules[1] = obs.FilterRule{Name: "suffix", Value: ".jpg"}
- topicConfigurations[0].FilterRules = filterRules[:]
- input.TopicConfigurations = topicConfigurations[:]
- output, err := obsClient.SetBucketNotification(input)
- 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)
- }
- }
- }
父主题:桶相关接口