2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 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.participant.sim.rest;
23 import jakarta.validation.Valid;
24 import jakarta.ws.rs.core.MediaType;
25 import java.util.UUID;
26 import lombok.RequiredArgsConstructor;
27 import org.onap.policy.clamp.acm.participant.sim.controller.genapi.SimulatorParticipantControllerApi;
28 import org.onap.policy.clamp.acm.participant.sim.main.handler.AutomationCompositionElementHandler;
29 import org.onap.policy.clamp.acm.participant.sim.model.InternalData;
30 import org.onap.policy.clamp.acm.participant.sim.model.InternalDatas;
31 import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
32 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
33 import org.springframework.http.HttpStatus;
34 import org.springframework.http.ResponseEntity;
35 import org.springframework.web.bind.annotation.RequestBody;
36 import org.springframework.web.bind.annotation.RequestMapping;
37 import org.springframework.web.bind.annotation.RestController;
39 @RequiredArgsConstructor
41 @RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON})
42 public class SimulatorController implements SimulatorParticipantControllerApi {
44 private final AutomationCompositionElementHandler automationCompositionElementHandler;
47 public ResponseEntity<SimConfig> getConfig(UUID xonapRequestId) {
48 return new ResponseEntity<>(automationCompositionElementHandler.getConfig(), HttpStatus.OK);
52 public ResponseEntity<Void> setConfig(UUID xonapRequestId, @Valid @RequestBody SimConfig body) {
53 automationCompositionElementHandler.setConfig(body);
54 return new ResponseEntity<>(HttpStatus.OK);
58 public ResponseEntity<AutomationCompositions> getAutomationCompositions(UUID xonapRequestId) {
59 return new ResponseEntity<>(automationCompositionElementHandler.getAutomationCompositions(), HttpStatus.OK);
63 public ResponseEntity<InternalDatas> getDatas(UUID xonapRequestId) {
64 return new ResponseEntity<>(automationCompositionElementHandler.getDataList(), HttpStatus.OK);
70 * @param body the Data
74 public ResponseEntity<Void> setData(UUID xonapRequestId, @Valid @RequestBody InternalData body) {
75 automationCompositionElementHandler.setOutProperties(body.getAutomationCompositionId(),
76 body.getAutomationCompositionElementId(), body.getUseState(), body.getOperationalState(),
77 body.getOutProperties());
78 return new ResponseEntity<>(HttpStatus.OK);