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();
}
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;
}
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());
}
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");
}
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));
}
Aggregations