File: idlmapping.html

package info (click to toggle)
raritan-json-rpc-sdk 3.6.1%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 41,748 kB
  • sloc: cs: 162,629; perl: 85,818; python: 24,275; javascript: 5,937; makefile: 21
file content (154 lines) | stat: -rw-r--r-- 14,262 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Raritan PX2/PX3 JSON-RPC API: Rules and Mechanism for Mapping PX2/EMX-IDL to JSON-RPC</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Raritan PX2/PX3 JSON-RPC API
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Rules and Mechanism for Mapping PX2/EMX-IDL to JSON-RPC </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2>Scope</h2>
<p>PX2/EMX devices provide a remote interface. The interface is a <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> architecture and utilizes <a href="http://json-rpc.org/">JSON-RPC version 2.0</a> for formatting messages sent to and received from the device. This document defines how formal PX2/EMX-IDL is mapped to JSON-RPC.</p>
<h2>Mapping Rules</h2>
<h3>Type Mapping</h3>
<p>IDL types are mapped to <a href="http://www.json.org">JSON</a> value types as follows:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">IDL Type  </th><th class="markdownTableHeadNone">JSON Representation   </th></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone">boolean  </td><td class="markdownTableBodyNone"><code>true</code> or <code>false</code>   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone">int  </td><td class="markdownTableBodyNone">number   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone">long  </td><td class="markdownTableBodyNone">number   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone">float  </td><td class="markdownTableBodyNone">number   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone">double  </td><td class="markdownTableBodyNone">number   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone">string  </td><td class="markdownTableBodyNone">string   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone">time  </td><td class="markdownTableBodyNone">number containing number of seconds since the start of the Unix epoch (midnight UTC of January 1, 1970)   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone">enumeration  </td><td class="markdownTableBodyNone">number representing the index of the enumeration value (0-based)   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone">structure  </td><td class="markdownTableBodyNone">object containing one element per structure member   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone">vector  </td><td class="markdownTableBodyNone">array   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowOdd">
<td class="markdownTableBodyNone">map  </td><td class="markdownTableBodyNone">array of objects, each containing two elements: 'key' for the entry's key, 'value' for the entry's value.   </td></tr>
<tr class="markdownTableBody" class="markdownTableRowEven">
<td class="markdownTableBodyNone">interface  </td><td class="markdownTableBodyNone">object containing two elements: 'rid' contains the object identifier, 'type' contains the most derived interface type   </td></tr>
</table>
<h3>Interface version Mapping</h3>
<p>Interface versions as specified in IDL-File (e.g. <code>NumericSensor_1_0_1</code>) are not mapped to the protocol as such as interface identifiers are not directly part of any protocol message. However, the interface version is part of the type information which is sent along with object references. Clients may use type information and hence version information to select a compatible proxy for a received object reference.</p>
<p>Interface changes between firmware releases are documented in the file <a href="Changelog.txt">Changelog.txt</a>.</p>
<h3>Method Mapping</h3>
<p>IDL method calls are mapped to JSON-RPC as follows:</p>
<p>In JSON-RPC Request:</p>
<ul>
<li>method name: element 'method' of request object</li>
<li>in-parameters: element 'params' of request object, containing an object with one element per parameter</li>
<li>out-parameters: not mapped</li>
<li>return value: not mapped</li>
</ul>
<p>Example (net.Net.setNetworkConfigLan): </p><div class="fragment"><div class="line">{</div><div class="line">    &quot;jsonrpc&quot;: &quot;2.0&quot;,</div><div class="line">    &quot;method&quot;: &quot;setNetworkConfigLan&quot;,</div><div class="line">    &quot;params&quot;: {</div><div class="line">        &quot;speed&quot;: 2,</div><div class="line">        &quot;duplex&quot;: 0,</div><div class="line">    },</div><div class="line">    &quot;id&quot;: 123</div><div class="line">}</div></div><!-- fragment --><p>In JSON-RPC Response:</p>
<ul>
<li>method name: not mapped</li>
<li>in-parameters: not mapped</li>
<li>out-parameters: element 'result' of response object, containing an object with one element per parameter</li>
<li>return value: special element'<em>ret</em>' of element 'result' of response object</li>
<li>system errors or exceptions: element 'error' of response object</li>
</ul>
<p>Example (result from devsettings.Snmp.getConfiguration): </p><div class="fragment"><div class="line">{</div><div class="line">    &quot;jsonrpc&quot;: &quot;2.0&quot;,</div><div class="line">    &quot;result&quot;: {</div><div class="line">        &quot;v2enable&quot;: true,</div><div class="line">        &quot;v3enable&quot;: false,</div><div class="line">        &quot;readComm&quot;: &quot;public&quot;,</div><div class="line">        &quot;writeComm&quot;: &quot;&quot;,</div><div class="line">        &quot;sysContact&quot;: &quot;&quot;,</div><div class="line">        &quot;sysName&quot;: &quot;&quot;,</div><div class="line">        &quot;sysLocation&quot;: &quot;&quot;</div><div class="line">    },</div><div class="line">    &quot;id&quot;: 456</div><div class="line">}</div></div><!-- fragment --><h2>Call Execution</h2>
<p>PX2/EMX-JSON-RPC uses HTTP-POST or HTTPS-POST requests. The JSON-RPC request is put into POST data, the JSON-RPC response is delivered in the HTTP/HTTPS response.</p>
<p>The HTTP URL includes an object reference which uniquely identifies a resource that implements a particular IDL interface. There are well-known references that must be used in initial requests. All well-known object references are defined in the file <a href="Well-Known-URIs.txt">Well-Known-URIs.txt</a>.</p>
<p>JSON-RPC responses may contain references to other objects. References returned by the device are "opaque", they do not use the well-known name. The 'rid' element of those opaque references must be used as URI in requests directed to the referenced resource.</p>
<h2>Authentication</h2>
<p>All RPC calls must be authenticated with valid user credentials. PX2/EMX supports two methods for passing those credentials:</p>
<ul>
<li>HTTP Basic Authentication</li>
<li>Raritan RPC Session Authentication</li>
</ul>
<h3>Basic Authentication</h3>
<p>For HTTP basic authentication the user name and password must be included in the <code>Authorization</code> header of every HTTP request. The contents of the header line must be the keyword <code>Basic</code> followed by a base64-encoded string containing the user name and password, separated by a colon. For instance, to authenticate a request with the default login admin/raritan the following header must be sent:</p>
<div class="fragment"><div class="line">Authorization: Basic YWRtaW46cmFyaXRhbg==</div></div><!-- fragment --><h3>Session Authentication</h3>
<p>For Session-based authentication the client contacts the session manager at <code>/session</code> to open a new session. The initial <code>newSession</code> request must be sent with basic authentication. The server generates a 128-bit session token and sends it to the client. Subsequent requests can be authenticated by including a <code>X-SessionToken</code> HTTP header with the secret session token:</p>
<div class="fragment"><div class="line">X-SessionToken: 9e520dc84533342cd034b49550969e7f</div></div><!-- fragment --><p>The session token remains valid until the session expires or is closed. A session expires 30 seconds after the last request.</p>
<ul>
<li>see: <a class="el" href="interfacesession_1_1SessionManager__2__0__0.html" title="Session manager interface ">session.SessionManager_2_0_0</a></li>
</ul>
<h2>Bulk RPC</h2>
<p>For complex client programs which perform a great number of requests it is not feasible to send a separate HTTP request for every JSON-RPC method call. There is a significant performance overhead, particularly when using HTTPS. To reduce that overhead it is possible to combine multiple JSON-RPC requests into a single HTTP request using the BulkRequest interface at <code>/bulk</code>.</p>
<p>A bulk request is performed by calling the performBulk method with a vector of resource IDs and JSON-RPC request objectss. The method returns a list of HTTP status codes and JSON-RPC response objects.</p>
<p>Example (sent to <a href="https://my-device/bulk">https://my-device/bulk</a>): </p><div class="fragment"><div class="line">{</div><div class="line">    &quot;jsonrpc&quot;: &quot;2.0&quot;,</div><div class="line">    &quot;method&quot;: &quot;performBulk&quot;,</div><div class="line">    &quot;params&quot;: {</div><div class="line">        &quot;requests&quot;: [</div><div class="line">            // First request: Firmware::getVersion()</div><div class="line">            { &quot;rid&quot;: &quot;/firmware&quot;,</div><div class="line">              &quot;json&quot;: { &quot;jsonrpc&quot;: &quot;2.0&quot;, &quot;method&quot;: &quot;getVersion&quot;, &quot;params&quot;: {}, &quot;id&quot;: 1 } },</div><div class="line">            // Second request: EventLog::clear()</div><div class="line">            { &quot;rid&quot;: &quot;/eventlog&quot;,</div><div class="line">              &quot;json&quot;: { &quot;jsonrpc&quot;: &quot;2.0&quot;, &quot;method&quot;: &quot;clear&quot;, &quot;params&quot;: {}, &quot;id&quot;: 2 } }</div><div class="line">        ]</div><div class="line">    },</div><div class="line">    &quot;id&quot;: 123</div><div class="line">}</div></div><!-- fragment --><p>Response: </p><div class="fragment"><div class="line">{</div><div class="line">    &quot;jsonrpc&quot;: &quot;2.0&quot;,</div><div class="line">    &quot;result&quot;: {</div><div class="line">        &quot;responses&quot;: [</div><div class="line">            // First response: HTTP 200 (OK), firmware version</div><div class="line">            { &quot;statcode&quot;: 200,</div><div class="line">              &quot;json&quot;: { &quot;jsonrpc&quot;: &quot;2.0&quot;, &quot;result&quot;: { &quot;_ret_&quot;: &quot;3.1.0.5-23456&quot; }, &quot;id&quot;: 1 } },</div><div class="line">            // Second response: HTTP 200 (OK), no return value</div><div class="line">            { &quot;statcode&quot;: 200,</div><div class="line">              &quot;json&quot;: { &quot;jsonrpc&quot;: &quot;2.0&quot;, &quot;result&quot;: null, &quot;id&quot;: 2 } }</div><div class="line">        ]</div><div class="line">    },</div><div class="line">    &quot;id&quot;: 123</div><div class="line">}</div></div><!-- fragment --><p>The Java language binding uses bulk RPC by default when using the asynchronous API. The Perl und Python bindings do not support bulk RPC yet.</p>
<ul>
<li>see: bulkrpc.BulkRequest_1_0_1 </li>
</ul>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Aug 21 2020 10:20:37 for Raritan PX2/PX3 JSON-RPC API by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>