summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-a1pms/src/main/java
diff options
context:
space:
mode:
authoraravind.est <aravindhan.a@est.tech>2022-11-21 15:26:58 +0000
committeraravind.est <aravindhan.a@est.tech>2022-11-28 14:44:15 +0000
commitbf6cc68f7f6c58f57ca8a384bbe71f4061a9285c (patch)
tree818109bc4cf2cc3f3dde9a73d8a9b6d6471b9dc1 /participant/participant-impl/participant-impl-a1pms/src/main/java
parenta2e99e7df02837d8270228c330bed4915043b996 (diff)
Add A1 PMS participant
Issue-ID: CCSDK-3816 Signed-off-by: aravind.est <aravindhan.a@est.tech> Change-Id: I00c04542f5ec4672b1c3a29ca32477bf5d2ca336
Diffstat (limited to 'participant/participant-impl/participant-impl-a1pms/src/main/java')
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/Application.java48
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java46
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/ParticipantConfig.java43
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/SecurityConfig.java45
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/exception/A1PolicyServiceException.java35
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java156
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/A1PolicyServiceEntity.java54
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/ConfigurationEntity.java37
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParameters.java55
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParticipantParameters.java44
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/webclient/AcA1PmsClient.java129
11 files changed, 692 insertions, 0 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/Application.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/Application.java
new file mode 100755
index 000000000..1adf5cdb1
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/Application.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
+import org.springframework.context.annotation.ComponentScan;
+
+/**
+ * Starter.
+ */
+// @formatter:off
+@SpringBootApplication
+@ComponentScan({
+ "org.onap.policy.clamp.acm.participant.a1pms",
+ "org.onap.policy.clamp.acm.participant.intermediary"
+})
+@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.participant.a1pms.parameters")
+//@formatter:on
+public class Application {
+ /**
+ * Main class.
+ *
+ * @param args args
+ */
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java
new file mode 100755
index 000000000..5e3441d82
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/MicrometerConfig.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.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-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/ParticipantConfig.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/ParticipantConfig.java
new file mode 100755
index 000000000..7158b5d53
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/ParticipantConfig.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.config;
+
+import org.onap.policy.clamp.acm.participant.a1pms.handler.AutomationCompositionElementHandler;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ParticipantConfig {
+
+ /**
+ * Register AutomationCompositionElementListener.
+ *
+ * @param intermediaryApi the ParticipantIntermediaryApi
+ * @param acElementHandler the AutomationComposition Element Handler
+ */
+ @Autowired
+ public void registerAutomationCompositionElementListener(ParticipantIntermediaryApi intermediaryApi,
+ AutomationCompositionElementHandler acElementHandler) {
+ intermediaryApi.registerAutomationCompositionElementListener(acElementHandler);
+ acElementHandler.setIntermediaryApi(intermediaryApi);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/SecurityConfig.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/SecurityConfig.java
new file mode 100755
index 000000000..fdbbc4558
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/config/SecurityConfig.java
@@ -0,0 +1,45 @@
+/*-
+ * ========================LICENSE_START=================================
+ * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * ======================================================================
+ * 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.
+ * ========================LICENSE_END===================================
+ */
+
+package org.onap.policy.clamp.acm.participant.a1pms.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@Configuration
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
+
+ @Value("${security.enable-csrf:true}")
+ private boolean csrfEnabled = true;
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ // @formatter:off
+ http.authorizeRequests()
+ .antMatchers().authenticated()
+ .anyRequest().authenticated()
+ .and().httpBasic();
+ // @formatter:on
+
+ if (!csrfEnabled) {
+ http.csrf().disable();
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/exception/A1PolicyServiceException.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/exception/A1PolicyServiceException.java
new file mode 100755
index 000000000..3a7ac7d9f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/exception/A1PolicyServiceException.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.exception;
+
+import javax.ws.rs.core.Response;
+import org.onap.policy.models.base.PfModelException;
+
+public class A1PolicyServiceException extends PfModelException {
+
+ public A1PolicyServiceException(int statusCode, String message) {
+ super(Response.Status.fromStatusCode(statusCode), message);
+ }
+
+ public A1PolicyServiceException(int statusCode, String message, Exception e) {
+ super(Response.Status.fromStatusCode(statusCode), message, e);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
new file mode 100755
index 000000000..072d14475
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.handler;
+
+import java.lang.invoke.MethodHandles;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import org.apache.http.HttpStatus;
+import org.onap.policy.clamp.acm.participant.a1pms.exception.A1PolicyServiceException;
+import org.onap.policy.clamp.acm.participant.a1pms.models.ConfigurationEntity;
+import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient;
+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.models.acm.concepts.AutomationCompositionElement;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+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 Coder CODER = new StandardCoder();
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ @Setter
+ private ParticipantIntermediaryApi intermediaryApi;
+
+ private final AcA1PmsClient acA1PmsClient;
+
+ // Map of acElement Id and A1PMS services
+ @Getter(AccessLevel.PACKAGE)
+ private final Map<UUID, ConfigurationEntity> configRequestMap = new HashMap<>();
+
+ /**
+ * Handle a automation composition element state change.
+ *
+ * @param automationCompositionElementId the ID of the automation composition element
+ * @param currentState the current state of the automation composition element
+ * @param newState the state to which the automation composition element is changing to
+ * @throws PfModelException in case of a model exception
+ */
+ @Override
+ public void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId,
+ UUID automationCompositionElementId, AutomationCompositionState currentState,
+ AutomationCompositionOrderedState newState) throws A1PolicyServiceException {
+ switch (newState) {
+ case UNINITIALISED:
+ ConfigurationEntity configurationEntity = configRequestMap.get(automationCompositionElementId);
+ if (configurationEntity != null && acA1PmsClient.isPmsHealthy()) {
+ acA1PmsClient.deleteService(configurationEntity.getPolicyServiceEntities());
+ configRequestMap.remove(automationCompositionElementId);
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ } else {
+ LOGGER.warn("Failed to connect with A1PMS. Service configuration is: {}", configurationEntity);
+ throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE,
+ "Unable to connect with A1PMS");
+ }
+ break;
+ case PASSIVE:
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, newState, AutomationCompositionState.PASSIVE,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ break;
+ case RUNNING:
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, newState, AutomationCompositionState.RUNNING,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ break;
+ default:
+ LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState);
+ break;
+ }
+ }
+
+ /**
+ * Callback method to handle an update on an automation composition element.
+ *
+ * @param element the information on the automation composition element
+ * @param nodeTemplate toscaNodeTemplate
+ */
+ @Override
+ public void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId,
+ AutomationCompositionElement element, ToscaNodeTemplate nodeTemplate) throws A1PolicyServiceException {
+ try {
+ var configurationEntity = CODER.convert(nodeTemplate.getProperties(), ConfigurationEntity.class);
+ Set<ConstraintViolation<ConfigurationEntity>> violations =
+ Validation.buildDefaultValidatorFactory().getValidator().validate(configurationEntity);
+ if (violations.isEmpty()) {
+ if (acA1PmsClient.isPmsHealthy()) {
+ acA1PmsClient.createService(configurationEntity.getPolicyServiceEntities());
+ configRequestMap.put(element.getId(), configurationEntity);
+
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE,
+ ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE);
+ } else {
+ LOGGER.error("Failed to connect with A1PMS");
+ throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE,
+ "Unable to connect with A1PMS");
+ }
+ } else {
+ LOGGER.error("Violations found in the config request parameters: {}", violations);
+ throw new ValidationException("Constraint violations in the config request");
+ }
+ } catch (ValidationException | CoderException e) {
+ LOGGER.error("Error invoking the A1PMS request for the config ", e);
+ throw new A1PolicyServiceException(HttpStatus.SC_BAD_REQUEST, "Invalid Configuration", e);
+ } catch (A1PolicyServiceException e) {
+ LOGGER.error("Error invoking the A1PMS request for the config ", e);
+ throw e;
+ }
+ }
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/A1PolicyServiceEntity.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/A1PolicyServiceEntity.java
new file mode 100755
index 000000000..991cb926f
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/A1PolicyServiceEntity.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.models;
+
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies;
+import com.fasterxml.jackson.databind.annotation.JsonNaming;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.DefaultValue;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+@Data
+@AllArgsConstructor
+@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
+public class A1PolicyServiceEntity {
+
+ @NotNull
+ @JsonIgnore
+ private ToscaConceptIdentifier a1PolicyServiceEntityId;
+
+ @NotNull
+ @Getter(onMethod_ = {@JsonGetter(value = "service_id")})
+ private String clientId;
+
+ @NotNull
+ private String callbackUrl;
+
+ @NotNull
+ @DefaultValue("0")
+ private int keepAliveIntervalSeconds;
+
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/ConfigurationEntity.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/ConfigurationEntity.java
new file mode 100755
index 000000000..80715c27c
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/models/ConfigurationEntity.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.models;
+
+import java.util.List;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class ConfigurationEntity {
+
+ @NotNull
+ @Valid
+ private List<A1PolicyServiceEntity> policyServiceEntities;
+
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParameters.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParameters.java
new file mode 100755
index 000000000..704ef4153
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParameters.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.parameters;
+
+import java.util.Map;
+import javax.validation.constraints.NotNull;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * Class to hold all parameters needed for the A1PMS participant.
+ */
+@Validated
+@Data
+@ConfigurationProperties(prefix = "a1pms")
+public class A1PmsParameters {
+
+ @NotNull
+ private String baseUrl;
+
+ @NotNull
+ private Endpoints endpoints;
+
+ @NotNull
+ private Map<String, String> headers;
+
+ @Data
+ public static class Endpoints {
+
+ String health;
+
+ String services;
+
+ String service;
+ }
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParticipantParameters.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParticipantParameters.java
new file mode 100755
index 000000000..b3e036041
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/parameters/A1PmsParticipantParameters.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.parameters;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters;
+import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * Class to hold all parameters needed for the A1PMS participant.
+ */
+@Validated
+@Getter
+@Setter
+@ConfigurationProperties(prefix = "participant")
+public class A1PmsParticipantParameters implements ParticipantParameters {
+
+ @NotNull
+ @Valid
+ private ParticipantIntermediaryParameters intermediaryParameters;
+}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/webclient/AcA1PmsClient.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/webclient/AcA1PmsClient.java
new file mode 100755
index 000000000..25fb67fb7
--- /dev/null
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/webclient/AcA1PmsClient.java
@@ -0,0 +1,129 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 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.a1pms.webclient;
+
+import java.lang.invoke.MethodHandles;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Predicate;
+import lombok.RequiredArgsConstructor;
+import org.onap.policy.clamp.acm.participant.a1pms.exception.A1PolicyServiceException;
+import org.onap.policy.clamp.acm.participant.a1pms.models.A1PolicyServiceEntity;
+import org.onap.policy.clamp.acm.participant.a1pms.parameters.A1PmsParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+@Component
+@RequiredArgsConstructor
+public class AcA1PmsClient {
+
+ private final A1PmsParameters a1PmsParameters;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ /**
+ * Get webclient for A1PMS.
+ *
+ * @return webClient
+ */
+ private WebClient getPmsClient() {
+ return WebClient.builder().baseUrl(a1PmsParameters.getBaseUrl())
+ .defaultHeaders(httpHeaders -> httpHeaders.addAll(createHeaders())).build();
+ }
+
+ /**
+ * Get A1PMS health status.
+ *
+ * @return whether A1PMS is healthy
+ */
+ public boolean isPmsHealthy() {
+ return Objects.equals(Boolean.TRUE,
+ getPmsClient().method(HttpMethod.GET).uri(a1PmsParameters.getEndpoints().getHealth())
+ .exchangeToMono(clientResponse -> Mono.just(clientResponse.statusCode().is2xxSuccessful()))
+ .block());
+ }
+
+
+ /**
+ * Create service in A1PMS.
+ * @param policyServiceEntities List of service entities
+ * @throws A1PolicyServiceException Exception on creating service
+ */
+ public void createService(List<A1PolicyServiceEntity> policyServiceEntities) throws A1PolicyServiceException {
+ policyServiceEntities.forEach(
+ a1PolicyServiceEntity -> getPmsClient().method(HttpMethod.PUT)
+ .uri(a1PmsParameters.getEndpoints().getServices())
+ .bodyValue(a1PolicyServiceEntity).retrieve()
+ .onStatus(HttpStatus::isError,
+ clientResponse -> Mono.error(new A1PolicyServiceException(
+ clientResponse.statusCode().value(),
+ "Error in creating policy service")))
+ .onStatus(Predicate.isEqual(HttpStatus.OK),
+ clientResponse -> {
+ LOGGER.warn("Client {} already exists and the configuration "
+ + "is updated",
+ a1PolicyServiceEntity.getClientId());
+ return Mono.empty();
+ })
+ .toBodilessEntity()
+ .block());
+ }
+
+ /**
+ * Delete service in A1PMS.
+ * @param policyServiceEntities List of service entities
+ * @throws A1PolicyServiceException Exception on deleting service
+ */
+ public void deleteService(List<A1PolicyServiceEntity> policyServiceEntities) throws A1PolicyServiceException {
+ policyServiceEntities.forEach(
+ a1PolicyServiceEntity -> getPmsClient().method(HttpMethod.DELETE)
+ .uri(a1PmsParameters.getEndpoints().getService(),
+ a1PolicyServiceEntity.getClientId())
+ .bodyValue(a1PolicyServiceEntity).retrieve()
+ .onStatus(HttpStatus::isError,
+ clientResponse -> Mono.error(
+ new A1PolicyServiceException(
+ clientResponse.statusCode().value(),
+ "Error in deleting policy service")))
+ .toBodilessEntity()
+ .block());
+ }
+
+ /**
+ * Prepare the Http headers to call A1PMS.
+ *
+ * @return httpHeaders
+ */
+ private HttpHeaders createHeaders() {
+ var headers = new HttpHeaders();
+ for (Map.Entry<String, String> entry : a1PmsParameters.getHeaders().entrySet()) {
+ headers.add(entry.getKey(), entry.getValue());
+ }
+ return headers;
+ }
+}