Creates an event rule for a specified event bus. You must specify an event pattern and an event target for an event rule. An event rule matches events based on the event pattern.
URI
/openapi/createRule
Limits
A maximum of 10 event rules can be created for a single event bus.
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
EventBusName | String | Yes | default | The name of the event bus.For more information, see Limits. |
RuleName | String | Yes | MNSRule | The name of the event rule.For more information, see Limits. |
Description | String | No | Filter rule for Message Service | The description of the event rule. |
Status | String | No | ENABLE | The status of the event rule. Valid values:
|
FilterPattern | String | No |
|
The event pattern, in the JSON format. Valid values:
Each field can have a maximum of five expressions in the map data structure. |
Targets | List<Target> | Yes | The event target to which events are delivered. | |
Id | String | Yes | 1 | The custom ID of the event target. |
Type | String | Yes | acs.mns.queue | The type of the event target. |
Endpoint | String | Yes | N/A | The endpoint of the event target. |
PushRetryStrategy | String | Yes | BACKOFF_RETRY | The retry policy that is used to push the event. Valid values:
|
ParamList | List<Param> | Yes | The parameters that the event passes. | |
resourceKey | String | Yes | body | The resource key of the transformed event.For more information, see Event target parameters. |
form | String | Yes | TEMPLATE | The transformation method.For more information, see Event target parameters. |
value | String | Yes |
|
The event value to be transformed. |
template | String | No | The value of ${key} is ${value}! | The format of the template. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RuleARN | String | acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/MNSRule | The Alibaba Cloud Resource Name (ARN) of the event rule. The ARN is used for authorization. |
Examples
Sample request
POST /openapi/createRule HTTP/1.1
Host: 123456789098****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26
{
"EventBusName":"default",
"RuleName":"MNSRule",
"Description":"Filter rule for Message Service",
"Status":"ENABLE",
"filterPattern":"{\"source\": [{\"prefix\": \"acs.\"}],\"type\": [{\"prefix\":\"oss:ObjectReplication\"}],\"subject\":[{\"prefix\":\"acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/\", \"suffix\":\".txt\"}]}",
"Targets":[
{
"Id":"1",
"Type":"acs.mns.queue",
"Endpoint":"acs:mns:cn-hangzhou:123456789098****:queues/myqueue",
"PushRetryStrategy":"BACKOFF_RETRY",
"ParamList":[
{
"resourceKey":"queue",
"form":"CONSTANT",
"value":"myqueue"
},
{
"resourceKey":"body",
"form":"TEMPLATE",
"value":"{\"key\"=\"value\"}",
"template":"The value of ${key} is ${value}!"
}
]
}
]
}
Sample response
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 5E9A9081333245F1D800****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"RuleARN":"acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/MNSRule"
}