From 4ade9ad1887d2ccdfa81596e9f22108cd90bf774 Mon Sep 17 00:00:00 2001 From: maopengzhang Date: Thu, 24 Aug 2017 18:20:20 +0800 Subject: [PATCH] swagger supports multifile Split the swagger into multi files to nslcm,vnflcm,etc. Change-Id: Ic9b645798316df9048528a84305af44855af7dd5 Issue-ID: VFC-145 Signed-off-by: maopengzhang --- lcm/ns/swagger.json | 1501 ----------------------------------- lcm/ns/urls.py | 1 - lcm/settings.py | 3 +- lcm/swagger/__init__.py | 10 + lcm/swagger/tests.py | 30 + lcm/swagger/urls.py | 23 + lcm/swagger/vfc.db.swagger.json | 758 ++++++++++++++++++ lcm/swagger/vfc.nslcm.swagger.json | 537 +++++++++++++ lcm/swagger/vfc.others.swagger.json | 135 ++++ lcm/swagger/vfc.sfclcm.swagger.json | 237 ++++++ lcm/swagger/vfc.vllcm.swagger.json | 238 ++++++ lcm/swagger/vfc.vnflcm.swagger.json | 232 ++++++ lcm/swagger/views.py | 73 ++ lcm/urls.py | 1 + 14 files changed, 2276 insertions(+), 1503 deletions(-) delete mode 100644 lcm/ns/swagger.json create mode 100644 lcm/swagger/__init__.py create mode 100644 lcm/swagger/tests.py create mode 100644 lcm/swagger/urls.py create mode 100644 lcm/swagger/vfc.db.swagger.json create mode 100644 lcm/swagger/vfc.nslcm.swagger.json create mode 100644 lcm/swagger/vfc.others.swagger.json create mode 100644 lcm/swagger/vfc.sfclcm.swagger.json create mode 100644 lcm/swagger/vfc.vllcm.swagger.json create mode 100644 lcm/swagger/vfc.vnflcm.swagger.json create mode 100644 lcm/swagger/views.py diff --git a/lcm/ns/swagger.json b/lcm/ns/swagger.json deleted file mode 100644 index e8a1f388..00000000 --- a/lcm/ns/swagger.json +++ /dev/null @@ -1,1501 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "version": "1.0.0", - "title": "ONAP VFC Service Rest API" - }, - "basePath": "/api/nslcm/v1", - "tags": [ - { - "name": "vfc nslcm resource" - } - ], - "paths": { - "/nspackage": { - "post": { - "tags": [ - "ns package Resource" - ], - "summary": "ns package distribute", - "description": "ns package distribute", - "operationId": "ns_pkg_distribute", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "distribute request param", - "required": true, - "schema": { - "$ref": "#/definitions/NsPkgPostRequest" - } - } - ], - "responses": { - "202": { - "description": "", - "schema": { - "$ref": "#/definitions/NsPkgPostResponse" - } - }, - "500": { - "description": "internal error" - } - } - } - }, - "/nspackage/{csarId}": { - "get": { - "tags": [ - "ns package Resource" - ], - "summary": "query one ns package info", - "description": "query one ns package info", - "operationId": "query_one_ns_package", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "csarId", - "in": "path", - "description": "csar id of ns package", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/NsPackageInfo" - } - }, - "500": { - "description": "internal error" - } - } - }, - "delete": { - "tags": [ - "ns package Resource" - ], - "summary": "delete ns pkg", - "description": "delete ns pkg", - "operationId": "delete_ns_pkg", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "csarId", - "in": "path", - "description": "csar id of ns package", - "required": true, - "type": "string" - } - ], - "responses": { - "202": { - "description": "", - "schema": { - "$ref": "#/definitions/NsPkgPostResponse" - } - }, - "500": { - "description": "internal error" - } - } - } - }, - "/vnfpackage": { - "get": { - "tags": [ - "nf package Resource" - ], - "summary": "query nf package info", - "description": "query nf package info", - "operationId": "query_nf_package", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/NfPackageListInfo" - } - }, - "500": { - "description": "internal error" - } - } - }, - "post": { - "tags": [ - "nf package Resource" - ], - "summary": "nf package distribute", - "description": "nf package distribute", - "operationId": "nf_pkg_distribute", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "distribute request param", - "required": true, - "schema": { - "$ref": "#/definitions/NfPkgPostRequest" - } - } - ], - "responses": { - "202": { - "description": "", - "schema": { - "$ref": "#/definitions/NfPkgPostResponse" - } - }, - "500": { - "description": "internal error" - } - } - } - }, - "/vnfpackage/{csarId}": { - "get": { - "tags": [ - "nf package Resource" - ], - "summary": "query one nf package info", - "description": "query one nf package info", - "operationId": "query_one_nf_package", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "csarId", - "in": "path", - "description": "csar id of nf package", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/NfPackageInfo" - } - }, - "500": { - "description": "internal error" - } - } - }, - "delete": { - "tags": [ - "nf package Resource" - ], - "summary": "delete nf pkg", - "description": "delete nf pkg", - "operationId": "delete_nf_pkg", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "csarId", - "in": "path", - "description": "csar id of nf package", - "required": true, - "type": "string" - } - ], - "responses": { - "202": { - "description": "", - "schema": { - "$ref": "#/definitions/NfPkgPostResponse" - } - }, - "500": { - "description": "internal error" - } - } - } - }, - "/ns/vls": { - "post": { - "tags": [ - "vls Resource" - ], - "summary": "vl create", - "description": "", - "operationId": "create_vl", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "instantiate request param", - "required": true, - "schema": { - "$ref": "#/definitions/VlPostRequest" - } - } - ], - "responses": { - "201": { - "description": "", - "schema": { - "$ref": "#/definitions/VlPostResponse" - } - } - } - } - }, - "/ns/vls/{vlId}": { - "get": { - "tags": [ - "vls Resource" - ], - "summary": "query the specified vl info", - "description": "", - "operationId": "query_vl", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "vlId", - "in": "path", - "description": "vl instance id", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/VlInfo" - } - }, - "404": { - "description": "the vl instance id is wrong" - }, - "500": { - "description": "the url is invalid" - } - } - }, - "delete": { - "tags": [ - "vls Resource" - ], - "summary": "delete vl", - "description": "", - "operationId": "delete_vl", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "", - "name": "vlId", - "in": "path" - } - ], - "responses": { - "204": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/DeleteVlResponse" - } - }, - "404": { - "description": "the vl instance id is wrong" - }, - "500": { - "description": "the url is invalid" - } - } - } - }, - "/ns/vnfs": { - "post": { - "tags": [ - "vnfs Resource" - ], - "summary": "vnf create", - "description": "", - "operationId": "create_vnf", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "instantiate request param", - "required": true, - "schema": { - "$ref": "#/definitions/VnfPostRequest" - } - } - ], - "responses": { - "201": { - "description": "", - "schema": { - "$ref": "#/definitions/VnfPostResponse" - } - } - } - } - }, - "/ns/vnfs/{vnfInstId}": { - "get": { - "tags": [ - "vnfs Resource" - ], - "summary": "query the specified vnf info", - "description": "", - "operationId": "query_vnf", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "vnfInstId", - "in": "path", - "description": "vnf instance id", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/VnfInfo" - } - }, - "404": { - "description": "the vnf instance id is wrong" - }, - "500": { - "description": "the url is invalid" - } - } - }, - "delete": { - "tags": [ - "vnfs Resource" - ], - "summary": "delete vnf", - "description": "", - "operationId": "delete_vnf", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "", - "name": "vnfInstId", - "in": "path" - } - ], - "responses": { - "204": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/DeleteResponse" - } - }, - "404": { - "description": "the vl instance id is wrong" - }, - "500": { - "description": "the url is invalid" - } - } - } - }, - "/ns/sfcs": { - "post": { - "tags": [ - "sfcs Resource" - ], - "summary": "sfc create", - "description": "", - "operationId": "create_sfc", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "in": "body", - "name": "body", - "description": "request param", - "required": true, - "schema": { - "$ref": "#/definitions/SfcPostRequest" - } - } - ], - "responses": { - "201": { - "description": "", - "schema": { - "$ref": "#/definitions/SfcPostResponse" - } - } - } - } - }, - "/ns/sfcs/{sfcInstId}": { - "get": { - "tags": [ - "sfcs Resource" - ], - "summary": "query the specified sfc info", - "description": "", - "operationId": "query_sfc", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "name": "sfcInstId", - "in": "path", - "description": "sfc instance id", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/SfcInfo" - } - }, - "404": { - "description": "the sfc instance id is wrong" - }, - "500": { - "description": "the url is invalid" - } - } - }, - "delete": { - "tags": [ - "vnfs Resource" - ], - "summary": "delete sfc", - "description": "", - "operationId": "delete_sfc", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "", - "name": "sfcInstId", - "in": "path" - } - ], - "responses": { - "204": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/DeleteResponse" - } - }, - "404": { - "description": "the sfc instance id is wrong" - }, - "500": { - "description": "the url is invalid" - } - } - } - }, - "/ns/{nsInstanceId}/postdeal": { - "post": { - "tags": [ - "ns postdeal" - ], - "summary": "ns postdeal", - "description": "", - "operationId": "ns_postdeal", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "", - "name": "nsInstanceId", - "in": "path" - }, - { - "in": "body", - "name": "body", - "description": "request param", - "required": true, - "schema": { - "$ref": "#/definitions/NSInstPostDetailRequest" - } - } - ], - "responses": { - "202": { - "description": "" - } - } - } - }, - "/ns/{nsInstanceId}/scale": { - "post": { - "tags": [ - "ns scale" - ], - "summary": "ns scale", - "description": "ns scale", - "operationId": "ns_scale", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "", - "name": "nsInstanceId", - "in": "path" - }, - { - "in": "body", - "name": "ScaleNSRequest", - "description": "Scale NS Request Body", - "required": true, - "schema": { - "$ref": "#/definitions/ScaleNsRequest" - } - } - ], - "responses": { - "200": { - "description": "", - "schema": { - "$ref": "#/definitions/NsScaleResponse" - } - }, - "201": { - "description": "Invalid Request" - } - } - } - }, - "/ns/{ns_instance_id}": { - "delete": { - "tags": [ - "ns lcm" - ], - "summary": "ns delete", - "description": "ns delete", - "operationId": "ns_delete", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "Identifier of the NS instance.", - "name": "ns_instance_id", - "in": "path" - } - ], - "responses": { - "204": { - "description": "The NS instance resource and the associated NS identifier were deleted successfully." - } - } - } - }, - "/ns/{ns_instance_id}/terminate": { - "post": { - "tags": [ - "ns lcm" - ], - "summary": "ns terminate", - "description": "ns terminate", - "operationId": "ns_terminate", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "Identifier of the NS instance.", - "name": "ns_instance_id", - "in": "path" - }, - { - "in": "body", - "name": "NsTerminateRequest", - "description": "NsTerminateRequest", - "required": true, - "schema": { - "$ref": "#/definitions/NsTerminateRequest" - } - } - ], - "responses": { - "202": { - "description": "", - "schema": { - "$ref": "#/definitions/NsTerminateResponse" - } - }, - "500": { - "description": "the url is invalid" - } - } - } - }, - "/ns/{ns_instance_id}/heal": { - "post": { - "tags": [ - "ns heal" - ], - "summary": "ns heal", - "description": "ns heal", - "operationId": "ns_heal", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "Identifier of the NS instance.", - "name": "ns_instance_id", - "in": "path" - }, - { - "in": "body", - "name": "healVnfData", - "description": "healVnfData", - "required": true, - "schema": { - "$ref": "#/definitions/healVnfDataRequest" - } - } - ], - "responses": { - "202": { - "description": "", - "schema": { - "$ref": "#/definitions/healVnfDataResponse" - } - }, - "500": { - "description": "the url is invalid" - } - } - } - }, - "/mandb/{modelName}": { - "get": { - "tags": [ - "ns lcm" - ], - "summary": "query ns table info", - "description": "query ns table info", - "operationId": "query_ns_table", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "model Name.", - "name": "modelName", - "in": "path" - } - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/TableInfo" - } - }, - "500": { - "description": "the url is invalid" - } - } - }, - "delete": { - "tags": [ - "ns lcm" - ], - "summary": "ns table delete", - "description": "ns table delete", - "operationId": "ns_table_delete", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "model Name.", - "name": "modelName", - "in": "path" - } - ], - "responses": { - "204": { - "description": "The tables were deleted successfully." - } - } - } - }, - "/ns": { - "get": { - "tags": [ - "ns lcm" - ], - "summary": "ns get", - "description": "ns get", - "operationId": "ns_get", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - - ], - "responses": { - "200": { - "description": "successful operation", - "schema": { - "$ref": "#/definitions/NsInfo" - } - } - } - } - }, - "/jobs/{jobId}":{ - "post": { - "tags": [ - "jobstatus" - ], - "summary": "jobstatus", - "description": "", - "operationId": "jobstatus", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "parameters": [ - { - "required": true, - "type": "string", - "description": "", - "name": "jobId", - "in": "path" - }, - { - "in": "body", - "name": "body", - "description": "request param", - "required": true, - "schema": { - "$ref": "#/definitions/JobProgressRequest" - } - } - ], - "responses": { - "202": { - "description": "" - } - } - } - } - }, - "definitions": { - "NsPkgPostRequest": { - "type": "object", - "properties": { - "csarId": { - "type": "string" - } - } - }, - "NsPkgPostResponse": { - "type": "object", - "properties": { - "status": { - "type": "string" - }, - "statusDescription": { - "type": "string" - }, - "errorCode": { - "type": "string" - } - } - }, - - "NsPackageInfo": { - "type": "object", - "properties": { - "csarId": { - "type": "string" - }, - "packageInfo": { - "$ref": "#/definitions/NsPkgDetailInfo" - }, - "nsInstanceInfo": { - "$ref": "#/definitions/NsInstListInfo" - } - } - }, - "NsPkgDetailInfo": { - "type": "object", - "properties": { - "nsdId": { - "type": "string" - }, - "nsdProvider": { - "type": "string" - }, - "nsdVersion": { - "type": "string" - } - } - }, - "NsInstListInfo": { - "type": "array", - "items": { - "type": "object" - } - }, - "NfPkgPostRequest": { - "type": "object", - "properties": { - "csarId": { - "type": "string" - } - } - }, - "NfPkgPostResponse": { - "type": "object", - "properties": { - "jobId": { - "type": "string" - } - } - }, - "NfPackageListInfo": { - "type": "object", - "properties": { - "csars": { - "$ref": "#/definitions/NfPkgListInfo" - } - } - }, - "NfPkgListInfo": { - "type": "array", - "items": { - "type": "object" - } - }, - "NfPackageInfo": { - "type": "object", - "properties": { - "csarId": { - "type": "string" - }, - "packageInfo": { - "$ref": "#/definitions/NfPkgDetailInfo" - }, - "imageInfo": { - "$ref": "#/definitions/NfPkgImgInfo" - }, - "vnfInstanceInfo": { - "$ref": "#/definitions/NfInstListInfo" - } - } - }, - "NfPkgDetailInfo": { - "type": "object", - "properties": { - "vnfdId": { - "type": "string" - }, - "vnfdProvider": { - "type": "string" - }, - "vnfdVersion": { - "type": "string" - }, - "vnfVersion": { - "type": "string" - } - } - }, - "NfInstListInfo": { - "type": "array", - "items": { - "type": "object" - } - }, - "NfPkgImgInfo": { - "type": "array", - "items": { - "type": "object" - } - }, - "VlPostRequest": { - "type": "object", - "properties": { - "jobId": { - "type": "string" - }, - "nsInstanceId": { - "type": "string" - }, - "flavourId": { - "type": "string" - }, - "sapData": { - "type": "array", - "items": { - "type": "object" - } - }, - "pnfInfo": { - "type": "array", - "items": { - "type": "object" - } - }, - "vnfInstanceData": { - "type": "array", - "items": { - "type": "object" - } - }, - "nestedNsInstanceId": { - "type": "array", - "items": { - "type": "object" - } - }, - "locationConstraints": { - "type": "array", - "items": { - "type": "object" - } - }, - "additionalParamForNs": { - "type": "array", - "items": { - "type": "object" - } - }, - "additionalParamForVnf": { - "type": "array", - "items": { - "type": "object" - } - }, - "extNSVirtualLink": { - "type": "array", - "items": { - "type": "object" - } - }, - "context": { - "type": "string" - }, - "vlIndex": { - "type": "string" - } - } - }, - "VlPostResponse": { - "type": "object", - "properties": { - "result": { - "type": "integer", - "enum": [ - 0, - 1 - ] - }, - "detail": { - "type": "string" - }, - "vlId": { - "type": "string" - } - } - }, - "VnfPostRequest": { - "type": "object", - "properties": { - "jobId": { - "type": "string" - }, - "nsInstanceId": { - "type": "string" - }, - "flavourId": { - "type": "string" - }, - "sapData": { - "type": "array", - "items": { - "type": "object" - } - }, - "pnfInfo": { - "type": "array", - "items": { - "type": "object" - } - }, - "vnfInstanceData": { - "type": "array", - "items": { - "type": "object" - } - }, - "nestedNsInstanceId": { - "type": "array", - "items": { - "type": "object" - } - }, - "locationConstraints": { - "type": "array", - "items": { - "type": "object" - } - }, - "additionalParamForNs": { - "type": "array", - "items": { - "type": "object" - } - }, - "additionalParamForVnf": { - "type": "array", - "items": { - "type": "object" - } - }, - "extNSVirtualLink": { - "type": "array", - "items": { - "type": "object" - } - }, - "context": { - "type": "string" - }, - "vnfIndex": { - "type": "string" - } - } - }, - "VnfPostResponse": { - "type": "object", - "properties": { - "vnfInstId": { - "type": "string" - }, - "jobId": { - "type": "string" - } - } - }, - "SfcPostRequest": { - "type": "object", - "properties": { - "jobId": { - "type": "string" - }, - "nsInstanceId": { - "type": "string" - }, - "sapData": { - "type": "array", - "items": { - "type": "object" - } - }, - "vnfInstanceData": { - "type": "array", - "items": { - "type": "object" - } - }, - "additionalParamForNs": { - "type": "array", - "items": { - "type": "object" - } - }, - "additionalParamForVnf": { - "type": "array", - "items": { - "type": "object" - } - }, - "sdnControllerId": { - "type": "string" - }, - "context": { - "type": "string" - }, - "fpindex": { - "type": "string" - } - } - }, - "NSInstPostDetailRequest": { - "type": "object", - "properties": { - "status": { - "type": "string" - } - } - }, - "JobProgressRequest": { - "type": "object", - "properties": { - "progress": { - "type": "string" - }, - "desc": { - "type": "string" - }, - "errcode": { - "type": "string" - } - } - }, - "SfcPostResponse": { - "type": "object", - "properties": { - "sfcInstId": { - "type": "string" - }, - "jobId": { - "type": "string" - } - } - }, - "VlInfo": { - "type": "object", - "properties": { - "vlId": { - "type": "string" - }, - "vlName": { - "type": "string" - }, - "vlStatus": { - "type": "string" - } - } - }, - "VnfInfo": { - "type": "object", - "properties": { - "vnfInstId": { - "type": "string" - }, - "vnfName": { - "type": "string" - }, - "vnfStatus": { - "type": "string" - } - } - }, - "SfcInfo": { - "type": "object", - "properties": { - "sfcInstId": { - "type": "string" - }, - "sfcName": { - "type": "string" - }, - "sfcStatus": { - "type": "string" - } - } - }, - "DeleteVlResponse": { - "type": "object", - "properties": { - "result": { - "type": "integer", - "enum": [ - 0, - 1 - ] - }, - "detail": { - "type": "string" - } - } - }, - "DeleteResponse": { - "type": "object", - "properties": { - "result": { - "type": "integer", - "enum": [ - 0, - 1 - ] - }, - "detail": { - "type": "string" - } - } - }, - "ScaleNsRequest": { - "type": "object", - "properties": { - "scaleType":{ - "type": "string" - }, - "scaleNsByStepsData": { - "$ref": "#/definitions/ScaleNsByStepsData" - } - } - }, - "ScaleNsByStepsData": { - "type": "object", - "properties": { - "scalingDirection": { - "type": "string" - }, - "aspectId": { - "type": "string" - }, - "numberOfSteps": { - "type": "integer" - } - } - }, - "NsScaleResponse": { - "type": "object", - "properties": { - "jobID": { - "type": "string" - } - } - }, - "NsTerminateRequest": { - "type": "object", - "properties": { - "terminationType": { - "type": "string" - }, - "gracefulTerminationTimeout": { - "type": "string" - } - } - }, - "NsTerminateResponse": { - "type": "object", - "properties": { - "jobID": { - "type": "string" - } - } - }, - "healVnfDataRequest": { - "type": "object", - "properties": { - "vnfInstanceId": { - "type": "string" - }, - "cause": { - "type": "string" - }, - "additionalParams": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "actionvminfo": { - "type": "object", - "properties": { - "vmid": { - "type": "string" - }, - "vmname": { - "type": "string" - } - } - } - } - } - } - }, - "healVnfDataResponse": { - "type": "object", - "properties": { - "jobId": { - "type": "string" - } - } - }, - "TableInfo": { - "type": "object", - "properties": { - "count": { - "type": "string" - } - } - }, - "NsInfo": { - "type": "object", - "properties": { - "vnfInfoId": { - "type": "string" - }, - "vlInfo": { - "type": "string" - }, - "nsState": { - "type": "string" - }, - "description": { - "type": "string" - }, - "nsName": { - "type": "string" - }, - "nsInstanceId": { - "type": "string" - }, - "nsdId": { - "type": "string" - }, - "vnffgInfo": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/lcm/ns/urls.py b/lcm/ns/urls.py index a18efcc5..f2025bfd 100644 --- a/lcm/ns/urls.py +++ b/lcm/ns/urls.py @@ -19,7 +19,6 @@ from lcm.ns.views import CreateNSView, NSInstView, TerminateNSView, NSDetailView urlpatterns = patterns('', url(r'^api/nslcm/v1/ns$', CreateNSView.as_view()), - url(r'^api/nslcm/v1/swagger.json$', SwaggerJsonView.as_view()), url(r'^api/nslcm/v1/ns/(?P[0-9a-zA-Z_-]+)/instantiate$', NSInstView.as_view()), url(r'^api/nslcm/v1/ns/(?P[0-9a-zA-Z_-]+)/terminate$', diff --git a/lcm/settings.py b/lcm/settings.py index 1cf13714..8f9f732a 100644 --- a/lcm/settings.py +++ b/lcm/settings.py @@ -45,7 +45,8 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'rest_framework', 'lcm.pub.database', - 'lcm.samples' + 'lcm.samples', + 'lcm.swagger' ] MIDDLEWARE_CLASSES = [ diff --git a/lcm/swagger/__init__.py b/lcm/swagger/__init__.py new file mode 100644 index 00000000..49c7b944 --- /dev/null +++ b/lcm/swagger/__init__.py @@ -0,0 +1,10 @@ +# Copyright 2016-2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/lcm/swagger/tests.py b/lcm/swagger/tests.py new file mode 100644 index 00000000..b877609a --- /dev/null +++ b/lcm/swagger/tests.py @@ -0,0 +1,30 @@ +# Copyright 2016-2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +import unittest +import json +from django.test import Client +from rest_framework import status + + +class SampleViewTest(unittest.TestCase): + def setUp(self): + self.client = Client() + + def tearDown(self): + pass + + def test_sample(self): + response = self.client.get("/api/nslcm/v1/swagger.json") + print response + self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) +# resp_data = json.loads(response.content) +# self.assertEqual({"status": "active"}, resp_data) diff --git a/lcm/swagger/urls.py b/lcm/swagger/urls.py new file mode 100644 index 00000000..c3b8ad62 --- /dev/null +++ b/lcm/swagger/urls.py @@ -0,0 +1,23 @@ +# Copyright 2016-2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from django.conf.urls import patterns, url +from rest_framework.urlpatterns import format_suffix_patterns + +from lcm.swagger.views import SwaggerJsonView + +urlpatterns = patterns('', + url(r'^api/nslcm/v1/swagger.json$', SwaggerJsonView.as_view()) + ) + +urlpatterns = format_suffix_patterns(urlpatterns) diff --git a/lcm/swagger/vfc.db.swagger.json b/lcm/swagger/vfc.db.swagger.json new file mode 100644 index 00000000..98f7696b --- /dev/null +++ b/lcm/swagger/vfc.db.swagger.json @@ -0,0 +1,758 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "ONAP VFC Service Internal Rest API" + }, + "basePath": "/api/nslcm/v1", + "paths": { + "/ns/vls": { + "post": { + "tags": [ + "vls" + ], + "summary": "vl create", + "description": "", + "operationId": "create_vl", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "instantiate request param", + "required": true, + "schema": { + "$ref": "#/definitions/VlPostRequest" + } + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/VlPostResponse" + } + } + } + } + }, + "/ns/vls/{vlId}": { + "get": { + "tags": [ + "vls" + ], + "summary": "query the specified vl info", + "description": "", + "operationId": "query_vl", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vlId", + "in": "path", + "description": "vl instance id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VlInfo" + } + }, + "404": { + "description": "the vl instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "vls" + ], + "summary": "delete vl", + "description": "", + "operationId": "delete_vl", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "vlId", + "in": "path" + } + ], + "responses": { + "204": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/DeleteVlResponse" + } + }, + "404": { + "description": "the vl instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + } + }, + "/ns/vnfs": { + "post": { + "tags": [ + "vnfs" + ], + "summary": "vnf create", + "description": "", + "operationId": "create_vnf", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "instantiate request param", + "required": true, + "schema": { + "$ref": "#/definitions/VnfPostRequest" + } + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/VnfPostResponse" + } + } + } + } + }, + "/ns/vnfs/{vnfInstId}": { + "get": { + "tags": [ + "vnfs" + ], + "summary": "query the specified vnf info", + "description": "", + "operationId": "query_vnf", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vnfInstId", + "in": "path", + "description": "vnf instance id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VnfInfo" + } + }, + "404": { + "description": "the vnf instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "vnfs" + ], + "summary": "delete vnf", + "description": "", + "operationId": "delete_vnf", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "vnfInstId", + "in": "path" + } + ], + "responses": { + "204": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/DeleteResponse" + } + }, + "404": { + "description": "the vl instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + } + }, + "/ns/sfcs": { + "post": { + "tags": [ + "sfcs" + ], + "summary": "sfc create", + "description": "", + "operationId": "create_sfc", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "request param", + "required": true, + "schema": { + "$ref": "#/definitions/SfcPostRequest" + } + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/SfcPostResponse" + } + } + } + } + }, + "/ns/sfcs/{sfcInstId}": { + "get": { + "tags": [ + "sfcs" + ], + "summary": "query the specified sfc info", + "description": "", + "operationId": "query_sfc", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "sfcInstId", + "in": "path", + "description": "sfc instance id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/SfcInfo" + } + }, + "404": { + "description": "the sfc instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "vnfs" + ], + "summary": "delete sfc", + "description": "", + "operationId": "delete_sfc", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "sfcInstId", + "in": "path" + } + ], + "responses": { + "204": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/DeleteResponse" + } + }, + "404": { + "description": "the sfc instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + } + }, + "/ns/{nsInstanceId}/postdeal": { + "post": { + "tags": [ + "postdeal" + ], + "summary": "ns postdeal", + "description": "", + "operationId": "ns_postdeal", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "nsInstanceId", + "in": "path" + }, + { + "in": "body", + "name": "body", + "description": "request param", + "required": true, + "schema": { + "$ref": "#/definitions/NSInstPostDetailRequest" + } + } + ], + "responses": { + "202": { + "description": "" + } + } + } + }, + "/mandb/{modelName}": { + "get": { + "tags": [ + "db" + ], + "summary": "query ns table info", + "description": "query ns table info", + "operationId": "query_ns_table", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "model Name.", + "name": "modelName", + "in": "path" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/TableInfo" + } + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "db" + ], + "summary": "ns table delete", + "description": "ns table delete", + "operationId": "ns_table_delete", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "model Name.", + "name": "modelName", + "in": "path" + } + ], + "responses": { + "204": { + "description": "The tables were deleted successfully." + } + } + } + } + }, + "definitions": { + "VlPostRequest": { + "type": "object", + "properties": { + "jobId": { + "type": "string" + }, + "nsInstanceId": { + "type": "string" + }, + "flavourId": { + "type": "string" + }, + "sapData": { + "type": "array", + "items": { + "type": "object" + } + }, + "pnfInfo": { + "type": "array", + "items": { + "type": "object" + } + }, + "vnfInstanceData": { + "type": "array", + "items": { + "type": "object" + } + }, + "nestedNsInstanceId": { + "type": "array", + "items": { + "type": "object" + } + }, + "locationConstraints": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForNs": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForVnf": { + "type": "array", + "items": { + "type": "object" + } + }, + "extNSVirtualLink": { + "type": "array", + "items": { + "type": "object" + } + }, + "context": { + "type": "string" + }, + "vlIndex": { + "type": "string" + } + } + }, + "VlPostResponse": { + "type": "object", + "properties": { + "result": { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + "detail": { + "type": "string" + }, + "vlId": { + "type": "string" + } + } + }, + "VnfPostRequest": { + "type": "object", + "properties": { + "jobId": { + "type": "string" + }, + "nsInstanceId": { + "type": "string" + }, + "flavourId": { + "type": "string" + }, + "sapData": { + "type": "array", + "items": { + "type": "object" + } + }, + "pnfInfo": { + "type": "array", + "items": { + "type": "object" + } + }, + "vnfInstanceData": { + "type": "array", + "items": { + "type": "object" + } + }, + "nestedNsInstanceId": { + "type": "array", + "items": { + "type": "object" + } + }, + "locationConstraints": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForNs": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForVnf": { + "type": "array", + "items": { + "type": "object" + } + }, + "extNSVirtualLink": { + "type": "array", + "items": { + "type": "object" + } + }, + "context": { + "type": "string" + }, + "vnfIndex": { + "type": "string" + } + } + }, + "VnfPostResponse": { + "type": "object", + "properties": { + "vnfInstId": { + "type": "string" + }, + "jobId": { + "type": "string" + } + } + }, + "SfcPostRequest": { + "type": "object", + "properties": { + "jobId": { + "type": "string" + }, + "nsInstanceId": { + "type": "string" + }, + "sapData": { + "type": "array", + "items": { + "type": "object" + } + }, + "vnfInstanceData": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForNs": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForVnf": { + "type": "array", + "items": { + "type": "object" + } + }, + "sdnControllerId": { + "type": "string" + }, + "context": { + "type": "string" + }, + "fpindex": { + "type": "string" + } + } + }, + "NSInstPostDetailRequest": { + "type": "object", + "properties": { + "status": { + "type": "string" + } + } + }, + + "SfcPostResponse": { + "type": "object", + "properties": { + "sfcInstId": { + "type": "string" + }, + "jobId": { + "type": "string" + } + } + }, + "VlInfo": { + "type": "object", + "properties": { + "vlId": { + "type": "string" + }, + "vlName": { + "type": "string" + }, + "vlStatus": { + "type": "string" + } + } + }, + "VnfInfo": { + "type": "object", + "properties": { + "vnfInstId": { + "type": "string" + }, + "vnfName": { + "type": "string" + }, + "vnfStatus": { + "type": "string" + } + } + }, + "SfcInfo": { + "type": "object", + "properties": { + "sfcInstId": { + "type": "string" + }, + "sfcName": { + "type": "string" + }, + "sfcStatus": { + "type": "string" + } + } + }, + "DeleteVlResponse": { + "type": "object", + "properties": { + "result": { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + "detail": { + "type": "string" + } + } + }, + "DeleteResponse": { + "type": "object", + "properties": { + "result": { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + "detail": { + "type": "string" + } + } + }, + + "TableInfo": { + "type": "object", + "properties": { + "count": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/lcm/swagger/vfc.nslcm.swagger.json b/lcm/swagger/vfc.nslcm.swagger.json new file mode 100644 index 00000000..75cc6bab --- /dev/null +++ b/lcm/swagger/vfc.nslcm.swagger.json @@ -0,0 +1,537 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "ONAP VFC Network Service Lifecycle Management API", + "description": "VFC Network Service Lifecycle Management Rest API.", + "contact": { + "name": "ONAP VFC team", + "email": "onap-discuss@lists.onap.org", + "url": "https://gerrit.onap.org/r/#/admin/projects/vfc/nfvo/lcm" + } + }, + "basePath": "/api/nslcm/v1", + "schemes": [ + "http", + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/ns": { + "post": { + "tags": [ + "ns" + ], + "summary": "ns create", + "description": "ns create", + "operationId": "ns_create", + "parameters": [ + { + "in": "body", + "name": "NSCreateRequest", + "description": "NS Instance Create Request", + "required": true, + "schema": { + "$ref": "#/definitions/NsCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/NsCreateResponse" + } + } + } + }, + "get": { + "tags": [ + "ns" + ], + "summary": "ns get", + "description": "ns get", + "operationId": "ns_get", + "parameters": [], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/NsInfo" + } + } + } + } + }, + "/ns/{nsInstanceId}/Instantiate": { + "post": { + "tags": [ + "ns" + ], + "summary": "ns Instantiate", + "description": "ns Instantiate", + "operationId": "ns_Instantiate", + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "nsInstanceId", + "in": "path" + }, + { + "in": "body", + "name": "NSInstantiateRequest", + "description": "NS Instantiate Request Body", + "required": true, + "schema": { + "$ref": "#/definitions/NsInstantiateRequest" + } + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/JobInfo" + } + }, + "201": { + "description": "Invalid Request" + } + } + } + }, + "/ns/{nsInstanceId}/scale": { + "post": { + "tags": [ + "ns" + ], + "summary": "ns scale", + "description": "ns scale", + "operationId": "ns_scale", + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "nsInstanceId", + "in": "path" + }, + { + "in": "body", + "name": "ScaleNSRequest", + "description": "Scale NS Request Body", + "required": true, + "schema": { + "$ref": "#/definitions/NsScaleRequest" + } + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/JobInfo" + } + }, + "201": { + "description": "Invalid Request" + } + } + } + }, + "/ns/{ns_instance_id}/heal": { + "post": { + "tags": [ + "ns" + ], + "summary": "ns heal", + "description": "ns heal", + "operationId": "ns_heal", + "parameters": [ + { + "required": true, + "type": "string", + "description": "Identifier of the NS instance.", + "name": "ns_instance_id", + "in": "path" + }, + { + "in": "body", + "name": "healVnfData", + "description": "healVnfData", + "required": true, + "schema": { + "$ref": "#/definitions/NsHealRequest" + } + } + ], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/JobInfo" + } + }, + "500": { + "description": "the url is invalid" + } + } + } + }, + "/ns/{ns_instance_id}/terminate": { + "post": { + "tags": [ + "ns" + ], + "summary": "ns terminate", + "description": "ns terminate", + "operationId": "ns_terminate", + "parameters": [ + { + "required": true, + "type": "string", + "description": "Identifier of the NS instance.", + "name": "ns_instance_id", + "in": "path" + }, + { + "in": "body", + "name": "NsTerminateRequest", + "description": "NsTerminateRequest", + "required": true, + "schema": { + "$ref": "#/definitions/NsTerminateRequest" + } + } + ], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/JobInfo" + } + }, + "500": { + "description": "the url is invalid" + } + } + } + }, + "/ns/{ns_instance_id}": { + "delete": { + "tags": [ + "ns" + ], + "summary": "ns delete", + "description": "ns delete", + "operationId": "ns_delete", + "parameters": [ + { + "required": true, + "type": "string", + "description": "Identifier of the NS instance.", + "name": "ns_instance_id", + "in": "path" + } + ], + "responses": { + "204": { + "description": "The NS instance resource and the associated NS identifier were deleted successfully." + } + } + } + }, + "/jobs/{jobId}": { + "post": { + "tags": [ + "job" + ], + "summary": "jobstatus", + "description": "", + "operationId": "jobstatus", + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "jobId", + "in": "path" + }, + { + "in": "body", + "name": "body", + "description": "request param", + "required": true, + "schema": { + "$ref": "#/definitions/JobProgressRequest" + } + } + ], + "responses": { + "202": { + "description": "" + } + } + } + } + }, + "definitions": { + "NsCreateRequest": { + "type": "object", + "properties": { + "csarId": { + "type": "string", + "description": "the NS package ID" + }, + "nsName": { + "type": "string" + }, + "description": { + "type": "string" + } + } + }, + "NsCreateResponse": { + "type": "object", + "properties": { + "nsInstanceId": { + "type": "string" + } + } + }, + "NsInstantiateRequest": { + "type": "object", + "properties": { + "LocationConstraints": { + "type": "array", + "items": { + "$ref": "#/definitions/LocationConstraint" + } + }, + "additionalParamForNs": { + "type": "string" + } + } + }, + "LocationConstraint": { + "type": "object", + "properties": { + "vnfProfileId": { + "type": "string" + }, + "locationConstraints": { + "type": "object", + "properties": { + "vimid": { + "type": "string" + } + } + } + } + }, + "NsScaleRequest": { + "type": "object", + "properties": { + "scaleType": { + "type": "string" + }, + "scaleNsByStepsData": { + "$ref": "#/definitions/NsScaleByStepsData" + } + } + }, + "NsScaleByStepsData": { + "type": "object", + "properties": { + "scalingDirection": { + "type": "string" + }, + "aspectId": { + "type": "string" + }, + "numberOfSteps": { + "type": "integer" + } + } + }, + "NsHealRequest": { + "type": "object", + "properties": { + "vnfInstanceId": { + "type": "string" + }, + "cause": { + "type": "string" + }, + "additionalParams": { + "type": "object", + "properties": { + "action": { + "type": "string" + }, + "actionvminfo": { + "type": "object", + "properties": { + "vmid": { + "type": "string" + }, + "vmname": { + "type": "string" + } + } + } + } + } + } + }, + "NsTerminateRequest": { + "type": "object", + "properties": { + "terminationType": { + "type": "string" + }, + "gracefulTerminationTimeout": { + "type": "string" + } + } + }, + "JobInfo": { + "type": "object", + "properties": { + "jobId": { + "type": "string" + } + } + }, + "JobProgressRequest": { + "type": "object", + "properties": { + "progress": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "errcode": { + "type": "string" + } + } + }, + "NsInfo": { + "type": "object", + "properties": { + "nsInstanceId": { + "type": "string" + }, + "nsName": { + "type": "string" + }, + "description": { + "type": "string" + }, + "nsdId": { + "type": "string" + }, + "vnfInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/vnfInfo" + } + }, + "vlInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/vlInfo" + } + }, + "vnffgInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/vnffgInfo" + } + }, + "nsState": { + "type": "string" + } + } + }, + "vnfInfo": { + "type": "object", + "properties": { + "vnfInstanceId": { + "type": "string" + }, + "vnfInstanceName": { + "type": "string" + }, + "vnfdId": { + "type": "string" + } + } + }, + "vlInfo": { + "type": "object", + "properties": { + "vlInstanceId": { + "type": "string" + }, + "vlInstanceName": { + "type": "string" + }, + "vldId": { + "type": "string" + }, + "relatedCpInstanceId": { + "type": "array", + "items": { + "$ref": "#/definitions/cpInfo" + } + } + } + }, + "cpInfo": { + "type": "object", + "properties": { + "cpInstanceId": { + "type": "string" + }, + "cpInstanceName": { + "type": "string" + }, + "cpdId": { + "type": "string" + } + } + }, + "vnffgInfo": { + "type": "object", + "properties": { + "vnffgInstanceId": { + "type": "string" + }, + "vnfId": { + "type": "string" + }, + "pnfId": { + "type": "string" + }, + "virtualLinkId": { + "type": "string" + }, + "cpId": { + "type": "string" + }, + "nfp": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/lcm/swagger/vfc.others.swagger.json b/lcm/swagger/vfc.others.swagger.json new file mode 100644 index 00000000..9be74901 --- /dev/null +++ b/lcm/swagger/vfc.others.swagger.json @@ -0,0 +1,135 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "ONAP VFC Service Internal Rest API" + }, + "basePath": "/api/nslcm/v1", + "paths": { + "/ns/{nsInstanceId}/postdeal": { + "post": { + "tags": [ + "postdeal" + ], + "summary": "ns postdeal", + "description": "", + "operationId": "ns_postdeal", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "nsInstanceId", + "in": "path" + }, + { + "in": "body", + "name": "body", + "description": "request param", + "required": true, + "schema": { + "$ref": "#/definitions/NSInstPostDetailRequest" + } + } + ], + "responses": { + "202": { + "description": "" + } + } + } + }, + "/mandb/{modelName}": { + "get": { + "tags": [ + "db" + ], + "summary": "query ns table info", + "description": "query ns table info", + "operationId": "query_ns_table", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "model Name.", + "name": "modelName", + "in": "path" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/TableInfo" + } + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "db" + ], + "summary": "ns table delete", + "description": "ns table delete", + "operationId": "ns_table_delete", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "model Name.", + "name": "modelName", + "in": "path" + } + ], + "responses": { + "204": { + "description": "The tables were deleted successfully." + } + } + } + } + }, + "definitions": { + + "NSInstPostDetailRequest": { + "type": "object", + "properties": { + "status": { + "type": "string" + } + } + }, + + + + "TableInfo": { + "type": "object", + "properties": { + "count": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/lcm/swagger/vfc.sfclcm.swagger.json b/lcm/swagger/vfc.sfclcm.swagger.json new file mode 100644 index 00000000..af06543f --- /dev/null +++ b/lcm/swagger/vfc.sfclcm.swagger.json @@ -0,0 +1,237 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "ONAP VFC Service SFC Rest API" + }, + "basePath": "/api/nslcm/v1", + "paths": { + "/ns/sfcs": { + "post": { + "tags": [ + "sfc" + ], + "summary": "sfc create", + "description": "", + "operationId": "create_sfc", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "request param", + "required": true, + "schema": { + "$ref": "#/definitions/SfcPostRequest" + } + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/SfcPostResponse" + } + } + } + } + }, + "/ns/sfcs/{sfcInstId}": { + "get": { + "tags": [ + "sfc" + ], + "summary": "query the specified sfc info", + "description": "", + "operationId": "query_sfc", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "sfcInstId", + "in": "path", + "description": "sfc instance id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/SfcInfo" + } + }, + "404": { + "description": "the sfc instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "sfc" + ], + "summary": "delete sfc", + "description": "", + "operationId": "delete_sfc", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "sfcInstId", + "in": "path" + } + ], + "responses": { + "204": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/DeleteResponse" + } + }, + "404": { + "description": "the sfc instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + } + } + }, + "definitions": { + + "SfcPostRequest": { + "type": "object", + "properties": { + "jobId": { + "type": "string" + }, + "nsInstanceId": { + "type": "string" + }, + "sapData": { + "type": "array", + "items": { + "type": "object" + } + }, + "vnfInstanceData": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForNs": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForVnf": { + "type": "array", + "items": { + "type": "object" + } + }, + "sdnControllerId": { + "type": "string" + }, + "context": { + "type": "string" + }, + "fpindex": { + "type": "string" + } + } + }, + "SfcPostResponse": { + "type": "object", + "properties": { + "sfcInstId": { + "type": "string" + }, + "jobId": { + "type": "string" + } + } + }, + "VlInfo": { + "type": "object", + "properties": { + "vlId": { + "type": "string" + }, + "vlName": { + "type": "string" + }, + "vlStatus": { + "type": "string" + } + } + }, + "VnfInfo": { + "type": "object", + "properties": { + "vnfInstId": { + "type": "string" + }, + "vnfName": { + "type": "string" + }, + "vnfStatus": { + "type": "string" + } + } + }, + + "DeleteResponse": { + "type": "object", + "properties": { + "result": { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + "detail": { + "type": "string" + } + } + }, + "SfcInfo": { + "type": "object", + "properties": { + "sfcInstId": { + "type": "string" + }, + "sfcName": { + "type": "string" + }, + "sfcStatus": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/lcm/swagger/vfc.vllcm.swagger.json b/lcm/swagger/vfc.vllcm.swagger.json new file mode 100644 index 00000000..1b5241a9 --- /dev/null +++ b/lcm/swagger/vfc.vllcm.swagger.json @@ -0,0 +1,238 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "ONAP VFC Service Internal Rest API" + }, + "basePath": "/api/nslcm/v1", + "paths": { + "/ns/vls": { + "post": { + "tags": [ + "vl" + ], + "summary": "vl create", + "description": "", + "operationId": "create_vl", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "instantiate request param", + "required": true, + "schema": { + "$ref": "#/definitions/VlPostRequest" + } + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/VlPostResponse" + } + } + } + } + }, + "/ns/vls/{vlId}": { + "get": { + "tags": [ + "vl" + ], + "summary": "query the specified vl info", + "description": "", + "operationId": "query_vl", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vlId", + "in": "path", + "description": "vl instance id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VlInfo" + } + }, + "404": { + "description": "the vl instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "vl" + ], + "summary": "delete vl", + "description": "", + "operationId": "delete_vl", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "vlId", + "in": "path" + } + ], + "responses": { + "204": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/DeleteVlResponse" + } + }, + "404": { + "description": "the vl instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + } + } + }, + "definitions": { + "VlPostRequest": { + "type": "object", + "properties": { + "jobId": { + "type": "string" + }, + "nsInstanceId": { + "type": "string" + }, + "flavourId": { + "type": "string" + }, + "sapData": { + "type": "array", + "items": { + "type": "object" + } + }, + "pnfInfo": { + "type": "array", + "items": { + "type": "object" + } + }, + "vnfInstanceData": { + "type": "array", + "items": { + "type": "object" + } + }, + "nestedNsInstanceId": { + "type": "array", + "items": { + "type": "object" + } + }, + "locationConstraints": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForNs": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForVnf": { + "type": "array", + "items": { + "type": "object" + } + }, + "extNSVirtualLink": { + "type": "array", + "items": { + "type": "object" + } + }, + "context": { + "type": "string" + }, + "vlIndex": { + "type": "string" + } + } + }, + "VlPostResponse": { + "type": "object", + "properties": { + "result": { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + "detail": { + "type": "string" + }, + "vlId": { + "type": "string" + } + } + }, + "VlInfo": { + "type": "object", + "properties": { + "vlId": { + "type": "string" + }, + "vlName": { + "type": "string" + }, + "vlStatus": { + "type": "string" + } + } + }, + "DeleteVlResponse": { + "type": "object", + "properties": { + "result": { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + "detail": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/lcm/swagger/vfc.vnflcm.swagger.json b/lcm/swagger/vfc.vnflcm.swagger.json new file mode 100644 index 00000000..3fbcb603 --- /dev/null +++ b/lcm/swagger/vfc.vnflcm.swagger.json @@ -0,0 +1,232 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "ONAP VFC Service Internal Rest API" + }, + "basePath": "/api/nslcm/v1", + "paths": { + "/ns/vnfs": { + "post": { + "tags": [ + "vnf" + ], + "summary": "vnf create", + "description": "", + "operationId": "create_vnf", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "instantiate request param", + "required": true, + "schema": { + "$ref": "#/definitions/VnfPostRequest" + } + } + ], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/VnfPostResponse" + } + } + } + } + }, + "/ns/vnfs/{vnfInstId}": { + "get": { + "tags": [ + "vnf" + ], + "summary": "query the specified vnf info", + "description": "", + "operationId": "query_vnf", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vnfInstId", + "in": "path", + "description": "vnf instance id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VnfInfo" + } + }, + "404": { + "description": "the vnf instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + }, + "delete": { + "tags": [ + "vnf" + ], + "summary": "delete vnf", + "description": "", + "operationId": "delete_vnf", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "required": true, + "type": "string", + "description": "", + "name": "vnfInstId", + "in": "path" + } + ], + "responses": { + "204": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/DeleteResponse" + } + }, + "404": { + "description": "the vl instance id is wrong" + }, + "500": { + "description": "the url is invalid" + } + } + } + } + }, + "definitions": { + "VnfPostRequest": { + "type": "object", + "properties": { + "jobId": { + "type": "string" + }, + "nsInstanceId": { + "type": "string" + }, + "flavourId": { + "type": "string" + }, + "sapData": { + "type": "array", + "items": { + "type": "object" + } + }, + "pnfInfo": { + "type": "array", + "items": { + "type": "object" + } + }, + "vnfInstanceData": { + "type": "array", + "items": { + "type": "object" + } + }, + "nestedNsInstanceId": { + "type": "array", + "items": { + "type": "object" + } + }, + "locationConstraints": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForNs": { + "type": "array", + "items": { + "type": "object" + } + }, + "additionalParamForVnf": { + "type": "array", + "items": { + "type": "object" + } + }, + "extNSVirtualLink": { + "type": "array", + "items": { + "type": "object" + } + }, + "context": { + "type": "string" + }, + "vnfIndex": { + "type": "string" + } + } + }, + "VnfPostResponse": { + "type": "object", + "properties": { + "vnfInstId": { + "type": "string" + }, + "jobId": { + "type": "string" + } + } + }, + + "VnfInfo": { + "type": "object", + "properties": { + "vnfInstId": { + "type": "string" + }, + "vnfName": { + "type": "string" + }, + "vnfStatus": { + "type": "string" + } + } + }, + "DeleteResponse": { + "type": "object", + "properties": { + "result": { + "type": "integer", + "enum": [ + 0, + 1 + ] + }, + "detail": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/lcm/swagger/views.py b/lcm/swagger/views.py new file mode 100644 index 00000000..8386bf05 --- /dev/null +++ b/lcm/swagger/views.py @@ -0,0 +1,73 @@ +# Copyright 2016-2017 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json +import logging +import os +import traceback + +from rest_framework import status +from rest_framework.response import Response +from rest_framework.views import APIView + + +logger = logging.getLogger(__name__) + + +class SwaggerJsonView(APIView): + + def get(self, request): + + json_file = os.path.join(os.path.dirname(__file__), 'vfc.nslcm.swagger.json') + f = open(json_file) + json_data = json.JSONDecoder().decode(f.read()) + f.close() + + json_file = os.path.join(os.path.dirname(__file__), 'vfc.vnflcm.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["definitions"].update(json_data_temp["definitions"]) + + json_file = os.path.join(os.path.dirname(__file__), 'vfc.vllcm.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["definitions"].update(json_data_temp["definitions"]) + + + json_file = os.path.join(os.path.dirname(__file__), 'vfc.sfclcm.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["definitions"].update(json_data_temp["definitions"]) + + + json_file = os.path.join(os.path.dirname(__file__), 'vfc.others.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["definitions"].update(json_data_temp["definitions"]) + + return Response(json_data) + + + diff --git a/lcm/urls.py b/lcm/urls.py index b0333513..5e647260 100644 --- a/lcm/urls.py +++ b/lcm/urls.py @@ -25,6 +25,7 @@ urlpatterns = [ url(r'^', include('lcm.ns.urls')), url(r'^', include('lcm.jobs.urls')), url(r'^', include('lcm.workflows.urls')), + url(r'^', include('lcm.swagger.urls')), ] # regist to MSB when startup -- 2.16.6