def edit_prefix(self, id):
try:<EOL><INDENT>p = Prefix.get(int(id))<EOL>if '<STR_LIT>' in request.json:<EOL><INDENT>p.prefix = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:type>' in request.json:<EOL><INDENT>p.type = validate_string(request.json, '<STR_LIT:type>')<EOL><DEDENT>if '<STR_LIT:description>' in request.json:<EOL><INDENT>p.description = validate_string(request.json, '<STR_LIT:description>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.expires = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.comment = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.node = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT:status>' in request.json:<EOL><INDENT>p.status = validate_string(request.json, '<STR_LIT:status>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>if request.json['<STR_LIT>'] is None:<EOL><INDENT>p.pool = None<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>p.pool = Pool.get(int(request.json['<STR_LIT>']))<EOL><DEDENT>except NipapError as e:<EOL><INDENT>return json.dumps({'<STR_LIT:error>': <NUM_LIT:1>, '<STR_LIT:message>': e.args, '<STR_LIT:type>': type(e).__name__})<EOL><DEDENT><DEDENT><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.alarm_priority = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.monitor = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.country = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.order_id = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.customer_id = validate_string(request.json, '<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>try:<EOL><INDENT>if request.json['<STR_LIT>'] is None or len(str(request.json['<STR_LIT>'])) == <NUM_LIT:0>:<EOL><INDENT>p.vrf = None<EOL><DEDENT>else:<EOL><INDENT>p.vrf = VRF.get(int(request.json['<STR_LIT>']))<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>return json.dumps({'<STR_LIT:error>': <NUM_LIT:1>, '<STR_LIT:message>': "<STR_LIT>" % request.json['<STR_LIT>']})<EOL><DEDENT>except NipapError as e:<EOL><INDENT>return json.dumps({'<STR_LIT:error>': <NUM_LIT:1>, '<STR_LIT:message>': e.args, '<STR_LIT:type>': type(e).__name__})<EOL><DEDENT><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.vlan = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.tags = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.avps = request.json['<STR_LIT>']<EOL><DEDENT>p.save()<EOL><DEDENT>except NipapError as e:<EOL><INDENT>return json.dumps({'<STR_LIT:error>': <NUM_LIT:1>, '<STR_LIT:message>': e.args, '<STR_LIT:type>': type(e).__name__})<EOL><DEDENT>return json.dumps(p, cls=NipapJSONEncoder)<EOL>
Edit a prefix.