def put_network(nb_db, content, parameters): received_network = get_entity(content, 'network') network = nb_db.update_network(received_network, parameters[NETWORK_ID]) return Response({'network': network})
def put_ports(nb_db, content, parameters): received_port = get_entity(content, 'port') port = nb_db.update_port(received_port, parameters[PORT_ID]) return Response({'port': port})
def post_ports(nb_db, content, parameters): received_port = get_entity(content, 'port') port = nb_db.add_port(received_port) return Response({'port': port})
def post_subnets(nb_db, content, parameters): received_subnet = get_entity(content, 'subnet') subnet = nb_db.add_subnet(received_subnet) return Response({'subnet': subnet})
def show_handler(nb_db, content, path_parts): return Response({'method:': REST_RESPONSE_SHOW})
def post_networks(nb_db, content, parameters): received_network = get_entity(content, 'network') network = nb_db.add_network(received_network) return Response({'network': network})
def delete_network(nb_db, content, parameters): nb_db.delete_network(parameters[NETWORK_ID]) return Response()
def post_routers(nb_db, content, parameters): content_json = json.loads(content) received_router = content_json['router'] router = nb_db.add_router(received_router) return Response({'router': router})
def tokens_handler(content, id): return Response({'value': REST_RESPONSE_POST + json.loads(content)['key']})
def empty_handler(content, id): return Response({'value': EMPTY})
def response_code_201(nb_db, content, path_parts): return Response({ 'method:': REST_RESPONSE_POST, 'value:': content }, code=httplib.CREATED)
def post_handler(nb_db, content, path_parts): return Response({'method:': REST_RESPONSE_POST, 'value:': content})
def delete_handler(nb_db, content, path_parts): return Response()
def put_subnets(nb_db, content, parameters): received_subnet = get_entity(content, 'subnet') subnet = nb_db.update_subnet(received_subnet, parameters[SUBNET_ID]) return Response({'subnet': subnet})
def delete_port(nb_db, content, parameters): nb_db.delete_port(parameters[PORT_ID]) return Response()
def get_routers(nb_db, content, parameters): return Response({'routers': nb_db.list_routers()})
def delete_subnet(nb_db, content, parameters): nb_db.delete_subnet(parameters[SUBNET_ID]) return Response()
def get_router(nb_db, content, parameters): return Response({'router': nb_db.get_router(parameters[ROUTER_ID])})
def get_handler(nb_db, content, path_parts): return Response({'method:': REST_RESPONSE_GET})