Configuring Event Notification for a Bucket
Functions
This operation notifies users of their operations on buckets, allowing users know events happened on buckets in a timely manner.
By default, the notification function of a bucket is not enabled, and the NotificationConfiguration element is null. If you want to disable the function, set the NotificationConfiguration element to null.
<NotificationConfiguration></NotificationConfiguration>
After receiving a request for configuring event notification, OBS verifies whether the specified SMN topic exists and whether the topic is authorized to OBS. If the topic exists and is authorized to OBS, OBS sends a test notification to the topic subscriber.
To perform this operation, you must have the PutBucketNotification permission. By default, the permission is granted to the bucket owner only. However, it can be granted to other users by configuring the bucket policy.
Request Syntax
PUT /?notification HTTP/1.1Host: bucketname.obs.region.example.comDate: dateAuthorization: authorization string<NotificationConfiguration><TopicConfiguration><Id>ConfigurationId</Id><Filter><Object><FilterRule><Name>prefix</Name><Value>prefix-value</Value></FilterRule><FilterRule><Name>suffix</Name><Value>suffix-value</Value></FilterRule></Object></Filter><Topic>TopicARN</Topic><Event>event-type</Event><Event>event-type</Event>...</TopicConfiguration>...</NotificationConfiguration>
Request Parameters
This request contains no message parameters.
Request Headers
This request uses common headers. For details, see Table 3.
Request Elements
This request contains elements to specify the notification configuration for the bucket in XML format. For details about the configuration elements, see Table 1.
<Topic>urn:smn:region:project_id:smn_topic</Topic>
<Topic>urn:smn:exampleRegion:d745b885f14941369b2d2138e7a65bef:obs_test</Topic>
Response Syntax
HTTP/1.1 status_codeDate: dateContent-Length: lengthContent-Type: type
Response Headers
The response to the request uses common headers. For details, see Table 1.
Response Elements
This response contains no elements.
Error Responses
When this operation is being called, the system checks whether the NotificationConfiguration element is valid and whether the configuration is valid. The following table lists the common errors and possible causes of this operation.
Error Code | Description | HTTP Status Code |
---|---|---|
InvalidArgument | Possible causes of this error are:
| 400 Bad Request |
AccessDenied | The operator is not the bucket owner and not granted with the PutBucketNotification permission. | 403 Forbidden |
Sample Request
PUT /?notification HTTP/1.1User-Agent: curl/7.29.0Host: examplebucket.obs.region.example.comAccept: */*Date: WED, 01 Jul 2015 03:15:45 GMTAuthorization: OBS H4IPJX0TQTHTHEBQQCEC:uRTt8YTkAqJCUfWfYkveEcIGAC0=Content-Length: 538<NotificationConfiguration><TopicConfiguration><Id>ConfigurationId</Id><Filter><Object><FilterRule><Name>prefix</Name><Value>object</Value></FilterRule><FilterRule><Name>suffix</Name><Value>txt</Value></FilterRule></Object></Filter><Topic>urn:smn:region:4b29a3cb5bd64581bda5714566814bb7:tet555</Topic><Event>ObjectCreated:Put</Event></TopicConfiguration></NotificationConfiguration>
Sample Response
HTTP/1.1 200 OKServer: OBSx-obs-request-id: 9046000001643C8E80C19FAC4D8068E3x-obs-id-2: 32AAAQAAEAABSAAkgAIAABAAAQAAEAABCTFAxJPTib3GkcQ7nVVs4C8Z6NNcfVDuDate: WED, 01 Jul 2015 03:15:46 GMTContent-Length: 0
- Functions
- Request Syntax
- Request Parameters
- Request Headers
- Request Elements
- Response Syntax
- Response Headers
- Response Elements
- Error Responses
- Sample Request
- Sample Response