@webob.dec.wsgify
@util.require_content('application/json')
def update_resource_provider(req):
 uuid = util.wsgi_path_item(req.environ, 'uuid')
 context = req.environ['placement.context']
 resource_provider = objects.ResourceProvider.get_by_uuid(context, uuid)
 data = util.extract_json(req.body, PUT_RESOURCE_PROVIDER_SCHEMA)
 resource_provider.name = data['name']
 try:
  resource_provider.save()
 except db_exc.DBDuplicateEntry as exc:
  raise webob.exc.HTTPConflict((_('Conflicting resource provider already exists: %(error)s') % {'error': exc}), json_formatter=util.json_error_formatter)
 except exception.ObjectActionError as exc:
  raise webob.exc.HTTPBadRequest((_('Unable to save resource provider %(rp_uuid)s: %(error)s') % {'rp_uuid': uuid, 'error': exc}), json_formatter=util.json_error_formatter)
 req.response.body = encodeutils.to_utf8(jsonutils.dumps(_serialize_provider(req.environ, resource_provider)))
 req.response.status = 200
 req.response.content_type = 'application/json'
 return req.response

@ webob . dec . wsgify @ util . require_content ( 'application/json' ) def update_resource_provider ( req ) : uuid = util . wsgi_path_item ( req . environ , 'uuid' ) context = req . environ [ 'placement.context' ] resource_provider = objects . ResourceProvider . get_by_uuid ( context , uuid ) data = util . extract_json ( req . body , PUT_RESOURCE_PROVIDER_SCHEMA ) resource_provider . name = data [ 'name' ] try : resource_provider . save ( ) except db_exc . DBDuplicateEntry as exc : raise webob . exc . HTTPConflict ( ( _ ( 'Conflicting resource provider already exists: %(error)s' ) % { 'error' : exc } ) , json_formatter = util . json_error_formatter ) except exception . ObjectActionError as exc : raise webob . exc . HTTPBadRequest ( ( _ ( 'Unable to save resource provider %(rp_uuid)s: %(error)s' ) % { 'rp_uuid' : uuid , 'error' : exc } ) , json_formatter = util . json_error_formatter ) req . response . body = encodeutils . to_utf8 ( jsonutils . dumps ( _serialize_provider ( req . environ , resource_provider ) ) ) req . response . status = 200 req . response . content_type = 'application/json' return req . response
put to update a single resource provider .