1st drop integration with BluePrintCatalogService
[ccsdk/apps.git] / ms / controllerblueprints / modules / service / src / main / java / org / onap / ccsdk / apps / controllerblueprints / service / rs / BlueprintModelRest.java
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/BlueprintModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/BlueprintModelRest.java
new file mode 100644 (file)
index 0000000..9d0b1e3
--- /dev/null
@@ -0,0 +1,90 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2019 Bell Canada.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
+\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.BlueprintModelService;\r
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.core.io.Resource;\r
+import org.springframework.http.MediaType;\r
+import org.springframework.http.ResponseEntity;\r
+import org.springframework.http.codec.multipart.FilePart;\r
+import org.springframework.web.bind.annotation.*;\r
+import reactor.core.publisher.Mono;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * {@inheritDoc}\r
+ */\r
+@RestController\r
+@RequestMapping(value = "/api/v1/blueprint-model")\r
+public class BlueprintModelRest {\r
+\r
+    @Autowired\r
+    private BlueprintModelService blueprintModelService;\r
+\r
+    @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)\r
+    public @ResponseBody\r
+    Mono<BlueprintModelSearch> saveBluePrint(@RequestPart("file") FilePart file) throws BluePrintException{\r
+        return blueprintModelService.saveBlueprintModel(file);\r
+    }\r
+\r
+    @DeleteMapping(path = "/{id}")\r
+    public void deleteBluePrint(@PathVariable(value = "id") String id) throws BluePrintException {\r
+        this.blueprintModelService.deleteBlueprintModel(id);\r
+    }\r
+\r
+    @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public @ResponseBody\r
+    BlueprintModelSearch getBluePrintByNameAndVersion(@PathVariable(value = "name") String name,\r
+                                                          @PathVariable(value = "version") String version) throws BluePrintException {\r
+        return this.blueprintModelService.getBlueprintModelByNameAndVersion(name, version);\r
+    }\r
+\r
+    @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public @ResponseBody\r
+    BlueprintModelSearch getCBA(@PathVariable(value = "id") String id) throws BluePrintException {\r
+        return this.blueprintModelService.getBlueprintModelSearch(id);\r
+    }\r
+\r
+    @GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public @ResponseBody\r
+    List<BlueprintModelSearch> getAllCBA() {\r
+        return this.blueprintModelService.getAllBlueprintModel();\r
+    }\r
+\r
+    @GetMapping(path = "/download/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public @ResponseBody\r
+    ResponseEntity<Resource> downloadBluePrint(@PathVariable(value = "id") String id) throws BluePrintException {\r
+        return this.blueprintModelService.downloadBlueprintModelFile(id);\r
+    }\r
+\r
+    @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public @ResponseBody\r
+    BlueprintModelSearch publishBlueprintModel(@PathVariable(value = "id") String id) throws BluePrintException {\r
+        return this.blueprintModelService.publishBlueprintModel(id);\r
+    }\r
+\r
+    @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
+    public @ResponseBody\r
+    List<BlueprintModelSearch> searchBlueprintModels(@PathVariable(value = "tags") String tags) {\r
+        return this.blueprintModelService.searchBlueprintModels(tags);\r
+    }\r
+}\r