[PATCH docs 2/2] Add REST API examples

OpenBMC Patches patches at stwcx.xyz
Fri Oct 30 08:09:09 AEDT 2015


From: Brad Bishop <bradleyb at us.ibm.com>

---
 rest-api.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 rest-api.md

diff --git a/rest-api.md b/rest-api.md
new file mode 100644
index 0000000..7167e71
--- /dev/null
+++ b/rest-api.md
@@ -0,0 +1,81 @@
+# OpenBMC REST API
+## HTTP GET operations
+List directory:
+```
+curl http://bmc/<path>/
+```
+Examples:
+```
+curl http://bmc/
+curl http://bmc/org/
+curl http://bmc/org/openbmc/
+curl http://bmc/org/openbmc/inventory/
+curl http://bmc/org/openbmc/inventory/system/chassis/
+```
+
+List objects recursively:
+```
+curl http://bmc/<path>/list
+```
+Examples:
+```
+curl http://bmc/list
+curl http://bmc/org/openbmc/inventory/list
+```
+
+Enumerate objects recursively:
+```
+curl http://bmc/<path>/enumerate
+```
+Examples:
+```
+curl http://bmc/enumerate
+curl http://bmc/org/openbmc/inventory/enumerate
+
+```
+
+Get object:
+```
+curl http://bmc/<path>
+```
+Examples:
+```
+curl http://bmc/org/openbmc/inventory/system/chassis/fan2
+```
+
+Get property:
+```
+curl http://bmc/<path>/attr/<attr>
+curl http://bmc/org/openbmc/inventory/system/chassis/fan2/attr/is_fru
+```
+
+## HTTP PUT operations
+These require a json formatted payload.  To get an example of what that looks like:
+```
+curl http://bmc/org/openbmc/flash/Bios_0 > bios.json # - or -
+curl http://bmc/org/openbmc/flash/Bios_0/attr/flasher_path > flasher_path.json
+```
+
+A put operation on an object requires a complete object.  For partial updates see POST.
+
+Make changes to the file and do a put (upload):
+
+```
+curl -T bios.json http://bmc/org/openbmc/flash/Bios_0
+curl -T flasher_path.json http://bmc/org/openbmc/flash/Bios_0/attr/flasher_path
+```
+
+## HTTP POST operations
+These also require a json formatted payload.
+
+To make a partial change to an object, try removing some properties from the bios.json example above.  Then do:
+
+```
+curl -d "`cat bios.partial.json`" http://bmc/org/openbmc/flash/Bios_0
+```
+
+To invoke a method:
+```
+curl -d "[ \"foo\", \"bar\" ]" http://bmc/org/openbmc/managers/System/action/getObjectFromId
+```
+
-- 
2.6.0




More information about the openbmc mailing list