xref: /openbmc/docs/rest-api.md (revision 224266ecfd528544e9f5473cc4607d9b6b7c435f)
120c0410bSBrad Bishop# OpenBMC REST API
24b0c7b8cSBrad Bishop
3*224266ecSGunnar MillsThe OpenBMC REST API is disabled by default in bmcweb. Most of the functionality
4*224266ecSGunnar Millsis available on Redfish. This document provides some basic structure and usage
5*224266ecSGunnar Millsexamples for the OpenBMC REST interface.
63ef8adf3SJeremy Kerr
7d4f32ba8SGunnar MillsThe schema for the rest interface is directly defined by the OpenBMC D-Bus
83ef8adf3SJeremy Kerrstructure. Therefore, the objects, attributes and methods closely map to those
9d4f32ba8SGunnar Millsin the D-Bus schema.
103ef8adf3SJeremy Kerr
113ef8adf3SJeremy KerrFor a quick explanation of HTTP verbs and how they relate to a RESTful API, see
123ef8adf3SJeremy Kerr<http://www.restapitutorial.com/lessons/httpmethods.html>.
133ef8adf3SJeremy Kerr
147273007dSMatt Spinler## Authentication
153ef8adf3SJeremy Kerr
16f4febd00SPatrick WilliamsSee the details on authentication at
17f4febd00SPatrick Williams[REST-cheatsheet](https://github.com/openbmc/docs/blob/master/REST-cheatsheet.md#establish-rest-connection-session).
183ef8adf3SJeremy Kerr
19b41aff0fSXiaochao MaThis tutorial uses token based authentication method:
203ef8adf3SJeremy Kerr
217273007dSMatt Spinler```
22b41aff0fSXiaochao Ma$ export bmc=xx.xx.xx.xx
23b41aff0fSXiaochao Ma$ export token=`curl -k -H "Content-Type: application/json" -X POST https://${bmc}/login -d '{"username" :  "root", "password" :  "0penBmc"}' | grep token | awk '{print $2;}' | tr -d '"'`
24b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/...
257273007dSMatt Spinler```
2620c0410bSBrad Bishop
273ef8adf3SJeremy Kerr## HTTP GET operations & URL structure
2820c0410bSBrad Bishop
293ef8adf3SJeremy KerrThere are a few conventions on the URL structure of the OpenBMC rest interface.
303ef8adf3SJeremy KerrThey are:
3120c0410bSBrad Bishop
323ef8adf3SJeremy Kerr- To query the attributes of an object, perform a GET request on the object
333ef8adf3SJeremy Kerr  name, with no trailing slash. For example:
3420c0410bSBrad Bishop
35b41aff0fSXiaochao Ma  ```
36b41aff0fSXiaochao Ma  $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/inventory/system
373ef8adf3SJeremy Kerr  {
383ef8adf3SJeremy Kerr  "data": {
390f345001SGunnar Mills   "AssetTag": "",
400f345001SGunnar Mills   "BuildDate": "",
41b41aff0fSXiaochao Ma   "Cached": true,
42b41aff0fSXiaochao Ma   "FieldReplaceable": true,
430f345001SGunnar Mills   "Manufacturer": "",
44b41aff0fSXiaochao Ma   "Model": "",
450f345001SGunnar Mills   "PartNumber": "",
46b41aff0fSXiaochao Ma   "Present": true,
470f345001SGunnar Mills   "PrettyName": "",
48b41aff0fSXiaochao Ma   "SerialNumber": ""
493ef8adf3SJeremy Kerr   },
503ef8adf3SJeremy Kerr   "message": "200 OK",
513ef8adf3SJeremy Kerr   "status": "ok"
523ef8adf3SJeremy Kerr  }
53b41aff0fSXiaochao Ma  ```
5420c0410bSBrad Bishop
55f4febd00SPatrick Williams- To query a single attribute, use the `attr/<name>` path. Using the `system`
56f4febd00SPatrick Williams  object from above, we can query just the `Name` value:
573ef8adf3SJeremy Kerr
58b41aff0fSXiaochao Ma  ```
59b41aff0fSXiaochao Ma  $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/inventory/system/attr/Cached
603ef8adf3SJeremy Kerr  {
61b41aff0fSXiaochao Ma   "data": true,
623ef8adf3SJeremy Kerr   "message": "200 OK",
633ef8adf3SJeremy Kerr   "status": "ok"
643ef8adf3SJeremy Kerr  }
65b41aff0fSXiaochao Ma  ```
663ef8adf3SJeremy Kerr
673ef8adf3SJeremy Kerr- When a path has a trailing-slash, the response will list the sub objects of
68f4febd00SPatrick Williams  the URL. For example, using the same object path as above, but adding a slash:
693ef8adf3SJeremy Kerr
70b41aff0fSXiaochao Ma  ```
71b41aff0fSXiaochao Ma  $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/
723ef8adf3SJeremy Kerr  {
733ef8adf3SJeremy Kerr   "data": [
74b41aff0fSXiaochao Ma   "/xyz/openbmc_project/Chassis",
75b41aff0fSXiaochao Ma   "/xyz/openbmc_project/Hiomapd",
76b41aff0fSXiaochao Ma   "/xyz/openbmc_project/Ipmi",
77b41aff0fSXiaochao Ma   "/xyz/openbmc_project/certs",
78b41aff0fSXiaochao Ma   "/xyz/openbmc_project/console",
790f345001SGunnar Mills   "/xyz/openbmc_project/control",
80b41aff0fSXiaochao Ma   "/xyz/openbmc_project/dump",
81b41aff0fSXiaochao Ma   "/xyz/openbmc_project/events",
820f345001SGunnar Mills   "/xyz/openbmc_project/inventory",
83b41aff0fSXiaochao Ma   "/xyz/openbmc_project/ipmi",
840f345001SGunnar Mills   "/xyz/openbmc_project/led",
85b41aff0fSXiaochao Ma   "/xyz/openbmc_project/logging",
86b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network",
87b41aff0fSXiaochao Ma   "/xyz/openbmc_project/object_mapper",
88b41aff0fSXiaochao Ma   "/xyz/openbmc_project/sensors",
89b41aff0fSXiaochao Ma   "/xyz/openbmc_project/software",
90b41aff0fSXiaochao Ma   "/xyz/openbmc_project/state",
91b41aff0fSXiaochao Ma   "/xyz/openbmc_project/time",
92b41aff0fSXiaochao Ma   "/xyz/openbmc_project/user"
933ef8adf3SJeremy Kerr       ],
943ef8adf3SJeremy Kerr       "message": "200 OK",
953ef8adf3SJeremy Kerr    "status": "ok"
963ef8adf3SJeremy Kerr  }
97b41aff0fSXiaochao Ma  ```
983ef8adf3SJeremy Kerr
99f4febd00SPatrick Williams  This shows that there are 19 children of the `openbmc_project/` object:
100f4febd00SPatrick Williams  `dump`, `software`, `control`, `network`, `logging`,etc. This can be used with
101f4febd00SPatrick Williams  the base REST URL (ie., `http://${bmc}/`), to discover all objects in the
102f4febd00SPatrick Williams  hierarchy.
1033ef8adf3SJeremy Kerr
1043ef8adf3SJeremy Kerr- Performing the same query with `/list` will list the child objects
105f4febd00SPatrick Williams  _recursively_.
1063ef8adf3SJeremy Kerr
107b41aff0fSXiaochao Ma  ```
108b41aff0fSXiaochao Ma  $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/network/list
1090f345001SGunnar Mills  {
1100f345001SGunnar Mills   "data": [
1110f345001SGunnar Mills   "/xyz/openbmc_project/network/config",
112b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/config/dhcp",
1130f345001SGunnar Mills   "/xyz/openbmc_project/network/eth0",
114b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth0/ipv4",
115b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth0/ipv4/3b9faa36",
116b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth0/ipv6",
117b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth0/ipv6/ff81b6d6",
118b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth1",
119b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth1/ipv4",
120b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth1/ipv4/3b9faa36",
121b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth1/ipv4/66e63348",
122b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth1/ipv6",
123b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/eth1/ipv6/ff81b6d6",
124b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/host0",
1250f345001SGunnar Mills   "/xyz/openbmc_project/network/host0/intf",
1260f345001SGunnar Mills   "/xyz/openbmc_project/network/host0/intf/addr",
127b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/sit0",
128b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/snmp",
129b41aff0fSXiaochao Ma   "/xyz/openbmc_project/network/snmp/manager"
1300f345001SGunnar Mills       ],
1310f345001SGunnar Mills     "message": "200 OK",
1320f345001SGunnar Mills     "status": "ok"
1330f345001SGunnar Mills  }
134b41aff0fSXiaochao Ma  ```
1353ef8adf3SJeremy Kerr
136f4febd00SPatrick Williams- Adding `/enumerate` instead of `/list` will also include the attributes of the
137f4febd00SPatrick Williams  listed objects.
1383ef8adf3SJeremy Kerr
139b41aff0fSXiaochao Ma  ```
140b41aff0fSXiaochao Ma  $ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/time/enumerate
1410f345001SGunnar Mills  {
1420f345001SGunnar Mills   "data": {
1430f345001SGunnar Mills   "/xyz/openbmc_project/time/bmc": {
144b41aff0fSXiaochao Ma     "Elapsed": 1563209492098739
1450f345001SGunnar Mills   },
1460f345001SGunnar Mills   "/xyz/openbmc_project/time/host": {
147b41aff0fSXiaochao Ma     "Elapsed": 1563209492101678
1480f345001SGunnar Mills   },
1490f345001SGunnar Mills   "/xyz/openbmc_project/time/owner": {
1500f345001SGunnar Mills     "TimeOwner": "xyz.openbmc_project.Time.Owner.Owners.BMC"
1510f345001SGunnar Mills   },
1520f345001SGunnar Mills   "/xyz/openbmc_project/time/sync_method": {
1530f345001SGunnar Mills     "TimeSyncMethod": "xyz.openbmc_project.Time.Synchronization.Method.NTP"
1540f345001SGunnar Mills   }
1550f345001SGunnar Mills   },
1560f345001SGunnar Mills   "message": "200 OK",
1570f345001SGunnar Mills   "status": "ok"
1580f345001SGunnar Mills  }
159b41aff0fSXiaochao Ma  ```
16020c0410bSBrad Bishop
16120c0410bSBrad Bishop## HTTP PUT operations
16220c0410bSBrad Bishop
1633ef8adf3SJeremy KerrPUT operations are for updating an existing resource (an object or property), or
164f4febd00SPatrick Williamsfor creating a new resource when the client already knows where to put it. These
165f4febd00SPatrick Williamsrequire a json formatted payload. To get an example of what that looks like:
16646ccbe9dSBrad Bishop
167b41aff0fSXiaochao Ma```
168b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/state/host0 > host.json
169f25a52ceSGunnar Mills$ cat host.json
170f25a52ceSGunnar Mills{
171f25a52ceSGunnar Mills  "data": {
172b41aff0fSXiaochao Ma    "AttemptsLeft": 3,
173f25a52ceSGunnar Mills    "BootProgress": "xyz.openbmc_project.State.Boot.Progress.ProgressStages.Unspecified",
174f25a52ceSGunnar Mills    "CurrentHostState": "xyz.openbmc_project.State.Host.HostState.Off",
175f25a52ceSGunnar Mills    "OperatingSystemState": "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive",
176f25a52ceSGunnar Mills    "RequestedHostTransition": "xyz.openbmc_project.State.Host.Transition.Off"
177f25a52ceSGunnar Mills  },
178f25a52ceSGunnar Mills  "message": "200 OK",
179f25a52ceSGunnar Mills  "status": "ok"
180f25a52ceSGunnar Mills}
181b41aff0fSXiaochao Ma```
18246ccbe9dSBrad Bishop
1833ef8adf3SJeremy Kerror
18420c0410bSBrad Bishop
185b41aff0fSXiaochao Ma```
186b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" https://${bmc}/xyz/openbmc_project/state/host0/attr/RequestedHostTransition > requested_host.json
187f25a52ceSGunnar Mills$ cat requested_host.json
188f25a52ceSGunnar Mills{
189f25a52ceSGunnar Mills  "data": "xyz.openbmc_project.State.Host.Transition.Off",
190f25a52ceSGunnar Mills  "message": "200 OK",
191f25a52ceSGunnar Mills  "status": "ok"
192f25a52ceSGunnar Mills}
193b41aff0fSXiaochao Ma```
19420c0410bSBrad Bishop
1953ef8adf3SJeremy KerrWhen turning around and sending these as requests, delete the message and status
1963ef8adf3SJeremy Kerrproperties.
1973ef8adf3SJeremy Kerr
1983ef8adf3SJeremy KerrTo make curl use the correct content type header use the -H option to specify
1993ef8adf3SJeremy Kerrthat we're sending JSON data:
2003ef8adf3SJeremy Kerr
201b41aff0fSXiaochao Ma```
202b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT -d <json> <url>
203b41aff0fSXiaochao Ma```
2043ef8adf3SJeremy Kerr
2053ef8adf3SJeremy KerrA PUT operation on an object requires a complete object. For partial updates
2063ef8adf3SJeremy Kerrthere is PATCH but that is not implemented yet. As a workaround individual
2073ef8adf3SJeremy Kerrattributes are PUTable.
2083ef8adf3SJeremy Kerr
209f25a52ceSGunnar MillsFor example, make changes to the requested_host.json file and do a PUT (upload):
2103ef8adf3SJeremy Kerr
211b41aff0fSXiaochao Ma```
212f25a52ceSGunnar Mills$ cat requested_host.json
213b41aff0fSXiaochao Ma{"data": "xyz.openbmc_project.State.Host.Transition.Off"}
214b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT -T requested_host.json https://${bmc}/xyz/openbmc_project/state/host0/attr/RequestedHostTransition
215b41aff0fSXiaochao Ma```
216f4febd00SPatrick Williams
21746ccbe9dSBrad BishopAlternatively specify the json inline with -d:
218f4febd00SPatrick Williams
219b41aff0fSXiaochao Ma```
220b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X PUT -d '{"data": "xyz.openbmc_project.State.Host.Transition.On"}' https://${bmc}/xyz/openbmc_project/state/host0/attr/RequestedHostTransition
221b41aff0fSXiaochao Ma```
222f4febd00SPatrick Williams
2230334d811SAndrew JefferyWhen using '-d' just remember that json requires quoting.
22446ccbe9dSBrad Bishop
22520c0410bSBrad Bishop## HTTP POST operations
226f4febd00SPatrick Williams
2273ef8adf3SJeremy KerrPOST operations are for calling methods, but also for creating new resources
2283ef8adf3SJeremy Kerrwhen the client doesn't know where to put it. OpenBMC does not support creating
2293ef8adf3SJeremy Kerrnew resources via REST so any attempt to create a new resource will result in a
230f4febd00SPatrick WilliamsHTTP 403 (Forbidden). These also require a json formatted payload. To delete
231f4febd00SPatrick Williamslogging entries:
23220c0410bSBrad Bishop
233b41aff0fSXiaochao Ma```
234b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://${bmc}/xyz/openbmc_project/logging/action/DeleteAll
235b41aff0fSXiaochao Ma```
236f4febd00SPatrick Williams
2378108a39cSGunnar MillsTo invoke a method without parameters (Factory Reset of BMC and Host):
238f4febd00SPatrick Williams
239b41aff0fSXiaochao Ma```
240b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H 'Content-Type: application/json' -X POST -d '{"data":[]}' https://${bmc}/xyz/openbmc_project/software/action/Reset
241b41aff0fSXiaochao Ma```
242f4febd00SPatrick Williams
243eaf65991SBrad Bishop## HTTP DELETE operations
244f4febd00SPatrick Williams
245d4f32ba8SGunnar MillsDELETE operations are for removing instances. Only D-Bus objects (instances) can
246d4f32ba8SGunnar Millsbe removed. If the underlying D-Bus object implements the
247b09f6be6SGunnar Mills`xyz.openbmc_project.Object.Delete` interface the REST server will call it. If
248b09f6be6SGunnar Mills`xyz.openbmc_project.Object.Delete` is not implemented, the REST server will
249b09f6be6SGunnar Millsreturn a HTTP 403 (Forbidden) error.
250eaf65991SBrad Bishop
251b41aff0fSXiaochao MaFor example, to delete a event record:
2523ef8adf3SJeremy Kerr
253b41aff0fSXiaochao MaDisplay logging entries:
2543ef8adf3SJeremy Kerr
255b41aff0fSXiaochao Ma```
256b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X GET https://${bmc}/xyz/openbmc_project/logging/entry/enumerate
257b41aff0fSXiaochao Ma```
258b41aff0fSXiaochao Ma
259b41aff0fSXiaochao MaThen delete the event record with ID 1:
260b41aff0fSXiaochao Ma
261b41aff0fSXiaochao Ma```
262b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/json" -X DELETE  https://${bmc}/xyz/openbmc_project/logging/entry/1
263b41aff0fSXiaochao Ma```
2640772bd82SDeepak Kodihalli
2650772bd82SDeepak Kodihalli## Uploading images
266f4febd00SPatrick Williams
2670772bd82SDeepak KodihalliIt is possible to upload software upgrade images (for example to upgrade the BMC
2680772bd82SDeepak Kodihallior host software) via REST. The content-type should be set to
2690772bd82SDeepak Kodihalli"application/octet-stream".
2700772bd82SDeepak Kodihalli
271b41aff0fSXiaochao MaFor example, to upload an image:(the `<file_to_upload>` must be a tar ball)
2720772bd82SDeepak Kodihalli
273b41aff0fSXiaochao Ma```
274b41aff0fSXiaochao Ma$ curl -k -H "X-Auth-Token: $token" -H "Content-Type: application/octet-stream" -X POST -T <file_to_upload> https://${bmc}/upload/image
275b41aff0fSXiaochao Ma```
2760772bd82SDeepak Kodihalli
2770772bd82SDeepak KodihalliIn above example, the filename on the BMC will be chosen by the REST server.
2780772bd82SDeepak Kodihalli
2790772bd82SDeepak KodihalliIt is possible for the user to choose the uploaded file's remote name:
2800772bd82SDeepak Kodihalli
281b41aff0fSXiaochao Ma```
282b41aff0fSXiaochao Macurl -k -H "X-Auth-Token: $token" -H "Content-Type: application/octet-stream" -X PUT -T foo https://${bmc}/upload/image/bar
283b41aff0fSXiaochao Ma```
2840772bd82SDeepak Kodihalli
2850772bd82SDeepak KodihalliIn above example, the file foo will be saved with the name bar on the BMC.
286e7ac10a2SDeepak Kodihalli
287f4febd00SPatrick WilliamsThe operation will either return the version id (hash) of the uploaded file on
288f4febd00SPatrick Williamssuccess:
2899e99e773SAdriana Kobylak
290b41aff0fSXiaochao Ma```
2919e99e773SAdriana Kobylak{
292b41aff0fSXiaochao Ma  "data": "afb92384",
2939e99e773SAdriana Kobylak  "message": "200 OK",
2949e99e773SAdriana Kobylak  "status": "ok"
2959e99e773SAdriana Kobylak}
296b41aff0fSXiaochao Ma```
2979e99e773SAdriana Kobylak
298b41aff0fSXiaochao Maor an error message
2999e99e773SAdriana Kobylak
300b41aff0fSXiaochao Ma```
3019e99e773SAdriana Kobylak{
3029e99e773SAdriana Kobylak    "data": {
3039e99e773SAdriana Kobylak        "description": "Version already exists or failed to be extracted"
3049e99e773SAdriana Kobylak    },
3059e99e773SAdriana Kobylak    "message": "400 Bad Request",
3069e99e773SAdriana Kobylak    "status": "error"
3079e99e773SAdriana Kobylak}
308b41aff0fSXiaochao Ma```
309b41aff0fSXiaochao Ma
310b41aff0fSXiaochao MaFor more details on uploading and updating software, see:
31131de159fSAdriana Kobylakhttps://github.com/openbmc/docs/tree/master/architecture/code-update
3129e99e773SAdriana Kobylak
313e7ac10a2SDeepak Kodihalli## Event subscription protocol
314e7ac10a2SDeepak Kodihalli
315f4febd00SPatrick WilliamsIt is possible to subscribe to events, of interest, occurring on the BMC. The
316f4febd00SPatrick Williamsimplementation on the BMC uses WebSockets for this purpose, so that clients
317f4febd00SPatrick Williamsdon't have do employ polling. Instead, the rest server on the BMC can push data
318f4febd00SPatrick Williamsto clients over a websocket. The BMC can push out information pertaining to
319f4febd00SPatrick WilliamsD-Bus InterfacesAdded and PropertiesChanged signals.
320e7ac10a2SDeepak Kodihalli
321f4febd00SPatrick WilliamsFollowing is a description of the event subscription protocol, with example JS
322f4febd00SPatrick Williamscode snippets denoting client-side code.
323f4febd00SPatrick Williams
324f4febd00SPatrick Williamsa) The client needs to have logged on to the BMC. b) The client needs to open a
325f4febd00SPatrick Williamssecure websocket with the URL <BMC IP>/subscribe.
326e7ac10a2SDeepak Kodihalli
327e7ac10a2SDeepak Kodihalli```
328e7ac10a2SDeepak Kodihalli   var ws = new WebSocket("wss://<BMC IP>/subscribe")
329e7ac10a2SDeepak Kodihalli```
330e7ac10a2SDeepak Kodihalli
331e7ac10a2SDeepak Kodihallic) The client needs to send, over the websocket, a JSON dictionary, comprising
332f4febd00SPatrick Williamsof key-value pairs. This dictionary serves as the "events filter". All the keys
333f4febd00SPatrick Williamsare optional, so the dictionary can be empty if no filtering is desired. The
334f4febd00SPatrick Williamsfilters represented by each of the key-value pairs are ORed.
335e7ac10a2SDeepak Kodihalli
336e7ac10a2SDeepak KodihalliOne of the supported keys is "paths". The corresponding value is an array of
337f4febd00SPatrick WilliamsD-Bus paths. The InterfacesAdded and PropertiesChanged D-Bus signals emanating
338f4febd00SPatrick Williamsfrom any of these path(s) alone, and not from any other paths, will be included
339f4febd00SPatrick Williamsin the event message going out of the BMC.
340e7ac10a2SDeepak Kodihalli
341f4febd00SPatrick WilliamsThe other supported key is "interfaces". The corresponding value is an array of
342f4febd00SPatrick WilliamsD-Bus interfaces. The InterfacesAdded and PropertiesChanged D-Bus signal
343f4febd00SPatrick Williamsmessages comprising of any of these interfaces will be included in the event
344f4febd00SPatrick Williamsmessage going out of the BMC.
345e7ac10a2SDeepak Kodihalli
346e7ac10a2SDeepak KodihalliAll of the following are valid:
347e7ac10a2SDeepak Kodihalli
348e7ac10a2SDeepak Kodihalli```
349e7ac10a2SDeepak Kodihallivar data = JSON.stringify(
350e7ac10a2SDeepak Kodihalli{
351e7ac10a2SDeepak Kodihalli    "paths": ["/xyz/openbmc_project/logging", "/xyz/openbmc_project/sensors"],
352e7ac10a2SDeepak Kodihalli    "interfaces": ["xyz.openbmc_project.Logging.Entry", "xyz.openbmc_project.Sensor.Value"]
353e7ac10a2SDeepak Kodihalli});
354e7ac10a2SDeepak Kodihalliws.onopen = function() {
355e7ac10a2SDeepak Kodihalli    ws.send(data);
356e7ac10a2SDeepak Kodihalli};
357e7ac10a2SDeepak Kodihalli```
358e7ac10a2SDeepak Kodihalli
359e7ac10a2SDeepak Kodihalli```
360e7ac10a2SDeepak Kodihallivar data = JSON.stringify(
361e7ac10a2SDeepak Kodihalli{
362e7ac10a2SDeepak Kodihalli    "paths": ["/xyz/openbmc_project/logging", "/xyz/openbmc_project/sensors"],
363e7ac10a2SDeepak Kodihalli});
364e7ac10a2SDeepak Kodihalliws.onopen = function() {
365e7ac10a2SDeepak Kodihalli    ws.send(data);
366e7ac10a2SDeepak Kodihalli};
367e7ac10a2SDeepak Kodihalli```
368e7ac10a2SDeepak Kodihalli
369e7ac10a2SDeepak Kodihalli```
370e7ac10a2SDeepak Kodihallivar data = JSON.stringify(
371e7ac10a2SDeepak Kodihalli{
372e7ac10a2SDeepak Kodihalli    "interfaces": ["xyz.openbmc_project.Logging.Entry", "xyz.openbmc_project.Sensor.Value"]
373e7ac10a2SDeepak Kodihalli});
374e7ac10a2SDeepak Kodihalliws.onopen = function() {
375e7ac10a2SDeepak Kodihalli    ws.send(data);
376e7ac10a2SDeepak Kodihalli};
377e7ac10a2SDeepak Kodihalli```
378e7ac10a2SDeepak Kodihalli
379e7ac10a2SDeepak Kodihalli```
380e7ac10a2SDeepak Kodihallivar data = JSON.stringify(
381e7ac10a2SDeepak Kodihalli{
382e7ac10a2SDeepak Kodihalli});
383e7ac10a2SDeepak Kodihalliws.onopen = function() {
384e7ac10a2SDeepak Kodihalli    ws.send(data);
385e7ac10a2SDeepak Kodihalli};
386e7ac10a2SDeepak Kodihalli```
387e7ac10a2SDeepak Kodihalli
388e7ac10a2SDeepak Kodihallid) The rest server on the BMC will respond over the websocket when a D-Bus event
389f4febd00SPatrick Williamsoccurs, considering the client supplied filters. The rest servers notifies about
390f4febd00SPatrick WilliamsInterfacesAdded and PropertiesChanged events. The response is a JSON dictionary
391f4febd00SPatrick Williamsas follows :
392e7ac10a2SDeepak Kodihalli
393e7ac10a2SDeepak KodihalliInterfacesAdded
394f4febd00SPatrick Williams
395e7ac10a2SDeepak Kodihalli```
396e7ac10a2SDeepak Kodihalli"event": InterfacesAdded
397e7ac10a2SDeepak Kodihalli"path": <string : new D-Bus path that was created>
398ad37a2e6SDeepak Kodihalli"interfaces": <dict : a dictionary of interfaces> (similar to org.freedesktop.DBus.ObjectManager.InterfacesAdded )
399e7ac10a2SDeepak Kodihalli```
400e7ac10a2SDeepak Kodihalli
401e7ac10a2SDeepak KodihalliPropertiesChanged
402f4febd00SPatrick Williams
403e7ac10a2SDeepak Kodihalli```
404e7ac10a2SDeepak Kodihalli"event": PropertiesChanged
405e7ac10a2SDeepak Kodihalli"path": <string : D-Bus path whose property changed>
406ad37a2e6SDeepak Kodihalli"interface": <string : D-Bus interface to which the changed property belongs>
407ad37a2e6SDeepak Kodihalli"properties": <dict : a dictionary of properties> (similar to org.freedesktop.DBus.Properties.PropertiesChanged)
408e7ac10a2SDeepak Kodihalli```
409