aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-simulator/src/main
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-06-13 09:19:08 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-06-13 10:43:14 +0100
commit73a48d9c7e599baf145820d0bc0968040142dac8 (patch)
tree6c43242a65decb54306ecd29bbe6a6591721f280 /participant/participant-impl/participant-impl-simulator/src/main
parent33f508d48de474c752c2c06d396b7b946f998447 (diff)
Add Java Implementation for mock participant in ACM
Add Java Code Implementation for mock participant to test different ACM scenarios. Issue-ID: POLICY-4722 Change-Id: I8475c05c2469e190ca81d4caff0babc22c5d6db9 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/main')
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/FilterConfig.java44
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java46
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SecurityConfig.java49
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SpringDocBean.java48
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java290
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java36
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java31
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java58
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java80
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml339
10 files changed, 1021 insertions, 0 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/FilterConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/FilterConfig.java
new file mode 100644
index 000000000..b685970eb
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/FilterConfig.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.config;
+
+import org.onap.policy.clamp.common.acm.rest.RequestResponseLoggingFilter;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class FilterConfig {
+
+ /**
+ * Logging Filter configuration.
+ *
+ * @return FilterRegistrationBean
+ */
+ @Bean
+ public FilterRegistrationBean<RequestResponseLoggingFilter> loggingFilter() {
+ FilterRegistrationBean<RequestResponseLoggingFilter> registrationBean = new FilterRegistrationBean<>();
+
+ registrationBean.setFilter(new RequestResponseLoggingFilter());
+ registrationBean.addUrlPatterns("/onap/policy/clamp/acm/simparticipant/v2/*");
+ return registrationBean;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java
new file mode 100644
index 000000000..2a319c3bd
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.config;
+
+import io.micrometer.core.aop.TimedAspect;
+import io.micrometer.core.instrument.MeterRegistry;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MicrometerConfig {
+
+ /**
+ * Load up the metrics registry.
+ */
+ @Bean
+ public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
+ return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
+ }
+
+ @Bean
+ public TimedAspect timedAspect(MeterRegistry registry) {
+ return new TimedAspect(registry);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SecurityConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SecurityConfig.java
new file mode 100644
index 000000000..f15491c4d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SecurityConfig.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.web.SecurityFilterChain;
+
+/**
+ * Configure how access to this module's REST end points is secured.
+ */
+@Configuration
+public class SecurityConfig {
+ /**
+ * Return the configuration of how access to this module's REST end points is secured.
+ *
+ * @param http the HTTP security settings
+ * @return the HTTP security settings
+ */
+ @Bean
+ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
+ http
+ .httpBasic()
+ .and()
+ .authorizeHttpRequests().anyRequest().authenticated()
+ .and()
+ .csrf().disable();
+ return http.build();
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SpringDocBean.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SpringDocBean.java
new file mode 100644
index 000000000..7bf1d1def
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/SpringDocBean.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.config;
+
+import io.swagger.v3.oas.models.ExternalDocumentation;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SpringDocBean {
+
+ /**
+ * Bean to configure Springdoc.
+ *
+ * @return the OpenAPI specification
+ */
+ @Bean
+ public OpenAPI acmElementParticipantOpenApi() {
+ return new OpenAPI()
+ .info(new Info().title("ACM Mock Participant")
+ .description("CLAMP Mock Participant API")
+ .license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
+ .externalDocs(new ExternalDocumentation()
+ .description("CLAMP Automation Composition Management Documentation")
+ .url("https://docs.onap.org/projects/onap-policy-parent/en/latest/clamp/clamp.html"));
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
new file mode 100644
index 000000000..7554c0b3c
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
@@ -0,0 +1,290 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.main.handler;
+
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.sim.model.InternalData;
+import org.onap.policy.clamp.acm.participant.sim.model.InternalDatas;
+import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
+import org.onap.policy.clamp.models.acm.concepts.DeployState;
+import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.models.base.PfModelException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class handles implementation of automationCompositionElement updates.
+ */
+@Component
+@RequiredArgsConstructor
+public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private final ParticipantIntermediaryApi intermediaryApi;
+
+ @Getter
+ @Setter
+ private SimConfig config = new SimConfig();
+
+ /**
+ * Callback method to handle an update on a automation composition element.
+ *
+ * @param automationCompositionId the automationComposition Id
+ * @param element the information on the automation composition element
+ * @param properties properties Map
+ * @throws PfModelException in case of a exception
+ */
+ @Override
+ public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException {
+ LOGGER.debug("deploy call");
+
+ if (!execution(config.getDeployTimerMs(), "Current Thread deploy is Interrupted during execution {}",
+ element.getId())) {
+ return;
+ }
+
+ if (config.isDeploySuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Deploy failed!");
+ }
+ }
+
+ private boolean execution(int timeMs, String msg, UUID elementId) {
+ long endTime = System.currentTimeMillis() + timeMs;
+ while (System.currentTimeMillis() < endTime) {
+ try {
+ if (Thread.currentThread().isInterrupted()) {
+ LOGGER.debug(msg, elementId);
+ return false;
+ }
+ Thread.sleep(10L);
+ } catch (InterruptedException e) {
+ LOGGER.debug(msg, elementId);
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Handle a automation composition element state change.
+ *
+ * @param automationCompositionElementId the ID of the automation composition element
+ */
+ @Override
+ public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ LOGGER.debug("undeploy call");
+
+ if (!execution(config.getUndeployTimerMs(), "Current Thread undeploy is Interrupted during execution {}",
+ automationCompositionElementId)) {
+ return;
+ }
+
+ if (config.isUndeploySuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Undeployed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.DEPLOYED, null, StateChangeResult.FAILED,
+ "Undeploy failed!");
+ }
+ }
+
+ @Override
+ public void lock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ LOGGER.debug("lock call");
+
+ if (!execution(config.getLockTimerMs(), "Current Thread lock is Interrupted during execution {}",
+ automationCompositionElementId)) {
+ return;
+ }
+
+ if (config.isLockSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.UNLOCKED, StateChangeResult.FAILED, "Lock failed!");
+ }
+ }
+
+ @Override
+ public void unlock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ LOGGER.debug("unlock call");
+
+ if (!execution(config.getUnlockTimerMs(), "Current Thread unlock is Interrupted during execution {}",
+ automationCompositionElementId)) {
+ return;
+ }
+
+ if (config.isUnlockSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.LOCKED, StateChangeResult.FAILED, "Unlock failed!");
+ }
+ }
+
+ @Override
+ public void delete(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ LOGGER.debug("delete call");
+
+ if (!execution(config.getDeleteTimerMs(), "Current Thread delete is Interrupted during execution {}",
+ automationCompositionElementId)) {
+ return;
+ }
+
+ if (config.isDeleteSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ "Delete failed!");
+ }
+ }
+
+ @Override
+ public void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException {
+ LOGGER.debug("updat call");
+
+ if (!execution(config.getUpdateTimerMs(), "Current Thread update is Interrupted during execution {}",
+ element.getId())) {
+ return;
+ }
+
+ if (config.isUpdateSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
+ }
+ }
+
+ /**
+ * Get AutomationComposition.
+ *
+ * @return the AutomationCompositions
+ */
+ public AutomationCompositions getAutomationCompositions() {
+ var result = new AutomationCompositions();
+ result.setAutomationCompositionList(new ArrayList<>(intermediaryApi.getAutomationCompositions().values()));
+ return result;
+ }
+
+ /**
+ * Set OutProperties.
+ *
+ * @param automationCompositionId the automationComposition Id
+ * @param elementId the automationComposition Element Id
+ * @param useState the useState
+ * @param operationalState the operationalState
+ * @param outProperties the outProperties
+ */
+ public void setOutProperties(UUID automationCompositionId, UUID elementId, String useState, String operationalState,
+ Map<String, Object> outProperties) {
+ intermediaryApi.sendAcElementInfo(automationCompositionId, elementId, useState, operationalState,
+ outProperties);
+ }
+
+ @Override
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
+ throws PfModelException {
+
+ if (!execution(config.getPrimeTimerMs(), "Current Thread prime is Interrupted during execution {}",
+ compositionId)) {
+ return;
+ }
+
+ if (config.isPrimeSuccess()) {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
+ "Primed");
+ } else {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.FAILED,
+ "Prime failed!");
+ }
+ }
+
+ @Override
+ public void deprime(UUID compositionId) throws PfModelException {
+
+ if (!execution(config.getDeprimeTimerMs(), "Current Thread deprime is Interrupted during execution {}",
+ compositionId)) {
+ return;
+ }
+
+ if (config.isDeprimeSuccess()) {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
+ "Deprimed");
+ } else {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.FAILED,
+ "Deprime failed!");
+ }
+ }
+
+ /**
+ * Get Data List.
+ *
+ * @return the InternalDatas
+ */
+ public InternalDatas getDataList() {
+ var result = new InternalDatas();
+ var map = intermediaryApi.getAutomationCompositions();
+ for (var instance : map.values()) {
+ for (var element : instance.getElements().values()) {
+ var data = new InternalData();
+ data.setAutomationCompositionId(instance.getInstanceId());
+ data.setAutomationCompositionElementId(element.getId());
+ data.setIntProperties(element.getProperties());
+ data.setOperationalState(element.getOperationalState());
+ data.setUseState(element.getUseState());
+ data.setOutProperties(element.getOutProperties());
+ result.getList().add(data);
+ }
+ }
+ return result;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java
new file mode 100644
index 000000000..14e53338d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.model;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+import lombok.Data;
+
+@Data
+public class InternalData {
+ Map<String, Object> intProperties = new LinkedHashMap<>();
+ Map<String, Object> outProperties = new LinkedHashMap<>();
+ UUID automationCompositionId;
+ UUID automationCompositionElementId;
+ String useState;
+ String operationalState;
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java
new file mode 100644
index 000000000..ca7844657
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Data;
+
+@Data
+public class InternalDatas {
+
+ List<InternalData> list = new ArrayList<>();
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
new file mode 100644
index 000000000..cf216c1e8
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.model;
+
+import lombok.Data;
+
+@Data
+public class SimConfig {
+ private boolean deploySuccess = true;
+
+ private boolean undeploySuccess = true;
+
+ private boolean lockSuccess = true;
+
+ private boolean unlockSuccess = true;
+
+ private boolean deleteSuccess = true;
+
+ private boolean updateSuccess = true;
+
+ private boolean primeSuccess = true;
+
+ private boolean deprimeSuccess = true;
+
+ private int deployTimerMs = 1000;
+
+ private int undeployTimerMs = 1000;
+
+ private int lockTimerMs = 100;
+
+ private int unlockTimerMs = 100;
+
+ private int updateTimerMs = 100;
+
+ private int deleteTimerMs = 100;
+
+ private int primeTimerMs = 100;
+
+ private int deprimeTimerMs = 100;
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
new file mode 100644
index 000000000..a12e5f70d
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.participant.sim.rest;
+
+import java.util.UUID;
+import javax.validation.Valid;
+import javax.ws.rs.core.MediaType;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.clamp.acm.participant.sim.controller.genapi.SimulatorParticipantControllerApi;
+import org.onap.policy.clamp.acm.participant.sim.main.handler.AutomationCompositionElementHandler;
+import org.onap.policy.clamp.acm.participant.sim.model.InternalData;
+import org.onap.policy.clamp.acm.participant.sim.model.InternalDatas;
+import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequiredArgsConstructor
+@RestController
+@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON})
+public class SimulatorController implements SimulatorParticipantControllerApi {
+
+ private final AutomationCompositionElementHandler automationCompositionElementHandler;
+
+ @Override
+ public ResponseEntity<SimConfig> getConfig(UUID xonapRequestId) {
+ return new ResponseEntity<>(automationCompositionElementHandler.getConfig(), HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> setConfig(UUID xonapRequestId, @Valid @RequestBody SimConfig body) {
+ automationCompositionElementHandler.setConfig(body);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<AutomationCompositions> getAutomationCompositions(UUID xonapRequestId) {
+ return new ResponseEntity<>(automationCompositionElementHandler.getAutomationCompositions(), HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<InternalDatas> getDatas(UUID xonapRequestId) {
+ return new ResponseEntity<>(automationCompositionElementHandler.getDataList(), HttpStatus.OK);
+ }
+
+ /**
+ * Set Data.
+ *
+ * @param body the Data
+ * @return Void
+ */
+ @Override
+ public ResponseEntity<Void> setData(UUID xonapRequestId, @Valid @RequestBody InternalData body) {
+ automationCompositionElementHandler.setOutProperties(body.getAutomationCompositionId(),
+ body.getAutomationCompositionElementId(), body.getUseState(), body.getOperationalState(),
+ body.getOutProperties());
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
new file mode 100644
index 000000000..b95aa33cd
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
@@ -0,0 +1,339 @@
+openapi: 3.0.3
+info:
+ title: ACM Simulator Participant
+ description: CLAMP Automation Composition Management Simulator Participant API
+ contact:
+ name: ONAP Support
+ url: https://lists.onap.org/g/onap-discuss
+ email: onap-discuss@lists.onap.org
+ license:
+ name: Apache 2.0
+ url: http://www.apache.org/licenses/LICENSE-2.0
+ version: '1.0'
+externalDocs:
+ description: CLAMP Automation Composition Management Documentation
+ url: https://docs.onap.org/projects/onap-policy-parent/en/latest/clamp/clamp.html
+tags:
+ - name: Simulator-participant-controller
+ description: Automation Composition Element Test Participant controller
+servers:
+ - url: http:{port}/{server}
+ variables:
+ port:
+ default: "8084"
+ description: This value is assigned by the service provider
+ server:
+ default: /onap/policy/clamp/acm/simparticipant
+ description: This value is assigned by the service provider
+paths:
+ /parameters:
+ get:
+ tags:
+ - Simulator-participant-controller
+ summary: Return all Parameters
+ description: Return all the parameters configured in the Simulator Participant
+ operationId: getConfig
+ parameters:
+ - name: X-onap-RequestId
+ in: header
+ description: RequestID for http transaction
+ schema:
+ type: string
+ format: uuid
+ responses:
+ 200:
+ description: OK, reutrns a serialised instance of
+ [SimConfig](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java)
+ headers:
+ api-version:
+ schema:
+ type: string
+ X-LatestVersion:
+ schema:
+ type: string
+ description: Used only to communicate an API's latest version
+ X-PatchVersion:
+ schema:
+ type: string
+ description:
+ Used only to communicate a PATCH version in a response for troubleshooting purposes only,
+ and will not be provided by the client on request
+ X-MinorVersion:
+ schema:
+ type: string
+ description:
+ Used to request or communicate a MINOR version back from the client
+ to the server, and from the server back to the client
+ X-onap-RequestId:
+ schema:
+ type: string
+ format: uuid
+ description: Used to track REST transactions for logging purposes
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/SimConfig'
+ application/yaml:
+ schema:
+ $ref: '#/components/schemas/SimConfig'
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
+ put:
+ tags:
+ - Simulator-participant-controller
+ summary: change the parameters
+ description: >-
+ Change the parameters the behaviour of the Simulator Participant
+ operationId: setConfig
+ parameters:
+ - name: X-ONAP-RequestID
+ in: header
+ description: RequestID for http transaction
+ required: false
+ schema:
+ type: string
+ format: uuid
+ requestBody:
+ description: The information for the behaviour in a serialised instance of
+ [SimConfig](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java)
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/SimConfig'
+ application/yaml:
+ schema:
+ $ref: '#/components/schemas/SimConfig'
+ responses:
+ 200:
+ description: OK, the parameters has been saved
+ headers:
+ api-version:
+ schema:
+ type: string
+ X-LatestVersion:
+ schema:
+ type: string
+ description: Used only to communicate an API's latest version
+ X-PatchVersion:
+ schema:
+ type: string
+ description:
+ Used only to communicate a PATCH version in a response for troubleshooting purposes only,
+ and will not be provided by the client on request
+ X-MinorVersion:
+ schema:
+ type: string
+ description:
+ Used to request or communicate a MINOR version back from the client
+ to the server, and from the server back to the client
+ X-onap-RequestId:
+ schema:
+ type: string
+ format: uuid
+ description: Used to track REST transactions for logging purposes
+ 400:
+ description: Bad Request
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
+ /instances:
+ get:
+ tags:
+ - Simulator-participant-controller
+ summary: Query details of the requested automation composition instances
+ description: Query details of the requested automation composition instances for the given automation composition definition ID, returning
+ details of all its automation composition instances
+ operationId: getAutomationCompositions
+ parameters:
+ - name: X-onap-RequestId
+ in: header
+ description: RequestID for http transaction
+ schema:
+ type: string
+ format: uuid
+ responses:
+ 200:
+ description: Serialised instance of
+ [AutomationCompositions](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java)
+ containing a list of automation composition instances found
+ headers:
+ api-version:
+ schema:
+ type: string
+ X-LatestVersion:
+ schema:
+ type: string
+ description: Used only to communicate an API's latest version
+ X-PatchVersion:
+ schema:
+ type: string
+ description:
+ Used only to communicate a PATCH version in a response for troubleshooting purposes only,
+ and will not be provided by the client on request
+ X-MinorVersion:
+ schema:
+ type: string
+ description:
+ Used to request or communicate a MINOR version back from the client
+ to the server, and from the server back to the client
+ X-onap-RequestId:
+ schema:
+ type: string
+ format: uuid
+ description: Used to track REST transactions for logging purposes
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/AutomationCompositions'
+ application/yaml:
+ schema:
+ $ref: '#/components/schemas/AutomationCompositions'
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
+ /datas:
+ get:
+ tags:
+ - Simulator-participant-controller
+ summary: Query details of the requested internal datas
+ description: Query details of the requested internal datas
+ operationId: getDatas
+ parameters:
+ - name: X-onap-RequestId
+ in: header
+ description: RequestID for http transaction
+ schema:
+ type: string
+ format: uuid
+ responses:
+ 200:
+ description: Serialised instance of
+ [InternalDatas](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java)
+ headers:
+ api-version:
+ schema:
+ type: string
+ X-LatestVersion:
+ schema:
+ type: string
+ description: Used only to communicate an API's latest version
+ X-PatchVersion:
+ schema:
+ type: string
+ description:
+ Used only to communicate a PATCH version in a response for troubleshooting purposes only,
+ and will not be provided by the client on request
+ X-MinorVersion:
+ schema:
+ type: string
+ description:
+ Used to request or communicate a MINOR version back from the client
+ to the server, and from the server back to the client
+ X-onap-RequestId:
+ schema:
+ type: string
+ format: uuid
+ description: Used to track REST transactions for logging purposes
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/InternalDatas'
+ application/yaml:
+ schema:
+ $ref: '#/components/schemas/InternalDatas'
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
+ put:
+ tags:
+ - Simulator-participant-controller
+ summary: change the parameters
+ description: >-
+ Change the data of the Simulator Participant
+ operationId: setData
+ parameters:
+ - name: X-ONAP-RequestID
+ in: header
+ description: RequestID for http transaction
+ required: false
+ schema:
+ type: string
+ format: uuid
+ requestBody:
+ description: The data in a serialised instance of
+ [InternalData](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java)
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/InternalData'
+ application/yaml:
+ schema:
+ $ref: '#/components/schemas/InternalData'
+ responses:
+ 200:
+ description: OK, the data has been saved
+ headers:
+ api-version:
+ schema:
+ type: string
+ X-LatestVersion:
+ schema:
+ type: string
+ description: Used only to communicate an API's latest version
+ X-PatchVersion:
+ schema:
+ type: string
+ description:
+ Used only to communicate a PATCH version in a response for troubleshooting purposes only,
+ and will not be provided by the client on request
+ X-MinorVersion:
+ schema:
+ type: string
+ description:
+ Used to request or communicate a MINOR version back from the client
+ to the server, and from the server back to the client
+ X-onap-RequestId:
+ schema:
+ type: string
+ format: uuid
+ description: Used to track REST transactions for logging purposes
+ 400:
+ description: Bad Request
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
+
+components:
+ securitySchemes:
+ basicAuth:
+ type: http
+ scheme: basic
+ schemas:
+ SimConfig:
+ title: SimConfig
+ type: object
+ AutomationCompositions:
+ title: AutomationCompositions
+ type: object
+ InternalDatas:
+ title: InternalDatas
+ type: object
+ InternalData:
+ title: InternalData
+ type: object