summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-05-29 23:10:53 +0800
committerYun Huang <yun.huang@windriver.com>2018-05-29 23:10:53 +0800
commit785f119effd057e0e5e44ab2e1d1f3ec90c5ce5d (patch)
tree86059c6690d6cb1dea7e90436171309a80c94f1b
parent5b67d58f7d59eaf81f15c21eef12a46c9d7e7688 (diff)
Enable swagger UI for proxied API
Change-Id: I46b561f5547d2c11cfd45bfc0ad0f06ace53c5d5 Issue-ID: MULTICLOUD-240 Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r--share/newton_base/swagger/multicloud.identity.swagger.json46
-rw-r--r--share/newton_base/swagger/multicloud.services.swagger.json284
-rw-r--r--share/newton_base/swagger/views.py6
3 files changed, 335 insertions, 1 deletions
diff --git a/share/newton_base/swagger/multicloud.identity.swagger.json b/share/newton_base/swagger/multicloud.identity.swagger.json
index b8020648..e2aeccc3 100644
--- a/share/newton_base/swagger/multicloud.identity.swagger.json
+++ b/share/newton_base/swagger/multicloud.identity.swagger.json
@@ -42,7 +42,51 @@
}
],
"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
index 00000000..0cc9a642
--- /dev/null
+++ b/share/newton_base/swagger/multicloud.services.swagger.json
@@ -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"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/share/newton_base/swagger/views.py b/share/newton_base/swagger/views.py
index 839abea2..0e3722ec 100644
--- a/share/newton_base/swagger/views.py
+++ b/share/newton_base/swagger/views.py
@@ -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)