description |
---|
This page provides the technical details of the Cloud Events policy |
You can use the cloud-events
policy to create a cloud-events JSON
object from messages. The datacontenttype
will be set accordingly to the message Content-type
if any.
This policy relies on the specification https://cloudevents.io and uses https://github.com/cloudevents/sdk-java library.
In APIM, you need to provide the cloud-events information in the policy configuration.
Functional and implementation information for the cloud-events
policy is organized into the following sections:
{% hint style="warning" %} This policy can be applied to v4 message APIs. It cannot be applied to v2 APIs or v4 proxy APIs. {% endhint %}
{% tabs %} {% tab title="Message API example" %} Sample policy configuration:
{
"cloud-events": {
"type": "demo-events",
"id": "{#message.metadata['key']}",
"source": "kafka://{#message.metadata['topic']}/{#message.metadata['partition']}/{#message.metadata['offset']}"
}
}
{% endtab %} {% endtabs %}
The phases checked below are supported by the cloud-events
policy:
v2 Phases | Compatible? | v4 Phases | Compatible? |
---|---|---|---|
onRequest | false | onRequest | false |
onResponse | false | onResponse | false |
onRequestContent | false | onMessageRequest | true |
onResponseContent | false | onMessageResponse | true |
You can configure the cloud-events
policy with the following options:
Property | Required | Description | Type | Default |
---|---|---|---|---|
id | true | The id of the cloud-events object. See here. Can contain EL. | string | |
type | true | The type of the cloud-events object. See here. Can contain EL. | string | |
source | true | The source of the cloud-events object. See here. Can contain EL. | string | |
subject | false | The subject of the cloud-events object. See here. Can contain EL. | string |
Code | Error template key | Description |
---|---|---|
500 | CLOUD_EVENTS_TRANSFORMATION_ERROR | Unable to create cloud-events object |