Zack YL Shih
Beauty vs Beautiful
Representational State Transfer
Constraints are liberating
/network/ethernets/{id}
{
"id":1,
"name":"eth0",
"ip":"192.168.3.127",
"mac":"FF:FF:FF:FF:FF:FF",
"netmask":"255.255.255.0",
"subnet":"192.168.3.0",
"gateway":"192.168.3.254",
"dns":["8.8.8.8", "8.8.4.4"],
"currentStatus":1,
"enable":1,
"enableDhcp":0
}
/network/ethernets/{id}
Request:
curl 'http://localhost/network/ethernets/1'
Response:
200 (OK)
Content-Type: application/json
{
"id":1,
"name":"eth0",
"ip":"192.168.3.127",
"mac":"FF:FF:FF:FF:FF:FF",
"netmask":"255.255.255.0",
"subnet":"192.168.3.0",
"gateway":"192.168.3.254",
"dns":["8.8.8.8", "8.8.4.4"],
"currentStatus":1,
"enable":1,
"enableDhcp":0
}
Get eth0 information
/network/ethernets/{id}
Request:
curl --request PUT \
--header "Content-Type: application/json" \
--data-binary '{"dns":["192.168.50.33", "168.95.1.1"]}' \
'http://localhost/network/ethernets/1'
Response:
200 (OK)
Content-Type: application/json
{
"id":1,
"name":"eth0",
"ip":"192.168.3.127",
"mac":"FF:FF:FF:FF:FF:FF",
"netmask":"255.255.255.0",
"subnet":"192.168.3.0",
"gateway":"192.168.3.254",
"dns":["8.8.8.8", "8.8.4.4"],
"currentStatus":1,
"enable":1,
"enableDhcp":0
}
Set eth0 DNS to 192.168.50.33 and 168.95.1.1
/network/wifis
{
"id":1,
"name":"wlan0",
"mode":1,
"enable":1,
"currentStatus":1,
"mac":"FF:FF:FF:FF:FF:FF",
"client": {
"ssid": "MOXA-MAR-1",
"signal": -79,
"ip":"192.168.41.127",
"netmask":"255.255.255.0",
"subnet":"192.168.41.0",
"gateway":"192.168.41.254",
"enableDhcp": 1,
"network": [
{
"enable": 1,
"priority": 0,
"ssid": "MOXA-MAR-1",
"mode": 2,
"keyFormat": 0,
"psk": "moxamoxa",
"txKey": 0,
"key": ["", "", "", ""],
"identity": "",
"password": ""
}
]
}
}
/system/status/cpu
{
"data": [
{"time": "2014/09/14 15:18:48", "value": 54.1},
{"time": "2014/09/14 15:19:48", "value": 40.2},
{"time": "2014/09/14 15:20:48", "value": 35.9}
]
}
/system/status/memory
{
"data": [
{
"time": "2014/09/14 15:18:48",
"total": "200MB",
"used": "50MB",
"free": "150MB",
"usedPercentage": 25
},
{
"time": "2014/09/14 15:19:48",
"total": "200MB",
"used": "50MB",
"free": "150MB",
"usedPercentage": 25
}
]
}