Data System API Events Format
This section describes common parameters for all Data System API (L2) event payloads, then payloads for specific event types.
For more on the Data System API service, see Data System APIs.
Event Format
Data Events Service adheres to the CloudEvents specification.
An example CloudEvent event for the Data System API (aka L2) follows:
{
"id" : "7be945d4-88cb-4b19-8dc9-f1dace8ff0c8",
"source" : "urn:autodesk:service:5zw90va0UuwMKTnPS5sLsdgZjDkVYXN7",
"specversion" : "1.0",
"type" : "autodesk.data.assetgraph:events.asset.created-1.0.0",
"subject" : "urn:autodesk.data.assetgraph:asset:co.2IdPqpWJTo6f4UxqSF_QMg",
"time" : "2020-03-11T17:54:07.074+00:00",
"dataschema" : "http://forge.autodesk.com/schemas/data-event-schema-v1.0.0.json",
"data" : {
"note": "data is a JSON object composed of Common Data Object fields & L2 object fields",
"commandid": "9568245c-5652-4bc5-9816-9f3aab3bbe77",
"acescopeurn": "urn:autodesk:acescope:9021923212",
"collectionurn": "urn:autodesk.data.assetgraph:collection:co.oeq8pG2JQyO-TewgIWD3FQ",
"modificationtype": "components",
"scopes": [
"urn:autodesk.data.assetgraph:space:co.5kDFyA4kRDmZH0jJO1u0FA"
]
}
}
The following table lists required fields in the CloudEvent. All fields are required unless otherwise stated.
Name | Data type | Description |
---|---|---|
id | String | Unique identifier of the event. Consumers can assume that events with identical source and ID are duplicates. |
source | URN | URN of the source of the event. Use this URN to uniquely identify the source application or service. |
specversion | String | CloudEvent specification version - must be 1.0. |
type | String | Type of the event. Prefix with a reverse-DNS name. The prefixed domain dictates the organization that defines the semantics for this event type. This field follows the Event Type ID field format: <namespace>:<eventType>-<semverVersion> |
subject | URN | Identifier of the object about which the event is reported in Entity URN format: urn:<namespace>:<type>:<ID> For example, urn:autodesk.data.assetgraph:asset:co.2IdPqpWJTo6f4UxqSF_QMg |
time | Timestamp | Timestamp for when the event occurred, in RFC3339 format. |
data | Object | Payload of the event as a JSON object. Contains the type-specific data of the event. |
The following table lists optional fields in the CloudEvent.
Name | Data type | Description |
---|---|---|
traceparent | String | Contains a version, trace ID, span ID, and trace options as defined in the W3C Distributed Trace Context Specification. |
tracestate | String | A comma-delimited list of key-value pairs, defined by W3C Distributed Trace Specification. Unified Logging trace headers would be embedded here. |
datacontenttype | String | Use this parameter when the content type of data is not application/json. |
dataschema | URI Reference | A reference to the versioned JSON schema specification of the data object in the event. |
sequence | Integer | Value expressing the relative order of the event. This enables interpretation of event supercedence. |
The following table lists common fields within the data field of all events. All fields are required unless otherwise stated.
Name | Data type | Description |
---|---|---|
scopes | Array | Optional. Array of related entity IDs, in URN format (urn:<namespace>:<type>:<ID>). Used to implement event roll-up. If provided, Data Events Service inspects subscriptions for these objects and publishes the event to subscribers of the scoped entity. NOTE: Scopes are not passed through to consumers of the event. |
customProperties | Object | Optional. A custom set of properties may be specified on each event that is published. Those custom properties can be utilized in the Event Definition Object (EDO) and passed to the permissions API call. customProperties is just a property bag of key-value pairs that have no semantic meaning beyond what is defined in the permissions API call. |
acescopeurn | URN | Optional. The ACE Scope identifier of the collection in which the event occurred, in URN format: urn:<namespace>:<type>:<ID>. For example, urn:autodesk:acescope:9021923212. |
commandid | String | Required for Data System APIs (aka L2) events, otherwise optional. The commandId (transactionId) of the event in L2 platform (a L2 command or batch-command Id) |
collectionurn | URN | Required for Data System APIs (aka L2) events, otherwise optional. The collection ID to which the event pertains, in URN format |
Versioning of Events
There are two places that version is specified – in the type field and in the dataschema field. For the type field, please see the Event Type ID documentation. For the dataschema field, see Versioning of CloudEvents.
Permissions
If the payload returned from the custom command contains resourceId or resourceIds fields, these fields are used to perform the authorization check before event delivery (as with normal commands). Otherwise, the server uses only the collectionUrn to perform the authorization check.
Event type | Permission Field(s) | Description |
---|---|---|
collection.created | data.acescopeurn | This option is currently under review |
collection.* | subject | |
space.* | subject | |
asset.* | subject | |
relationship.* | data.relationshipurn | |
snapshot.* | data.snapshoturn | |
command.* (non-collection commands) | data.collectionurn and data.resultpayload.resourceids | Must have access to all fields. data.resultpayload might be null for custom events. |
command.* (collection commands) | data.acescopeurn and and data.resultpayload.resourceids | This option is currently under review |
Defined Entity Event Types
To specify a type of event to subscribe to, you need to know the full name of the event type for that event. The table below lists all the event types for the different entities that emit events. All combinations of entity types are typically supported.
The table shows the name and version of the corresponding event. To get the full type name for use in the Subscribe API call, prefix the name in the table below with autodesk.data.assetgraph:
. For example, autodesk.data.assetgraph:events.asset.created-1.0.0
.
Entity Type |
Created |
Deleted |
Purged |
Restored |
Updated |
---|---|---|---|---|---|
Asset | events.asset.created-1.0.0 |
events.asset.deleted-1.0.0 |
events.asset.purged-1.0.0 |
events.asset.restored-1.0.0 |
events.asset.updated-1.0.0 |
Collection | events.collection.created-1.0.0 |
events.collection.deleted-1.0.0 |
events.collection.purged-1.0.0 |
events.collection.restored-1.0.0 |
events.collection.updated-1.0.0 |
Relationship | events.relationship.created-1.0.0 |
events.relationship.deleted-1.0.0 |
events.relationship.purged-1.0.0 |
events.relationship.restored-1.0.0 |
events.relationship.updated-1.0.0 |
Snapshot | events.snapshot.created-1.0.0 |
events.snapshot.deleted-1.0.0 |
events.snapshot.purged-1.0.0 |
events.snapshot.restored-1.0.0 |
events.snapshot.updated-1.0.0 |
Space | events.space.created-1.0.0 |
events.space.deleted-1.0.0 |
events.space.purged-1.0.0 |
events.space.restored-1.0.0 |
events.space.updated-1.0.0 |
Subscriptions
Consumers can subscribe to events using the scopes defined here. For all eventTypes, the collectionId and subject of the event are automatically defined. Some eventTypes offer additional scopes.
EntityType | Additional Scopes |
---|---|
Asset.* | The Space in the Asset command |
Relationship.Created | The Asset, Collection, or Snapshot of the From and To of the Relationship command |
Snapshot.* | All Assets in the Snapshot command |
Data Fields
Most non-command event types share the same field definitions. They have the Command Data Object fields listed above, in addition to the fields in the table that follows.
Field Name | Type | On Event Types | description |
---|---|---|---|
category | String | relationship.created, relationship.updated | Can be reference or relationship. |
entitytype | String | * | Fully qualified, domain-specific type of the subject of this event |
ispinned | Boolean | relationship.created | Indicates relationship is pinned if true. |
modificationtype | String | snapshot.created, snapshot.updated | One of UpdateSnapshot, AddAssets, RemoveAssets |
attributes | Array | *.updated, *.created | Optional. An array of attributes. Attributes should be complete for created events. For updated events, you only provide the changed attributes. |
components | Array | *.updated, *.created | Optional. An array of components for the subject of this event. Components indicate regular properties. Components should be complete for created events. For updated events, you only provide the changed components. |
spaceid | String | asset.* | Space GUID of the space that contains this asset |
assetIds | Array | snapshot.created, snapshot.updated | Optional. Array of asset GUIDs of the assets that is added/removed for the snapshot. |
relationshipIds | Array | snapshot.created, snapshot.updated | Optional. Array of relationship GUIDs of the assets that is added/removed for the snapshot. |
Created and Updated Event Payloads
Attributes Field
The schema for the Attributes field is different for create vs update events.
For create events it consists of an array of Data Model level AttributeRequest objects. For update events it consists of an array of Data Model level ChangeSets.
General Events
The data for all created and updated event types generally has the following schema.
{
"commandid" : <commandid>,
"acescopeurn" : <aceScopeURN>,
"collectionurn": <CollectionURN>,
"entitytype" : <EntityType>,
"attributes": [
{..}, {..}
],
"components": [
{..}, {..}
]
}
Asset Events
Asset events have an additional spaceid field.
{
"commandid" : <commandid>,
"acescopeurn" : <aceScopeURN>,
"collectionurn": <CollectionURN>,
"entitytype" : <EntityType>,
"spaceid": <SpaceId>,
"attributes": [
{..}, {..}
],
"components": [
{..}, {..}
]
}
Relationship Events
Relationship events have additional category and ispinned fields. IsPinned is not available for updates.
{
"commandid" : <commandid>,
"acescopeurn" : <aceScopeURN>,
"collectionurn": <CollectionURN>,
"entitytype" : <EntityType>,
"category": "Relationship",
"ispinned": true,
"attributes": [
{..}, {..}
],
"components": [
{..}, {..}
]
}
Snapshot Created and Updated Events
Snapshot created and updated events have the additional modificationtype field. ModificationType is one of AddAssets, RemoveAssets, or UpdateSnapshot.
"commandid" : <commandid>,
"acescopeurn" : <aceScopeURN>,
"collectionurn": <CollectionURN>,
"entitytype" : <EntityType>,
"modificationtype": <ModificationType>,
"attributes": [
{..}, {..}
],
"components": [
{..}, {..}
],
"assetIds"; ["assetId1", "assetId2"],
"relationshipIds"; ["relaionshipId1", "relationshipId2"]
}
Deleted, Purged, and Restored Event Payloads
General events for deleted,` purged`, and restored events return a payload with the following schema.
{
"commandid" : <commandid>,
"acescopeurn" : <aceScopeURN>,
"collectionurn": <CollectionURN>
}
Explicit Events
Deletion events require special consideration for events. The Data Events Service only supports explicit deletion. For example, a space.deleted event implies that all the assets in that space are marked for deletion. Forge Events does not auto-generate asset.deleted events for the (potentially huge) number of assets in the space. The same is true for collecion.deleted and spaces, and also applies to relationship.deleted events and their associated From asset. Clients might need to subscribe to higher-level parent or associated asset deletion events in order to correctly understand the lifetime of all Data Model entity types using the Data Events Service.
Command Events
This payload returns information about the resolution of a command.
EventType | Description | Subject |
---|---|---|
command.completed | A command has completed successfully | CommandGUID |
command.failed | A command has failed | CommandGUID |
Only consumers with access to collectionURN and all the resources specified in the resultPayload receive the event.
Consumers will be able to subscribe to commands using a collectionURN or the resourceUrn that is in the resultPayload.
Event Subject
The event subject (as defined by the CloudEvent Spec) can only have a single value. Commands are often often about multiple entities (for example, commands such as CopyAssetBatch). The event subject cannot be about all the entities affected by the command. The event subject is just a URN representation of the commandId.
Data Fields
The following table lists field definitions for command event types.
Field Name | Type | description |
---|---|---|
commandtype | String | Optional. Command type. For example, Create <Entity> . Not present for batch commands. To filter a subscription by commandType, you can use jsonPath filtering – for example, [$[?(@.filter='CreateSpace']] |
journalid | Long | ID of the Journal to which this command belongs |
status | String | The Data Model status of the command |
isbatch | Boolean | True if this command is a batch command. False if it is not a batch command. |
resultpayload | Object | Contains the payload of the command result. For non-custom events, it is a CommandResult. Might or might not be available for custom commands. |
CommandResult
The following table describes the fields of a type definition for the resultpayload field.
Field Name | Type |
---|---|
resourceUrns | String array |
resourceIds | String array |
revisionId | String |
resourceTypes | String array |
These are the accommodations for result payloads for custom commands.
ResultPayload Contents
The resultPayload for custom events is defined by the service that implements the command. If the payload returned from the custom command contains the resourceId(s) and resourceType(s) fields at the top level (as do non-custom commands), the resultPayload field of the event contains the full payload returned from the custom command. If it does not contain the resourceId(s) and resourceType(s) fields, then the resultPayload is empty.
Permissions
If the payload returned from the custom command contains resourceId or resourceIds fields, these fields are used to perform the authorization check before event delivery (as with normal commands). Otherwise, the server uses only the collectionUrn to perform the authorization check.
The following is a sample data field payload from the command.completed event.
{
"commandid" <CommandId>,
"commandtype": "Create<Entity>Command",
"collectionurn": <CollectionURN>,
"status": "SUCCESS",
"isbatch": false,
"resultpayload" : {
"resourceIds" : ["co.Ic6p9JSuTM-ZUl8wKTLbsw"],
"resourceUrns" : ["/collections/co.Ic6p9JSuTM-ZUl8wKTLbsw"],
"revisionId" : "TWgcZd2NV8sfPDRiUcW5uG",
"resourceTypes: ["collection"]
}
}
The following is a sample data field payload from the command.failed event.
{
"commandid" <CommandId>,
"commandtype": "Create<Entity>Command",
"collectionurn": <CollectionURN>,
"status": "NOT_PROCESSED",
"isbatch": false,
"resultpayload" : {
"resourceIds" : ["co.Ic6p9JSuTM-ZUl8wKTLbsw"],
"resourceUrns" : ["/collections/co.Ic6p9JSuTM-ZUl8wKTLbsw"],
"revisionId" : "TWgcZd2NV8sfPDRiUcW5uG",
"resourceTypes: ["collection"]
}
}
Full Event Payload Sample
The following is an example payload, including the event wrapper and the data for a command event.
{
"id": "7be945d4-88cb-4b19-8dc9-f1dace8ff0c8",
"source": "urn:autodesk:service:5zw90va0UuwMKTnPS5sLsdgZjDkVYXN7",
"specversion": "1.0",
"type": "autodesk.data.assetgraph:events.command.completed-1.0.0",
"subject": "urn:autodesk.data.assetgraph:command:LbVY2KGzMicvuFjVl2rxgz",
"time": "2020-03-11T17:54:07.074+00:00",
"dataschema": "http://forge.autodesk.com/schemas/data-event-schema-v1.0.0.json",
"data": {
"commandid": "< CommandId >",
"commandtype": "Create<Entity>Command",
"collectionurn": "< CollectionURN >",
"status": "SUCCESS",
"isbatch": false,
"resultpayload": {
"resourceIds": ["co.Ic6p9JSuTM-ZUl8wKTLbsw"],
"resourceUrns": ["/collections/co.Ic6p9JSuTM-ZUl8wKTLbsw"],
"revisionId": "TWgcZd2NV8sfPDRiUcW5uG",
"resourceTypes: ["collection"]
}
}
}