FacadeServer exposes access to the various resources both with an HTTP REST API and over WebSocket.
The API specification is defined in the OpenAPI 3.0 format, and is contained in the swagger.json file at the root of this repository.
You can view it in a browser at this link.
All the information necessary to interact with FacadeServer over HTTP is explained in the previously mentioned specification;
the base path for the HTTP API is /api, so to request, for example, the server Message Of The Day, you need to do a GET /api/resources/config/MOTD.
The WebSocket protocol allows to access the same resources provided over HTTP, with the plus of supporting push notifications.
WebSocket connections are accepted at the /ws endpoint.
It is defined as follows:
- A message sent from the client to the server is a JSON object with two keys,
messageTypeanddata.messageTypeis an enum, and the following values are allowed:RESOURCE_REQUEST,AUTHENTICATION_REQUESTandAUTHENTICATION_DATA.-
If
messageTypeisRESOURCE_REQUEST, the message is a request to one of the resources that are accessible via HTTP under/resources.datamust be an object with these keys:method: The request method to the resource; allowed values areGET,POST,PUT,PATCHandDELETE.resourcePath: The path to the resource to request, as a JSON array. For example, setting it to["games", "myGame"]points the request to the same resource which can be accessed via HTTP at/api/resources/games/myGame.data(optional): The request payload data. Usually, must not be sent with GET requests; refer to the specification for detailed information.
Here is an example message to request the execution of the
say hello, worldconsole command:{ "messageType": "RESOURCE_REQUEST", "data": { "method": "POST", "resourcePath": ["console"], "data": "say hello, world" } } -
If
messageTypeisAUTHENTICATION_REQUEST, nodatamust be specified. With the{"messageType": "AUTHENTICATION_REQUEST"}message, the client indicates to the server that it no longer wants to send requests anonymously, and wants to initiate an authentication handshake. The server will then answer with a server handshake hello message (see below for more details). -
A message with
messageTypeset toAUTHENTICATION_DATAmust be sent by the client after it has received the server handshake hello message and has generated the authentication data using the said message and the client identity certificate. For more detail on how to generate the authentication data, which must be sent as thedatakey to finish the authentication handshake, please consult the "POST /auth" section of the API specification.
-
- A message sent from the server to the client is a JSON object with the keys
messageType,resourcePathanddata. The possible values ofresourcePathareACTION_RESULT,RESOURCE_CHANGEDandRESOURCE_EVENT.-
If
messageTypeisACTION_RESULT, the server is either sending the authentication handshake hello or the response to a client request. In both cases,datais an object with the following keys:status: enum which carries information about the response status, like HTTP response status codes. Possible values areOK,BAD_REQUEST,FORBIDDEN,ACTION_NOT_ALLOWED,NOT_FOUND,GENERIC_ERROR,CONFLICT;message: ifstatusis notOK, contains an optional error message;data: contains the response data, if any, or the authentication handshake data. In the second case only (the message is a response to a request), in the root object theresourcePathkey is set to the path of the resource which is answering the request, in the array format (as described above).
-
If
messageTypeisRESOURCE_CHANGED, the server is notifying the client that the data in a resource has changed.resourcePathis set to the path of the resource which has changed, anddatacontains its new value, the same that could be obtained by performing a GET request to the resource. -
If
messageTypeisRESOURCE_EVENT, the server is notified that a resource has emitted an event. As before,resourcePathis set to the path of the resource which has generated the event.datacarries the serialized event data. At the moment, the only resource which emits events is the console, and a console event is an object with themessageType(can beCONSOLE,CHAT,ERRORorNOTIFICATION) andmessage(the actual message text) keys.Via HTTP, events for a client are put in a queue on the server and accessible at the
GET /eventsendpoint (which also drains the queue - see the specification for more detail).
-