Search in sources :

Example 11 with Recipe

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();
}
Also used : Recipe(org.onap.so.db.catalog.beans.Recipe) ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Path(javax.ws.rs.Path) ResponseUpdater(org.onap.so.apihandler.filters.ResponseUpdater) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) Transactional(javax.transaction.Transactional)

Example 12 with Recipe

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();
}
Also used : Recipe(org.onap.so.db.catalog.beans.Recipe) ServiceInstancesResponse(org.onap.so.serviceinstancebeans.ServiceInstancesResponse) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) Path(javax.ws.rs.Path) ResponseUpdater(org.onap.so.apihandler.filters.ResponseUpdater) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation) Transactional(javax.transaction.Transactional)

Example 13 with Recipe

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");
}
Also used : Recipe(org.onap.so.db.catalog.beans.Recipe) ServiceRecipe(org.onap.so.db.catalog.beans.ServiceRecipe) ServiceRecipe(org.onap.so.db.catalog.beans.ServiceRecipe) Test(org.junit.Test)

Example 14 with Recipe

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());
}
Also used : Recipe(org.onap.so.db.catalog.beans.Recipe) VnfComponentsRecipe(org.onap.so.db.catalog.beans.VnfComponentsRecipe) VnfComponentsRecipe(org.onap.so.db.catalog.beans.VnfComponentsRecipe) Test(org.junit.Test)

Aggregations

Recipe (org.onap.so.db.catalog.beans.Recipe)14 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 Test (org.junit.Test)6 ServiceRecipe (org.onap.so.db.catalog.beans.ServiceRecipe)6 Operation (io.swagger.v3.oas.annotations.Operation)5 Transactional (javax.transaction.Transactional)5 Consumes (javax.ws.rs.Consumes)5 DELETE (javax.ws.rs.DELETE)5 ResponseUpdater (org.onap.so.apihandler.filters.ResponseUpdater)5 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)5 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)5 ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)5 VnfRecipe (org.onap.so.db.catalog.beans.VnfRecipe)4 NetworkResource (org.onap.so.db.catalog.beans.NetworkResource)2 VnfComponentsRecipe (org.onap.so.db.catalog.beans.VnfComponentsRecipe)2 VnfResource (org.onap.so.db.catalog.beans.VnfResource)2 ValidationException (org.onap.so.exceptions.ValidationException)2 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)2 GET (javax.ws.rs.GET)1