aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Stanior <piotr.stanior@t-mobile.pl>2021-01-08 14:03:30 +0100
committerPiotr Stanior <piotr.stanior@t-mobile.pl>2021-01-08 14:03:41 +0100
commit325ebe9b3778fdf8db7637042391f609f692d188 (patch)
treee856c56f6f28d9bcbe16ac99d4ee6c86eb777204
parent63eb67ed6c6e36eb441b92ac0552f2e17ae5173a (diff)
CDS add Swagger annotations for Model Type API
Issue-ID: CCSDK-3014 Change-Id: I469151beef8ebf63b3a24ca4ce9a047c0b80850a Signed-off-by: Piotr Stanior <piotr.stanior@t-mobile.pl>
-rw-r--r--docs/api-reference/media/bp-processor.postman_collection.json233
-rw-r--r--docs/api-reference/media/cds-bp-processor-api-swagger.json158
-rwxr-xr-xms/blueprintsprocessor/application/pom.xml1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt35
4 files changed, 426 insertions, 1 deletions
diff --git a/docs/api-reference/media/bp-processor.postman_collection.json b/docs/api-reference/media/bp-processor.postman_collection.json
index 2aabe1393..b87415db9 100644
--- a/docs/api-reference/media/bp-processor.postman_collection.json
+++ b/docs/api-reference/media/bp-processor.postman_collection.json
@@ -3659,6 +3659,239 @@
"protocolProfileBehavior": {}
},
{
+ "name": "Model Type Catalog",
+ "item": [
+ {
+ "name": "Save a model type",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "username",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "password",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "showPassword",
+ "value": false,
+ "type": "boolean"
+ }
+ ]
+ },
+ "method": "POST",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": "{\r\n \"modelName\": \"test\",\r\n \"derivedFrom\": \"test\",\r\n \"definitionType\": \"data_type\",\r\n \"definition\": {},\r\n \"description\": \"Some test\",\r\n \"version\": \"1.0\",\r\n \"tags\": \"test\",\r\n \"updatedBy\": \"test\"\r\n}",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ }
+ },
+ "url": {
+ "raw": "http://{{host}}:{{port}}/api/v1/model-type/",
+ "protocol": "http",
+ "host": [
+ "{{host}}"
+ ],
+ "port": "{{port}}",
+ "path": [
+ "api",
+ "v1",
+ "model-type",
+ ""
+ ]
+ },
+ "description": "Save a model type by model type definition provided."
+ },
+ "response": []
+ },
+ {
+ "name": "Retrieve a list of model types",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "username",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "password",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "showPassword",
+ "value": false,
+ "type": "boolean"
+ }
+ ]
+ },
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://{{host}}:{{port}}/api/v1/model-type/by-definition/data_type",
+ "protocol": "http",
+ "host": [
+ "{{host}}"
+ ],
+ "port": "{{port}}",
+ "path": [
+ "api",
+ "v1",
+ "model-type",
+ "by-definition",
+ "data_type"
+ ]
+ },
+ "description": "Retrieve a list of model types by definition type provided."
+ },
+ "response": []
+ },
+ {
+ "name": "Retrieve a list of model types",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "username",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "password",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "showPassword",
+ "value": false,
+ "type": "boolean"
+ }
+ ]
+ },
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://{{host}}:{{port}}/api/v1/model-type/search/test",
+ "protocol": "http",
+ "host": [
+ "{{host}}"
+ ],
+ "port": "{{port}}",
+ "path": [
+ "api",
+ "v1",
+ "model-type",
+ "search",
+ "test"
+ ]
+ },
+ "description": "Retrieve a list of model types by tags provided."
+ },
+ "response": []
+ },
+ {
+ "name": "Retrieve a model type",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "username",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "password",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "showPassword",
+ "value": false,
+ "type": "boolean"
+ }
+ ]
+ },
+ "method": "GET",
+ "header": [],
+ "url": {
+ "raw": "http://{{host}}:{{port}}/api/v1/model-type/test",
+ "protocol": "http",
+ "host": [
+ "{{host}}"
+ ],
+ "port": "{{port}}",
+ "path": [
+ "api",
+ "v1",
+ "model-type",
+ "test"
+ ]
+ },
+ "description": "Retrieve a model type by name provided."
+ },
+ "response": []
+ },
+ {
+ "name": "Remove a model type",
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "username",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "password",
+ "value": "ccsdkapps",
+ "type": "string"
+ },
+ {
+ "key": "showPassword",
+ "value": false,
+ "type": "boolean"
+ }
+ ]
+ },
+ "method": "DELETE",
+ "header": [],
+ "url": {
+ "raw": "http://{{host}}:{{port}}/api/v1/model-type/test",
+ "protocol": "http",
+ "host": [
+ "{{host}}"
+ ],
+ "port": "{{port}}",
+ "path": [
+ "api",
+ "v1",
+ "model-type",
+ "test"
+ ]
+ },
+ "description": "Remove a model type by name provided."
+ },
+ "response": []
+ }
+ ],
+ "description": "Manages data types in CDS",
+ "protocolProfileBehavior": {}
+ },
+ {
"name": "List all endpoints",
"request": {
"auth": {
diff --git a/docs/api-reference/media/cds-bp-processor-api-swagger.json b/docs/api-reference/media/cds-bp-processor-api-swagger.json
index c7f24262e..9053672e5 100644
--- a/docs/api-reference/media/cds-bp-processor-api-swagger.json
+++ b/docs/api-reference/media/cds-bp-processor-api-swagger.json
@@ -20,6 +20,9 @@
"name" : "Blueprint Model Catalog",
"description" : "Manages all blueprint models which are available in CDS"
}, {
+ "name" : "Model Type Catalog",
+ "description" : "Manages data types in CDS"
+ }, {
"name" : "Resource configuration",
"description" : "Interaction with stored configurations"
}, {
@@ -962,6 +965,127 @@
}
}
},
+ "/api/v1/model-type/" : {
+ "post" : {
+ "tags" : [ "Model Type Catalog" ],
+ "summary" : "Save a model type",
+ "description" : "Save a model type by model type definition provided.",
+ "operationId" : "ModelTypeController_saveModelType_POST.org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
+ "consumes" : [ "application/json" ],
+ "produces" : [ "application/json" ],
+ "parameters" : [ {
+ "in" : "body",
+ "name" : "body",
+ "required" : false,
+ "schema" : {
+ "$ref" : "#/definitions/ModelType"
+ }
+ } ],
+ "responses" : {
+ "200" : {
+ "description" : "successful operation",
+ "schema" : {
+ "$ref" : "#/definitions/ModelType"
+ }
+ }
+ }
+ }
+ },
+ "/api/v1/model-type/by-definition/{definitionType}" : {
+ "get" : {
+ "tags" : [ "Model Type Catalog" ],
+ "summary" : "Retrieve a list of model types",
+ "description" : "Retrieve a list of model types by definition type provided.",
+ "operationId" : "ModelTypeController_getModelTypeByDefinitionType_GET.org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
+ "produces" : [ "application/json" ],
+ "parameters" : [ {
+ "name" : "definitionType",
+ "in" : "path",
+ "required" : true,
+ "type" : "string"
+ } ],
+ "responses" : {
+ "200" : {
+ "description" : "successful operation",
+ "schema" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/definitions/ModelType"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/api/v1/model-type/search/{tags}" : {
+ "get" : {
+ "tags" : [ "Model Type Catalog" ],
+ "summary" : "Retrieve a list of model types",
+ "description" : "Retrieve a list of model types by tags provided.",
+ "operationId" : "ModelTypeController_searchModelTypes_GET.org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
+ "produces" : [ "application/json" ],
+ "parameters" : [ {
+ "name" : "tags",
+ "in" : "path",
+ "required" : true,
+ "type" : "string"
+ } ],
+ "responses" : {
+ "200" : {
+ "description" : "successful operation",
+ "schema" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/definitions/ModelType"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/api/v1/model-type/{name}" : {
+ "get" : {
+ "tags" : [ "Model Type Catalog" ],
+ "summary" : "Retrieve a model type",
+ "description" : "Retrieve a model type by name provided.",
+ "operationId" : "ModelTypeController_getModelTypeByName_GET.org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
+ "produces" : [ "application/json" ],
+ "parameters" : [ {
+ "name" : "name",
+ "in" : "path",
+ "required" : true,
+ "type" : "string"
+ } ],
+ "responses" : {
+ "200" : {
+ "description" : "successful operation",
+ "schema" : {
+ "$ref" : "#/definitions/ModelType"
+ }
+ }
+ }
+ },
+ "delete" : {
+ "tags" : [ "Model Type Catalog" ],
+ "summary" : "Remove a model type",
+ "description" : "Remove a model type by name provided.",
+ "operationId" : "ModelTypeController_deleteModelTypeByName_DELETE.org.onap.ccsdk.cds.blueprintsprocessor.designer.api",
+ "parameters" : [ {
+ "name" : "name",
+ "in" : "path",
+ "required" : true,
+ "type" : "string"
+ } ],
+ "responses" : {
+ "200" : {
+ "description" : "successful operation",
+ "schema" : {
+ "$ref" : "#/definitions/ModelType"
+ }
+ }
+ }
+ }
+ },
"/api/v1/resources" : {
"get" : {
"tags" : [ "Resources" ],
@@ -1532,6 +1656,40 @@
}
}
},
+ "ModelType" : {
+ "type" : "object",
+ "required" : [ "definition", "definitionType", "derivedFrom", "description", "modelName", "tags", "updatedBy", "version" ],
+ "properties" : {
+ "modelName" : {
+ "type" : "string"
+ },
+ "derivedFrom" : {
+ "type" : "string"
+ },
+ "definitionType" : {
+ "type" : "string"
+ },
+ "definition" : {
+ "$ref" : "#/definitions/JsonNode"
+ },
+ "description" : {
+ "type" : "string"
+ },
+ "version" : {
+ "type" : "string"
+ },
+ "tags" : {
+ "type" : "string"
+ },
+ "creationDate" : {
+ "type" : "string",
+ "format" : "date-time"
+ },
+ "updatedBy" : {
+ "type" : "string"
+ }
+ }
+ },
"NodeFilterDefinition" : {
"type" : "object",
"properties" : {
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 00e7fe2c8..a4776e73e 100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -334,6 +334,7 @@
<locations>
<location>org.onap.ccsdk.cds.blueprintsprocessor.designer.api.BlueprintModelController</location>
<location>org.onap.ccsdk.cds.blueprintsprocessor.designer.api.ResourceDictionaryController</location>
+ <location>org.onap.ccsdk.cds.blueprintsprocessor.designer.api.ModelTypeController</location>
<location>org.onap.ccsdk.cds.blueprintsprocessor.resource.api</location>
<location>org.onap.ccsdk.cds.blueprintsprocessor.configs.api</location>
<!-- This location is not implemented yet
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
index 1c550bb3e..3689f735e 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
@@ -17,6 +17,8 @@
package org.onap.ccsdk.cds.blueprintsprocessor.designer.api
+import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ModelTypeHandler
import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.mdcWebCoroutineScope
@@ -33,19 +35,40 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(value = ["/api/v1/model-type"])
+@Api(
+ value = "Model Type Catalog",
+ description = "Manages data types in CDS"
+)
open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
@GetMapping(path = ["/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ApiOperation(
+ value = "Retrieve a model type",
+ notes = "Retrieve a model type by name provided.",
+ response = ModelType::class
+ )
suspend fun getModelTypeByName(@PathVariable(value = "name") name: String): ModelType? = mdcWebCoroutineScope {
modelTypeHandler.getModelTypeByName(name)
}
@GetMapping(path = ["/search/{tags}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ApiOperation(
+ value = "Retrieve a list of model types",
+ notes = "Retrieve a list of model types by tags provided.",
+ responseContainer = "List",
+ response = ModelType::class
+ )
suspend fun searchModelTypes(@PathVariable(value = "tags") tags: String): List<ModelType> = mdcWebCoroutineScope {
modelTypeHandler.searchModelTypes(tags)
}
@GetMapping(path = ["/by-definition/{definitionType}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ApiOperation(
+ value = "Retrieve a list of model types",
+ notes = "Retrieve a list of model types by definition type provided.",
+ responseContainer = "List",
+ response = ModelType::class
+ )
@ResponseBody
suspend fun getModelTypeByDefinitionType(@PathVariable(value = "definitionType") definitionType: String): List<ModelType> =
mdcWebCoroutineScope {
@@ -53,10 +76,15 @@ open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
}
@PostMapping(
- path = [""],
+ path = ["/"],
produces = [MediaType.APPLICATION_JSON_VALUE],
consumes = [MediaType.APPLICATION_JSON_VALUE]
)
+ @ApiOperation(
+ value = "Save a model type",
+ notes = "Save a model type by model type definition provided.",
+ response = ModelType::class
+ )
@ResponseBody
@Throws(BluePrintException::class)
suspend fun saveModelType(@RequestBody modelType: ModelType): ModelType = mdcWebCoroutineScope {
@@ -64,6 +92,11 @@ open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
}
@DeleteMapping(path = ["/{name}"])
+ @ApiOperation(
+ value = "Remove a model type",
+ notes = "Remove a model type by name provided.",
+ response = ModelType::class
+ )
suspend fun deleteModelTypeByName(@PathVariable(value = "name") name: String) = mdcWebCoroutineScope {
modelTypeHandler.deleteByModelName(name)
}