summaryrefslogtreecommitdiffstats
path: root/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org')
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/Constants.java35
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/GsonSerializerConfiguration.java42
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/SoCnfmAsLcmManagerUrlProvider.java53
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLcmOperationOccurrenceManager.java125
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLifeCycleManager.java86
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLcmOperationOccurrencesController.java71
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLifecycleManagementController.java107
7 files changed, 519 insertions, 0 deletions
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/Constants.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/Constants.java
new file mode 100644
index 0000000..d7237c9
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/Constants.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.so.cnfm.lcm;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class Constants {
+
+ public static final String SERVICE_NAME = "so-cnfm";
+ public static final String SERVICE_VERSION = "v1";
+ public static final String BASE_URL = "/so/" + SERVICE_NAME + "/" + SERVICE_VERSION + "/api";
+ public static final String AS_LIFE_CYCLE_MANAGEMENT_BASE_URL = BASE_URL + "/aslcm/v1";
+
+ private Constants() {}
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/GsonSerializerConfiguration.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/GsonSerializerConfiguration.java
new file mode 100644
index 0000000..f979f99
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/GsonSerializerConfiguration.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.so.cnfm.lcm;
+
+import java.time.LocalDateTime;
+import org.onap.so.cnfm.lcm.bpmn.flows.utils.LocalDateTimeTypeAdapter;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import com.google.gson.GsonBuilder;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+public class GsonSerializerConfiguration {
+
+ @Bean
+ public GsonBuilder gsonBuilder() {
+ return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter());
+ }
+
+}
+
+
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/SoCnfmAsLcmManagerUrlProvider.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/SoCnfmAsLcmManagerUrlProvider.java
new file mode 100644
index 0000000..2e8aa05
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/SoCnfmAsLcmManagerUrlProvider.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.so.cnfm.lcm;
+
+import java.net.URI;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+public class SoCnfmAsLcmManagerUrlProvider {
+
+ private final String soCnfmLcmManagerEndpoint;
+
+ @Autowired
+ public SoCnfmAsLcmManagerUrlProvider(
+ @Value("${so-cnfm-lcm.endpoint:http://so-cnfm-lcm.onap:9888}") final String soCnfmLcmManagerEndpoint) {
+ this.soCnfmLcmManagerEndpoint = soCnfmLcmManagerEndpoint;
+ }
+
+ public URI getCreatedAsResourceUri(final String asInstanceId) {
+ return URI.create(soCnfmLcmManagerEndpoint + Constants.AS_LIFE_CYCLE_MANAGEMENT_BASE_URL + "/as_instances/"
+ + asInstanceId);
+ }
+
+ public URI getAsLcmOpOccUri(final String asLcmOpOccId) {
+ return URI.create(soCnfmLcmManagerEndpoint + Constants.AS_LIFE_CYCLE_MANAGEMENT_BASE_URL + "/as_lcm_op_occs/"
+ + asLcmOpOccId);
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLcmOperationOccurrenceManager.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLcmOperationOccurrenceManager.java
new file mode 100644
index 0000000..8bb1c6b
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLcmOperationOccurrenceManager.java
@@ -0,0 +1,125 @@
+/*-
+ * ============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.so.cnfm.lcm.lifecycle;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.Optional;
+import org.onap.so.cnfm.lcm.SoCnfmAsLcmManagerUrlProvider;
+import org.onap.so.cnfm.lcm.database.service.DatabaseServiceProvider;
+import org.onap.so.cnfm.lcm.model.AsInstanceLinksSelf;
+import org.onap.so.cnfm.lcm.model.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.model.AsLcmOpOcc.CancelModeEnum;
+import org.onap.so.cnfm.lcm.model.AsLcmOpOcc.OperationEnum;
+import org.onap.so.cnfm.lcm.model.AsLcmOpOcc.OperationStateEnum;
+import org.onap.so.cnfm.lcm.model.AsLcmOpOccLinks;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Service
+public class AsLcmOperationOccurrenceManager {
+ private static final Logger logger = getLogger(AsLcmOperationOccurrenceManager.class);
+ private final DatabaseServiceProvider databaseServiceProvider;
+ private final SoCnfmAsLcmManagerUrlProvider cnfmAsLcmManagerUrlProvider;
+
+ @Autowired
+ public AsLcmOperationOccurrenceManager(final DatabaseServiceProvider databaseServiceProvider,
+ final SoCnfmAsLcmManagerUrlProvider cnfmAsLcmManagerUrlProvider) {
+ this.databaseServiceProvider = databaseServiceProvider;
+ this.cnfmAsLcmManagerUrlProvider = cnfmAsLcmManagerUrlProvider;
+ }
+
+ public Optional<AsLcmOpOcc> getAsLcmOperationOccurrence(final String asLcmOpOccId) {
+ logger.info("Getting AS LCM Operation Occurrence Operation for id: {}", asLcmOpOccId);
+
+ final Optional<org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc> optionalDatabaseEntry =
+ databaseServiceProvider.getAsLcmOpOcc(asLcmOpOccId);
+
+ if (optionalDatabaseEntry.isEmpty()) {
+ logger.info("No AS LCM Operation Occurrence found for id: {}", asLcmOpOccId);
+ return Optional.empty();
+ }
+ logger.info("Found AS LCM Operation Occurrence for id: {}", asLcmOpOccId);
+ final org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc asLcmOpOccDatabaseEntry = optionalDatabaseEntry.get();
+ final AsLcmOpOcc asLcmOpOcc = convertToAsLcmOpOccsAsLcmOpOcc(asLcmOpOccDatabaseEntry);
+ return Optional.of(asLcmOpOcc);
+ }
+
+ private AsLcmOpOcc convertToAsLcmOpOccsAsLcmOpOcc(
+ final org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc databaseEntry) {
+
+ final AsLcmOpOcc asLcmOpOcc = new AsLcmOpOcc().id(databaseEntry.getId())
+ .stateEnteredTime(databaseEntry.getStateEnteredTime()).startTime(databaseEntry.getStartTime())
+ .isAutomaticInvocation(databaseEntry.getIsAutoInvocation())
+ .isCancelPending(databaseEntry.getIsCancelPending());
+
+ if (databaseEntry.getAsInst() != null) {
+ asLcmOpOcc.setAsInstanceId(databaseEntry.getAsInst().getAsInstId());
+ }
+
+ if (databaseEntry.getOperationState() != null) {
+ asLcmOpOcc.setOperationState(OperationStateEnum.fromValue(databaseEntry.getOperationState().toString()));
+ }
+
+ if (databaseEntry.getOperation() != null) {
+ asLcmOpOcc.setOperation(OperationEnum.fromValue(databaseEntry.getOperation().toString()));
+ }
+
+ if (databaseEntry.getOperationParams() != null) {
+ asLcmOpOcc.setOperationParams(databaseEntry.getOperationParams());
+ }
+
+ if (databaseEntry.getCancelMode() != null) {
+ asLcmOpOcc.setCancelMode(CancelModeEnum.fromValue(databaseEntry.getCancelMode().toString()));
+ }
+
+ asLcmOpOcc.setLinks(generateLinks(databaseEntry));
+
+ logger.info("Database AsLcmOpOcc converted to API AsLcmOpOcc successfully... {}", asLcmOpOcc);
+
+ return asLcmOpOcc;
+ }
+
+ private AsLcmOpOccLinks generateLinks(final org.onap.so.cnfm.lcm.database.beans.AsLcmOpOcc databaseEntry) {
+ logger.info("Generating links...");
+ final String asLcmOpOccId = databaseEntry.getId();
+
+ final AsInstanceLinksSelf asLcmOpOccLinksSelf =
+ new AsInstanceLinksSelf().href(cnfmAsLcmManagerUrlProvider.getAsLcmOpOccUri(asLcmOpOccId).toString());
+
+ final AsLcmOpOccLinks links = new AsLcmOpOccLinks().self(asLcmOpOccLinksSelf);
+
+ if (databaseEntry.getAsInst() != null) {
+ final String asInstId = databaseEntry.getAsInst().getAsInstId();
+ final AsInstanceLinksSelf asInstanceLinksSelf = new AsInstanceLinksSelf()
+ .href(cnfmAsLcmManagerUrlProvider.getCreatedAsResourceUri(asInstId).toString());
+ links.setAsInstance(asInstanceLinksSelf);
+ }
+
+ return links;
+
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLifeCycleManager.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLifeCycleManager.java
new file mode 100644
index 0000000..7ba8f8b
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/lifecycle/AsLifeCycleManager.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.so.cnfm.lcm.lifecycle;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import java.net.URI;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.onap.so.cnfm.lcm.SoCnfmAsLcmManagerUrlProvider;
+import org.onap.so.cnfm.lcm.bpmn.flows.service.JobExecutorService;
+import org.onap.so.cnfm.lcm.model.AsInstance;
+import org.onap.so.cnfm.lcm.model.CreateAsRequest;
+import org.onap.so.cnfm.lcm.model.InstantiateAsRequest;
+import org.onap.so.cnfm.lcm.model.TerminateAsRequest;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Service
+public class AsLifeCycleManager {
+ private static final Logger logger = getLogger(AsLifeCycleManager.class);
+
+ private final JobExecutorService jobExecutorService;
+
+ private final SoCnfmAsLcmManagerUrlProvider cnfmAsLcmManagerUrlProvider;
+
+ @Autowired
+ public AsLifeCycleManager(final JobExecutorService jobExecutorService,
+ final SoCnfmAsLcmManagerUrlProvider cnfmAsLcmManagerUrlProvider) {
+ this.jobExecutorService = jobExecutorService;
+ this.cnfmAsLcmManagerUrlProvider = cnfmAsLcmManagerUrlProvider;
+ }
+
+ public ImmutablePair<URI, AsInstance> createAs(final CreateAsRequest createAsRequest) {
+ logger.info("Will execute Create AS for CreateAsRequest: {}", createAsRequest);
+
+ final AsInstance nsInstanceResponse = jobExecutorService.runCreateAsJob(createAsRequest);
+
+ return ImmutablePair.of(
+ cnfmAsLcmManagerUrlProvider.getCreatedAsResourceUri(nsInstanceResponse.getAsInstanceid()),
+ nsInstanceResponse);
+ }
+
+ public URI instantiateAs(final String asInstanceId, final InstantiateAsRequest instantiateAsRequest) {
+ logger.info("Will execute Instantiate AS for InstantiateAsRequest: {} and asInstanceId: {}",
+ instantiateAsRequest, asInstanceId);
+
+ final String asLcmOpOccId = jobExecutorService.runInstantiateAsJob(asInstanceId, instantiateAsRequest);
+ return cnfmAsLcmManagerUrlProvider.getAsLcmOpOccUri(asLcmOpOccId);
+
+ }
+
+ public URI terminateAs(final String asInstanceId, final TerminateAsRequest terminateAsRequest) {
+ logger.info("Will execute Terminate AS for TerminateAsRequest: {} and asInstanceId: {}", terminateAsRequest,
+ asInstanceId);
+
+ final String asLcmOpOccId = jobExecutorService.runTerminateAsJob(asInstanceId, terminateAsRequest);
+ return cnfmAsLcmManagerUrlProvider.getAsLcmOpOccUri(asLcmOpOccId);
+ }
+
+ public void deleteAs(final String asInstanceId) {
+ logger.info("Will execute Delete AS for asInstanceId: {}", asInstanceId);
+ jobExecutorService.runDeleteAsJob(asInstanceId);
+ }
+
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLcmOperationOccurrencesController.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLcmOperationOccurrencesController.java
new file mode 100644
index 0000000..8c25d20
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLcmOperationOccurrencesController.java
@@ -0,0 +1,71 @@
+/*-
+ * ============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.so.cnfm.lcm.rest;
+
+import static org.onap.so.cnfm.lcm.Constants.AS_LIFE_CYCLE_MANAGEMENT_BASE_URL;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.Optional;
+import javax.ws.rs.core.MediaType;
+import org.onap.so.cnfm.lcm.lifecycle.AsLcmOperationOccurrenceManager;
+import org.onap.so.cnfm.lcm.model.AsLcmOpOcc;
+import org.onap.so.cnfm.lcm.model.ErrorDetails;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Controller
+@RequestMapping(value = AS_LIFE_CYCLE_MANAGEMENT_BASE_URL)
+public class AsLcmOperationOccurrencesController {
+ private static final Logger logger = getLogger(AsLcmOperationOccurrencesController.class);
+ private final AsLcmOperationOccurrenceManager asLcmOperationOccurrenceManager;
+
+ @Autowired
+ public AsLcmOperationOccurrencesController(final AsLcmOperationOccurrenceManager asLcmOperationOccurrenceManager) {
+ this.asLcmOperationOccurrenceManager = asLcmOperationOccurrenceManager;
+ }
+
+ @GetMapping(value = "/as_lcm_op_occs/{asLcmOpOccId}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getOperationStatus(@PathVariable("asLcmOpOccId") final String asLcmOpOccId) {
+ logger.info("Received request to retrieve operation status for asLcmOpOccId: {}", asLcmOpOccId);
+ final Optional<AsLcmOpOcc> optionalAsLcmOpOccs =
+ asLcmOperationOccurrenceManager.getAsLcmOperationOccurrence(asLcmOpOccId);
+
+ if (optionalAsLcmOpOccs.isPresent()) {
+ final AsLcmOpOcc asLcmOpOcc = optionalAsLcmOpOccs.get();
+ logger.info("Sending back AsLcmOpOcc: {}", asLcmOpOcc);
+ return ResponseEntity.ok().body(asLcmOpOcc);
+ }
+
+ final String errorMessage = "Unable to retrieve operation occurrence status for asLcmOpOccId: " + asLcmOpOccId;
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ErrorDetails().detail(errorMessage));
+ }
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLifecycleManagementController.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLifecycleManagementController.java
new file mode 100644
index 0000000..698ef7c
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-service/src/main/java/org/onap/so/cnfm/lcm/rest/AsLifecycleManagementController.java
@@ -0,0 +1,107 @@
+/*-
+ * ============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.so.cnfm.lcm.rest;
+
+import static org.onap.so.cnfm.lcm.Constants.AS_LIFE_CYCLE_MANAGEMENT_BASE_URL;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.net.URI;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.onap.so.cnfm.lcm.lifecycle.AsLifeCycleManager;
+import org.onap.so.cnfm.lcm.model.AsInstance;
+import org.onap.so.cnfm.lcm.model.CreateAsRequest;
+import org.onap.so.cnfm.lcm.model.InstantiateAsRequest;
+import org.onap.so.cnfm.lcm.model.TerminateAsRequest;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Controller
+@RequestMapping(value = AS_LIFE_CYCLE_MANAGEMENT_BASE_URL)
+public class AsLifecycleManagementController {
+ private static final Logger logger = getLogger(AsLifecycleManagementController.class);
+
+ private final AsLifeCycleManager asLifeCycleManager;
+
+ @Autowired
+ public AsLifecycleManagementController(final AsLifeCycleManager asLifeCycleManager) {
+ this.asLifeCycleManager = asLifeCycleManager;
+ }
+
+ @PostMapping(value = "/as_instances", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<AsInstance> createAs(@RequestBody final CreateAsRequest createAsRequest) {
+ logger.info("Received Create AS Request: {}n", createAsRequest);
+
+ final ImmutablePair<URI, AsInstance> nsInstance = asLifeCycleManager.createAs(createAsRequest);
+
+ final URI resourceUri = nsInstance.getLeft();
+ final AsInstance createdAsresponse = nsInstance.getRight();
+
+ logger.info("AS resource created successfully. Resource location: {}, response: {}", resourceUri,
+ createdAsresponse);
+
+ return ResponseEntity.created(resourceUri).body(createdAsresponse);
+ }
+
+ @PostMapping(value = "/as_instances/{asInstanceId}/instantiate",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<Void> instantiateAs(@PathVariable("asInstanceId") final String asInstanceId,
+ @RequestBody final InstantiateAsRequest instantiateAsRequest) {
+ logger.debug("Received instantiate AS request: {}\n with asInstanceId: {}", instantiateAsRequest, asInstanceId);
+ final URI resourceUri = asLifeCycleManager.instantiateAs(asInstanceId, instantiateAsRequest);
+ logger.info("{} AS Instantiation started successfully. Resource Operation Occurrence uri: {}", asInstanceId,
+ resourceUri);
+ return ResponseEntity.accepted().location(resourceUri).build();
+ }
+
+ @PostMapping(value = "/as_instances/{asInstanceId}/terminate",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
+ consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<Void> terminateAs(@PathVariable("asInstanceId") final String asInstanceId,
+ @RequestBody(required = false) final TerminateAsRequest terminateAsRequest) {
+ logger.debug("Received terminate AS request: {}\n with asInstanceId: {}", terminateAsRequest, asInstanceId);
+ final URI resourceUri = asLifeCycleManager.terminateAs(asInstanceId, terminateAsRequest);
+ logger.info("{} As Terminate started successfully. Resource Operation Occurrence uri: {}", asInstanceId,
+ resourceUri);
+ return ResponseEntity.accepted().location(resourceUri).build();
+ }
+
+ @DeleteMapping(value = "/as_instances/{asInstanceId}",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<Void> deleteAs(@PathVariable("asInstanceId") final String asInstanceId) {
+ logger.debug("Received delete AS request for asInstanceId: {}", asInstanceId);
+ asLifeCycleManager.deleteAs(asInstanceId);
+ logger.info("Successfully deleted AS for asInstanceId: {}", asInstanceId);
+ return ResponseEntity.noContent().build();
+ }
+
+}