2 * Copyright © 2019 IBM.
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.cds.controllerblueprints.service.controller
19 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
20 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping
21 import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary
22 import org.onap.ccsdk.cds.controllerblueprints.service.handler.ResourceDictionaryHandler
23 import org.springframework.http.MediaType
24 import org.springframework.web.bind.annotation.*
27 @RequestMapping(value = ["/api/v1/dictionary"])
28 open class ResourceDictionaryController(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
30 @GetMapping(path = ["/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE])
32 @Throws(BluePrintException::class)
33 fun getResourceDictionaryByName(@PathVariable(value = "name") name: String): ResourceDictionary {
34 return resourceDictionaryHandler.getResourceDictionaryByName(name)
37 @PostMapping(path = [""], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
39 @Throws(BluePrintException::class)
40 fun saveResourceDictionary(@RequestBody dataDictionary: ResourceDictionary): ResourceDictionary {
41 return resourceDictionaryHandler.saveResourceDictionary(dataDictionary)
44 @DeleteMapping(path = ["/{name}"])
45 fun deleteResourceDictionaryByName(@PathVariable(value = "name") name: String) {
46 resourceDictionaryHandler.deleteResourceDictionary(name)
49 @PostMapping(path = ["/by-names"], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
51 fun searchResourceDictionaryByNames(@RequestBody names: List<String>): List<ResourceDictionary> {
52 return resourceDictionaryHandler.searchResourceDictionaryByNames(names)
55 @GetMapping(path = ["/search/{tags}"], produces = [MediaType.APPLICATION_JSON_VALUE])
57 fun searchResourceDictionaryByTags(@PathVariable(value = "tags") tags: String): List<ResourceDictionary> {
58 return resourceDictionaryHandler.searchResourceDictionaryByTags(tags)
62 @GetMapping(path = ["/source-mapping"], produces = [MediaType.APPLICATION_JSON_VALUE])
64 fun getResourceSourceMapping(): ResourceSourceMapping {
65 return resourceDictionaryHandler.getResourceSourceMapping()