Completed REST api
[osm/vim-emu.git] / src / emuvim / api / sonata / README.md
1 # SONATA dummy gatekeeper API:
2
3 ## Upload a package (*.son) file:
4
5 To upload the file `sonata-demo.son` (from son-schema repo) do:
6
7 * `curl -i -X POST -F file=@sonata-demo.son http://127.0.0.1:8000/api/packages`
8
9 To list all uploaded packages do:
10
11 * `curl http://127.0.0.1:8000/api/packages`
12
13 To instantiate (start) a service do:
14
15 * Specific service: `curl -X POST http://127.0.0.1:8000/api/instantiations -d "{\"service_uuid\":\"59446b64-f941-40a8-b511-effb0512c21b\"}"`
16 * Last uploaded service (makes manual tests easier): `curl -X POST http://127.0.0.1:8000/api/instantiations -d "{}"`
17
18 To list all running services do:
19
20 * `curl http://127.0.0.1:8000/api/instantiations`
21
22
23 ## API definition
24
25 This page describes the dummy gatekeeper API. This gatekeeper fakes the original platform gatekeeper during development SDK tools like son-push. 
26
27 It is also able to deploy our example service package (not any arbitrary service package!) in the emulator for the Y1 demo.
28
29 _Note: This API should converge to the API of the original GK as much as possible!_
30
31 ## REST API:
32 <table>
33 <tr>
34 <th>Endpoint:</th>
35 <th>Method:</th>
36 <th>Header:</th>
37 <th>Body:</th>
38 <th>Response:</th>
39 </tr>
40 <tr>
41 <td>/api/packages</td>
42 <td>POST</td>
43 <td>-</td>
44 <td>{file-content} as enctype=multipart/form-data</td>
45 <td>{"service_uuid": "c880aaab-f3b9-43ac-ac6b-3d27b46146b7", size=456, sha1=49ee6468dfa4ecbad440d669b249d523a38651be, error: null}</td>
46 </tr>
47 <tr>
48 <td>/api/packages</td>
49 <td>GET</td>
50 <td>-</td>
51 <td></td>
52 <td>{service_uuid_list: ["c880aaab-f3b9-43ac-ac6b-3d27b46146b7", "c880aaab-f3b9-43ac-ac6b-3d27b46146b8", "c880aaab-f3b9-43ac-ac6b-3d27b46146b9"]}</td>
53 </tr>
54 <tr>
55 <td>/api/instantiations</td>
56 <td>POST</td>
57 <td>-</td>
58 <td>{service_uuid: "c880aaab-f3b9-43ac-ac6b-3d27b46146b7"}</td>
59 <td>{service_instance_uuid: "de4567-f3b9-43ac-ac6b-3d27b461123"}</td>
60 </tr>
61 <tr>
62 <td>/api/instantiations</td>
63 <td>GET</td>
64 <td>-</td>
65 <td></td>
66 <td>
67 {
68     "service_instance_list": [
69         [
70             "9da044b3-1f7a-40e6-a9b3-9e83a9834249", 
71             "9371df14-a595-436a-92b5-fc243b74a9d7"
72         ]
73     ]
74 }
75 </td>
76 </tr>
77 </table>
78
79 ## Run REST API as part of the emulator:
80
81 * `sudo python src/emuvim/examples/sonata_y1_demo_topology_1.py`
82
83 ## Run REST API in standalone mode (without emulator):
84
85 * `sudo python src/emuvim/api/sonata/dummygatekeeper.py`