Updated on 2026-08-14 GMT+08:00

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

Method

ObsClient.getBucketNotification(final BaseBucketRequest request)

Request Parameters

Table 1 List of request parameters

Parameter

Type

Mandatory (Yes/No)

Description

request

BaseBucketRequest

Yes

Explanation:

Request parameters for obtaining event notification configurations. For details, see Table 2.

Table 2 BaseBucketRequest

Parameter

Type

Mandatory (Yes/No)

Description

bucketName

String

Yes

Explanation:

Bucket name.

Restrictions:

  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain a period (.) and a hyphen (-) adjacent to each other, for example, my-.bucket or my.-bucket.
  • If you repeatedly create buckets with the same name in the same region, no error will be reported and the bucket properties comply with those set in the first creation request.

Default value:

None

Responses

Table 3 BucketNotificationConfiguration

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.

Table 4 TopicConfiguration

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

Table 6

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.

Table 5 FunctionGraphConfiguration

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

Table 6

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.

Table 6 Filter

Parameter

Type

Description

filterRules

List<Table 8>

Explanation:

It stores rules for filtering object names.

Value range:

For details, see Table 8.

Table 7 EventTypeEnum

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.

Table 8 FilterRule

Parameter

Type

Mandatory (Yes/No)

Description

name

String

No

Whether to filter objects by object name prefix or suffix. Possible values are:

  • prefix
  • suffix

value

String

No

Keyword used to filter objects based on the chosen prefix or suffix.

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);