public static CloudEntity.Meta getV3Meta(Map<String, Object> resource) { // In V3, the metadata is embedded in the resources. return toMeta(resource); }
public static String parse(Object object) { return parse(String.class, object); }
public String getNameOfV3Resource(Map<String, Object> resource) { return getAttributeOfV3Resource(resource, "name", String.class); }
private CloudSecurityGroup mapApplicationSecurityGroupResource(Map<String, Object> resource) { return new CloudSecurityGroup(getMeta(resource), getNameOfResource(resource), getSecurityGroupRules(resource), getEntityAttribute(resource, "running_default", Boolean.class), getEntityAttribute(resource, "staging_default", Boolean.class)); }
private CloudTask mapTaskResource(Map<String, Object> resource) { CloudTask task = new CloudTask(getV3Meta(resource), getNameOfV3Resource(resource)); task.setCommand(getAttributeOfV3Resource(resource, "command", String.class)); task.setMemory(getAttributeOfV3Resource(resource, "memory_in_mb", Integer.class)); task.setDiskQuota(getAttributeOfV3Resource(resource, "disk_in_mb", Integer.class)); task.setState(getTaskState(resource)); task.setResult(getTaskResult(resource)); return task; }
public CloudControllerClientFactory(HttpProxyConfiguration httpProxyConfiguration, boolean trustSelfSignedCerts) { this.restUtil = new RestUtil(); this.restTemplate = restUtil.createRestTemplate(httpProxyConfiguration, trustSelfSignedCerts); this.httpProxyConfiguration = httpProxyConfiguration; this.trustSelfSignedCerts = trustSelfSignedCerts; this.objectMapper = new ObjectMapper(); }
private CloudServiceBroker mapServiceBrokerResource(Map<String, Object> resource) { return new CloudServiceBroker(getV2Meta(resource), getAttributeOfV2Resource(resource, "name", String.class), getAttributeOfV2Resource(resource, "broker_url", String.class), getAttributeOfV2Resource(resource, "auth_username", String.class)); }
private CloudSpace toCloudSpace(Map<String, Object> resource) { return resourceMapper.mapResource(resource, CloudSpace.class); }
private CloudStack mapStackResource(Map<String, Object> resource) { return new CloudStack(getMeta(resource), getNameOfResource(resource), getEntityAttribute(resource, "description", String.class)); }
public String getNameOfV2Resource(Map<String, Object> resource) { return getAttributeOfV2Resource(resource, "name", String.class); }
private CloudUser mapUserResource(Map<String, Object> resource) { boolean isActiveUser = getEntityAttribute(resource, "active", Boolean.class); boolean isAdminUser = getEntityAttribute(resource, "admin", Boolean.class); String defaultSpaceGuid = getEntityAttribute(resource, "default_space_guid", String.class); String username = getEntityAttribute(resource, "username", String.class); return new CloudUser(getMeta(resource), username,isAdminUser,isActiveUser,defaultSpaceGuid); }
private byte[] trimCRLF(byte[] bytes) { if (endsWithCRLF(bytes)) { return Arrays.copyOf(bytes, bytes.length - 2); } return bytes; }
public static <T> T getAttributeOfV3Resource(Map<String, Object> resource, String attributeName, Class<T> targetClass) { // In V3, the entities are embedded in the resources. return getResourceAttribute(resource, attributeName, targetClass); }
protected CloudEntityResourceMapper getResourceMapper() { return new CloudEntityResourceMapper(); }
public String getNameOfResource(Map<String, Object> resource) { return getEntityAttribute(resource, "name", String.class); }
public static String parse(Object object) { return parse(String.class, object); }
@SuppressWarnings("unchecked") private ServiceKey mapServiceKeyResource(Map<String, Object> resource) { ServiceKey serviceKey = new ServiceKey(getV2Meta(resource), getAttributeOfV2Resource(resource, "name", String.class), null, getAttributeOfV2Resource(resource, "credentials", Map.class), null); return serviceKey; }
private String getError(Map<String, Object> resource) { return getAttributeOfV3Resource(resource, "error", String.class); }
public Usage(Map<String, Object> data) { if (data != null && !data.isEmpty()) { apps = CloudUtil.parse(Integer.class, data.get("apps")); totalMemory = CloudUtil.parse(Integer.class, data.get("memory")); urisPerApp = CloudUtil.parse(Integer.class, data.get("app_uris")); services = CloudUtil.parse(Integer.class, data.get("services")); } }