def user_unsubscribe(): statsd_client.incr('www.user.unsubscribe') user = current_user.user ioc.manager().user_set_subscribed(request.form, user.email) return 'Successfully set', 200
def domain_delete(): statsd_client.incr('www.domain.delete') user = current_user.user ioc.manager().user_domain_delete(request.form, user) return 'Domain deleted', 200
def login(): statsd_client.incr('www.user.login') user = ioc.manager().authenticate(request.form) user_flask = UserFlask(user) login_user(user_flask, remember=False) return 'User logged in', 200
def domain_update(): statsd_client.incr('rest.domain.update') request_data = json.loads(request.data) domain = ioc.manager().domain_update(request_data, request.remote_addr) domain_data = convertible.to_dict(domain) return jsonify(success=True, message='Domain was updated', data=domain_data), 200
def user_delete(): statsd_client.incr('rest.user.update') ioc.manager().delete_user(request.form) return jsonify(success=True, message='User deleted'), 200
def user_log(): statsd_client.incr('rest.user.log') ioc.manager().user_log(request.form) return jsonify(success=True, message='Error report sent successfully'), 200
def drop_device(): statsd_client.incr('rest.device.drop') domain = ioc.manager().drop_device(request.form) domain_data = convertible.to_dict(domain) return jsonify(success=True, message='Device was dropped', data=domain_data), 200
def user_get(): statsd_client.incr('rest.user.get') user = ioc.manager().authenticate(request.args) user_data = convertible.to_dict(user) return jsonify(success=True, message='User provided', data=user_data), 200
def domain_acquire(): statsd_client.incr('rest.domain.acquire') domain = ioc.manager().domain_acquire(request.form) return jsonify(success=True, user_domain=domain.user_domain, update_token=domain.update_token), 200
def user_create(): statsd_client.incr('rest.user.create') user = ioc.manager().create_new_user(request.form) user_data = convertible.to_dict(user) return jsonify(success=True, message='User was created', data=user_data), 200
def user_activate(): statsd_client.incr('rest.user.activate') ioc.manager().activate(request.args) return jsonify(success=True, message='User was activated'), 200
def probe_port_v2(): statsd_client.incr('rest.probe.port_v2') result, status_code = ioc.manager().port_probe(request.args, request.remote_addr) return json.dumps(result), status_code
def probe_port_v1(): statsd_client.incr('rest.probe.port_v1') result, status_code = ioc.manager().port_probe(request.args, request.remote_addr) return result['message'], status_code
def user_set_password(): statsd_client.incr('rest.user.set_password') ioc.manager().user_set_password(request.form) return jsonify(success=True, message='Password was set successfully'), 200
def load_user(email): user = ioc.manager().get_user(email) if not user: return None return UserFlask(user)
def domain_get(): statsd_client.incr('rest.domain.get') domain = ioc.manager().get_domain(request.args) domain_data = convertible.to_dict(domain) return jsonify(success=True, message='Domain retrieved', data=domain_data), 200
def user_delete(): statsd_client.incr('www.user.delete') user = current_user.user ioc.manager().do_delete_user(user.email) return 'User deleted', 200
def domain_delete(): statsd_client.incr('rest.domain.delete') request_data = json.loads(request.data) ioc.manager().domain_delete(request_data) return jsonify(success=True, message='Domain was deleted'), 200
def user_reset_password(): statsd_client.incr('rest.user.reset_password') ioc.manager().user_reset_password(request.form) return jsonify(success=True, message='Reset password requested'), 200