Warning
This documentation is only intended for private beta users.
Event Filtering
When you subscribe to a data event, you can specify a subscription filter that limits the events you eventually receive based on the filter definition. The filter is passed as JSON in the subscribe REST API request payload. The filter allows you to specify what portions of the event payload you want to constrain, as well as the values that you want to limit – for example, specifying certain event types and certain event sources limits the events to only those event types, and only from those specified sources.
Asset Graph publishes events as described in the above Event Types section. To select a JSON element within the event payload, you can leverage JsonPath. Some example paths using JsonPath are:
$[?(@.type=='autodesk.data.assetgraph:events.collection.updated-1.0.0')]
$[?(@.source=='urn:autodesk:service:0hg0AgFYdTDOrfF1IlJlQoXA6nU0raiN')]
$.data.attributes[?(@.name== 'attributeA')]
Filters are specified as an array of JsonPath items as follows:
[
"filterJsonPath1",
"filterJsonPath2"
]
Examples
Given this example event payload:
{
"type":"autodesk.data.assetgraph:events.collection.updated-1.0.0",
"source":"urn:autodesk:service:0hg0AgFYdTDOrfF1IlJlQoXA6nU0raiN",
"specversion":"1.0",
"subject":"urn:autodesk.data.assetgraph:collection:co.oeq8pG2JQyO-TewgIWD3FQ",
"time":"2020-09-15T22:59:16Z",
"data":{
"commandid":"9568245c-5652-4bc5-9816-9f3aab3bbe77",
"acescopeurn":"urn:autodesk:acescope:9021923212",
"scopes":[
],
"collectionurn":"urn:autodesk.data.assetgraph:collection:co.oeq8pG2JQyO-TewgIWD3FQ",
"modificationtype":"attributes",
"attributes":[
{
"name":"attributeA",
"value":"myValueForAttributeA",
"type":"String",
"category":"system"
}
]
}
}
…you can describe some filters.
To select that you want only collection created events, you can specify a filter like this:
[
"$[?(@.type=='autodesk.data.assetgraph:events.collection.updated-1.0.0')]"
]
To select that you want only “attributes” modification types, you can specify a filter like this:
[
"$[?(@.data.modificationtype=='attributes')]"
]
To select that you want only events that contain an attribute with the name “attributeA”, you can specify a filter like this:
[
"$.data.attributes[?(@.name== 'attributeA')]"
]
For more on the Asset Graph service, see Data System APIs.