CreateTargets

更新时间:
复制 MD 格式

You can call the CreateTargets operation to create one or more event targets for a rule.

URI

/openapi/createTargets

Request parameters

NameTypeRequiredExampleDescription
EventBusNameStringYesdefaultThe name of the event bus.For more information, see Limits.
RuleNameStringYesmyRule2The name of the event rule.For more information, see Limits.
TargetsList<Target>YesThe list of event targets to add. For more information, see Limits.
IdStringYestarget5The custom ID of the event target.
TypeStringYesacs.fc.functionTarget type.
EndpointStringYesacs:fc:cn-hangzhou:123456789098****:services/guide.LATEST/functions/HelloFCThe endpoint to which events are delivered.
PushRetryStrategyStringYesBACKOFF_RETRYThe retry policy for pushing events. Valid values:
  • BACKOFF_RETRY: backoff retry. The request can be retried up to three times. The interval between two consecutive retries is a random value between 10 and 20 seconds.
  • EXPONENTIAL_DECAY_RETRY: exponential decay retry. The request can be retried up to 176 times. The interval between two consecutive retries exponentially increases to 512 seconds, and the total retry time is one day. The specific retry intervals are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, ..., and 512 seconds, including a maximum of one hundred and sixty-seven 512 seconds in total.
ParamListList<Param>YesThe parameters for event delivery.
resourceKeyStringYesbodyThe resource parameter for the event transformation.For more information, see Event target parameters.
formStringYesTEMPLATEThe format of the event transformation.For more information, see Event target parameters.
valueStringYes
{\"key\"=\"value\"}
The value for the event transformation.
templateStringNoThe value of ${key} is ${value}!Template style

Response parameters

NameTypeExampleDescription
ErrorEntriesCountInt
  • 0
  • 1
The number of event targets that failed to be created. Valid values:
  • 0: All events are processed successfully.
  • Any integer other than 0 represents the number of failed events.
ErrorEntriesList
  • None
  • [
        {
            "ErrorCode":"EventRuleTargetIdDuplicate",
            "ErrorMessage":"The id of event target is duplicate! ",
            "EntryId":"target5"
        }
    ]
The body of the event that failed to be processed.
ErrorCodeStringEventRuleTargetIdDuplicateThe error code.
ErrorMessageStringThe id of event target is duplicate!The detailed error message.
EntryIdStringtarget5The 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"
    }
]
}