Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Mihini/REST API"

(New page: {{:DocumentationGuidelines/DraftHeader}} This page gathers initial thoughts on providing a REST API for the Mihini framework)
 
(Application container)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{:DocumentationGuidelines/DraftHeader}}
+
This page describes the current status of the Mihini agent REST service. The Mihini agent REST exposes agent services by a REST API.
  
This page gathers initial thoughts on providing a REST API for the Mihini framework
+
== Specifications  ==
 +
 
 +
=== Returned values  ===
 +
 
 +
Each REST function returns the same value as the function to which it corresponds, except that it is serialized with JSON
 +
 
 +
== API  ==
 +
 
 +
See below a list of the current Lua API with their corresponding REST API  
 +
 
 +
=== Devicetree  ===
 +
 
 +
{| border="1" cellspacing="0" cellpadding="5"
 +
|-
 +
! Module API
 +
! REST URL
 +
! HTTP method
 +
! HTTP payload
 +
|-
 +
| devicetree.get("node.subnode.leaf")
 +
| devicetree/node/subnode/leaf
 +
| GET
 +
| Nothing
 +
|-
 +
| devicetree.set("node.subnode.leaf", "myvalue")
 +
| devicetree/node/subnode/leaf
 +
| PUT
 +
| The new value of "node.subnode.leaf" serialiazed with JSON
 +
|}
 +
 
 +
=== Application container  ===
 +
 
 +
{| border="1" cellspacing="0" cellpadding="5"
 +
|-
 +
! Module API
 +
! REST URL
 +
! HTTP method
 +
! HTTP payload
 +
|-
 +
| appcon.list()
 +
| application
 +
| GET
 +
| Nothing
 +
|-
 +
| appcon.status("id")
 +
| application/id
 +
| GET
 +
| Nothing
 +
|-
 +
| appcon.start("id")
 +
| application/id/start
 +
| PUT
 +
| Empty JSON table ({ }) or empty JSON string ""<br>
 +
|-
 +
| appcon.stop("id")
 +
| application/id/stop
 +
| PUT
 +
|
 +
Empty JSON table ({ }) or empty JSON string ""
 +
 
 +
|-
 +
| appcon.configure("id", autostart)
 +
| application/id/configure
 +
| PUT
 +
| A boolean value corresponding to "autostart" and serialized with JSON
 +
|}
 +
 
 +
=== Update  ===
 +
 
 +
{| border="1" cellspacing="0" cellpadding="5"
 +
|-
 +
! Module API
 +
! REST URL
 +
! URL parameter
 +
! HTTP method
 +
! HTTP payload
 +
|-
 +
| update.localupdate(path, sync)
 +
| update/
 +
| sync=[0-1] (optional, asynchronous by default)
 +
| POST
 +
| The tar archive sent as binary data in a http chunked request
 +
|-
 +
| update.getstatus()
 +
| update/
 +
| sync=[0-1] (optional, asynchronous by default)
 +
| GET
 +
| Nothing
 +
|}
 +
 
 +
== Configuration  ==
 +
 
 +
Everything is configurable in the config store
 +
 
 +
=== defaultconfig.lua  ===
 +
<pre style="width: 45em;">-- REST related settings
 +
rest = {}
 +
rest.activate = true
 +
rest.port = 8357
 +
</pre>
 +
=== Lua shell  ===
 +
<pre style="width: 45em;">$ telnet localhost 2000
 +
&gt;&nbsp;:agent.config.rest.activate
 +
true
 +
&gt;&nbsp;:agent.config.rest.port
 +
8357
 +
</pre>
 +
== Suggestions  ==
 +
 
 +
Feel free to send your feedbacks on the Mihini mailing list, suggestions for improvements are always welcome

Latest revision as of 05:34, 8 August 2013

This page describes the current status of the Mihini agent REST service. The Mihini agent REST exposes agent services by a REST API.

Specifications

Returned values

Each REST function returns the same value as the function to which it corresponds, except that it is serialized with JSON

API

See below a list of the current Lua API with their corresponding REST API

Devicetree

Module API REST URL HTTP method HTTP payload
devicetree.get("node.subnode.leaf") devicetree/node/subnode/leaf GET Nothing
devicetree.set("node.subnode.leaf", "myvalue") devicetree/node/subnode/leaf PUT The new value of "node.subnode.leaf" serialiazed with JSON

Application container

Module API REST URL HTTP method HTTP payload
appcon.list() application GET Nothing
appcon.status("id") application/id GET Nothing
appcon.start("id") application/id/start PUT Empty JSON table ({ }) or empty JSON string ""
appcon.stop("id") application/id/stop PUT

Empty JSON table ({ }) or empty JSON string ""

appcon.configure("id", autostart) application/id/configure PUT A boolean value corresponding to "autostart" and serialized with JSON

Update

Module API REST URL URL parameter HTTP method HTTP payload
update.localupdate(path, sync) update/ sync=[0-1] (optional, asynchronous by default) POST The tar archive sent as binary data in a http chunked request
update.getstatus() update/ sync=[0-1] (optional, asynchronous by default) GET Nothing

Configuration

Everything is configurable in the config store

defaultconfig.lua

-- REST related settings
rest = {}
rest.activate = true
rest.port = 8357

Lua shell

$ telnet localhost 2000
> :agent.config.rest.activate
true
> :agent.config.rest.port
8357

Suggestions

Feel free to send your feedbacks on the Mihini mailing list, suggestions for improvements are always welcome

Back to the top