2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
19 import io.swagger.annotations.ApiOperation
20 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
21 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
22 import org.springframework.beans.factory.annotation.Autowired
23 import org.springframework.http.MediaType
24 import org.springframework.http.codec.multipart.FilePart
25 import org.springframework.web.bind.annotation.PostMapping
26 import org.springframework.web.bind.annotation.RequestBody
27 import org.springframework.web.bind.annotation.RequestMapping
28 import org.springframework.web.bind.annotation.RequestMethod
29 import org.springframework.web.bind.annotation.RequestPart
30 import org.springframework.web.bind.annotation.ResponseBody
31 import org.springframework.web.bind.annotation.RestController
32 import reactor.core.publisher.Mono
35 @RequestMapping("/api/v1/execution-service")
36 class ExecutionServiceController {
39 lateinit var executionServiceHandler: ExecutionServiceHandler
41 @RequestMapping(path = ["/ping"], method = [RequestMethod.GET], produces = [MediaType.APPLICATION_JSON_VALUE])
43 fun ping(): Mono<String> {
44 return Mono.just("Success")
47 @PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
48 @ApiOperation(value = "Upload CBA", notes = "Takes a File and load it in the runtime database")
50 fun upload(@RequestPart("file") parts: Mono<FilePart>): Mono<String> {
52 .filter { it is FilePart }
53 .ofType(FilePart::class.java)
54 .flatMap(executionServiceHandler::upload)
57 @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE])
58 @ApiOperation(value = "Resolve Resource Mappings", notes = "Takes the blueprint information and process as per the payload")
60 fun process(@RequestBody executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
61 return executionServiceHandler.process(executionServiceInput)