@webob.dec.wsgify
@microversion.version_handler(1.2)
@util.require_content('application/json')
def update_resource_class(req):
 name = util.wsgi_path_item(req.environ, 'name')
 context = req.environ['placement.context']
 data = util.extract_json(req.body, PUT_RC_SCHEMA_V1_2)
 rc = objects.ResourceClass.get_by_name(context, name)
 rc.name = data['name']
 try:
  rc.save()
 except exception.ResourceClassExists:
  raise webob.exc.HTTPConflict((_('Resource class already exists: %(name)s') % {'name': name}), json_formatter=util.json_error_formatter)
 except exception.ResourceClassCannotUpdateStandard:
  raise webob.exc.HTTPBadRequest((_('Cannot update standard resource class %(rp_name)s') % {'rp_name': name}), json_formatter=util.json_error_formatter)
 req.response.body = encodeutils.to_utf8(jsonutils.dumps(_serialize_resource_class(req.environ, rc)))
 req.response.status = 200
 req.response.content_type = 'application/json'
 return req.response

@ webob . dec . wsgify @ microversion . version_handler ( 1.2 ) @ util . require_content ( 'application/json' ) def update_resource_class ( req ) : name = util . wsgi_path_item ( req . environ , 'name' ) context = req . environ [ 'placement.context' ] data = util . extract_json ( req . body , PUT_RC_SCHEMA_V1_2 ) rc = objects . ResourceClass . get_by_name ( context , name ) rc . name = data [ 'name' ] try : rc . save ( ) except exception . ResourceClassExists : raise webob . exc . HTTPConflict ( ( _ ( 'Resource class already exists: %(name)s' ) % { 'name' : name } ) , json_formatter = util . json_error_formatter ) except exception . ResourceClassCannotUpdateStandard : raise webob . exc . HTTPBadRequest ( ( _ ( 'Cannot update standard resource class %(rp_name)s' ) % { 'rp_name' : name } ) , json_formatter = util . json_error_formatter ) req . response . body = encodeutils . to_utf8 ( jsonutils . dumps ( _serialize_resource_class ( req . environ , rc ) ) ) req . response . status = 200 req . response . content_type = 'application/json' return req . response
put to update a single resource class .