Obtaining Event Notification Configurations (SDK for Java)
Function
You can configure notifications for certain types of events. When such events happen in your bucket, you will be notified of the operations in a timely manner.
This API is used to obtain the event notification configurations of a specified bucket.
Restrictions
- To obtain the event notification configurations of a bucket, you must be the bucket owner or have the required permission (obs:bucket:GetBucketNotification granted using IAM or GetBucketNotification granted using a bucket policy). For details, see Introduction to OBS Access Control, IAM Custom Policies, and Creating a Custom Bucket Policy.
- The mapping between OBS regions and endpoints must comply with what is listed in Regions and Endpoints.
Method
ObsClient.getBucketNotification(final BaseBucketRequest request)
Request Parameters
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| request | Yes | Explanation: Request parameters for obtaining event notification configurations. For details, see Table 2. |
| Parameter | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
| bucketName | String | Yes | Explanation: Bucket name. Restrictions:
Default value: None |
Responses
| Parameter | Type | Description |
|---|---|---|
| topicConfigurations | List<Table 4> | Explanation: List of event notification topic configurations. Value range: For details, see Table 4. |
| functionGraphConfigurations | List<Table 5> | Explanation: List of FunctionGraph configurations. Value range: For details, see Table 5. |
| Parameter | Type | Description |
|---|---|---|
| id | String | Explanation: Unique ID of each event notification configuration. If the ID is not specified, OBS automatically assigns an ID. |
| filter | Explanation: It stores rules for filtering object names. Value range: For details, see Table 6. | |
| topic | String | Explanation: URN of the event notification topic. When OBS detects a specific event in the bucket, it publishes a notification message to the topic. You can find the topic's URN on the Topics page of the SMN console. |
| events | List<Table 7> | Explanation: List of event types for which notifications will be sent. Value range: For details, see Table 7. |
| Parameter | Type | Description |
|---|---|---|
| id | String | Explanation: Unique ID of each event notification configuration. If the ID is not specified, OBS automatically assigns an ID. |
| filter | Explanation: It stores rules for filtering object names. Value range: For details, see Table 6. | |
| functionGraph | String | Explanation: URN of FunctionGraph. When OBS detects a specific event in the bucket, it sends a message to FunctionGraph and calls FunctionGraph. |
| events | List<Table 7> | Explanation: List of event types for which notifications will be sent. Value range: For details, see Table 7. |
| Parameter | Type | Description |
|---|---|---|
| filterRules | List<Table 8> | Explanation: It stores rules for filtering object names. Value range: For details, see Table 8. |
| Constant | Description |
|---|---|
| OBJECT_CREATED_ALL | All events for creating objects, including uploading objects using PUT and POST, copying objects, and completing multipart uploads. |
| OBJECT_CREATED_PUT | All events for uploading objects using PUT. |
| OBJECT_CREATED_POST | All events for uploading objects using POST. |
| OBJECT_CREATED_COPY | All events for copying objects. |
| OBJECT_CREATED_COMPLETE_MULTIPART_UPLOAD | All events for completing multipart uploads. |
| OBJECT_REMOVED_ALL | Events of calling the APIs for deleting objects or aborting multipart uploads. These events include deleting objects by specifying object version IDs, and deleting objects without specifying object version IDs after versioning is enabled. |
| OBJECT_REMOVED_DELETE | Events for deleting objects by specifying object version IDs. |
| OBJECT_REMOVED_DELETE_MARKER_CREATED | Events for deleting objects without specifying object version IDs after versioning is enabled. |
Sample Code
Sample code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 | // Enter the endpoint corresponding to the bucket. CN-Hong Kong is used here as an example. Replace it with the one currently in use. String endPoint = "https://obs.ap-southeast-1.myhuaweicloud.com"; // Hard-coded or plaintext AK/SK are risky. For security purposes, encrypt your AK/SK and store them in the configuration file or environment variables. In this example, the AK/SK are stored in environment variables for identity authentication. Before running this example, configure environment variables ACCESS_KEY_ID and SECRET_ACCESS_KEY_ID. // 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. String ak = System.getenv("ACCESS_KEY_ID"); String sk = System.getenv("SECRET_ACCESS_KEY_ID"); // Create an ObsClient instance. ObsClient obsClient = new ObsClient(ak, sk, endPoint); BucketNotificationConfiguration config = obsClient.getBucketNotification("bucketname"); System.out.println(config); |
What is your overall rating for this page?
Thank 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