def delete(self, address, prefixlen): network = Network.get(address, prefixlen).first_or_404() if network.owner != g.user: abort(401) db.session.delete(network) db.session.commit() return jsonify(message='success')
def get(self, address, prefixlen): if address is None or prefixlen is None: no_networks = request.args.get('no_networks', type=bool, default=False) networks = Network.get_all(no_networks = no_networks) return jsonify(networks=map(lambda n: n.as_dict(), networks)) network = Network.get(address).first_or_404() return jsonify(network=network.as_dict(compact=False))
def put(self, address, prefixlen): network = Network.get(address, prefixlen).first_or_404() if 'address' in request.form: network.network_address = request.form['address'] if 'prefixlen' in request.form: network.prefixlen = int(request.form['prefixlen']) db.session.commit() return jsonify(message='success')