summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-06-23 15:30:36 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-07-04 15:53:42 -0400
commit2791db21e7d7f7d31ea402fe978dab216a41367f (patch)
treef73d5a97b77f6eb17f18fb93465870b8b341219e /ms/blueprintsprocessor/modules/inbounds
parentc5276ff19122435871c3deedbf0d983962ac2537 (diff)
Fix swagger definition for blueprint processor
Change-Id: I69ba541b4b301735a988cf01673827a79daf1f8c Issue-ID: CCSDK-1431 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt58
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt58
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resolutionresults/api/ResourceControllerTest.kt2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt2
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt54
5 files changed, 123 insertions, 51 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
index c50853ff2..4c8fc193c 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
@@ -16,10 +16,14 @@
package org.onap.ccsdk.cds.blueprintsprocessor.resource.api
+import com.fasterxml.jackson.databind.JsonNode
+import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
+import io.swagger.annotations.ApiParam
import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolution
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionDBService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
@@ -27,27 +31,42 @@ import org.springframework.web.bind.annotation.*
@RestController
@RequestMapping("/api/v1/resources")
+@Api(value = "/api/v1/resources",
+ description = "Interaction with resolved resources.")
open class ResourceController(private var resourceResolutionDBService: ResourceResolutionDBService) {
- @RequestMapping(path = ["/ping"], method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(path = ["/health-check"],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
- fun ping(): String = runBlocking {
- "Success"
+ @ApiOperation(value = "Health Check", hidden = true)
+ fun resourceControllerHealthCheck(): JsonNode = runBlocking {
+ JacksonUtils.getJsonNode("Success")
}
@RequestMapping(path = [""],
method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Fetch all resource values associated to a resolution key. ",
- notes = "Retrieve a stored resource value using the blueprint metadata, artifact name and the resolution-key.",
+ @ApiOperation(value = "Get all resolved resources using the resolution key. ",
+ notes = "Retrieve all stored resolved resources using the blueprint name, blueprint version, " +
+ "artifact name and the resolution-key.",
+ response = ResourceResolution::class,
+ responseContainer = "List",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun getAllFromResolutionKeyOrFromResourceTypeAndId(@RequestParam(value = "bpName", required = true) bpName: String,
- @RequestParam(value = "bpVersion", required = true) bpVersion: String,
- @RequestParam(value = "artifactName", required = false, defaultValue = "") artifactName: String,
- @RequestParam(value = "resolutionKey", required = false, defaultValue = "") resolutionKey: String,
- @RequestParam(value = "resourceType", required = false, defaultValue = "") resourceType: String,
- @RequestParam(value = "resourceId", required = false, defaultValue = "") resourceId: String)
+ fun getAllFromResolutionKeyOrFromResourceTypeAndId(
+ @ApiParam(value = "Name of the CBA.", required = true)
+ @RequestParam(value = "bpName", required = true) bpName: String,
+ @ApiParam(value = "Version of the CBA.", required = true)
+ @RequestParam(value = "bpVersion", required = true) bpVersion: String,
+ @ApiParam(value = "Artifact name for which to retrieve a resolved resource.", required = true)
+ @RequestParam(value = "artifactName", required = false, defaultValue = "") artifactName: String,
+ @ApiParam(value = "Resolution Key associated with the resolution.", required = false)
+ @RequestParam(value = "resolutionKey", required = false, defaultValue = "") resolutionKey: String,
+ @ApiParam(value = "Resource Type associated with the resolution.", required = false)
+ @RequestParam(value = "resourceType", required = false, defaultValue = "") resourceType: String,
+ @ApiParam(value = "Resource Id associated with the resolution.", required = false)
+ @RequestParam(value = "resourceId", required = false, defaultValue = "") resourceId: String)
: ResponseEntity<List<ResourceResolution>> = runBlocking {
if ((resolutionKey.isNotEmpty() || artifactName.isNotEmpty()) && (resourceId.isNotEmpty() || resourceType.isNotEmpty())) {
@@ -55,9 +74,12 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
} else if (resolutionKey.isNotEmpty() && artifactName.isNotEmpty()) {
ResponseEntity.ok()
.body(resourceResolutionDBService.readWithResolutionKey(bpName, bpVersion, artifactName, resolutionKey))
- } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()){
- ResponseEntity.ok()
- .body(resourceResolutionDBService.readWithResourceIdAndResourceType(bpName, bpVersion, resourceId, resourceType))
+ } else if (resourceType.isNotEmpty() && resourceId.isNotEmpty()) {
+ ResponseEntity.ok()
+ .body(resourceResolutionDBService.readWithResourceIdAndResourceType(bpName,
+ bpVersion,
+ resourceId,
+ resourceType))
} else {
throw ResourceException("Missing param. Either retrieve resolved value using artifact name and resolution-key OR using resource-id and resource-type.")
}
@@ -71,10 +93,16 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun getOneFromResolutionKey(@RequestParam(value = "bpName", required = true) bpName: String,
+ fun getOneFromResolutionKey(@ApiParam(value = "Name of the CBA.", required = true)
+ @RequestParam(value = "bpName", required = true) bpName: String,
+ @ApiParam(value = "Version of the CBA.", required = true)
@RequestParam(value = "bpVersion", required = true) bpVersion: String,
+ @ApiParam(value = "Artifact name for which to retrieve a resolved resource.",
+ required = true)
@RequestParam(value = "artifactName", required = true) artifactName: String,
+ @ApiParam(value = "Resolution Key associated with the resolution.", required = true)
@RequestParam(value = "resolutionKey", required = true) resolutionKey: String,
+ @ApiParam(value = "Name of the resource to retrieve.", required = true)
@RequestParam(value = "name", required = true) name: String)
: ResponseEntity<ResourceResolution> = runBlocking {
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt
index d3ebd5c49..83e813079 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt
@@ -16,10 +16,14 @@
package org.onap.ccsdk.cds.blueprintsprocessor.resource.api
+import com.fasterxml.jackson.databind.JsonNode
+import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
+import io.swagger.annotations.ApiParam
import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.TemplateResolution
import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.TemplateResolutionService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
@@ -33,26 +37,41 @@ import org.springframework.web.bind.annotation.*
*/
@RestController
@RequestMapping("/api/v1/template")
+@Api(value = "/api/v1/template",
+ description = "Interaction with resolved template.")
open class TemplateController(private val templateResolutionService: TemplateResolutionService) {
- @RequestMapping(path = ["/ping"], method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(path = ["/health-check"],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
- fun ping(): String = runBlocking {
- "Success"
+ @ApiOperation(value = "Health Check", hidden = true)
+ fun templateControllerHealthCheck(): JsonNode = runBlocking {
+ JacksonUtils.getJsonNode("Success")
}
- @RequestMapping(path = [""], method = [RequestMethod.GET], produces = [MediaType.TEXT_PLAIN_VALUE])
- @ApiOperation(value = "Retrieve a meshed template.",
- notes = "Retrieve a meshed template for a given CBA's action, identified by its blueprint name, blueprint version, " +
- "artifact name and resolution key. And extra 'format' parameter can be passed to tell what content-type" +
+ @RequestMapping(path = [""],
+ method = [RequestMethod.GET],
+ produces = [MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE])
+ @ApiOperation(value = "Retrieve a resolved template.",
+ notes = "Retrieve a config template for a given CBA's action, identified by its blueprint name, blueprint version, " +
+ "artifact name and resolution key. An extra 'format' parameter can be passed to tell what content-type" +
" to expect in return")
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun get(@RequestParam(value = "bpName") bpName: String,
- @RequestParam(value = "bpVersion") bpVersion: String,
- @RequestParam(value = "artifactName") artifactName: String,
- @RequestParam(value = "resolutionKey") resolutionKey: String,
- @RequestParam(value = "format", required = false, defaultValue = "text/plain") format: String)
+ fun get(
+ @ApiParam(value = "Name of the CBA.", required = true)
+ @RequestParam(value = "bpName") bpName: String,
+ @ApiParam(value = "Version of the CBA.", required = true)
+ @RequestParam(value = "bpVersion") bpVersion: String,
+ @ApiParam(value = "Artifact name for which to retrieve a resolved resource.", required = true)
+ @RequestParam(value = "artifactName") artifactName: String,
+ @ApiParam(value = "Resolution Key associated with the resolution.", required = true)
+ @RequestParam(value = "resolutionKey") resolutionKey: String,
+ @ApiParam(value = "Expected format of the template being retrieved.",
+ defaultValue = MediaType.TEXT_PLAIN_VALUE,
+ required = true)
+ @RequestParam(value = "format", required = false, defaultValue = MediaType.TEXT_PLAIN_VALUE) format: String)
: ResponseEntity<String> = runBlocking {
val result = templateResolutionService.read(bpName, bpVersion, artifactName, resolutionKey)
@@ -68,15 +87,22 @@ open class TemplateController(private val templateResolutionService: TemplateRes
@PostMapping("/{bpName}/{bpVersion}/{artifactName}/{resolutionKey}", produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Store a meshed template",
- notes = "Store a meshed template for a given CBA's action, identified by its blueprint name, blueprint version, " +
- "artifact name and resolution key.")
+ @ApiOperation(value = "Store a resolved template",
+ notes = "Store a template for a given CBA's action, identified by its blueprint name, blueprint version, " +
+ "artifact name and resolution key.",
+ response = TemplateResolution::class,
+ produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun post(@PathVariable(value = "bpName") bpName: String,
+ fun post(@ApiParam(value = "Name of the CBA.", required = true)
+ @PathVariable(value = "bpName") bpName: String,
+ @ApiParam(value = "Version of the CBA.", required = true)
@PathVariable(value = "bpVersion") bpVersion: String,
+ @ApiParam(value = "Artifact name for which to retrieve a resolved resource.", required = true)
@PathVariable(value = "artifactName") artifactName: String,
+ @ApiParam(value = "Resolution Key associated with the resolution.", required = true)
@PathVariable(value = "resolutionKey") resolutionKey: String,
+ @ApiParam(value = "Template to store.", required = true)
@RequestBody result: String): ResponseEntity<TemplateResolution> = runBlocking {
val resultStored =
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resolutionresults/api/ResourceControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resolutionresults/api/ResourceControllerTest.kt
index cde71d86c..daab7b3bb 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resolutionresults/api/ResourceControllerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resolutionresults/api/ResourceControllerTest.kt
@@ -77,7 +77,7 @@ class ResourceControllerTest {
@Test
fun `ping return Success`() {
runBlocking {
- webTestClient.get().uri("/api/v1/resources/ping")
+ webTestClient.get().uri("/api/v1/resources/health-check")
.exchange()
.expectStatus().isOk
.expectBody()
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt
index d12d05804..649f6b5fe 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateControllerTest.kt
@@ -72,7 +72,7 @@ class TemplateControllerTest {
@Test
fun `ping return Success`() {
runBlocking {
- webTestClient.get().uri("/api/v1/template/ping")
+ webTestClient.get().uri("/api/v1/template/health-check")
.exchange()
.expectStatus().isOk
.expectBody()
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
index eff977348..60016fb98 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
@@ -17,15 +17,17 @@
package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
+import com.fasterxml.jackson.databind.JsonNode
+import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
+import io.swagger.annotations.ApiParam
import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.determineHttpStatusCode
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.http.codec.multipart.FilePart
@@ -34,43 +36,59 @@ import org.springframework.web.bind.annotation.*
@RestController
@RequestMapping("/api/v1/execution-service")
+@Api(value = "/api/v1/execution-service",
+ description = "Interaction with CBA.")
open class ExecutionServiceController {
@Autowired
lateinit var executionServiceHandler: ExecutionServiceHandler
- @RequestMapping(path = ["/ping"], method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @RequestMapping(path = ["/health-check"],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
- fun ping(): String = runBlocking {
- "Success"
+ @ApiOperation(value = "Health Check", hidden = true)
+ fun executionServiceControllerHealthCheck(): JsonNode = runBlocking {
+ JacksonUtils.getJsonNode("Success")
}
@PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
- @ApiOperation(value = "Upload CBA", notes = "Takes a File and load it in the runtime database")
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun upload(@RequestPart("file") filePart: FilePart): String = runBlocking {
- executionServiceHandler.upload(filePart)
+ @ApiOperation(value = "Upload a CBA",
+ notes = "Upload the CBA package. This will also run validation on the CBA.",
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ fun upload(@ApiParam(value = "The ZIP file containing the overall CBA package.", required = true)
+ @RequestPart("file") filePart: FilePart): JsonNode = runBlocking {
+ JacksonUtils.getJsonNode(executionServiceHandler.upload(filePart))
}
@DeleteMapping("/name/{name}/version/{version}")
- @Throws(BluePrintException::class)
+ @ApiOperation(value = "Delete a CBA",
+ notes = "Delete the CBA package identified by its name and version.",
+ produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('USER')")
- fun deleteBlueprint(@PathVariable(value = "name") name: String,
+ fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true)
+ @PathVariable(value = "name") name: String,
+ @ApiParam(value = "Version of the CBA.", required = true)
@PathVariable(value = "version") version: String) = runBlocking {
executionServiceHandler.remove(name, version)
}
@RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE])
- @ApiOperation(value = "Resolve Resource Mappings",
- notes = "Takes the blueprint information and process as per the payload")
+ @ApiOperation(value = "Execute a CBA workflow (action)",
+ notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.",
+ produces = MediaType.APPLICATION_JSON_VALUE,
+ response = ExecutionServiceOutput::class)
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun process(@RequestBody executionServiceInput: ExecutionServiceInput): ResponseEntity<ExecutionServiceOutput> = runBlocking {
- if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
- throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
+ fun process(@ApiParam(value = "ExecutionServiceInput payload.", required = true)
+ @RequestBody executionServiceInput: ExecutionServiceInput): ResponseEntity<ExecutionServiceOutput> =
+ runBlocking {
+ if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
+ throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
+ }
+ val processResult = executionServiceHandler.doProcess(executionServiceInput)
+ ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code))
}
- val processResult = executionServiceHandler.doProcess(executionServiceInput)
- ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code))
- }
}