Help Center> Object Storage Service> API Reference> APIs> Data+> Configuring a Bucket Trigger

Configuring a Bucket Trigger

Functions

Binds a workflow trigger to a bucket.

Request Syntax

PUT /?obsworkflowtriggerpolicy HTTP/1.1
Host: bucket.obs.cn-north-4.myhuaweicloud.com 
Authorization: authorization
Content-Type: application/json
Content-Length: length
Date: date

json body

Request parameters

This request contains no message parameters.

Request Headers

This request uses common headers. For details, see Table 3.

Request Elements

Table 1 Request Elements

Parameter

Mandatory

Type

Description

Constraints

rules

Yes

Array

Policy rule array. For details, see Table 2.

For the same bucket, different policy rules (prefix or suffix rules) associated with the same workflow cannot contain each other or overlap with each other.

Table 2 Parameters in the rule structure

Parameter

Mandatory

Type

Description

Constraints

id

Yes

String

Policy rule ID

A rule ID contains 1 to 256 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Each rule ID must be unique in a policy.

graph_urn

Yes

String

Workflow URN.

You need to create the workflow first.

events

Yes

Array String

OBS event list. For details, see the description about OBS event types.

-

prefix

No

String

Object name prefix.

Key word of object names. Based on the prefix defined by this parameter, enter the key word for filtering objects. A longer string of characters delivers a more accurate filtering result. A maximum of 1024 characters are supported. It also can be empty.

In addition, the total length of the prefix and suffix cannot exceed 1024 characters.

suffix

No

String

Suffix of an object name.

Key word of object names. Based on the suffix defined by this parameter, enter the key word for filtering objects. A longer string of characters delivers a more accurate filtering result. A maximum of 1024 characters are supported. It also can be empty.

In addition, the total length of the prefix and suffix cannot exceed 1024 characters.

Table 3 OBS event types

Event Types

Description

Value

OBJECT_CREATED_PUT

Upload objects using the PUT method.

ObjectCreated:Put

OBJECT_CREATED_POST

Upload objects using the POST method.

ObjectCreated:Post

OBJECT_CREATED_COPY

Upload objects using the COPY method.

ObjectCreated:Copy

OBJECT_CREATED_COMPLETEMULTIPARTUPLOAD

Upload objects using the multipart method.

ObjectCreated:CompleteMultipartUpload

OBJECT_CREATED_ALL

The wildcard can be used to indicate that objects can be uploaded using any methods.

ObjectCreated:*

OBJECT_REMOVED_DELETE

Delete objects.

ObjectRemoved:Delete

OBJECT_REMOVED_DELETEMARKERCREATED

Delete objects.

ObjectRemoved:DeleteMarkerCreated

OBJECT_REMOVED_ALL

The wildcard can be used to indicate that objects can be deleted using any methods.

ObjectRemoved:*

Response Syntax

HTTP/1.1 status_code 
Date: date 
Content-Length: length 
X-Request-ID: obs request id

Response Headers

The response to the request uses common headers. For details, see Table 1.

Response Elements

This response contains no element.

Error Responses

No special error responses are returned. For details about error responses, see Table 2.

Sample Request

PUT /?obsworkflowtriggerpolicy HTTP/1.1
Host: bucket.obs.cn-north-4.myhuaweicloud.com 
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:sc2PM13Wlfcoc/YZLK0MwsI2Zpo=
Content-Type: application/json
Content-Length: 100
Date: Thu, 27 Aug 2020 12:38:10 GMT

{
    "rules": [{
        "id":"event-01",
        "graph_urn": "graph_urn",
        "events": ["ObjectCreated:*", "ObjectRemoved:*"],
        "prefix": "",
        "suffix": ""
    }]
}

Sample Response

HTTP/1.1 status_code 
Date: date 
Content-Length: length 
X-Request-ID: obs request id