Search in sources :

Example 21 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class Vnf method deleteVnfInstance.

@DELETE
@ResponseUpdater
@Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Delete a Vnf instance", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ServiceInstancesResponse.class)))))
@Transactional
public Response deleteVnfInstance(@PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws AAIEntityNotFound, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
    String requestId = vnfRestHandler.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 = vnfRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
    ServiceInstancesRequest request = requestBuilder.buildVnfDeleteRequest(vnfInstanceId);
    vnfRestHandler.saveInstanceName(request, currentRequest);
    vnfRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
    Recipe recipe = vnfRestHandler.findVnfModuleRecipe(request.getRequestDetails().getModelInfo().getModelCustomizationId(), "vnf", "deleteInstance");
    vnfRestHandler.callWorkflowEngine(vnfRestHandler.buildRequestParams(request, vnfRestHandler.getRequestUri(requestContext), requestId, serviceInstanceId, vnfInstanceId), recipe.getOrchestrationUri());
    ServiceInstancesResponse response = vnfRestHandler.createResponse(vnfInstanceId, 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 22 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class ConfigurationParametersValidation method validate.

@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
    ServiceInstancesRequest sir = info.getSir();
    List<Map<String, String>> configParams = sir.getRequestDetails().getConfigurationParameters();
    String requestScope = info.getRequestScope();
    Actions action = info.getAction();
    if (configParams.isEmpty() && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut) {
        throw new ValidationException("configuration parameters");
    }
    return info;
}
Also used : ValidationException(org.onap.so.exceptions.ValidationException) Actions(org.onap.so.apihandlerinfra.Actions) Map(java.util.Map) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest)

Example 23 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class VolumeGroupDeleteValidatorTest method validateSuccessTest.

@Test
public void validateSuccessTest() {
    instanceIdMap.put("volumeGroupInstanceId", "1");
    ServiceInstancesRequest request = new ServiceInstancesRequest();
    RequestDetails details = new RequestDetails();
    details.setCloudConfiguration(new CloudConfiguration());
    request.setRequestDetails(details);
    when(aaiDataRetrieval.isVolumeGroupRelatedToVFModule(any(CloudConfiguration.class), eq("1"))).thenReturn(false);
    Optional<String> result = volumeGroupDeleteValidator.validate(instanceIdMap, request, null, null);
    assertEquals(false, result.isPresent());
}
Also used : CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 24 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class ServiceInstancesTest method setServiceTypeTestDefault.

@Test
public void setServiceTypeTestDefault() throws JsonProcessingException {
    String requestScope = ModelType.service.toString();
    Boolean aLaCarteFlag = false;
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    RequestDetails requestDetails = new RequestDetails();
    RequestInfo requestInfo = new RequestInfo();
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
    requestInfo.setSource("VID");
    requestDetails.setModelInfo(modelInfo);
    requestDetails.setRequestInfo(requestInfo);
    sir.setRequestDetails(requestDetails);
    Service defaultService = new Service();
    defaultService.setServiceType("testServiceType");
    wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
    wireMockServer.stubFor(get(urlMatching(".*/service/search/.*")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
    String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
    assertEquals(serviceType, "testServiceType");
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Service(org.onap.so.db.catalog.beans.Service) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) Test(org.junit.Test)

Example 25 with ServiceInstancesRequest

use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.

the class BpmnRequestBuilderTest method test_buildVolumeGroupDeleteRequest.

@Test
public void test_buildVolumeGroupDeleteRequest() throws Exception {
    GenericVnf vnf = provider.getMapper().readValue(new File(RESOURCE_PATH + "Vnf.json"), GenericVnf.class);
    doReturn(Optional.of(vnf)).when(aaiResourcesClient).get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")));
    VolumeGroup volumeGroup = provider.getMapper().readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
    AAIResultWrapper wrapper = new AAIResultWrapper(volumeGroup);
    doReturn(wrapper).when(aaiResourcesClient).get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")).relatedTo(Types.VOLUME_GROUP.getFragment("volumeGroupId")));
    ServiceInstancesRequest expectedRequest = mapper.readValue(new File(RESOURCE_PATH + "ExpectedVolumeGroupRequest.json"), ServiceInstancesRequest.class);
    ServiceInstancesRequest actualRequest = reqBuilder.buildVolumeGroupDeleteRequest("vnfId", "volumeGroupId");
    assertThat(actualRequest, sameBeanAs(expectedRequest));
}
Also used : GenericVnf(org.onap.aai.domain.yang.GenericVnf) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) File(java.io.File) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Aggregations

ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)100 Test (org.junit.Test)58 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)36 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)17 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)15 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)15 IOException (java.io.IOException)11 BaseTest (org.onap.so.apihandlerinfra.BaseTest)11 CloudConfiguration (org.onap.so.serviceinstancebeans.CloudConfiguration)11 ValidationException (org.onap.so.exceptions.ValidationException)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)8 CloudConfigurationNotFoundException (org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException)8 Service (org.onap.so.db.catalog.beans.Service)8 ArrayList (java.util.ArrayList)7 RequestClientParameter (org.onap.so.apihandler.common.RequestClientParameter)7 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)7 ServiceInstancesResponse (org.onap.so.serviceinstancebeans.ServiceInstancesResponse)7 GenericVnf (org.onap.aai.domain.yang.GenericVnf)6