def get_one(self, tenant_id): context = pecan.request.environ['context'] quotas = self.central_api.get_quotas(context, tenant_id) quotas = QuotaList.from_dict(quotas) return DesignateAdapter.render('API_v2', quotas)
def patch_one(self, tenant_id): """Modify a Quota""" request = pecan.request context = request.environ['context'] body = request.body_dict quotas = DesignateAdapter.parse('API_v2', body, QuotaList()) for quota in quotas: self.central_api.set_quota(context, tenant_id, quota.resource, quota.hard_limit) quotas = self.central_api.get_quotas(context, tenant_id) quotas = QuotaList.from_dict(quotas) return DesignateAdapter.render('API_v2', quotas)
def patch_one(self, tenant_id): """Modify a Quota""" request = pecan.request context = request.environ['context'] body = request.body_dict # NOTE(pas-ha) attempting to verify the validity of the project-id # on a best effort basis # this will raise only if KeystoneV3 endpoint is not found at all, # or the creds are passing but the project is not found if cfg.CONF['service:api'].quotas_verify_project_id: keystone.verify_project_id(context, tenant_id) quotas = DesignateAdapter.parse('API_v2', body, QuotaList()) for quota in quotas: self.central_api.set_quota(context, tenant_id, quota.resource, quota.hard_limit) quotas = self.central_api.get_quotas(context, tenant_id) quotas = QuotaList.from_dict(quotas) return DesignateAdapter.render('API_v2', quotas)