You can call the CreateTargets operation to create one or more event targets for a rule.
URI
/openapi/createTargets
Request parameters
| Name | Type | Required | Example | Description |
| EventBusName | String | Yes | default | The name of the event bus.For more information, see Limits. |
| RuleName | String | Yes | myRule2 | The name of the event rule.For more information, see Limits. |
| Targets | List<Target> | Yes | The list of event targets to add. For more information, see Limits. | |
| Id | String | Yes | target5 | The custom ID of the event target. |
| Type | String | Yes | acs.fc.function | Target type. |
| Endpoint | String | Yes | acs:fc:cn-hangzhou:123456789098****:services/guide.LATEST/functions/HelloFC | The endpoint to which events are delivered. |
| PushRetryStrategy | String | Yes | BACKOFF_RETRY | The retry policy for pushing events. Valid values:
|
| ParamList | List<Param> | Yes | The parameters for event delivery. | |
| resourceKey | String | Yes | body | The resource parameter for the event transformation.For more information, see Event target parameters. |
| form | String | Yes | TEMPLATE | The format of the event transformation.For more information, see Event target parameters. |
| value | String | Yes | | The value for the event transformation. |
| template | String | No | The value of ${key} is ${value}! | Template style |
Response parameters
| Name | Type | Example | Description |
| ErrorEntriesCount | Int |
| The number of event targets that failed to be created. Valid values:
|
| ErrorEntries | List |
| The body of the event that failed to be processed. |
| ErrorCode | String | EventRuleTargetIdDuplicate | The error code. |
| ErrorMessage | String | The id of event target is duplicate! | The detailed error message. |
| EntryId | String | target5 | The ID of the event whose body failed to be processed. |
Examples
Sample request
POST /openapi/createTargets 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****:Jo2PbTj******zYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26
{
"EventBusName":"default",
"RuleName":"myRule2",
"Targets":[
{
"Id":"target5",
"Type":"acs.fc.function",
"Endpoint":"acs:fc:cn-hangzhou:123456789098****:services/guide.LATEST/functions/HelloFC",
"PushRetryStrategy":"BACKOFF_RETRY",
"ParamList":[
{
"resourceKey":"serviceName",
"form":"CONSTANT",
"value":"guide"
},
{
"resourceKey":"functionName",
"form":"CONSTANT",
"value":"HelloFC"
},
{
"resourceKey":"body",
"form":"TEMPLATE",
"value":"{\"key\"=\"value\"}",
"template":"The value of ${key} is ${value}!"
}
]
}
]
}Sample response 1: Successful creation
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 5E9A908133324571D800****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"errorEntriesCount":0,
"errorEntries":[
]
}Response Example 2: Creation Error
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 5E9A908133324571D800****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"errorEntriesCount":1,
"errorEntries":[
{
"ErrorCode":"EventRuleTargetIdDuplicate",
"ErrorMessage":"The id of event target is duplicate! ",
"EntryId":"target5"
}
]
}该文章对您有帮助吗?