public void updateQuota(CloudQuota quota, String name) { CloudQuota oldQuota = this.getQuotaByName(name, true); String setPath = "/v2/quota_definitions/{quotaGuid}"; Map<String, Object> setVars = new HashMap<String, Object>(); setVars.put("quotaGuid", oldQuota.getMeta().getGuid()); HashMap<String, Object> setRequest = new HashMap<String, Object>(); setRequest.put("name", quota.getName()); setRequest.put("memory_limit", quota.getMemoryLimit()); setRequest.put("total_routes", quota.getTotalRoutes()); setRequest.put("total_services", quota.getTotalServices()); setRequest.put("non_basic_services_allowed", quota.isNonBasicServicesAllowed()); getRestTemplate().put(getUrl(setPath), setRequest, setVars); }
public void deleteQuota(String quotaName) { CloudQuota quota = this.getQuotaByName(quotaName, true); String setPath = "/v2/quota_definitions/{quotaGuid}"; Map<String, Object> setVars = new HashMap<String, Object>(); setVars.put("quotaGuid", quota.getMeta().getGuid()); getRestTemplate().delete(getUrl(setPath), setVars); }
private CloudQuota mapQuotaResource(Map<String, Object> resource) { Boolean nonBasicServicesAllowed = getAttributeOfV2Resource(resource, "non_basic_services_allowed", Boolean.class); int totalServices = getAttributeOfV2Resource(resource, "total_services", Integer.class); int totalRoutes = getAttributeOfV2Resource(resource, "total_routes", Integer.class); long memoryLimit = getAttributeOfV2Resource(resource, "memory_limit", Long.class); return new CloudQuota(getV2Meta(resource), getNameOfV2Resource(resource), nonBasicServicesAllowed, totalServices, totalRoutes, memoryLimit); }
@Override public void deleteQuota(String quotaName) { CloudQuota quota = this.getQuota(quotaName); String setPath = "/v2/quota_definitions/{quotaGuid}"; Map<String, Object> setVars = new HashMap<String, Object>(); setVars.put("quotaGuid", quota.getMeta() .getGuid()); getRestTemplate().delete(getUrl(setPath), setVars); }
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); }
/** * Create quota from a CloudQuota instance (Quota Plan) * * @param quota */ public void createQuota(CloudQuota quota) { String setPath = "/v2/quota_definitions"; HashMap<String, Object> setRequest = new HashMap<String, Object>(); setRequest.put("name", quota.getName()); setRequest.put("memory_limit", quota.getMemoryLimit()); setRequest.put("total_routes", quota.getTotalRoutes()); setRequest.put("total_services", quota.getTotalServices()); setRequest.put("non_basic_services_allowed", quota.isNonBasicServicesAllowed()); getRestTemplate().postForObject(getUrl(setPath), setRequest, String.class); }
/** * Set quota to organization * * @param orgName * @param quotaName */ public void setQuotaToOrg(String orgName, String quotaName) { CloudQuota quota = this.getQuotaByName(quotaName, true); CloudOrganization org = this.getOrgByName(orgName, true); doSetQuotaToOrg(org.getMeta().getGuid(), quota.getMeta().getGuid()); }
/** * Create quota from a CloudQuota instance (Quota Plan) * * @param quota */ @Override public void createQuota(CloudQuota quota) { String setPath = "/v2/quota_definitions"; HashMap<String, Object> setRequest = new HashMap<String, Object>(); setRequest.put("name", quota.getName()); setRequest.put("memory_limit", quota.getMemoryLimit()); setRequest.put("total_routes", quota.getTotalRoutes()); setRequest.put("total_services", quota.getTotalServices()); setRequest.put("non_basic_services_allowed", quota.isNonBasicServicesAllowed()); getRestTemplate().postForObject(getUrl(setPath), setRequest, String.class); }
/** * Set quota to organization * * @param orgName * @param quotaName */ @Override public void setQuotaToOrg(String orgName, String quotaName) { CloudQuota quota = this.getQuota(quotaName); CloudOrganization org = this.getOrganization(orgName); doSetQuotaToOrg(org.getMeta() .getGuid(), quota.getMeta() .getGuid()); }
@Override public void updateQuota(CloudQuota quota, String name) { CloudQuota oldQuota = this.getQuota(name); String setPath = "/v2/quota_definitions/{quotaGuid}"; Map<String, Object> setVars = new HashMap<String, Object>(); setVars.put("quotaGuid", oldQuota.getMeta() .getGuid()); HashMap<String, Object> setRequest = new HashMap<String, Object>(); setRequest.put("name", quota.getName()); setRequest.put("memory_limit", quota.getMemoryLimit()); setRequest.put("total_routes", quota.getTotalRoutes()); setRequest.put("total_services", quota.getTotalServices()); setRequest.put("non_basic_services_allowed", quota.isNonBasicServicesAllowed()); getRestTemplate().put(getUrl(setPath), setRequest, setVars); }