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,
messageType
anddata
.messageType
is an enum, and the following values are allowed:RESOURCE_REQUEST
,AUTHENTICATION_REQUEST
andAUTHENTICATION_DATA
.-
If
messageType
isRESOURCE_REQUEST
, the message is a request to one of the resources that are accessible via HTTP under/resources
.data
must be an object with these keys:method
: The request method to the resource; allowed values areGET
,POST
,PUT
,PATCH
andDELETE
.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, world
console command:{ "messageType": "RESOURCE_REQUEST", "data": { "method": "POST", "resourcePath": ["console"], "data": "say hello, world" } }
-
If
messageType
isAUTHENTICATION_REQUEST
, nodata
must 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
messageType
set toAUTHENTICATION_DATA
must 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 thedata
key 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
,resourcePath
anddata
. The possible values ofresourcePath
areACTION_RESULT
,RESOURCE_CHANGED
andRESOURCE_EVENT
.-
If
messageType
isACTION_RESULT
, the server is either sending the authentication handshake hello or the response to a client request. In both cases,data
is 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
: ifstatus
is 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 theresourcePath
key is set to the path of the resource which is answering the request, in the array format (as described above).
-
If
messageType
isRESOURCE_CHANGED
, the server is notifying the client that the data in a resource has changed.resourcePath
is set to the path of the resource which has changed, anddata
contains its new value, the same that could be obtained by performing a GET request to the resource. -
If
messageType
isRESOURCE_EVENT
, the server is notified that a resource has emitted an event. As before,resourcePath
is set to the path of the resource which has generated the event.data
carries 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
,ERROR
orNOTIFICATION
) 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 /events
endpoint (which also drains the queue - see the specification for more detail).
-