def add_prefix(self):
p = Prefix()<EOL>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: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:type>' in request.json:<EOL><INDENT>p.type = validate_string(request.json, '<STR_LIT:type>')<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>if request.json['<STR_LIT>'] is not None:<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.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>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.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>args = {}<EOL>if '<STR_LIT>' in request.json:<EOL><INDENT>args['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>try:<EOL><INDENT>args['<STR_LIT>'] = 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>if '<STR_LIT>' in request.json:<EOL><INDENT>args['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>args['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if args == {}:<EOL><INDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>p.prefix = request.json['<STR_LIT>']<EOL><DEDENT><DEDENT>try:<EOL><INDENT>p.save(args)<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>
Add prefix according to the specification.

            The following keys can be used:

            vrf             ID of VRF to place the prefix in
            prefix          the prefix to add if already known
            family          address family (4 or 6)
            description     A short description
            expires         Expiry time of assignment
            comment         Longer comment
            node            Hostname of node
            type            Type of prefix; reservation, assignment, host
            status          Status of prefix; assigned, reserved, quarantine
            pool            ID of pool
            country         Country where the prefix is used
            order_id        Order identifier
            customer_id     Customer identifier
            vlan            VLAN ID
            alarm_priority  Alarm priority of prefix
            monitor         If the prefix should be monitored or not

            from-prefix     A prefix the prefix is to be allocated from
            from-pool       A pool (ID) the prefix is to be allocated from
            prefix_length   Prefix length of allocated prefix