Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
 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
Esempio n. 4
0
 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