EMI-RPC API Overview

September 8th, 2009 Leave a comment Go to comments

EMI-RPC (EmbedOne Management Interface – Remote Procedure Call) is a lightweight remote procedure call protocol that is used for communicate between EMI Client and EMI Server. EMI Server provides features for managing system configuration, retrieving statistics, and controlling system applications and utilities. EMI Client is used to perform system management features offered by EMI Server.

EMI-RPC is heavily inspired by the JSON-RPC concept but implements a much more defined and restrictive communication protocol, suitable especially for embedded applications. The EMI-RPC communication protocol is implemented on top of HTTP and all entities of the protocol are JSON objects.

EMI-RPC REQUEST

Requests are sent in the following form:

{
   "EMI-RPC": <version>,
   "id": <id>,
   "method": <method>,
   "params": [params]
}
Key Meaning Type Required
version Version of the EMI-RPC protocol. This key must be set to “1.0”. JSON string Required
id Request id. Id can be used to match request to response in case multiple requests and responses are sent simultaneously. Id must be unique for the client sending the request and always > 0. Any request with id 0 will result an error EBADPARAM. JSON int Required
method EMI-RPC method name. Please refer to EmbedOne Linux EMI-RPC Methods Reference for details about the methods supported by EmbedOne Linux. JSON string Required
params EMI-RPC method specific parameters. Please refer to EmbedOne Linux EMI-RPC Methods Reference for details about the methods supported by EmbedOne Linux. JSON object Optional

EMI-RPC RESPONSE

Response to a request will come in the following form:

{
   "EMI-RPC": <version>,
   “id": <id>,
   "result": [result],
   "error": [error]
}
Key Meaning Type Required
version Version of the EMI-RPC protocol. This key is always “1.0”. JSON string Required
id Id of the response. Response id is the same as the respective request id. If id field was not present in the original request, or it was not parsed correctly, the resulting response will have id of 0. Value 0 in id field has a special meaning (=missing) and could only be used by EMI Server for reporting an error. Any request with id set to 0 will return an error EBADPARAM. JSON int Required
result Request specific result. Please refer to EmbedOne Linux EMI-RPC Methods Reference for details about the results. JSON object Optional
error Error object. Error object has an extensible structure. It carries a main error code, error message, and also optionally more detailed error information encoded in the data field. Please refer to EMI-RPC Error Codes for more information. JSON object Optional

Both error and result fields are optional. If none of the fields are present in the response it means that the method was executed successfully and there is nothing to report.

EMI-RPC Communication Example

EMI Client sends request to EMI Server:

{
   "EMI-RPC": "1.0",
   "id": 1,
   "method": "emi.sys.version"
}

EMI Server sends response to EMI Client:

{
   "EMI-RPC": "1.0",
   "id": 1,
   "result": {"version":"1.0"}
}
  1. No comments yet.
  1. No trackbacks yet.