Enable swagger UI for proxied API 83/49383/1
authorYun Huang <yun.huang@windriver.com>
Tue, 29 May 2018 15:10:53 +0000 (23:10 +0800)
committerYun Huang <yun.huang@windriver.com>
Tue, 29 May 2018 15:10:53 +0000 (23:10 +0800)
Change-Id: I46b561f5547d2c11cfd45bfc0ad0f06ace53c5d5
Issue-ID: MULTICLOUD-240
Signed-off-by: Yun Huang <yun.huang@windriver.com>
share/newton_base/swagger/multicloud.identity.swagger.json
share/newton_base/swagger/multicloud.services.swagger.json [new file with mode: 0644]
share/newton_base/swagger/views.py

index b802064..e2aeccc 100644 (file)
                     }
                 ],
                 "responses": {
-                    "200": {
+                    "201": {
+                        "description": "successful operation",
+                        "type": "string"
+                    },
+                    "404": {
+                        "description": "the vim id or tenant name is wrong"
+                    },
+                    "500": {
+                        "description": "the vim instance is not accessable"
+                    }
+                }
+            }
+        },
+        "/{vimid}/identity/v2.0/tokens": {
+            "post": {
+                "tags": [
+                    "MultiCloud Identity Proxy"
+                ],
+                "summary": "Authenticate and get Catalog of endpoints",
+                "description": "Authenticate to get token and catalog of service endpoints",
+                "operationId": "authenticate",
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "parameters": [
+                    {
+                        "name": "vimid",
+                        "in": "path",
+                        "description": "vim instance id, composed by {cloud-owner}_{cloud-region-id}",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "tenant_name",
+                        "in": "body",
+                        "description": "tenant name",
+                        "required": false,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "201": {
                         "description": "successful operation",
                         "type": "string"
                     },
diff --git a/share/newton_base/swagger/multicloud.services.swagger.json b/share/newton_base/swagger/multicloud.services.swagger.json
new file mode 100644 (file)
index 0000000..0cc9a64
--- /dev/null
@@ -0,0 +1,284 @@
+{
+    "swagger": "2.0",
+    "info": {
+        "version": "1.0.0",
+        "title": "MultiVIM Service rest API"
+    },
+    "basePath": "/api/multicloud-newton/v0/",
+    "tags": [
+        {
+            "name": "MultiVIM services"
+        }
+    ],
+    "paths": {
+        "/{vimid}/{service_type}/{resource_type}": {
+            "post": {
+                "tags": [
+                    "MultiCloud Service Proxy"
+                ],
+                "summary": "create a resource",
+                "description": "create a resource",
+                "operationId": "create_openstack_resource",
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "parameters": [
+                    {
+                        "name": "vimid",
+                        "in": "path",
+                        "description": "vim instance id",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "service_type",
+                        "in": "path",
+                        "description": "service type:identity, compute, network, server,volume,volumev2,image, etc",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "resource_type",
+                        "in": "path",
+                        "description": "resource type:flavors,servers,etc.",
+                        "required": true,
+                        "type": "string"
+                    },
+                                       {
+                        "name": "X-Auth-Token",
+                        "in": "header",
+                        "description": "authenticated token",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "in": "body",
+                        "name": "body",
+                        "description": "parameters to create a openstack resource",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "201": {
+                        "description": "successful operation",
+                        "type": "string"
+                    },
+                    "404": {
+                        "description": "the vim id is wrong"
+                    },
+                    "500": {
+                        "description": "the vim instance is not accessable"
+                    }
+                }
+            },
+            "get": {
+                "tags": [
+                    "MultiCloud Service Proxy"
+                ],
+                "summary": "query openstack resource list",
+                "description": "query openstack resource list",
+                "operationId": "query_openstack_resource",
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "parameters": [
+                    {
+                        "name": "vimid",
+                        "in": "path",
+                        "description": "vim instance id",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "service_type",
+                        "in": "path",
+                        "description": "service type:identity, compute, network, server,volume,volumev2,image, etc",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "resource_type",
+                        "in": "path",
+                        "description": "resource type:flavors,servers,etc.",
+                        "required": true,
+                        "type": "string"
+                    },
+                                       {
+                        "name": "X-Auth-Token",
+                        "in": "header",
+                        "description": "authenticated token",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "name",
+                        "in":  "query",
+                        "description": "resource name to filter list",
+                        "required": false,
+                        "type": "string"
+                    },
+                    {
+                        "name": "limit",
+                        "in":  "query",
+                        "description": "Requests a page size of items",
+                        "required": false,
+                        "type": "string"
+                    },
+                    {
+                        "name": "marker",
+                        "in":  "query",
+                        "description": "image ID of the last-seen item",
+                        "required": false,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "successful operation",
+                        "type": "string"
+                    },
+                    "404": {
+                        "description": "the vim id is wrong"
+                    },
+                    "500": {
+                        "description": "the vim flavor is not accessable"
+                    }
+                }
+            }
+        },
+        "/{vimid}/{service_type}/{resource_type}/{resource_id}": {
+            "delete": {
+                "tags": [
+                    "MultiCloud Service Proxy"
+                 ],
+                 "summary": "delete a openstack resource",
+                "description": "delete a openstack resource",
+                "operationId": "delete_a_openstack_resource",
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "parameters": [
+                    {
+                        "name": "vimid",
+                        "in": "path",
+                        "description": "vim instance id",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "service_type",
+                        "in": "path",
+                        "description": "service type:identity, compute, network, server,volume,volumev2,image, etc",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "resource_type",
+                        "in": "path",
+                        "description": "resource type:flavors,servers,etc.",
+                        "required": true,
+                        "type": "string"
+                    },
+                                       {
+                        "name": "X-Auth-Token",
+                        "in": "header",
+                        "description": "authenticated token",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "resource_id",
+                        "in": "path",
+                        "description": "resource id",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "204": {
+                        "description": "successful operation"
+                    },
+                    "404": {
+                        "description": "the vim id is wrong"
+                    },
+                    "500": {
+                        "description": "the resource is not accessable"
+                    }
+                }
+            },
+            "get": {
+                "tags": [
+                    "MultiCloud Service Proxy"
+                ],
+                "summary": "query a openstack resource",
+                "description": "query a openstack resource",
+                "operationId": "query_a_openstack_resource",
+                "consumes": [
+                    "application/json"
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "parameters": [
+                    {
+                        "name": "vimid",
+                        "in": "path",
+                        "description": "vim instance id",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "service_type",
+                        "in": "path",
+                        "description": "service type:identity, compute, network, server,volume,volumev2,image, etc",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "resource_type",
+                        "in": "path",
+                        "description": "resource type:flavor,server,etc.",
+                        "required": true,
+                        "type": "string"
+                    },
+                                       {
+                        "name": "X-Auth-Token",
+                        "in": "header",
+                        "description": "authenticated token",
+                        "required": true,
+                        "type": "string"
+                    },
+                    {
+                        "name": "resource_id",
+                        "in": "path",
+                        "description": "resource id",
+                        "required": true,
+                        "type": "string"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "successful operation",
+                        "type": "string"
+                    },
+                    "404": {
+                        "description": "the vim id is wrong"
+                    },
+                    "500": {
+                        "description": "the resource is not accessable"
+                    }
+                }
+            }
+        }
+    }
+}
index 839abea..0e3722e 100644 (file)
@@ -90,6 +90,12 @@ class SwaggerJsonView(APIView):
         f.close()
         json_data["paths"].update(json_data_temp["paths"])
 
+        json_file = os.path.join(os.path.dirname(__file__), 'multicloud.services.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)