private Boolean checkIfPlanExist(String planName, String serviceLabel){ for(CloudServicePlan csp : findCloudServiceOffering(serviceLabel).getCloudServicePlans()){ if(csp.getMeta().equals(serviceLabel)) return true; } return false; }
private Map<String, Object> createServiceRequest(CloudServiceExtended service, String spaceId, CloudServicePlan cloudServicePlan) { Map<String, Object> serviceRequest = new HashMap<>(); serviceRequest.put(SPACE_GUID, spaceId); serviceRequest.put(SERVICE_NAME, service.getName()); serviceRequest.put(SERVICE_PLAN_GUID, cloudServicePlan.getMeta() .getGuid() .toString()); serviceRequest.put(SERVICE_PARAMETERS, service.getCredentials()); serviceRequest.put(SERVICE_TAGS, service.getTags()); return serviceRequest; }
private MethodExecution<String> attemptToUpdateServicePlan(CloudControllerClient client, String serviceName, String servicePlanName) { CloudService service = client.getService(serviceName); CloudServicePlan servicePlan = findPlanForService(client, service, servicePlanName); String servicePlanGuid = servicePlan.getMeta().getGuid().toString(); return attemptToUpdateServiceParameter(client, serviceName, SERVICE_INSTANCES_URL, SERVICE_PLAN_GUID, servicePlanGuid); }
@Override public void createService(CloudService service) { assertSpaceProvided("create service"); Assert.notNull(service, "Service must not be null"); Assert.notNull(service.getName(), "Service name must not be null"); Assert.notNull(service.getLabel(), "Service label must not be null"); Assert.notNull(service.getPlan(), "Service plan must not be null"); CloudServicePlan cloudServicePlan = findPlanForService(service); HashMap<String, Object> serviceRequest = new HashMap<String, Object>(); serviceRequest.put("space_guid", sessionSpace.getMeta().getGuid()); serviceRequest.put("name", service.getName()); serviceRequest.put("service_plan_guid", cloudServicePlan.getMeta().getGuid()); getRestTemplate().postForObject(getUrl("/v2/service_instances"), serviceRequest, String.class); }
@Override public void createService(CloudService service) { assertSpaceProvided("create service"); Assert.notNull(service, "Service must not be null"); Assert.notNull(service.getName(), "Service name must not be null"); Assert.notNull(service.getLabel(), "Service label must not be null"); Assert.notNull(service.getPlan(), "Service plan must not be null"); CloudServicePlan cloudServicePlan = findPlanForService(service); HashMap<String, Object> serviceRequest = new HashMap<String, Object>(); serviceRequest.put("space_guid", sessionSpace.getMeta() .getGuid()); serviceRequest.put("name", service.getName()); serviceRequest.put("service_plan_guid", cloudServicePlan.getMeta() .getGuid()); getRestTemplate().postForObject(getUrl("/v2/service_instances"), serviceRequest, String.class); }