使用ListRules查询所有规则,可以结合Limit和NextToken进行翻页。

URI

/openapi/listRules

请求参数

名称 类型 是否必选 示例值 描述
EventBusName String default 事件总线(EventBus)名称。详情请参见使用限制
RuleNamePrefix String my 事件规则名称。详情请参见使用限制
Limit String 10 限定每次返回的最大条数,可以和NextToken搭配使用实现翻页能力。
NexToken String Null 当指定Limit时,如果还有多余的返回值则会返回NextToken。

返回参数

名称 类型 描述
Rules List<Rule> 查询到的规则。
NextToken String 下次翻页请求的偏移量。如果翻页请求还有更多数据可以获取,则会返回NextToken。
表 1. Rules数据结构列表
名称 类型 示例值 描述
EventBusName String default 事件总线(EventBus)名称。
RuleName String myRule1 事件规则名称。
Description String 针对OSS的过滤规则 规则说明。
Status String ENABLE 规则的状态。取值说明如下:
  • ENABLE:规则已启用。规则默认状态。
  • DISABLE:规则已禁用。
FilterPattern String {\"source\":[\"acs.oss\"],\"type\":[\"oss:ObjectCreated:UploadPart\"]} 事件过滤器,JSON格式。
  • stringEqual模式
  • stringExpression模式

    每个field最多5个expression(map结构)。

Targets List<Target>
"Targets": [{
            "Id": "target1",
            "Type": "http",
            "Endpoint": "http://www.myHost.com",
            "PushSelector": "DATA_OF_EVENT",
            "PushRetryStrategy": "BACKOFF_RETRY"
        }]
规则过滤到事件时,事件被投递的目标。详情请参见使用限制

示例

请求示例

POST /openapi/listRules 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: EVENTBRIDGE vZ3VL0SuJdHiEmvU:Jo2PbTj****zYAYoYslKLvWzg=
Content-Type: text/xml;charset=UTF-8
Content-Length: 26

{
  "EventBusName": "default",
  "RuleNamePrefix": "my",
  "Limit": 10,
  "NextToken": null
}

返回示例

HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 5E9A9081333245F1D8000085
Date: Sat, 18 Apr 2020 05:30:41 GMT

{
    "NextToken": null,
    "Rules": [{
        "EventBusName": "default",
        "RuleARN": "acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/myRule1",
        "RuleName": "myRule1",
        "status": "ENABLE",
        "FilterPattern": "{\"source\":[\"acs.oss\"],\"type\":[\"oss:ObjectCreated:UploadPart\"]}",
        "Targets": [{
            "Id": "target1",
            "Type": "http",
            "Endpoint": "http://www.myHost.com",
            "PushSelector": "MATCHED_EVENT",
            "PushRetryStrategy": "EXPONENTIAL_DECAY_RETRY"
        }]}, {
        "EventBusName": "default",
        "RuleARN": "acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/myRule2",
        "RuleName": "myRule2",
        "Status": "ENABLE",
        "FilterPattern": "{\"source\":[\"acs.oss\"],\"type\":[\"oss:ObjectCreated:UploadPart\"]}",
        "Targets": [{
            "Id": "target1",
            "Type": "http",
            "Endpoint": "http://www.myHost.com",
            "PushSelector": "DATA_OF_EVENT",
            "PushRetryStrategy": "BACKOFF_RETRY"
        }]
    }]
}