Search in sources :

Example 81 with ServiceInstancesRequest

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

the class BpmnRequestBuilder method createServiceInstancesRequest.

protected ServiceInstancesRequest createServiceInstancesRequest(GenericVnf vnf, VolumeGroup volumeGroup) {
    ServiceInstancesRequest request = new ServiceInstancesRequest();
    RequestDetails requestDetails = mapRequestDetails(vnf, volumeGroup);
    request.setRequestDetails(requestDetails);
    return request;
}
Also used : ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails)

Example 82 with ServiceInstancesRequest

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

the class BpmnRequestBuilder method createServiceInstancesRequest.

protected ServiceInstancesRequest createServiceInstancesRequest(GenericVnf vnf, VfModule vfModule, ModelType modelType) {
    ServiceInstancesRequest request = new ServiceInstancesRequest();
    RequestDetails requestDetails = mapRequestDetails(vnf, vfModule, modelType);
    request.setRequestDetails(requestDetails);
    return request;
}
Also used : ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails)

Example 83 with ServiceInstancesRequest

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

the class BpmnRequestBuilder method mapCloudConfigurationNetwork.

public CloudConfiguration mapCloudConfigurationNetwork(L3Network network) {
    CloudConfiguration cloudConfig = new CloudConfiguration();
    String tenantId = null;
    String cloudOwner = null;
    String lcpRegionId = null;
    Map<String, String[]> filters = createQueryRequest("networkId", network.getNetworkId());
    Optional<ServiceInstancesRequest> request = findServiceInstanceRequest(filters);
    if (request.isPresent()) {
        if (request.get().getRequestDetails() != null && request.get().getRequestDetails().getCloudConfiguration() != null) {
            if (request.get().getRequestDetails().getCloudConfiguration().getTenantId() != null) {
                tenantId = request.get().getRequestDetails().getCloudConfiguration().getTenantId();
            }
            if (request.get().getRequestDetails().getCloudConfiguration().getCloudOwner() != null) {
                cloudOwner = request.get().getRequestDetails().getCloudConfiguration().getCloudOwner();
            }
            if (request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId() != null) {
                lcpRegionId = request.get().getRequestDetails().getCloudConfiguration().getLcpCloudRegionId();
            }
        }
    } else {
        throw new CloudConfigurationNotFoundException(CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND);
    }
    cloudConfig.setTenantId(tenantId);
    cloudConfig.setCloudOwner(cloudOwner);
    cloudConfig.setLcpCloudRegionId(lcpRegionId);
    return cloudConfig;
}
Also used : CloudConfigurationNotFoundException(org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest)

Example 84 with ServiceInstancesRequest

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

the class ServiceInstance method deleteServiceInstance.

@DELETE
@ResponseUpdater
@Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Delete a Service instance", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ServiceInstancesResponse.class)))))
@Transactional
public Response deleteServiceInstance(@PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
    String requestId = requestHandler.getRequestId(requestContext);
    String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID);
    String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
    String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
    InfraActiveRequests currentRequest = requestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, requestorId, source, requestURI);
    ServiceInstancesRequest request = requestBuilder.buildServiceDeleteRequest(serviceInstanceId);
    requestHandler.saveInstanceName(request, currentRequest);
    requestHandler.checkDuplicateRequest(serviceInstanceId, request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
    Recipe recipe = requestHandler.findServiceRecipe(request.getRequestDetails().getModelInfo().getModelUuid(), Action.deleteInstance.toString());
    requestHandler.callWorkflowEngine(requestHandler.buildRequestParams(request, requestHandler.getRequestUri(requestContext), requestId, serviceInstanceId), recipe.getOrchestrationUri());
    ServiceInstancesResponse response = requestHandler.createResponse(serviceInstanceId, 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 85 with ServiceInstancesRequest

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

the class Network method deleteNetworkInstance.

@DELETE
@ResponseUpdater
@Path("/{version:[vV][8]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Delete provided Network instance", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Transactional
public Response deleteNetworkInstance(@PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
    String requestId = networkRestHandler.getRequestId(requestContext);
    String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID);
    String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
    String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
    InfraActiveRequests currentRequest = networkRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, networkInstanceId, requestorId, source, requestURI);
    ServiceInstancesRequest request = requestBuilder.buildNetworkDeleteRequest(networkInstanceId);
    networkRestHandler.saveInstanceName(request, currentRequest);
    networkRestHandler.checkDuplicateRequest(serviceInstanceId, networkInstanceId, request.getRequestDetails().getRequestInfo().getInstanceName(), currentRequest.getRequestId());
    Recipe recipe = networkRestHandler.findNetworkRecipe(Action.deleteInstance.toString());
    networkRestHandler.callWorkflowEngine(networkRestHandler.buildRequestParams(request, networkRestHandler.getRequestUri(requestContext), requestId, serviceInstanceId, networkInstanceId), recipe.getOrchestrationUri());
    ServiceInstancesResponse response = networkRestHandler.createResponse(networkInstanceId, 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)

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