From c29d356fc27aaa1cdc704db844ad8786c379241d Mon Sep 17 00:00:00 2001 From: jbnadal Date: Mon, 30 Apr 2018 13:57:53 +0200 Subject: [PATCH] Update json file to new format --- .../ovl/usr/local/configs/restd/core.json | 53 ------- .../usr/local/configs/restd/v1-lights.json | 45 ++++++ .../usr/local/configs/restd/v1-sequences.json | 45 ++++++ .../usr/local/configs/restd/v1-shutters.json | 45 ++++++ .../local/configs/restd/v1-sprinklers.json | 61 ++++++++ .../domo/ovl/usr/local/configs/restd/v1.json | 13 ++ .../usr/local/share/domo/capabilities.json | 19 ++- .../ovl/usr/local/share/domo/devices.json | 137 ++++++++---------- docs/api/.vuepress/config.js | 12 ++ docs/api/README.md | 12 ++ docs/api/device-management.md | 2 + docs/api/history.md | 7 + docs/api/package.json | 6 + 13 files changed, 326 insertions(+), 131 deletions(-) delete mode 100644 bsp/board/domo/ovl/usr/local/configs/restd/core.json create mode 100644 bsp/board/domo/ovl/usr/local/configs/restd/v1-lights.json create mode 100644 bsp/board/domo/ovl/usr/local/configs/restd/v1-sequences.json create mode 100644 bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json create mode 100644 bsp/board/domo/ovl/usr/local/configs/restd/v1-sprinklers.json create mode 100644 bsp/board/domo/ovl/usr/local/configs/restd/v1.json create mode 100644 docs/api/.vuepress/config.js create mode 100644 docs/api/README.md create mode 100644 docs/api/device-management.md create mode 100644 docs/api/history.md create mode 100644 docs/api/package.json diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/core.json b/bsp/board/domo/ovl/usr/local/configs/restd/core.json deleted file mode 100644 index 09d3c061..00000000 --- a/bsp/board/domo/ovl/usr/local/configs/restd/core.json +++ /dev/null @@ -1,53 +0,0 @@ -// Comments -{ - "controller": [ - { - "model": "get", - "endpoint": ["/v1/capabilities"], - "ubus": { - "path": "domo.capabilities", - "method": "get" - } - }, - { - "model": "get", - "endpoint": ["/v1/capabilities/lights", "/v1/capabilities/lights/:id"], - "ubus": { - "path": "domo.capabilities.lights", - "method": "get" - } - }, - { - "model": "get", - "endpoint": ["/v1/capabilities/shutters", "/v1/capabilities/shutters/:id"], - "ubus": { - "path": "domo.capabilities.shutters", - "method": "get" - } - }, - { - "model": "get", - "endpoint": ["/v1/capabilities/sprinklers", "/v1/capabilities/sprinklers/:id"], - "ubus": { - "path": "domo.capabilities.sprinklers", - "method": "get" - } - }, - { - "model": "put", - "endpoint": ["/v1/capabilities/sprinklers/:id/open"], - "ubus": { - "path": "domo.capabilities.sprinklers.open", - "method": "open" - } - }, - { - "model": "put", - "endpoint": ["/v1/capabilities/sprinklers/:id/close"], - "ubus": { - "path": "domo.capabilities.sprinklers.close", - "method": "close" - } - } - ] -} diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/v1-lights.json b/bsp/board/domo/ovl/usr/local/configs/restd/v1-lights.json new file mode 100644 index 00000000..d428a4ac --- /dev/null +++ b/bsp/board/domo/ovl/usr/local/configs/restd/v1-lights.json @@ -0,0 +1,45 @@ +// Lights +{ + "resources": [ + { + "model": "post", + "endpoint": "/v1/lights", + "ubus": { + "path": "domo.lights", + "method": "create" + } + }, + { + "model": "get", + "endpoint": "/v1/lights", + "ubus": { + "path": "domo.lights", + "method": "list" + } + }, + { + "model": "get", + "endpoint": "/v1/lights/:id", + "ubus": { + "path": "domo.lights", + "method": "read" + } + }, + { + "model": "put", + "endpoint": "/v1/lights/:id", + "ubus": { + "path": "domo.lights", + "method": "update" + } + }, + { + "model": "delete", + "endpoint": "/v1/lights/:id", + "ubus": { + "path": "domo.lights", + "method": "delete" + } + } + ] +} \ No newline at end of file diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/v1-sequences.json b/bsp/board/domo/ovl/usr/local/configs/restd/v1-sequences.json new file mode 100644 index 00000000..f7bcdcff --- /dev/null +++ b/bsp/board/domo/ovl/usr/local/configs/restd/v1-sequences.json @@ -0,0 +1,45 @@ +// Sequences +{ + "resources": [ + { + "model": "post", + "endpoint": "/v1/sequences", + "ubus": { + "path": "domo.sequences", + "method": "create" + } + }, + { + "model": "get", + "endpoint": "/v1/sequences", + "ubus": { + "path": "domo.sequences", + "method": "list" + } + }, + { + "model": "get", + "endpoint": "/v1/sequences/:id", + "ubus": { + "path": "domo.sequences", + "method": "read" + } + }, + { + "model": "put", + "endpoint": "/v1/sequences/:id", + "ubus": { + "path": "domo.sequences", + "method": "update" + } + }, + { + "model": "delete", + "endpoint": "/v1/sequences/:id", + "ubus": { + "path": "domo.sequences", + "method": "delete" + } + } + ] +} diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json b/bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json new file mode 100644 index 00000000..8dcfa538 --- /dev/null +++ b/bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json @@ -0,0 +1,45 @@ +// Shutters +{ + "resources": [ + { + "model": "post", + "endpoint": "/v1/shutters", + "ubus": { + "path": "domo.shutters", + "method": "create" + } + }, + { + "model": "get", + "endpoint": "/v1/shutters", + "ubus": { + "path": "domo.shutters", + "method": "list" + } + }, + { + "model": "get", + "endpoint": "/v1/shutters/:id", + "ubus": { + "path": "domo.shutters", + "method": "read" + } + }, + { + "model": "put", + "endpoint": "/v1/shutters/:id", + "ubus": { + "path": "domo.shutters", + "method": "update" + } + }, + { + "model": "delete", + "endpoint": "/v1/shutters/:id", + "ubus": { + "path": "domo.shutters", + "method": "delete" + } + } + ] +} \ No newline at end of file diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/v1-sprinklers.json b/bsp/board/domo/ovl/usr/local/configs/restd/v1-sprinklers.json new file mode 100644 index 00000000..284cbf37 --- /dev/null +++ b/bsp/board/domo/ovl/usr/local/configs/restd/v1-sprinklers.json @@ -0,0 +1,61 @@ +// Sprinklers +{ + "resources": [ + { + "model": "post", + "endpoint": "/v1/sprinklers", + "ubus": { + "path": "domo.sprinklers", + "method": "create" + } + }, + { + "model": "get", + "endpoint": "/v1/sprinklers", + "ubus": { + "path": "domo.sprinklers", + "method": "list" + } + }, + { + "model": "get", + "endpoint": "/v1/sprinklers/:id", + "ubus": { + "path": "domo.sprinklers", + "method": "read" + } + }, + { + "model": "put", + "endpoint": "/v1/sprinklers/:id", + "ubus": { + "path": "domo.sprinklers", + "method": "update" + } + }, + { + "model": "delete", + "endpoint": "/v1/sprinklers/:id", + "ubus": { + "path": "domo.sprinklers", + "method": "delete" + } + }, + { + "model": "put", + "endpoint": "/v1/sprinklers/:id/open", + "ubus": { + "path": "domo.sprinklers.open", + "method": "open" + } + }, + { + "model": "put", + "endpoint": "/v1/sprinklers/:id/close", + "ubus": { + "path": "domo.sprinklers.close", + "method": "close" + } + } + ] +} diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/v1.json b/bsp/board/domo/ovl/usr/local/configs/restd/v1.json new file mode 100644 index 00000000..b8a262b5 --- /dev/null +++ b/bsp/board/domo/ovl/usr/local/configs/restd/v1.json @@ -0,0 +1,13 @@ +// Root +{ + "resources": [ + { + "model": "get", + "endpoint": "/v1/device-capabilities", + "ubus": { + "path": "domo.devices.capabilities", + "method": "list" + } + } + ] +} diff --git a/bsp/board/domo/ovl/usr/local/share/domo/capabilities.json b/bsp/board/domo/ovl/usr/local/share/domo/capabilities.json index a3afdb7b..fda4fc8e 100644 --- a/bsp/board/domo/ovl/usr/local/share/domo/capabilities.json +++ b/bsp/board/domo/ovl/usr/local/share/domo/capabilities.json @@ -1,7 +1,16 @@ { - "capabilities":[ - "lights", - "shutters", - "sprinklers" + "capabilities": [ + { + "name": "lights", + "speach_name": "lumière" + }, + { + "name": "shutters", + "speach_name": "volet" + }, + { + "name": "sprinklers", + "speach_name": "station" + } ] -} +} \ No newline at end of file diff --git a/bsp/board/domo/ovl/usr/local/share/domo/devices.json b/bsp/board/domo/ovl/usr/local/share/domo/devices.json index 542ffa72..56514b6f 100644 --- a/bsp/board/domo/ovl/usr/local/share/domo/devices.json +++ b/bsp/board/domo/ovl/usr/local/share/domo/devices.json @@ -1,74 +1,65 @@ { - "lights" : { - "speach_name": "lumière", - "devices": [ - { - "id": 1, - "name": "Bureau JB", - "speach_name": "bureau", - "zone": "", - "state": true, - "sender": 12797322, - "interruptor": 0 - }, - { - "id": 2, - "name": "Salon", - "speach_name": "salon", - "zone": "", - "state": false, - "sender": 12797322, - "interruptor": 1 - }, - { - "id": 3, - "name": "Sapin", - "speach_name": "sapin", - "zone": "", - "state": false, - "sender": 12797322, - "interruptor": 2 - } - ] - }, - "shutters" : { - "speach_name": "volet", - "devices": [ - { - "id": 1, - "name": "Chambre de JB", - "zone": "", - "state": true, - "sender": 14997046, - "interruptor": 12, - "speed_up": 20, - "speed_down": 18 - } - ] - }, - "sprinklers" : { - "speach_name": "station", - "devices": [ - { - "id": 7, - "name": "Zone A", - "state": false - }, - { - "id": 8, - "name": "Zone B", - "state": false - }, - { - "id": 25, - "name": "Zone C", - "state": false - }, - { - "id": 24, - "name": "Zone D", - "state": false - } - ] - } -} + "lights": [ + { + "id": 1, + "name": "Bureau JB", + "speach_name": "bureau", + "zone": "", + "state": true, + "sender": 12797322, + "interruptor": 0 + }, + { + "id": 2, + "name": "Salon", + "speach_name": "salon", + "zone": "", + "state": false, + "sender": 12797322, + "interruptor": 1 + }, + { + "id": 3, + "name": "Sapin", + "speach_name": "sapin", + "zone": "", + "state": false, + "sender": 12797322, + "interruptor": 2 + } + ], + "shutters": [ + { + "id": 1, + "name": "Chambre de JB", + "zone": "", + "state": true, + "sender": 14997046, + "interruptor": 12, + "speed_up": 20, + "speed_down": 18 + } + ], + "sprinklers": [ + { + "id": 7, + "name": "Zone A", + "state": false + }, + { + "id": 8, + "name": "Zone B", + "state": false + }, + { + "id": 25, + "name": "Zone C", + "state": false + }, + { + "id": 24, + "name": "Zone D", + "state": false + } + ] +} \ No newline at end of file diff --git a/docs/api/.vuepress/config.js b/docs/api/.vuepress/config.js new file mode 100644 index 00000000..bffa893e --- /dev/null +++ b/docs/api/.vuepress/config.js @@ -0,0 +1,12 @@ +module.exports = { + base: '.', + title: 'Domo Api 1.0', + description: 'domo API', + themeConfig: { + sidebar: [ + '/', + ['/ history', 'History'], + ['/ capabilities', 'Capabilities'], + ] + } +} diff --git a/docs/api/README.md b/docs/api/README.md new file mode 100644 index 00000000..a352d6db --- /dev/null +++ b/docs/api/README.md @@ -0,0 +1,12 @@ +# Domo API documentation + +## Quick overview + +This documentation allow you to control the domo system. + + +## API design +http://dev.enchant.com/api/v1 +http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#useful-post-responses +https://restfulapi.net/resource-naming/ + diff --git a/docs/api/device-management.md b/docs/api/device-management.md new file mode 100644 index 00000000..7f48239c --- /dev/null +++ b/docs/api/device-management.md @@ -0,0 +1,2 @@ +/device-management/capabilities + diff --git a/docs/api/history.md b/docs/api/history.md new file mode 100644 index 00000000..8a1c7b2c --- /dev/null +++ b/docs/api/history.md @@ -0,0 +1,7 @@ +Revision History +================ + +| Current Version | Date | Description | +| --------------- | ------------------- | -------------- | +| 1.1 | | current update | +| 1.0 | February 07th, 2014 | First Draft | diff --git a/docs/api/package.json b/docs/api/package.json new file mode 100644 index 00000000..71ecfe3d --- /dev/null +++ b/docs/api/package.json @@ -0,0 +1,6 @@ +{ + "scripts": { + "docs:dev": "vuepress dev .", + "docs:build": "vuepress build" + } +}