Enable swagger UI for proxied API of capacity 71/49471/1
authorYun Huang <yun.huang@windriver.com>
Wed, 30 May 2018 10:15:36 +0000 (18:15 +0800)
committerYun Huang <yun.huang@windriver.com>
Wed, 30 May 2018 10:15:36 +0000 (18:15 +0800)
Change-Id: I429c77dafd14a639ff607272ce86a37dd27f3c83
Issue-ID: MULTICLOUD-240
Signed-off-by: Yun Huang <yun.huang@windriver.com>
share/newton_base/swagger/multicloud.capacity.swagger.json [new file with mode: 0644]
share/newton_base/swagger/views.py

diff --git a/share/newton_base/swagger/multicloud.capacity.swagger.json b/share/newton_base/swagger/multicloud.capacity.swagger.json
new file mode 100644 (file)
index 0000000..903458a
--- /dev/null
@@ -0,0 +1,66 @@
+{
+    "swagger": "2.0",
+    "info": {
+        "version": "1.0.0",
+        "title": "MultiVIM Capacity check rest API"
+    },
+    "basePath": "/api/multicloud-newton/v0/",
+    "tags": [
+        {
+            "name": "MultiVIM Capacity check"
+        }
+    ],
+    "paths": {
+        "/{vimid}/capacity_check": {
+            "post": {
+                "tags": [
+                    "MultiCloud Capacity Proxy"
+                ],
+                "summary": "check capacity",
+                "description": "check capacity",
+                "operationId": "check_openstack_capacity",
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "parameters": [
+                    {
+                        "name": "vimid",
+                        "in": "path",
+                        "description": "vim instance id",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "X-Auth-Token",
+                        "in": "header",
+                        "description": "authenticated token",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "body",
+                        "name": "body",
+                        "description": "parameters to check openstack capacity",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "successful operation",
+                        "type": "string"
+                    },
+                    "404": {
+                        "description": "the vim id is wrong"
+                    },
+                    "500": {
+                        "description": "the vim capacity check is not accessable"
+                    }
+                }
+            }
+        }
+    }
+}
index 0e3722e..165cf01 100644 (file)
@@ -96,6 +96,12 @@ class SwaggerJsonView(APIView):
         f.close()
         json_data["paths"].update(json_data_temp["paths"])
 
+        json_file = os.path.join(os.path.dirname(__file__), 'multicloud.capacity.swagger.json')
+        f = open(json_file)
+        json_data_temp = json.JSONDecoder().decode(f.read())
+        f.close()
+        json_data["paths"].update(json_data_temp["paths"])
+
         json_data["basePath"] = "/api/multicloud-newton/v0/"
         json_data["info"]["title"] = "Service NBI of MultiCloud plugin for OpenStack Newton"
         return Response(json_data)