|
Minsky: 3.17.0
|
REST (https://en.wikipedia.org/wiki/Representational_state_transfer) is an architectural style for manipulating an object via a simple protocol such as http. In this case, the Minsky REST server instantiates a Minsky model object, and the object can be manipulated using two items: a URI and a JSON encoded set of arguments. A simple example of this is querying or setting the minsky t attribute:
There are currently two REST servers available in the RESTService branch
The leadin string /minsky on the URI introduces the global minsky model. The available attributes and methods are described in Minsky's API.
An attribute can be accessed as a getter (REST arguments is null) or a setter (REST argument contains a suitable JSON encoded value) (see previous /minsky/t example).
Methods can be called also by specifying the arguments as a json array. A single argument function cann be called with a one element JSON array, or just the JSON for the argument.
An exception to this latter rule is if the argument is a container, such as std::vector, in which case nested arrays are needed to indicate that a single sequence argument is intended ie
not
Overloaded methods are supported, with limitations. Best effort is made to resolve which method overload the JSON arguments refer to, but sometimes this is just not possible. Methods with different numbers of arguments are always resolvable.
There are a number of meta methods, introduced by the '@' sign for query types/signatures and available methods:
/minsky/@type null -> minsky::Minsky/minsky/t/@signature null -> [{"args":[],"ret":"double"},{"args":["double"],"ret":"double"}] This means that /minsky/t is an overloaded method, taking 0 or 1 argument of type double, and returning a double. All attributes have a similar sort of signature representing the getter and setter methods./minsky/variableValues/@list null -> ["/@elem","/@insert","/@size"]Container types (eg std::vector, std::map) have some additional properties, introduced by the '@' sign.
The "enumerators" of an enum can be listed using the /