예제 #1
0
def cluster_egonet(currency, cluster):
    direction = request.args.get("direction")
    if not cluster:
        abort(404, "Cluster not provided")
    try:
        cluster = int(cluster)
        cluster = str(cluster)
    except Exception:
        abort(404, "Invalid cluster ID")
    if not direction:
        direction = ""
    limit = request.args.get("limit")
    if not limit:
        limit = 50
    else:
        try:
            limit = int(limit)
        except Exception:
            abort(404, "Invalid limit value")
    try:
        egoNet = gm.ClusterEgoNet(
            gd.query_cluster(currency, cluster),
            gd.query_cluster_tags(currency, cluster),
            gd.query_cluster_incoming_relations(currency, cluster, int(limit)),
            gd.query_cluster_outgoing_relations(currency, cluster, int(limit)))
        ret = egoNet.construct(cluster, direction)
    except Exception:
        ret = {}
    return jsonify(ret)
예제 #2
0
def address_cluster_with_tags(currency, address):
    if not address:
        abort(404, "Address not provided")

    address_cluster = gd.query_address_cluster(currency, address)
    if "cluster" in address_cluster:
        address_cluster["tags"] = gd.query_cluster_tags(
            currency, address_cluster["cluster"])
    return jsonify(address_cluster)
예제 #3
0
def cluster_tags(currency, cluster):
    if not cluster:
        abort(404, "Cluster not provided")
    try:
        cluster = int(cluster)
    except Exception:
        abort(404, "Invalid cluster ID")
    tags = gd.query_cluster_tags(currency, cluster)
    return jsonify(tags)
예제 #4
0
 def get(self, currency, cluster):
     """
     Returns a JSON with the tags of the cluster
     """
     if not cluster:
         abort(404, "Cluster id not provided")
     cluster_obj = gd.query_cluster(currency, cluster)
     if not cluster_obj:
         abort(404, "Cluster not found")
     cluster_obj.tags = gd.query_cluster_tags(currency, cluster)
     return cluster_obj
예제 #5
0
    def get(self, currency, address):
        """
        Returns a JSON with edges and nodes of the address
        """
        if not address:
            abort(404, "Address not provided")

        address_cluster = gd.query_address_cluster(currency, address)
        if "cluster" in address_cluster:
            address_cluster["tags"] = gd.query_cluster_tags(
                currency, address_cluster["cluster"])
        return address_cluster
예제 #6
0
 def get(self, currency, cluster):
     """
     Returns a JSON with the tags of the cluster
     """
     if not cluster:
         abort(404, "Cluster not provided")
     try:
         cluster = int(cluster)
     except Exception:
         abort(404, "Invalid cluster ID")
     tags = gd.query_cluster_tags(currency, cluster)
     return tags
예제 #7
0
    def get(self, currency, cluster):
        """
        Returns a JSON with the tags of the cluster
        """
        if not cluster:
            abort(404, "Cluster not provided")
        try:
            cluster = int(cluster)
        except Exception:
            abort(404, "Invalid cluster ID")

        tags = gd.query_cluster_tags(currency, cluster)

        return Response(tagsToCSV(tags), mimetype="text/csv")
예제 #8
0
def cluster_with_tags(currency, cluster):
    if not cluster:
        abort(404, "Cluster id not provided")
    cluster_obj = gd.query_cluster(currency, cluster)
    cluster_obj.tags = gd.query_cluster_tags(currency, cluster)
    return jsonify(cluster_obj.__dict__) if cluster_obj else jsonify({})