def create(self, req, type_id, body=None): context = req.environ['monitor.context'] authorize(context) if not self.is_valid_body(body, 'extra_specs'): raise webob.exc.HTTPBadRequest() self._check_type(context, type_id) specs = body['extra_specs'] db.servicemanage_type_extra_specs_update_or_create( context, type_id, specs) return body
def create(self, req, type_id, body=None): context = req.environ['monitor.context'] authorize(context) if not self.is_valid_body(body, 'extra_specs'): raise webob.exc.HTTPBadRequest() self._check_type(context, type_id) specs = body['extra_specs'] db.servicemanage_type_extra_specs_update_or_create(context, type_id, specs) return body
def update(self, req, type_id, id, body=None): context = req.environ['monitor.context'] authorize(context) if not body: expl = _('Request body empty') raise webob.exc.HTTPBadRequest(explanation=expl) self._check_type(context, type_id) if id not in body: expl = _('Request body and URI mismatch') raise webob.exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise webob.exc.HTTPBadRequest(explanation=expl) db.servicemanage_type_extra_specs_update_or_create( context, type_id, body) return body
def update(self, req, type_id, id, body=None): context = req.environ['monitor.context'] authorize(context) if not body: expl = _('Request body empty') raise webob.exc.HTTPBadRequest(explanation=expl) self._check_type(context, type_id) if id not in body: expl = _('Request body and URI mismatch') raise webob.exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise webob.exc.HTTPBadRequest(explanation=expl) db.servicemanage_type_extra_specs_update_or_create(context, type_id, body) return body