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.controllerblueprints.service.controller
19 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
20 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
21 import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler
22 import org.springframework.http.MediaType
23 import org.springframework.web.bind.annotation.*
26 @RequestMapping(value = arrayOf("/api/v1/model-type"))
27 open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
29 @GetMapping(path = arrayOf("/{name}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
30 fun getModelTypeByName(@PathVariable(value = "name") name: String): ModelType? {
31 return modelTypeHandler.getModelTypeByName(name)
34 @GetMapping(path = arrayOf("/search/{tags}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
35 fun searchModelTypes(@PathVariable(value = "tags") tags: String): List<ModelType> {
36 return modelTypeHandler.searchModelTypes(tags)
39 @GetMapping(path = arrayOf("/by-definition/{definitionType}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
41 fun getModelTypeByDefinitionType(@PathVariable(value = "definitionType") definitionType: String): List<ModelType> {
42 return modelTypeHandler.getModelTypeByDefinitionType(definitionType)
45 @PostMapping(path = arrayOf(""), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE))
47 @Throws(BluePrintException::class)
48 fun saveModelType(@RequestBody modelType: ModelType): ModelType {
49 return modelTypeHandler.saveModel(modelType)
52 @DeleteMapping(path = arrayOf("/{name}"))
53 fun deleteModelTypeByName(@PathVariable(value = "name") name: String) {
54 modelTypeHandler.deleteByModelName(name)