2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * 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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.clamp.acm.element.main.rest;
23 import java.util.UUID;
24 import lombok.RequiredArgsConstructor;
25 import org.onap.policy.clamp.acm.element.main.rest.genapi.AcElementControllerApi;
26 import org.onap.policy.clamp.acm.element.service.ConfigService;
27 import org.onap.policy.clamp.models.acm.messages.rest.element.ElementConfig;
28 import org.springframework.http.HttpStatus;
29 import org.springframework.http.ResponseEntity;
30 import org.springframework.web.bind.annotation.RestController;
33 @RequiredArgsConstructor
34 public class AcElementController implements AcElementControllerApi {
36 private final ConfigService configService;
39 * REST end point to get the existing element configuration.
41 * @return the element configuration parameters
44 public ResponseEntity<ElementConfig> getElementConfig(UUID onapRequestId) {
45 return new ResponseEntity<>(configService.getElementConfig(), HttpStatus.OK);
49 * REST end point to activate the element.
51 * @param params element parameters for this AC element
54 public ResponseEntity<String> activateElement(UUID onapRequestId, ElementConfig params) {
55 configService.activateElement(params);
56 return new ResponseEntity<>(HttpStatus.CREATED);
60 * REST end point to delete the element configuration.
62 * @return Status of operation
65 public ResponseEntity<Void> deleteConfig(UUID onapRequestId) {
66 configService.deleteConfig();
67 return new ResponseEntity<>(HttpStatus.NO_CONTENT);