Replacing ModelMapper with MapStruct
[cps.git] / cps-ncmp-rest / src / main / java / org / onap / cps / ncmp / rest / controller / NetworkCmProxyInventoryController.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Bell Canada
4  *  Modifications Copyright (C) 2022 Nordix Foundation
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  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 package org.onap.cps.ncmp.rest.controller;
23
24 import javax.validation.Valid;
25 import lombok.RequiredArgsConstructor;
26 import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
27 import org.onap.cps.ncmp.rest.api.NetworkCmProxyInventoryApi;
28 import org.onap.cps.ncmp.rest.model.RestDmiPluginRegistration;
29 import org.springframework.http.HttpStatus;
30 import org.springframework.http.ResponseEntity;
31 import org.springframework.web.bind.annotation.RequestMapping;
32 import org.springframework.web.bind.annotation.RestController;
33
34 @RestController
35 @RequestMapping("${rest.api.ncmp-inventory-base-path}")
36 @RequiredArgsConstructor
37 public class NetworkCmProxyInventoryController implements NetworkCmProxyInventoryApi {
38
39     private final NetworkCmProxyDataService networkCmProxyDataService;
40     private final NcmpRestInputMapper ncmpRestInputMapper;
41
42     /**
43      * Update DMI Plugin Registration (used for first registration also).
44      * @param restDmiPluginRegistration the registration data
45      */
46     @Override
47     public ResponseEntity<Void> updateDmiPluginRegistration(
48         final @Valid RestDmiPluginRegistration restDmiPluginRegistration) {
49         networkCmProxyDataService.updateDmiRegistrationAndSyncModule(
50             ncmpRestInputMapper.toDmiPluginRegistration(restDmiPluginRegistration));
51         return new ResponseEntity<>(HttpStatus.NO_CONTENT);
52     }
53
54 }
55
56