summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-07-08 15:13:57 +0000
committerGerrit Code Review <gerrit@onap.org>2019-07-08 15:13:57 +0000
commitefad912becfc6923414ad3edffa7bad85420a8d4 (patch)
tree8299d4c5a60c2b1ec5e61f0a2bd51096db3d55f1 /ms/blueprintsprocessor/modules/inbounds/selfservice-api/src
parentd13961fbbf4eeaed3f2f70e6d189979d47f6fdb9 (diff)
parent2791db21e7d7f7d31ea402fe978dab216a41367f (diff)
Merge "Fix swagger definition for blueprint processor"
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api/src')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt54
1 files changed, 36 insertions, 18 deletions
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))
- }
}