Merge "Enable tests using test containers on jenkins"
[cps.git] / cps-rest / src / main / java / org / onap / cps / rest / controller / CpsRestController.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation
4  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.rest.controller;
22
23 import java.util.Collection;
24 import javax.validation.Valid;
25 import org.modelmapper.ModelMapper;
26 import org.onap.cps.api.CpsAdminService;
27 import org.onap.cps.rest.api.CpsRestApi;
28 import org.onap.cps.spi.model.Anchor;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.http.HttpStatus;
31 import org.springframework.http.ResponseEntity;
32 import org.springframework.web.bind.annotation.RestController;
33 import org.springframework.web.multipart.MultipartFile;
34
35 @RestController
36 public class CpsRestController implements CpsRestApi {
37
38     @Autowired
39     private CpsAdminService cpsAdminService;
40
41     @Autowired
42     private ModelMapper modelMapper;
43
44     /**
45      * Create a new anchor.
46      *
47      * @param anchor        the anchor details object.
48      * @param dataspaceName the dataspace name.
49      * @return a ResponseEntity with the anchor name.
50      */
51     @Override
52     public ResponseEntity<String> createAnchor(final org.onap.cps.rest.model.@Valid Anchor anchor,
53         final String dataspaceName) {
54         final Anchor anchorDetails = modelMapper.map(anchor, Anchor.class);
55         anchorDetails.setDataspaceName(dataspaceName);
56         final String anchorName = cpsAdminService.createAnchor(anchorDetails);
57         return new ResponseEntity<>(anchorName, HttpStatus.CREATED);
58     }
59
60     @Override
61     public ResponseEntity<Object> createNode(@Valid final MultipartFile multipartFile, final String dataspaceName) {
62         return null;
63     }
64
65     @Override
66     public ResponseEntity<Object> deleteAnchor(final String dataspaceName, final String anchorName) {
67         return null;
68     }
69
70     @Override
71     public ResponseEntity<Object> deleteDataspace(final String dataspaceName) {
72         return null;
73     }
74
75     @Override
76     public ResponseEntity<Object> getAnchor(final String dataspaceName, final String anchorName) {
77         return null;
78     }
79
80     @Override
81
82     public ResponseEntity<Object> getAnchors(final String dataspaceName) {
83         final Collection<Anchor> anchorDetails = cpsAdminService.getAnchors(dataspaceName);
84         return new ResponseEntity<>(anchorDetails, HttpStatus.OK);
85     }
86
87     @Override
88     public ResponseEntity<Object> getModule(final String dataspaceName, @Valid final String namespaceName,
89         @Valid final String revision) {
90         return null;
91     }
92
93     @Override
94     public ResponseEntity<Object> getNode(final String dataspaceName) {
95         return null;
96     }
97
98     @Override
99     public ResponseEntity<Object> getNodeByDataspaceAndAnchor(final String dataspaceName, final String anchorName) {
100         return null;
101     }
102 }