Obtaining the Event Notification Configuration of a Bucket (SDK for Node.js)
If you have any questions during development, post them on the Issues page of GitHub.
Function
This API is used to obtain the event notification configuration of a bucket.
Method
ObsClient.getBucketNotification
Request Parameters
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| Bucket | String | Yes | Bucket name |
| RequestDate | String or Date | No | Request time NOTE: When the parameter type is String, the value must comply with the ISO8601 or RFC822 standard. |
Responses (InterfaceResult)
| Parameter | Type | Description | |||
|---|---|---|---|---|---|
| RequestId | String | Request ID returned by the OBS server | |||
| TopicConfigurations | Array | SMN configuration list | |||
| ID | String | SMN configuration ID | |||
| Topic | String | URN of the event notification topic. When OBS detects a specific event in the bucket, it sends a notification to the topic. | |||
| Event | Array | List of event types for which notifications will be sent | |||
| Filter | Object | Filter rule information | |||
| FilterRules | Array | List of filter rules | |||
| Name | String | Whether to filter objects by object name prefix or suffix | |||
| Value | String | Keyword used to filter objects based on the chosen prefix or suffix | |||
Sample Code
// Import the OBS library.
// Use npm for installation.
var ObsClient = require('esdk-obs-nodejs');
// Use the source code for installation.
// var ObsClient = require('./lib/obs');
// Create an ObsClient instance.
const obsClient = new ObsClient({
//Obtain an AK and SK pair using environment variables or import an AK and SK pair in other ways. Using hard coding may result in leakage.
//Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html.
access_key_id: process.env.ACCESS_KEY_ID,
secret_access_key: process.env.SECRET_ACCESS_KEY,
//CN-Hong Kong is used here as an example. Replace it with the one currently in use.
server: 'https://obs.ap-southeast-1.myhuaweicloud.com'
});
obsClient.getBucketNotification({
Bucket : 'bucketname'
},(err, result) => {
if(err){
console.error('Error-->' + err);
}else{
console.log('Status-->' + result.CommonMsg.Status);
if(result.CommonMsg.Status < 300 && result.InterfaceResult){
if(result.InterfaceResult.TopicConfigurations){
for(let j=0;j<result.InterfaceResult.TopicConfigurations.length;j++){
console.log('ID-->' + result.InterfaceResult.TopicConfigurations[j].ID);
console.log('Topic-->' + result.InterfaceResult.TopicConfigurations[j].Topic);
console.log('Event-->' + result.InterfaceResult.TopicConfigurations[j].Event);
if(result.InterfaceResult.TopicConfigurations[j].Filter){
for(let i=0;i<result.InterfaceResult.TopicConfigurations[j].Filter.FilterRules.length;i++){
console.log('FilterRule[' + i + '][Name]-->' + result.InterfaceResult.TopicConfigurations[j].Filter.FilterRules[i].Name);
console.log('FilterRule[' + i + '][Value]-->' + result.InterfaceResult.TopicConfigurations[j].Filter.FilterRules[i].Value);
}
}
}
}
}
}
}); Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot