#!/usr/bin/env python3

# Displays ...

# Runs GetElements to perform a query, and then uses Limit to restrict the
# data set to 15.

import requests
import json
import sys
from gaffer import Gaffer

query = {
  "class": "uk.gov.gchq.gaffer.operation.OperationChain",
  "operations": [
    {
      "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements",
            "view": {
                "edges": {
                    "useragent": {}
                }
            }
     
    }
  ]
}

g = Gaffer("https://analytics.trustnetworks.com/gaffer-threat")
# g = Gaffer("http://localhost:8080")
g.use_cert()

url = "/rest/v2/graph/operations/execute"
  
res = g.post(url, data=json.dumps(query))

obj = res.json()

ua=set()

for o in obj:
    ua.add(o["destination"])

for v in ua:
    print(v)

