@Override public FcNetwork getFcNetwork(final RestParams params, final String resourceId) { logger.info("FcNetworkClientImpl : getFcNetwork : 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.FC_NETWORK_URI, resourceId)); final String returnObj = restClient.sendRequestToHPOV(params, null); logger.debug("FcNetworkClientImpl : getFcNetwork : response from OV :" + returnObj); if (null == returnObj || returnObj.equals("")) { throw new SDKNoResponseException( SDKErrorEnum.noResponseFromAppliance, null, null, null, SdkConstants.FC_NETWORK, null); } // Call adaptor to convert to DTO final FcNetwork fcNetworkDto = adaptor.buildDto(returnObj); logger.debug("FcNetworkClientImpl : getFcNetwork : name :" + fcNetworkDto.getName()); logger.info("FcNetworkClientImpl : getFcNetwork : End"); return fcNetworkDto; }
@Override public String getId(final RestParams creds, final String name) { String resourceId = ""; // fetch resource Id using resource name FcNetwork fcNetwork = getFcNetworkByName(creds, name); if (null != fcNetwork.getUri()) { resourceId = urlUtils.getResourceIdFromUri(fcNetwork.getUri()); } return resourceId; }
@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; }