本文介绍事件规则中的请求参数。
请求参数
| 参数 | 是否必填 | 参数类型 | 说明 | 示例 |
|---|---|---|---|---|
| eventBusName | 是 | String | 事件总线名。 | bus1 |
| eventRuleName | 是 | String | 事件规则名。 规则:长度限制为2~63个字符,可以由小写字母、数字或短划线(-)组成,必须以小写字母开始,事件规则名不可重复。 | rule1 |
| desc | 否 | String | 事件规则描述,非必填,限制为须小于256个字符。 | test |
| filterPattern | 是 | String | 事件模式。需符合一定的规则,详见事件模式说明。 | {} |
| eventTargets | 是 | Array of Objects | 事件目标数组,详见下文表EventTargets。 |
表 EventTargets
| 参数 | 是否必填 | 参数类型 | 说明 | 示例 |
|---|---|---|---|---|
| type | 是 | String | 事件目标类型,具体调用方式请按事件目标类型查看下文。 | kafka |
| eventTargetName | 是 | String | 事件目标名。同一事件规则下事件目标名不可重复。 | target1 |
| params | 是 | Array of Objects | 事件目标参数。详见下表EventTarget。 |
表 EventTarget
| 参数 | 是否必填 | 参数类型 | 说明 |
|---|---|---|---|
| resourceKey | 是 | String | 事件目标参数名 |
| value | 是 | String | 事件目标参数值 |
| form | 是 | String | 事件目标参数格式。 |
| template | 否 | String | 事件目标参数模板样式,详见事件内容转换。 |
分布式消息服务Kafka
当事件目标选择分布式消息服务Kafka时,事件目标的type值为kafka,eventTargets中的resourceKey字段中含义如下表所示。
| resourceKey | 是否必传 | form | value | template |
|---|---|---|---|---|
| instanceId | 是 |
| 分布式消息服务Kafka实例Id。 说明 实例Id可在分布式消息服务Kafka管理控制台-实例详情页获取。 | 无 |
| topic | 是 |
| Kafka主题。 | 无 |
| value | 是 |
| 消息体。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
| key | 是 |
| 消息键值。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
请求示例:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "kafka",
"eventTargetName": "1gQfuPljs9MJsWM1eHYch",
"params": [
{
"resourceKey": "instanceId",
"value": "356b3496b87xxxxxxxxfe7deef7fe35",
"form": "CONSTANT"
},
{
"resourceKey": "topic",
"value": "test2",
"form": "CONSTANT"
},
{
"resourceKey": "value",
"value": "",
"form": "ORIGINAL"
},
{
"resourceKey": "key",
"value": "",
"form": "EMPTY"
}
]
}
]
}分布式消息服务RocketMQ
当事件目标选择分布式消息服务RocketMQ时,事件目标的type值为rocketmq,eventTargets中的resourceKey字段中含义如下表所示。
| resourceKey | 是否必传 | form | value | template |
|---|---|---|---|---|
| instanceId | 是 |
| 分布式消息服务RocketMQ实例ID。 说明 实例Id可在分布式消息服务RocketMQ管理控制台-实例详情页获取。 | 无 |
| topic | 是 |
| RocketMQ主题。 | 无 |
| body | 是 |
| 消息体。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
| keys | 是 |
| 消息索引。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
| properties | 是 |
| 消息自定义属性。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
| tags | 是 |
| 消息标签。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
请求示例:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "rocketmq",
"eventTargetName": "lMVBoqi55L3Q6QaCKFWYA",
"params": [
{
"resourceKey": "instanceId",
"value": "89ceb110331e4c968499744c2ccbdbcc",
"form": "CONSTANT"
},
{
"resourceKey": "topic",
"value": "TopicA",
"form": "CONSTANT"
},
{
"resourceKey": "body",
"value": "",
"form": "ORIGINAL"
},
{
"resourceKey": "properties",
"value": "",
"form": "EMPTY"
},
{
"resourceKey": "keys",
"value": "",
"form": "EMPTY"
},
{
"resourceKey": "tags",
"value": "",
"form": "EMPTY"
}
]
}
]
}
分布式消息服务RabbitMQ
当事件目标选择分布式消息服务RabbitMQ时,事件目标的type值为rabbitmq,eventTargets中的resourceKey字段中含义如下表所示。
| resourceKey | 是否必传 | form | value | template |
|---|---|---|---|---|
| instanceId | 是 |
| 分布式消息服务RabbitMQ实例ID。 说明 实例Id可在分布式消息服务RabbitMQ管理控制台-实例详情页获取。 | 无 |
| vhost | 是 |
| 无 | |
| targetType | 是 |
| 目标类型。
| 无 |
| exchange | 否,但当targetType选择exchange时必填 |
| Exchange模式。 | 无 |
| queueName | 否,但当targetType选择queue时必填 |
| Queue模式。 | 无 |
| routeKey | 否,但当targetType选择exchange时必填 |
| 消息路由规则。 | 无 |
| body | 是 |
| 消息体。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
| messageId | 是 |
| 消息Id,若为空则客户端自动生成。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
| properties | 是 |
| 消息属性。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
请求示例:
示例一:当targetType为queue时:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "rabbitmq",
"eventTargetName": "Y2o0ykK-ifaUeq1JG-IPC",
"params": [
{
"resourceKey": "instanceId",
"value": "e8c05d2c9f44xxxxxxx373c6737df98b",
"form": "CONSTANT"
},
{
"resourceKey": "vhost",
"value": "/",
"form": "CONSTANT"
},
{
"resourceKey": "targetType",
"value": "queue",
"form": "CONSTANT"
},
{
"resourceKey": "queueName",
"value": "test",
"form": "CONSTANT"
},
{
"resourceKey": "body",
"value": "",
"form": "ORIGINAL"
},
{
"resourceKey": "properties",
"value": "",
"form": "EMPTY"
},
{
"resourceKey": "messageId",
"value": "",
"form": "EMPTY"
}
]
}
]
}示例二:当targetType为exchange时:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "rabbitmq",
"eventTargetName": "Y2o0ykK-ifaUeq1JG-IPC",
"params": [
{
"resourceKey": "instanceId",
"value": "e8c05d2c9xxxxxxx373c6737df98b",
"form": "CONSTANT"
},
{
"resourceKey": "vhost",
"value": "/",
"form": "CONSTANT"
},
{
"resourceKey": "targetType",
"value": "exchange",
"form": "CONSTANT"
},
{
"resourceKey": "exchangeName",
"value": "11",
"form": "CONSTANT"
},
{
"resourceKey": "body",
"value": "",
"form": "ORIGINAL"
},
{
"resourceKey": "properties",
"value": "",
"form": "EMPTY"
},
{
"resourceKey": "messageId",
"value": "",
"form": "EMPTY"
},
{
"resourceKey": "routeKey",
"value": "$.data",
"form": "JSONPATH"
}
]
}
]
}函数计算
当事件目标选择函数计算时,事件目标的type值为faas,eventTargets中的resourceKey字段中含义如下表所示。
| resourceKey | 是否必传 | form | value | template |
|---|---|---|---|---|
| functionName | 是 |
| 函数名。 | 无 |
| functionVersion | 否,当不传functionAlias时此参数必传 |
| 函数版本。 | 无 |
| functionAlias | 否,当不传functionVersion时此参数必传 |
| 函数别名。 | 无 |
| invokeType | 是 |
| 调用方式。
| 无 |
| value | 否 |
| 函数的消息体内容。不传时默认为全部事件。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
请求示例:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "faas",
"eventTargetName": "cdBFQM0yVUw2FSaJ7EPcG",
"params": [
{
"resourceKey": "functionName",
"value": "testgo4",
"form": "CONSTANT"
},
{
"resourceKey": "functionVersion",
"value": "LATEST",
"form": "CONSTANT"
},
{
"resourceKey": "invokeType",
"value": "synchronous",
"form": "CONSTANT"
},
{
"resourceKey": "value",
"value": "",
"form": "ORIGINAL"
}
]
}
]
}云工作流
当事件目标选择云工作流时,事件目标的type值为cloudflow,eventTargets中的resourceKey字段中含义如下表所示。
| resourceKey | 是否必传 | form | value | template |
| workflowName | 是 |
| 工作流流程名。 | 无 |
| executionName | 是 |
| 工作流执行名称。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
| invokeType | 是 |
| 调用方式。
| 无 |
| executionInput | 是 |
| 云工作流输入Body。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
请求示例:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "cloudflow",
"eventTargetName": "9AzCNjDn7aS9YKbdFAQj-",
"params": [
{
"resourceKey": "workflowName",
"value": "test1",
"form": "CONSTANT"
},
{
"resourceKey": "invokeType",
"value": "synchronous",
"form": "CONSTANT"
},
{
"resourceKey": "executionName",
"value": "",
"form": "EMPTY"
},
{
"resourceKey": "executionInput",
"value": "",
"form": "EMPTY"
}
]
}
]
}HTTP/HTTPS端点
当事件目标选择HTTP/HTTPS时,事件目标的type值为http,eventTargets中的resourceKey字段中含义如下表所示。
请求示例:
| resourceKey | 是否必传 | form | value | template |
| url | 是 |
| URL地址。 | 无 |
| method | 是 |
| http请求METHOD。 | 无 |
| networkType | 是 |
| 网络类型。
| 无 |
| authType | 是 |
| 鉴权配置。
| 无 |
| username | 否,当authType为basic时必传 |
| 用户名。 | 无 |
| passwordString | 否,当authType为basic时必传 |
| 密码。 | 无 |
| vpcId | 否,当networkType为privateNetwork时必传 |
| 虚拟私有云id。 | 无 |
| subnetId | 否,当networkType为privateNetwork时必传 |
| 子网id。 | 无 |
| body | 是 |
| http请求body。 | 如果form选择TEMPLATE,则在此处配置模板。详见事件内容转换。 |
请求示例:
当网络类型为公共网络时:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "http",
"eventTargetName": "wXjvy6yMpgqmwawqG3msa",
"params": [
{
"resourceKey": "url",
"value": "http://test.***.webhook/put-event",
"form": "CONSTANT"
},
{
"resourceKey": "method",
"value": "GET",
"form": "CONSTANT"
},
{
"form": "CONSTANT",
"resourceKey": "networkType",
"value": "publicNetwork"
},
{
"form": "CONSTANT",
"resourceKey": "authType",
"value": ""
},
{
"resourceKey": "body",
"value": "",
"form": "ORIGINAL"
}
]
}
]
}当网络类型为私有网络时:
{
"eventBusName": "test",
"eventRuleName": "test",
"desc": "",
"filterPattern": "{}",
"eventTargets": [
{
"type": "http",
"eventTargetName": "yV9UTnhmc_UTTVVxlu7bl",
"params": [
{
"resourceKey": "url",
"value": "http://test.***.webhook/put-event",
"form": "CONSTANT"
},
{
"resourceKey": "method",
"value": "POST",
"form": "CONSTANT"
},
{
"form": "CONSTANT",
"resourceKey": "networkType",
"value": "publicNetwork"
},
{
"form": "CONSTANT",
"resourceKey": "authType",
"value": "basic"
},
{
"form": "CONSTANT",
"resourceKey": "username",
"value": "test"
},
{
"form": "CONSTANT",
"resourceKey": "passwordString",
"value": "test"
},
{
"resourceKey": "body",
"value": "",
"form": "ORIGINAL"
}
]
}
]
}