@Override public FwBaseline getFirmwareDriver(final RestParams params, final String resourceId) { logger.info("FirmwareDriverClientImpl : getFirmwareDriver : Start"); // validate args if (null == params) { throw new SDKInvalidArgumentException( SDKErrorEnum.invalidArgument, null, null, null, SdkConstants.APPLIANCE, null); } // set the additional params params.setType(HttpMethodType.GET); params.setUrl( urlUtils.createRestUrl(params.getHostname(), ResourceUris.FIRMWARE_DRIVER_URI, resourceId)); final String returnObj = restClient.sendRequestToHPOV(params, null); logger.debug("FirmwareDriverClientImpl : getFirmwareDriver : response from OV :" + returnObj); if (null == returnObj || returnObj.equals("")) { throw new SDKNoResponseException( SDKErrorEnum.noResponseFromAppliance, null, null, null, SdkConstants.FIRMWARE_DRIVER, null); } // Call adaptor to convert to DTO final FwBaseline fwBaselineDto = adaptor.buildDto(returnObj); logger.debug("FirmwareDriverClientImpl : getFirmwareDriver : name :" + fwBaselineDto.getName()); logger.info("FirmwareDriverClientImpl : getFirmwareDriver : End"); return fwBaselineDto; }
@Override public FcNetworkCollection getFcNetworkByFilter( final RestParams params, final Integer start, final Integer count) { logger.info("FcNetworkClientImpl : getFcNetworkByFilter : Start"); final String query = "start=" + start + "&count=" + count; // validate args if (null == params) { throw new SDKInvalidArgumentException( SDKErrorEnum.invalidArgument, null, null, null, SdkConstants.APPLIANCE, null); } // set the additional params params.setType(HttpMethodType.GET); params.setUrl( urlUtils.createRestQueryUrl(params.getHostname(), ResourceUris.FC_NETWORK_URI, query)); final String returnObj = restClient.sendRequestToHPOV(params, null); logger.debug("FcNetworkClientImpl : getFcNetworkByFilter : response from OV :" + returnObj); if (null == returnObj || returnObj.equals("")) { throw new SDKNoResponseException( SDKErrorEnum.noResponseFromAppliance, null, null, null, SdkConstants.FC_NETWORKS, null); } // Call adaptor to convert to DTO final FcNetworkCollection fcNetworkCollectionDto = adaptor.buildCollectionDto(returnObj); logger.debug( "FcNetworkClientImpl : getFcNetworkByFilter : count :" + fcNetworkCollectionDto.getCount()); logger.info("FcNetworkClientImpl : getFcNetworkByFilter : End"); return fcNetworkCollectionDto; }
@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; }
@Override public FcNetwork getFcNetworkByName(final RestParams params, final String name) { logger.info("FcNetworkClientImpl : getFcNetworkByName : Start"); // final String query = "filter=\"name=\'" + name + "\'\""; final String query = urlUtils.createFilterString(name); // validate args if (null == params) { throw new SDKInvalidArgumentException( SDKErrorEnum.invalidArgument, null, null, null, SdkConstants.APPLIANCE, null); } // set the additional params params.setType(HttpMethodType.GET); params.setUrl( urlUtils.createRestQueryUrl(params.getHostname(), ResourceUris.FC_NETWORK_URI, query)); final String returnObj = restClient.sendRequestToHPOV(params, null); logger.debug("FcNetworkClientImpl : getFcNetworkByName : response from OV :" + returnObj); if (null == returnObj || returnObj.equals("")) { throw new SDKNoResponseException( SDKErrorEnum.noResponseFromAppliance, null, null, null, SdkConstants.FC_NETWORKS, null); } // Call adaptor to convert to DTO final FcNetworkCollection fcNetworkCollectionDto = adaptor.buildCollectionDto(returnObj); FcNetwork fcNetworkDto; if (fcNetworkCollectionDto.getCount() != 0) { fcNetworkDto = fcNetworkCollectionDto.getMembers().get(0); } else { fcNetworkDto = null; } if (fcNetworkDto == null) { logger.error( "FcNetworkClientImpl : getFcNetworkByName : resource not Found for name :" + name); throw new SDKResourceNotFoundException( SDKErrorEnum.resourceNotFound, null, null, null, SdkConstants.FC_NETWORK, null); } logger.info("FcNetworkClientImpl : getFcNetworkByName : End"); return fcNetworkDto; }