Event Management – Event Operations¶
Creating a Standard Event¶
Create a standard event: HTTP POST /events
{
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"code" : "123",
"description" : "Error happened in the engine",
"severity" : 5,
"source" : "eventSource",
"acknowledged" : false
}
The response shows the content and link to the created event:
{
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "com.siemens.mindsphere.eventmgmt.event.type.MindSphereStandardEvent",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 1,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"severity" : 5,
"code" : "123",
"acknowledged" : false,
"description" : "Error happened in the engine",
"source" : "eventSource"
}
Creating a Custom Event¶
Create a custom event:
- All the required fields from custom EventType and its parent eventTypes in the hierarchy should be included in the event payload when creating a custom event.
- Suppose that a child EventType with the id 'c3d6749a-c9e4-11e7-abc4-cec278b6b50a' is created from a parent EventType that has a required field as 'additionalFieldParent'. The 'additionalFieldParent' must be included in the event payload when creating an event for a child EventType.
HTTP POST /events
{
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"typeId" : "c3d6749a-c9e4-11e7-abc4-cec278b6b50a",
"additionalFieldChild" : "additionalFieldChildValue",
"additionalFieldParent" : "additionalFieldParentalue"
}
The response shows the content and link to the created event:
{
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "c3d6749a-c9e4-11e7-abc4-cec278b6b50a",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 1,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"additionalFieldChild" : "additionalFieldChildValue",
"additionalFieldParent" : "additionalFieldParentalue"
}
Creating Multiple Events¶
Run a job which creates two events:
HTTP POST /createEventsJobs
{
"events" : [ {
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T12:17:48.454Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"typeId" : "c3d6749a-c9e4-11e7-abc4-cec278b6b50a"
}, {
"correlationId" : "97b33fb8-c536-11e7-abc4-cec278b6b99x",
"timestamp" : "2018-07-29T12:17:48.454Z",
"entityId" : "pp9973c4-bd67-11e7-abc4-cec278b6po77",
"typeId" : "x9x9949a-c9e4-11e7-abc4-cec278b6x99x"
} ]
}
The response shows the ID and the state of the request:
{
"id" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"state" : "ACCEPTED"
}
The state of the job created above can be checked by the following request:
HTTP GET /createEventsJobs/cd5f73c4-bd67-11e7-abc4-cec278b6b50b
The response shows the current state of the job:
{
"id" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"state" : "FINISHED_WITH_ERROR",
"details" : {
"resultDescription" : [ {
"event" : {
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T12:17:48.454Z",
"typeId" : "c3d6749a-c9e4-11e7-abc4-cec278b6b50a",
"customStringField" : "customValue"
},
"resultCode" : "400",
"errorMessage" : "Missing entity id"
}, {
"event" : {
"customStringField" : "CustomStringValue",
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"typeId" : "c3d6749a-c9e4-11e7-abc4-cec278b6b50a",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 0,
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T12:17:48.454Z"
},
"resultCode" : "201"
} ]
}
}
Reading a Standard Event¶
Request an event by ID:
HTTP GET /events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a
The response shows the content and link to the requested event:
{
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "com.siemens.mindsphere.eventmgmt.event.type.MindSphereStandardEvent",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 1,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"severity" : 5,
"code" : "123",
"acknowledged" : false,
"description" : "Error happened in the engine",
"source" : "eventSource"
}
Reading a Custom Event¶
Request an event by ID:
HTTP GET /events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a
The response shows the content and link to the requested event:
{
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "c3d6749a-c9e4-11e7-abc4-cec278b6b50a",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 1,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"additionalField" : "additionalFieldValue"
}
Listing Standard Events¶
List standard events sorted in descending
order by the timestamp
of their history
field:
HTTP GET /events?page=0&size=20&sort=timestamp%2Cdesc&history=true
The response shows the list of events according to provided filter information:
{
"_embedded" : {
"events" : [ {
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "com.siemens.mindsphere.eventmgmt.event.type.MindSphereStandardEvent",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 1,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"severity" : 5,
"code" : "123",
"acknowledged" : false,
"description" : "Error happened in the engine",
"source" : "eventSource"
}, {
"id" : "xy5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "com.siemens.mindsphere.eventmgmt.event.type.MindSphereStandardEvent",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-28T06:09:29.745Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 1,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/xy5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"severity" : 3,
"code" : "123",
"acknowledged" : false,
"description" : "Error happened in the engine",
"source" : "eventSource"
} ]
},
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events?history=true{&filter}",
"templated" : true
}
},
"page" : {
"size" : 20,
"totalElements" : 2,
"totalPages" : 1,
"number" : 0
}
}
Listing Custom Events¶
List custom events sorted in descending
order by the timestamp
of their history
field:
HTTP GET /events?filter=%7B%22typeId%22%3A%22dud6749a-c9e4-11e7-abc4-cec278b6b50a%22%7D&page=0&size=20&sort=timestamp%2Cdesc&history=true
The response shows the list of events according to provided filter information:
{
"_embedded" : {
"events" : [ {
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "dud6749a-c9e4-11e7-abc4-cec278b6b50a",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 1,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"additionalField" : "additionalFieldValue"
}, {
"id" : "zu5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "dud6749a-c9e4-11e7-abc4-cec278b6b50a",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-28T06:09:29.745Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 2,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/zu5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"additionalField" : "additionalFieldValue"
} ]
},
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events?filter=%7B%22typeId%22:%22dud6749a-c9e4-11e7-abc4-cec278b6b50a%22%7D&history=true"
}
},
"page" : {
"size" : 20,
"totalElements" : 2,
"totalPages" : 1,
"number" : 0
}
}
Updating an Event¶
Update an event by ID:
HTTP PUT /events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a
{
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "ef5f73c4-bd67-11e7-abc4-cec278b6b50b",
"description" : "Error happened in the engine"
}
The response shows the content and link to the updated event:
{
"id" : "ab5f73c4-bd67-11e7-abc4-cec278b6b50a",
"typeId" : "com.siemens.mindsphere.eventmgmt.event.type.MindSphereStandardEvent",
"correlationId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50a",
"timestamp" : "2018-07-29T06:09:29.743Z",
"entityId" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"etag" : 2,
"_links" : {
"self" : {
"href" : "https://eventmanagement.advanced.mindsphere.io/events/ab5f73c4-bd67-11e7-abc4-cec278b6b50a"
}
},
"severity" : 5,
"code" : "123",
"acknowledged" : false,
"description" : "Error happened in the engine",
"source" : "eventSource"
}
Deleting Events¶
Delete events by filter:
HTTP POST /deleteEventsJobs
{
"filter" : {
"typeId" : "anyTypeId"
}
}
The response shows the ID and the state of the request:
{
"id" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"state" : "ACCEPTED"
}
The status of the job created above can be checked by the following request:
HTTP GET /deleteEventsJobs/cd5f73c4-bd67-11e7-abc4-cec278b6b50b
The response shows the current state of the job:
{
"id" : "cd5f73c4-bd67-11e7-abc4-cec278b6b50b",
"state" : "IN_PROGRESS"
}
This response shows a successfully finished delete:
{
"id": "a3a35ea8-5893-4aac-af98-8fac29148386",
"state": "FINISHED",
"details": {
"resultCode": "200",
"resultDescription": "1 events deleted."
}
}
Sharing of events¶
Events can be shared between collaborating tenants. Events are associated with assets and events are shared implicitly if the corresponding asset is shared, i.e, a sharer tenant needs to share with the asset with receiver tenant to share the events with receiver tenant. The receiver tenant is only allowed to read the events. Param "includeShared" is needed to query shared events.
HTTP GET /events?includeShared=true