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.AutomationComposition;
33 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
34 import org.springframework.http.HttpStatus;
35 import org.springframework.http.ResponseEntity;
36 import org.springframework.web.bind.annotation.RequestBody;
37 import org.springframework.web.bind.annotation.RequestMapping;
38 import org.springframework.web.bind.annotation.RestController;
40 @RequiredArgsConstructor
42 @RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON})
43 public class SimulatorController implements SimulatorParticipantControllerApi {
45 private final AutomationCompositionElementHandler automationCompositionElementHandler;
48 public ResponseEntity<SimConfig> getConfig(UUID xonapRequestId) {
49 return new ResponseEntity<>(automationCompositionElementHandler.getConfig(), HttpStatus.OK);
53 public ResponseEntity<Void> setConfig(UUID xonapRequestId, @Valid @RequestBody SimConfig body) {
54 automationCompositionElementHandler.setConfig(body);
55 return new ResponseEntity<>(HttpStatus.OK);
59 public ResponseEntity<AutomationCompositions> getAutomationCompositions(UUID xonapRequestId) {
60 return new ResponseEntity<>(automationCompositionElementHandler.getAutomationCompositions(), HttpStatus.OK);
64 public ResponseEntity<AutomationComposition> getAutomationComposition(UUID instanceId, UUID xonapRequestId) {
65 return new ResponseEntity<>(automationCompositionElementHandler.getAutomationComposition(instanceId),
70 public ResponseEntity<InternalDatas> getDatas(UUID xonapRequestId) {
71 return new ResponseEntity<>(automationCompositionElementHandler.getDataList(), HttpStatus.OK);
77 * @param body the Data
81 public ResponseEntity<Void> setData(UUID xonapRequestId, @Valid @RequestBody InternalData body) {
82 automationCompositionElementHandler.setOutProperties(body.getAutomationCompositionId(),
83 body.getAutomationCompositionElementId(), body.getUseState(), body.getOperationalState(),
84 body.getOutProperties());
85 return new ResponseEntity<>(HttpStatus.OK);
89 public ResponseEntity<InternalDatas> getCompositionDatas(UUID xonapRequestId) {
90 return new ResponseEntity<>(automationCompositionElementHandler.getCompositionDataList(), HttpStatus.OK);
94 public ResponseEntity<Void> setCompositionData(UUID xonapRequestId, @Valid InternalData body) {
95 automationCompositionElementHandler.setCompositionOutProperties(body.getCompositionId(),
96 body.getCompositionDefinitionElementId(), body.getOutProperties());
97 return new ResponseEntity<>(HttpStatus.OK);