aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java
diff options
context:
space:
mode:
authorSagarS <sagar.shetty@est.tech>2022-05-11 14:16:29 +0100
committerSagarS <sagar.shetty@est.tech>2022-05-12 10:00:56 +0100
commitac1dbd50fb13a05f17c417c374fbdddfee4dfa4e (patch)
treecc0a41a894b4f8718779768589be683cd6004b8d /mso-api-handlers/mso-api-handler-infra/src/main/java
parent131fd74f717f76bc23af1ef935f6e96654f703d6 (diff)
[SO] Implementing CNFM API endpoint
Change-Id: I45202df4cd3a418414b1189cfc59bb845c37edd4 Signed-off-by: SagarS <sagar.shetty@est.tech> Issue-ID: SO-3905
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java9
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java27
3 files changed, 40 insertions, 2 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index 64c42a0498..811d88869e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -9,6 +9,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Nokia
* ================================================================================
+ * Modifications Copyright (c) 2022 Ericsson. 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
@@ -376,7 +378,9 @@ public class MsoRequest {
aq.setInstanceGroupId(servInsReq.getInstanceGroupId());
aq.setInstanceGroupName(requestInfo.getInstanceName());
}
- if (ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
+
+ if (ModelType.vnf.name().equalsIgnoreCase(requestScope)
+ || ModelType.cnf.name().equalsIgnoreCase(requestScope)) {
if (requestInfo != null) {
aq.setVnfName(requestInfo.getInstanceName());
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index 531d87c229..efa037d393 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -8,6 +8,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2022 Ericsson. 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
@@ -547,6 +549,9 @@ public class RequestHandlerUtils extends AbstractRestHandler {
requestScope = ModelType.vnf.name();
} else if (requestUri.contains(ModelType.pnf.name())) {
requestScope = ModelType.pnf.name();
+
+ } else if (requestUri.contains(ModelType.cnf.name())) {
+ requestScope = ModelType.cnf.name();
} else {
requestScope = ModelType.service.name();
}
@@ -723,6 +728,10 @@ public class RequestHandlerUtils extends AbstractRestHandler {
}
} else if (modelInfo.getModelType().equals(ModelType.instanceGroup)) {
recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180);
+ } else if (modelInfo.getModelType().equals(ModelType.cnf)) {
+ // Capturing CNF workflow URI
+ logger.debug("Capturing cnf workflow URI");
+ recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 360);
}
if (recipeLookupResult == null) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 4aa9cd0696..7e9231b5df 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -6,6 +6,8 @@
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * Modifications Copyright (c) 2022 Ericsson. 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.
@@ -379,6 +381,28 @@ public class ServiceInstances extends AbstractRestHandler {
}
@POST
+ @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/cnfs")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Operation(description = "Create CNF on a specified version and serviceInstance", responses = @ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
+ @Transactional
+ public Response createCnfInstance(String request, @PathParam("version") String version,
+ @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext)
+ throws ApiException {
+ String requestId = requestHandlerUtils.getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ try {
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId,
+ requestHandlerUtils.getRequestUri(requestContext, uriPrefix));
+ } catch (Exception e) {
+ logger.error("Error in cnf", e);
+ throw e;
+ }
+ }
+
+ @POST
@Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/upgrade")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@@ -899,7 +923,8 @@ public class ServiceInstances extends AbstractRestHandler {
requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId,
currentActiveReq);
if ((action == Action.replaceInstance || action == Action.replaceInstanceRetainAssignments)
- && (requestScope.equals(ModelType.vnf.toString()) || requestScope.equals(ModelType.vfModule.toString()))
+ && (requestScope.equals(ModelType.vnf.toString()) || requestScope.equals(ModelType.vfModule.toString())
+ || requestScope.equals(ModelType.cnf.toString()))
&& sir.getRequestDetails().getCloudConfiguration() == null) {
CloudConfiguration cloudConfiguration =
getCloudConfigurationOnReplace(requestScope, instanceIdMap, currentActiveReq);