diff options
author | sreeja gattagouni <sg00744975@techmahindra.com> | 2023-01-05 20:54:08 +0530 |
---|---|---|
committer | Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> | 2023-01-11 12:29:51 +0000 |
commit | 7a475e244b329f9f179d30c8fc96aed6045037ce (patch) | |
tree | 39cd89ae888fe95ed2f5231f9b9619f0cb0de776 /mso-api-handlers | |
parent | d04f54dedba3e4ade3ac92282c1e3a408a29e70b (diff) |
Add or Delete a PNF to an Active Service
-This feature Enables adding or deleting a PNF to an active Service.
Issue-ID: SO-4046
Change-ID:I73f97f986a817d423f92f8d925dcd0947b8a2503
Signed-off-by: sreeja gattagouni <sg00744975@techmahindra.com>
Diffstat (limited to 'mso-api-handlers')
2 files changed, 58 insertions, 6 deletions
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..a0f3e1a20a 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 @@ -11,9 +11,9 @@ * 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. @@ -721,6 +721,10 @@ public class RequestHandlerUtils extends AbstractRestHandler { throw validateException; } + } + + else if (modelInfo.getModelType().equals(ModelType.pnf)) { + recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180); } else if (modelInfo.getModelType().equals(ModelType.instanceGroup)) { recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180); } @@ -1191,7 +1195,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { throw new ValidationException("vfModuleCustomization"); } else if (vfModule == null && vfmc != null) { vfModule = vfmc.getVfModule(); // can't be null as vfModuleModelUUID is not-null property in - // VfModuleCustomization table + // VfModuleCustomization table } if (modelInfo.getModelVersionId() == 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..353daf8afb 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 @@ -10,9 +10,9 @@ * 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. @@ -719,6 +719,53 @@ public class ServiceInstances extends AbstractRestHandler { requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/pnfs") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Create VNF on a specified version and serviceInstance", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Transactional + public Response createPnfInstance(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 pnf", e); + throw e; + } + } + + + @DELETE + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/pnfs/{pnfInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Create PNF on a specified version and serviceInstance", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Transactional + public Response deletePnfInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("pnfInstanceId") String pnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("pnfInstanceId", pnfInstanceId); + try { + return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } catch (Exception e) { + logger.error("Error in pnf", e); + throw e; + } + } + @POST @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks") @Consumes(MediaType.APPLICATION_JSON) @@ -989,7 +1036,8 @@ public class ServiceInstances extends AbstractRestHandler { } if (!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance - && !requestScope.equalsIgnoreCase(ModelType.vnf.name())) { + && !requestScope.equalsIgnoreCase(ModelType.vnf.name()) + && !requestScope.equalsIgnoreCase(ModelType.pnf.name())) { aLaCarte = true; } else if (aLaCarte == null) { aLaCarte = false; |