@Override public TaskResourceV2 createFcNetwork( final RestParams params, final FcNetwork fcNetworkDto, final boolean aSync, final boolean useJsonRequest) { logger.info("FcNetworkClientImpl : createFcNetwork : Start"); String returnObj = null; // validate params if (fcNetworkDto == null) { throw new SDKInvalidArgumentException( SDKErrorEnum.invalidArgument, null, null, null, SdkConstants.FC_NETWORKS, null); } // set the additional params params.setType(HttpMethodType.POST); params.setUrl(urlUtils.createRestUrl(params.getHostname(), ResourceUris.FC_NETWORK_URI)); // check for json request in the input dto. if it is present, // then // convert that into jsonObject and pass it rest client // idea is : user can create json string and call the sdk api. // user can save time in creating network dto. if (useJsonRequest == true) { final FcNetwork dto = adaptor.buildDto(fcNetworkDto.getJsonRequest().getBody()); // create JSON request from dto jsonObject = adaptor.buildJsonObjectFromDto(dto); } else { // create JSON request from dto jsonObject = adaptor.buildJsonObjectFromDto(fcNetworkDto); } returnObj = restClient.sendRequestToHPOV(params, jsonObject); // convert returnObj to taskResource TaskResourceV2 taskResourceV2 = taskAdaptor.buildDto(returnObj); logger.debug("FcNetworkClientImpl : createFcNetwork : returnObj =" + returnObj); logger.debug("FcNetworkClientImpl : createFcNetwork : taskResource =" + taskResourceV2); // check for aSync flag. if user is asking async mode, return directly // the TaskResourceV2 // if user is asking for sync mode, call task monitor polling method and // send the update // once task is complete or exceeds the timeout. if (taskResourceV2 != null && aSync == false) { taskResourceV2 = taskMonitor.checkStatus(params, taskResourceV2.getUri(), TIMEOUT); } logger.info("FcNetworkClientImpl : createFcNetwork : End"); return taskResourceV2; }
@Override public TaskResourceV2 deleteFirmwareDriver( RestParams params, String resourceId, Boolean isForce, final boolean aSync, final boolean useJsonRequest) { logger.info("FirmwareDriverClientImpl : deleteFirmwareDriver : Start"); // validate args if (null == params) { throw new SDKInvalidArgumentException( SDKErrorEnum.invalidArgument, null, null, null, SdkConstants.APPLIANCE, null); } // set the additional params params.setType(HttpMethodType.DELETE); params.setUrl( urlUtils.createRestUrl(params.getHostname(), ResourceUris.FIRMWARE_DRIVER_URI, resourceId)); final String returnObj = restClient.sendRequestToHPOV(params, null); logger.debug( "FirmwareDriverClientImpl : deleteFirmwareDriver : response from OV :" + returnObj); if (null == returnObj || returnObj.equals("")) { throw new SDKNoResponseException( SDKErrorEnum.noResponseFromAppliance, null, null, null, SdkConstants.FIRMWARE_DRIVER, null); } TaskResourceV2 taskResourceV2 = taskAdaptor.buildDto(returnObj); logger.debug("FirmwareDriverClientImpl : deleteFirmwareDriver : returnObj =" + returnObj); logger.debug( "FirmwareDriverClientImpl : deleteFirmwareDriver : taskResource =" + taskResourceV2); // check for asyncOrSyncMode. if user is asking async mode, return the // directly the TaskResourceV2 // if user is asking for sync mode, calling the tasking polling method // and send the update // once task is complete. if (taskResourceV2 != null && aSync == false) { taskResourceV2 = taskMonitor.checkStatus(params, taskResourceV2.getUri(), TIMEOUT); } logger.info("FirmwareDriverClientImpl : deleteFirmwareDriver : End"); return taskResourceV2; }