Websocket API Documentation (Event)
Connecting To The Websocket
The following URL can be used to connect to the websocket event API:
Security
By default the Event API websocket will be restricted via HTTP Realm Auth and ACLs. The default credentials will be set to manager:manag3rpa55word, and the ACLs will be set up to only allow connections from localhost. You can also secure the connection further with SSL encryption. See Security for more information.
JSON
All messages sent to or from the Event API websocket must be in JSON format. Each event will contain a set of properties providing details of the event. Each event documentation page will specify the JSON representation, and properties, of the event.
Below is an example of an event that will be generated, when a user logs into the client interface:
"coreServerId": "e5c01703-3c6d-429a-8712-66c826064e65",
"port": 57042,
"ip": "127.0.0.1",
"time": 1436889915953,
"type": "userLogin",
"userId": "e7577c7b-5d58-46a5-a834-386f52401c19",
"userLoginId": "0c51236d-5f93-4379-8997-8a840a511497",
"username": "mike"
}
Base Event Properties
Every event will contain the following two properties:
- type : Describes the type of event.
- time : Specifies the date/time the event was generated. Represented as a unix timestamp, in milliseconds.
Object IDs
Most events generated by the event API will contain UUIDs that can be used to identify objects the event relates to. Some events will reference multiple ids. These UUIDs are the same ids that are used to reference resources in the Live REST API, allowing collaboration between the Live REST API and the Event API.
Event Filtering
The Event API allows connections to specify which events they want to receive from the websocket, by specifying property filters.
The Filter Message
A message, with the following format, can be sent to the websocket, in order to set the current filters for the connection.
"type" : "filter",
"filters" : [
{"property" : "<property name>" : "value" : "<filter value>"},
{"property" : "<property name>" : "value" : "<filter value>"},
...
]
}
Where <property name> is the name of the property to filter, and <filter value> is the property value to filter on. Multiple property filters can be specified.
Filter Message Response
When a filter message is sent, the websocket will respond with one of the following messages:
Success Message
Returned when the filter was properly applied.
"correlationId": null,
"time": 1436889163971,
"type": "success"
}
Error Message
Returned when an error occurred while processing the filter message.
"correlationId": null,
"error": "<error message>",
"time": 1436889377766,
"type": "error"
}
The error property will contain the details of the error that occurred.
Correlation ID
You can specify a correlation id in the filter message, in order to tie the filter message to the generated response message. The correlation id is optional, and can be any unique string. Randomly generated numbers, or UUIDs, are a good choice for correlation ids.
"type" : "filter",
"correlationId" : "123456",
"filters" : [
{"property" : "type" : "value" : "dial"}
]
}
The filter message above will respond with the following message:
"correlationId": "123456",
"time": 1436889163971,
"type": "success"
}
Wildcard
If you specify a value of "*" for a filter property value, the property filter will match on any value of the property. This can be used to specify that you wish to receive events that contain a specific property, but the value of the property does not matter.
Examples
The following filter will only allow events of type dial:
"type" : "filter",
"filters" : [
{"property" : "type" : "value" : "dial"}
]
}
The following filter will only allow events of type userLogin and userLogout:
"type" : "filter",
"filters" : [
{"property" : "type" : "value" : "userLogin"},
{"property" : "type" : "value" : "userLogout"}
]
}
The following filter will only allow events of type userLogin and userLogout, on a user with username mike.
"type" : "filter",
"filters" : [
{"property" : "type" : "value" : "userLogin"},
{"property" : "type" : "value" : "userLogout"},
{"property" : "username" : "value" : "mike"}
]
}
The following filter will only allow events that reference a user (i.e. contains the username property):
"type" : "filter",
"filters" : [
{"property" : "username" : "value" : "*"}
]
}
REST Resources
The Live API exposes several REST resources, that allow access to the current state of specific objects in the system. All current live resources are listed below. Details concerning each resource, and their actions, can be found within the individual resource documentation pages.
Resource List
Notes on Resource Documentation
Due to the interdependent nature of resources in the system, the resource path information in the documentation is split into several sections. Paths in a specific section may relate to, or require, paths specified in other sections.
- Root Resource Paths : Specifies paths that can be used to access sets (multiple instances) of a resource, in relation to a parent resource.
- Instance Resource Paths : Specifies paths that can be used to access a specific instance of a resource. These paths require a Root Resource Path, in most cases, but not all.
- Sub Resource Paths : Specifies paths that provide access to the child resources, of a specific resource instance. These paths require an Instance Resource Path.
- Action Paths: Specifies paths that are used to perform actions on a specific resource instance. These paths require an Instance Resource Path.