Mjsonrpc: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
This page is a placeholder for the documentation of the MIDAS JSON RPC interface.
test
test


Line 7: Line 9:
</pre>
</pre>


{| class="wikitable" border=1
<pre>
|+List of MIDAS JSON-RPC methods
------------------------------------------------------------------------
|-
Autogenerated schema for all MIDAS JSON-RPC methods
! method name  
------------------------------------------------------------------------
!colspan=3| description
cm_exist?      | calls MIDAS cm_exist() to check if given MIDAS program is running
|-
              | -------------------------------------------------------
||
              | params  | name          | string        | name of the program, corresponding to ODB /Programs/name
|-
              |          | unique?        | bool          | bUnique argument to cm_exist()
| echo
              | -------------------------------------------------------
|colspan="3"| echo the request parameters back to the caller
              | result  | status        | integer        | return status of cm_exist()
|-
------------------------------------------------------------------------
! || parameters || type || description
cm_shutdown?  | calls MIDAS cm_shutdown() to stop given MIDAS program
|-
              | -------------------------------------------------------
| || - || object || any object
              | params  | name          | string        | name of the program, corresponding to ODB /Programs/name
|-
              |         | unique?        | bool          | bUnique argument to cm_shutdown()
! || returns || type || description
              | -------------------------------------------------------
|-
              | result  | status        | integer        | return status of cm_shutdown()
| || - || object || parameters object
------------------------------------------------------------------------
|-
db_copy?      | get copies of given ODB subtrees in the "save" json encoding
||
              | -------------------------------------------------------
|-
              | params  | paths[]        | array of ODB subtree paths, see note on array indices
| null
              |         |               | array of      | string
|colspan=3| always return a null
              | -------------------------------------------------------
|-
              | result  | data[]        | copy of ODB data for each path
! || parameters || type || description
              |         |               | array of      | object  
|-
              |          | status[]      | return status of db_copy_json() for each path
| || - || anything || any object (object)
              |          |                | array of      | integer
|-
              |         | last_written[] | last_written value of the ODB subtree for each path
! || returns || type || description
              |          |                | array of      | number
|-
------------------------------------------------------------------------
| || null || null || always returns a null value
db_create?    | get copies of given ODB subtrees in the "save" json encoding
|-
              | -------------------------------------------------------
||
              | params[] | array of ODB paths to be created
|-
              |          | array of      | arguments to db_create() and db_resize()
| db_copy
              |          |                | path          | string  | ODB path
|colspan="3"| get a copy of ODB in JSON format
              |          |               | type          | integer | MIDAS TID_xxx type
|-
              |          |                | array_length?  | integer | optional array length, default is 1
! || parameters || type || description
              |          |               | string_length? | integer | for TID_STRING, optional string length, default is NAME_LENGTH
|-
              | -------------------------------------------------------
| || names || array of strings || odb paths to copy
              | result  | status[]      | return status of db_create() for each path
|-
              |         |               | array of      | integer
! || returns || type || description
------------------------------------------------------------------------
|-
db_get_values? | get values of ODB data from given subtrees
| || data || array of objects || odb data for each entry in names[]
              | -------------------------------------------------------
|-
              | params  | paths[]        | array of ODB subtree paths, see note on array indices
| || last_written || array of numbers || odb last_written for each entry in names[]
              |          |                | array of      | string
|-
              | -------------------------------------------------------
| || status || array of numbers || odb get status for each entry in names[]
              | result  | data[]        | values of ODB data for each path, all key names are in lower case, all symlinks are followed
|}
              |          |                | array of      | any   
              |          | status[]      | return status of db_copy_json() for each path
              |          |                | array of      | integer
              |          | last_written[] | last_written value of the ODB subtree for each path
              |          |                | array of      | number
------------------------------------------------------------------------
db_paste?      | write data into ODB
              | -------------------------------------------------------
              | params  | paths[]        | array of ODB subtree paths, see note on array indices
              |         |               | array of      | string
              |         | values[]      | data to be written using db_paste_json()
              |          |                | array of      | any   
              | -------------------------------------------------------
              | result  | status[]      | return status of db_paste_json() for each path
              |          |                | array of      | integer
------------------------------------------------------------------------
get_debug?    | get current value of mjsonrpc_debug
              | -------------------------------------------------------
              | params  | any           | there are no input parameters
              | -------------------------------------------------------
              | result  | integer        | current value of mjsonrpc_debug
------------------------------------------------------------------------
get_schema?    | Get the MIDAS JSON-RPC schema JSON object
              | -------------------------------------------------------
              | params  | any            | there are no input parameters
              | -------------------------------------------------------
              | result  | object        | returns the MIDAS JSON-RPC schema JSON object
------------------------------------------------------------------------
null?          | RPC method always returns null
              | -------------------------------------------------------
              | params  | any            | method parameters are ignored
              | -------------------------------------------------------
              | result  | null           | always returns null
------------------------------------------------------------------------
set_debug?    | set new value of mjsonrpc_debug
              | -------------------------------------------------------
              | params  | integer        | new value of mjsonrpc_debug
              | -------------------------------------------------------
              | result  | integer        | new value of mjsonrpc_debug
------------------------------------------------------------------------
start_program? | start MIDAS program defined in ODB /Programs/name
              | -------------------------------------------------------
              | params  | name          | string        | name of the program, corresponding to ODB /Programs/name
              | -------------------------------------------------------
              | result  | status        | integer        | return status of ss_system()
------------------------------------------------------------------------
user_example1? | example of user defined RPC method that returns up to 3 results
              | -------------------------------------------------------
              | params  | arg            | string        | example string argment
              |         | optional_arg?  | integer        | optional example integer argument
              | -------------------------------------------------------
              | result  | string        | string        | returns the value of "arg" parameter
              |          | integer        | integer        | returns the value of "optional_arg" parameter
------------------------------------------------------------------------
user_example2? | example of user defined RPC method that returns more than 3 results
              | -------------------------------------------------------
              | params  | arg            | string        | example string argment
              |         | optional_arg?  | integer        | optional example integer argument
              | -------------------------------------------------------
              | result  | string1        | string        | returns the value of "arg" parameter
              |          | string2        | string        | returns "hello"
              |          | string3        | string        | returns "world!"
              |          | value1        | integer        | returns the value of "optional_arg" parameter
              |          | value2        | number        | returns 3.14
------------------------------------------------------------------------
user_example3? | example of user defined RPC method that returns an error
              | -------------------------------------------------------
              | params  | arg            | integer        | integer value, if zero, throws a JSON-RPC error
              | -------------------------------------------------------
              | result  | status         | integer        | returns the value of "arg" parameter
</pre>

Revision as of 12:16, 11 November 2015

This page is a placeholder for the documentation of the MIDAS JSON RPC interface.

test

$ curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","id":null,"method":"db_get_values","params":{"paths":["/runinfo/run number"]}}' 'http://localhost:8080?mjsonrpc'
{"jsonrpc": "2.0","result":{"data":[324],"status":[1],"last_written":[1443570804]},"id":null}
$ 
------------------------------------------------------------------------
Autogenerated schema for all MIDAS JSON-RPC methods
------------------------------------------------------------------------
cm_exist?      | calls MIDAS cm_exist() to check if given MIDAS program is running
               | -------------------------------------------------------
               | params   | name           | string         | name of the program, corresponding to ODB /Programs/name
               |          | unique?        | bool           | bUnique argument to cm_exist()
               | -------------------------------------------------------
               | result   | status         | integer        | return status of cm_exist()
------------------------------------------------------------------------
cm_shutdown?   | calls MIDAS cm_shutdown() to stop given MIDAS program
               | -------------------------------------------------------
               | params   | name           | string         | name of the program, corresponding to ODB /Programs/name
               |          | unique?        | bool           | bUnique argument to cm_shutdown()
               | -------------------------------------------------------
               | result   | status         | integer        | return status of cm_shutdown()
------------------------------------------------------------------------
db_copy?       | get copies of given ODB subtrees in the "save" json encoding
               | -------------------------------------------------------
               | params   | paths[]        | array of ODB subtree paths, see note on array indices
               |          |                | array of       | string 
               | -------------------------------------------------------
               | result   | data[]         | copy of ODB data for each path
               |          |                | array of       | object 
               |          | status[]       | return status of db_copy_json() for each path
               |          |                | array of       | integer
               |          | last_written[] | last_written value of the ODB subtree for each path
               |          |                | array of       | number 
------------------------------------------------------------------------
db_create?     | get copies of given ODB subtrees in the "save" json encoding
               | -------------------------------------------------------
               | params[] | array of ODB paths to be created
               |          | array of       | arguments to db_create() and db_resize()
               |          |                | path           | string  | ODB path
               |          |                | type           | integer | MIDAS TID_xxx type
               |          |                | array_length?  | integer | optional array length, default is 1
               |          |                | string_length? | integer | for TID_STRING, optional string length, default is NAME_LENGTH
               | -------------------------------------------------------
               | result   | status[]       | return status of db_create() for each path
               |          |                | array of       | integer
------------------------------------------------------------------------
db_get_values? | get values of ODB data from given subtrees
               | -------------------------------------------------------
               | params   | paths[]        | array of ODB subtree paths, see note on array indices
               |          |                | array of       | string 
               | -------------------------------------------------------
               | result   | data[]         | values of ODB data for each path, all key names are in lower case, all symlinks are followed
               |          |                | array of       | any    
               |          | status[]       | return status of db_copy_json() for each path
               |          |                | array of       | integer
               |          | last_written[] | last_written value of the ODB subtree for each path
               |          |                | array of       | number 
------------------------------------------------------------------------
db_paste?      | write data into ODB
               | -------------------------------------------------------
               | params   | paths[]        | array of ODB subtree paths, see note on array indices
               |          |                | array of       | string 
               |          | values[]       | data to be written using db_paste_json()
               |          |                | array of       | any    
               | -------------------------------------------------------
               | result   | status[]       | return status of db_paste_json() for each path
               |          |                | array of       | integer
------------------------------------------------------------------------
get_debug?     | get current value of mjsonrpc_debug
               | -------------------------------------------------------
               | params   | any            | there are no input parameters
               | -------------------------------------------------------
               | result   | integer        | current value of mjsonrpc_debug
------------------------------------------------------------------------
get_schema?    | Get the MIDAS JSON-RPC schema JSON object
               | -------------------------------------------------------
               | params   | any            | there are no input parameters
               | -------------------------------------------------------
               | result   | object         | returns the MIDAS JSON-RPC schema JSON object
------------------------------------------------------------------------
null?          | RPC method always returns null
               | -------------------------------------------------------
               | params   | any            | method parameters are ignored
               | -------------------------------------------------------
               | result   | null           | always returns null
------------------------------------------------------------------------
set_debug?     | set new value of mjsonrpc_debug
               | -------------------------------------------------------
               | params   | integer        | new value of mjsonrpc_debug
               | -------------------------------------------------------
               | result   | integer        | new value of mjsonrpc_debug
------------------------------------------------------------------------
start_program? | start MIDAS program defined in ODB /Programs/name
               | -------------------------------------------------------
               | params   | name           | string         | name of the program, corresponding to ODB /Programs/name
               | -------------------------------------------------------
               | result   | status         | integer        | return status of ss_system()
------------------------------------------------------------------------
user_example1? | example of user defined RPC method that returns up to 3 results
               | -------------------------------------------------------
               | params   | arg            | string         | example string argment
               |          | optional_arg?  | integer        | optional example integer argument
               | -------------------------------------------------------
               | result   | string         | string         | returns the value of "arg" parameter
               |          | integer        | integer        | returns the value of "optional_arg" parameter
------------------------------------------------------------------------
user_example2? | example of user defined RPC method that returns more than 3 results
               | -------------------------------------------------------
               | params   | arg            | string         | example string argment
               |          | optional_arg?  | integer        | optional example integer argument
               | -------------------------------------------------------
               | result   | string1        | string         | returns the value of "arg" parameter
               |          | string2        | string         | returns "hello"
               |          | string3        | string         | returns "world!"
               |          | value1         | integer        | returns the value of "optional_arg" parameter
               |          | value2         | number         | returns 3.14
------------------------------------------------------------------------
user_example3? | example of user defined RPC method that returns an error
               | -------------------------------------------------------
               | params   | arg            | integer        | integer value, if zero, throws a JSON-RPC error
               | -------------------------------------------------------
               | result   | status         | integer        | returns the value of "arg" parameter