private CloudStack mapStackResource(Map<String, Object> resource) { return new CloudStack(getMeta(resource), getNameOfResource(resource), getEntityAttribute(resource, "description", String.class)); }
private CloudSpace mapSpaceResource(Map<String, Object> resource) { Map<String, Object> organizationMap = getEmbeddedResource(resource, "organization"); CloudOrganization organization = null; if (organizationMap != null) { organization = mapOrganizationResource(organizationMap); } return new CloudSpace(getMeta(resource), getNameOfResource(resource), organization); }
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 CloudOrganization mapOrganizationResource(Map<String, Object> resource) { Boolean billingEnabled = getEntityAttribute(resource, "billing_enabled", Boolean.class); Map<String, Object> quotaDefinition = getEmbeddedResource(resource, "quota_definition"); CloudQuota quota = null; if (quotaDefinition != null) { quota = mapQuotaResource(quotaDefinition); } return new CloudOrganization(getMeta(resource), getNameOfResource(resource), quota, billingEnabled); }
private CloudQuota mapQuotaResource(Map<String, Object> resource) { Boolean nonBasicServicesAllowed = getEntityAttribute(resource, "non_basic_services_allowed", Boolean.class); int totalServices = getEntityAttribute(resource, "total_services", Integer.class); int totalRoutes = getEntityAttribute(resource, "total_routes", Integer.class); long memoryLimit = getEntityAttribute(resource, "memory_limit", Long.class); return new CloudQuota(getMeta(resource), getNameOfResource(resource), nonBasicServicesAllowed, totalServices, totalRoutes, memoryLimit); }
private CloudDomain mapDomainResource(Map<String, Object> resource) { @SuppressWarnings("unchecked") Map<String, Object> ownerResource = getEntityAttribute(resource, "owning_organization", Map.class); CloudOrganization owner; if (ownerResource == null) { owner = new CloudOrganization(CloudEntity.Meta.defaultMeta(), "none"); } else { owner = mapOrganizationResource(ownerResource); } return new CloudDomain(getMeta(resource), getNameOfResource(resource), owner); }
@SuppressWarnings("unchecked") private CloudServiceBinding mapServiceBinding(Map<String, Object> resource) { CloudServiceBinding binding = new CloudServiceBinding(getMeta(resource), getNameOfResource(resource)); binding.setAppGuid(UUID.fromString(getEntityAttribute(resource, "app_guid", String.class))); binding.setSyslogDrainUrl(getEntityAttribute(resource, "syslog_drain_url", String.class)); binding.setCredentials(getEntityAttribute(resource, "credentials", Map.class)); binding.setBindingOptions(getEntityAttribute(resource, "binding_options", Map.class)); return binding; }
@SuppressWarnings("unchecked") private CloudServiceInstance mapServiceInstanceResource(Map<String, Object> resource) { CloudServiceInstance serviceInstance = new CloudServiceInstance(getMeta(resource), getNameOfResource(resource)); serviceInstance.setType(getEntityAttribute(resource, "type", String.class)); serviceInstance.setDashboardUrl(getEntityAttribute(resource, "dashboard_url", String.class)); serviceInstance.setCredentials(getEntityAttribute(resource, "credentials", Map.class)); Map<String, Object> servicePlanResource = getEmbeddedResource(resource, "service_plan"); serviceInstance.setServicePlan(mapServicePlanResource(servicePlanResource)); CloudService service = mapServiceResource(resource); serviceInstance.setService(service); List<Map<String, Object>> bindingsResource = getEmbeddedResourceList(getEntity(resource), "service_bindings"); List<CloudServiceBinding> bindings = new ArrayList<>(bindingsResource.size()); for (Map<String, Object> bindingResource : bindingsResource) { bindings.add(mapServiceBinding(bindingResource)); } serviceInstance.setBindings(bindings); return serviceInstance; }
CloudApplication app = new CloudApplication( getMeta(resource), getNameOfResource(resource)); app.setInstances(getEntityAttribute(resource, "instances", Integer.class)); app.setServices(new ArrayList<String>()); for (Map<String, Object> binding : serviceBindings) { Map<String, Object> service = getEntityAttribute(binding, "service_instance", Map.class); String serviceName = getNameOfResource(service); if (serviceName != null) { serviceList.add(serviceName);
private CloudService mapServiceResource(Map<String, Object> resource) { CloudService cloudService = new CloudService(getMeta(resource), getNameOfResource(resource)); Map<String, Object> servicePlanResource = getEmbeddedResource(resource, "service_plan"); if (servicePlanResource != null) { cloudService.setPlan(getEntityAttribute(servicePlanResource, "name", String.class)); Map<String, Object> serviceResource = getEmbeddedResource(servicePlanResource, "service"); if (serviceResource != null) { cloudService.setLabel(getEntityAttribute(serviceResource, "label", String.class)); cloudService.setProvider(getEntityAttribute(serviceResource, "provider", String.class)); cloudService.setVersion(getEntityAttribute(serviceResource, "version", String.class)); } } return cloudService; }
private CloudEvent mapEventResource(Map<String, Object> resource) { CloudEvent event = new CloudEvent( getMeta(resource), getNameOfResource(resource)); event.setType(getEntityAttribute(resource, "type", String.class)); event.setActor(getEntityAttribute(resource, "actor", String.class)); event.setActorType(getEntityAttribute(resource, "actor_type", String.class)); event.setActorName(getEntityAttribute(resource, "actor_name", String.class)); event.setActee(getEntityAttribute(resource, "actee", String.class)); event.setActeeType(getEntityAttribute(resource, "actee_type", String.class)); event.setActeeName(getEntityAttribute(resource, "actee_name", String.class)); Date timestamp = parseDate(getEntityAttribute(resource, "timestamp", String.class)); event.setTimestamp(timestamp); return event; }