use of org.onap.so.db.catalog.beans.Recipe in project so by onap.
the class VfModules method deleteVfModuleInstance.
@DELETE
@ResponseUpdater
@Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Delete a VfModule instance", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ServiceInstancesResponse.class)))))
@Transactional
public Response deleteVfModuleInstance(@PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
String requestId = restHandler.getRequestId(requestContext);
String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID);
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
InfraActiveRequests currentRequest = restHandler.createInfraActiveRequestForDelete(requestId, vfmoduleInstanceId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
ServiceInstancesRequest request = requestBuilder.buildVFModuleDeleteRequest(vnfInstanceId, vfmoduleInstanceId, ModelType.vfModule);
restHandler.saveInstanceName(request, currentRequest);
restHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, vfmoduleInstanceId, request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
Recipe recipe = restHandler.findVfModuleRecipe(request.getRequestDetails().getModelInfo().getModelCustomizationId(), ModelType.vfModule.toString(), Action.deleteInstance.toString());
restHandler.callWorkflowEngine(restHandler.buildRequestParams(request, restHandler.getRequestUri(requestContext), requestId, serviceInstanceId, vnfInstanceId, vfmoduleInstanceId), recipe.getOrchestrationUri());
ServiceInstancesResponse response = restHandler.createResponse(vfmoduleInstanceId, requestId, requestContext);
return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
}
use of org.onap.so.db.catalog.beans.Recipe in project so by onap.
the class Volumes method deleteVfModuleInstance.
@DELETE
@ResponseUpdater
@Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Delete a VfModule instance", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ServiceInstancesResponse.class)))))
@Transactional
public Response deleteVfModuleInstance(@PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("volumeGroupInstanceId") String volumeGroupId, @Context ContainerRequestContext requestContext) throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
String requestId = volumeRestHandler.getRequestId(requestContext);
String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID);
String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
InfraActiveRequests currentRequest = volumeRestHandler.createInfraActiveRequestForDelete(requestId, volumeGroupId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
ServiceInstancesRequest request = requestBuilder.buildVolumeGroupDeleteRequest(vnfInstanceId, volumeGroupId);
volumeRestHandler.saveInstanceName(request, currentRequest);
volumeRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, volumeGroupId, request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
Recipe recipe = vfModuleRestHandler.findVfModuleRecipe(request.getRequestDetails().getModelInfo().getModelCustomizationId(), ModelType.volumeGroup.toString(), Action.deleteInstance.toString());
volumeRestHandler.callWorkflowEngine(volumeRestHandler.buildRequestParams(request, volumeRestHandler.getRequestUri(requestContext), requestId, serviceInstanceId, vnfInstanceId, volumeGroupId), recipe.getOrchestrationUri());
ServiceInstancesResponse response = volumeRestHandler.createResponse(volumeGroupId, requestId, requestContext);
return Response.status(HttpStatus.ACCEPTED.value()).entity(response).build();
}
use of org.onap.so.db.catalog.beans.Recipe in project so by onap.
the class ServiceInstanceRestHandlerTest method test_find_service_recipe_default_recipe.
@Test
public void test_find_service_recipe_default_recipe() throws MalformedURLException, NoRecipeException {
ServiceRecipe expected = new ServiceRecipe();
expected.setAction("createInstance");
doReturn(null).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
doReturn(expected).when(catalogDbClient).findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
Recipe actual = restHandler.findServiceRecipe("testModelId", Action.createInstance.toString());
assertThat(actual, sameBeanAs(expected));
Mockito.verify(catalogDbClient, Mockito.times(1)).findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "testModelId");
Mockito.verify(catalogDbClient, Mockito.times(1)).findServiceRecipeByActionAndServiceModelUUID(Action.createInstance.toString(), "d88da85c-d9e8-4f73-b837-3a72a431622b");
}
use of org.onap.so.db.catalog.beans.Recipe in project so by onap.
the class VfModuleRestHandlerTest method test_find_vf_module_recipe_default_recipe.
@Test
public void test_find_vf_module_recipe_default_recipe() throws MalformedURLException, NoRecipeException {
VnfComponentsRecipe expected = new VnfComponentsRecipe();
expected.setAction("createInstance");
doReturn(null).when(catalogDbClient).getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString());
doReturn(expected).when(catalogDbClient).getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("GR-API-DEFAULT", ModelType.vfModule.toString(), Action.createInstance.toString());
Recipe actual = restHandler.findVfModuleRecipe("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString());
assertThat(actual, sameBeanAs(expected));
Mockito.verify(catalogDbClient, Mockito.times(1)).getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction("testModelId", ModelType.vfModule.toString(), Action.createInstance.toString());
}
Aggregations