Update JSON API
[src/app-framework-demo.git] / afm-client / app / Backend / RestApis / AfmMainMockApi.js
1 /* 
2  * Copyright (C) 2015 "IoT.bzh"
3  * Author "Fulup Ar Foll"
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 /* ----------------------------------------------------------------------
20  *   This module simulate Application Framework Binder
21  *   
22  *   /api/afm-main/runnables  // no params
23  *   /api/afm-main/details    &id="xxxx"
24  *   /api/afm-main/start      &id="xxxx"
25  *   /api/afm-main/terminate  &runid="xxxx"
26  *   /api/afm-main/stop       &runid="xxxx"
27  *   /api/afm-main/continue   &runid="xxxx"
28  *   /api/afm-main/runners    // no params
29  *   /api/afm-main/state      &runid="xxxx"
30  * ----------------------------------------------------------------------*/
31
32  
33 function NewApi(handle, prefix) {
34     var scope=this; // I hate JavaScript
35     scope.connected=false;
36     
37     // Simulate Client Context Session Creation
38     handle.app.get (prefix +'/runnables', function (req, res) {
39         var Response= { jtype: "AJB_reply",
40                         request: { "prefix": "afm-main", "api": "runnables", "uuid": "e4ef5e66-xxxx", "token": "123456789-xxxxx", "status": "processed" },
41                         response: {runnables: [ 
42                             {id: "webapps-rabbit@0.0", version: "0.0.8", name: "Rabbit", description: "Fun grid game where the rabbit finds and eats the carrots dodging the foxes.", shortname: "", author: "Todd Brandt <todd.e.brandt@intel.com>" },
43                             {id: "webapps-annex@0.0", version: "0.0.10", name: "Annex", description: "Reversi/Othello", shortname: "", author: "Todd Brandt <todd.e.brandt@intel.com>" },
44                             {id: "webapps-memory-match@1.1", version: "1.1.7", name: "MemoryMatch", description: "Memory match", shortname: "", author: "Todd Brandt <todd.e.brandt@intel.com>"  }
45                        ]}};
46                    
47                    /* "jtype":"AJB_reply","request":{"prefix":"afm-main","api":"runnables","status":"processed"},"response":{"runnables":[{"id":"webapps-annex@0.0","version":"0.0.10","width":0,"height":0,"name":"Annex","description":"Reversi/Othello","shortname":"","author":"Todd Brandt <todd.e.brandt@intel.com>"},{"id":"webapps-rabbit@0.0","version":"0.0.8","width":0,"height":0,"name":"Rabbit","description":"Fun grid game where the rabbit finds and eats the carrots dodging the foxes.","shortname":"","author":"Todd Brandt <todd.e.brandt@intel.com>"}]}}*/
48                     
49         res.send(Response);
50     });
51 }
52
53 // Export Class
54 module.exports = NewApi;