summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
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
parentd13961fbbf4eeaed3f2f70e6d189979d47f6fdb9 (diff)
parent2791db21e7d7f7d31ea402fe978dab216a41367f (diff)
Merge "Fix swagger definition for blueprint processor"
Diffstat (limited to 'ms/blueprintsprocessor/modules')
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt59
-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
6 files changed, 158 insertions, 75 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index c2698c026..c45ebc127 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -30,24 +30,32 @@ import java.util.*
*/
open class ExecutionServiceInput {
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Headers providing request context.")
lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true,
+ value = "Contain the information to be passed as input to the action." +
+ "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
+ " and the input for resource resolution located within the xxx-request block, contained within xxx-properties")
lateinit var payload: ObjectNode
+ @get:ApiModelProperty(hidden = true)
var stepData: StepData? = null
}
open class ExecutionServiceOutput {
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Headers providing request context.")
lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Provide information about the action to execute.")
lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Status of the request.")
lateinit var status: Status
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true,
+ value = "Contain the information to be passed as input to the action." +
+ "The payload is constituted of two section: the workflow input which is the higher level block (xxx-request)" +
+ " and the input for resource resolution located within the xxx-request block, contained within xxx-properties")
lateinit var payload: ObjectNode
+ @get:ApiModelProperty(hidden = true)
var stepData: StepData? = null
}
@@ -55,53 +63,56 @@ const val ACTION_MODE_ASYNC = "async"
const val ACTION_MODE_SYNC = "sync"
open class ActionIdentifiers {
- @get:ApiModelProperty(required = false)
+ @get:ApiModelProperty(required = false, value = "Name of the CBA.")
lateinit var blueprintName: String
- @get:ApiModelProperty(required = false)
+ @get:ApiModelProperty(required = false, value = "Version of the CBA.")
lateinit var blueprintVersion: String
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Name of the workflow to execute.")
lateinit var actionName: String
- @get:ApiModelProperty(required = true, allowableValues = "sync, async")
+ @get:ApiModelProperty(required = true,
+ value = "Async processing is only supported for gRPC client.",
+ allowableValues = "sync, async")
lateinit var mode: String
}
open class CommonHeader {
- @get:ApiModelProperty(required = true, example = "2012-04-23T18:25:43.511Z")
+ @get:ApiModelProperty(required = true, value = "Date of the execution", example = "2012-04-23T18:25:43.511Z")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
var timestamp: Date = Date()
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Identify the system/person triggering the request.")
lateinit var originatorId: String
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Uniquely identify a request.")
lateinit var requestId: String
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Allow for fine-grain request identifier")
lateinit var subRequestId: String
- @get:ApiModelProperty(required = false)
+ @get:ApiModelProperty(required = false, hidden = true)
var flags: Flags? = null
}
open class Flags {
+ @get:ApiModelProperty(value = "Whether or not to force the action.")
var isForce: Boolean = false
@get:ApiModelProperty(value = "3600")
var ttl: Int = 3600
}
open class Status {
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "HTTP status code equivalent.")
var code: Int = 200
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Type of the event being emitted by CDS.")
var eventType: String = ""
- @get:ApiModelProperty(required = true, example = "2012-04-23T18:25:43.511Z")
+ @get:ApiModelProperty(required = true,
+ value = "Time when the execution ended.",
+ example = "2012-04-23T18:25:43.511Z")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
var timestamp: Date = Date()
- @get:ApiModelProperty(required = false)
+ @get:ApiModelProperty(required = false, value = "Error message when system failed")
var errorMessage: String? = null
- @get:ApiModelProperty(required = true)
+ @get:ApiModelProperty(required = true, value = "Message providing request status")
var message: String = "success"
}
open class StepData {
lateinit var name: String
var properties: MutableMap<String, JsonNode> = mutableMapOf()
-}
-
-
+} \ No newline at end of file
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))
- }
}