Example #1
0
    def capture_create(self,
                       query,
                       name="",
                       description="",
                       extra_tcp_metric=False,
                       ip_defrag=False,
                       reassemble_tcp=False,
                       layer_key_mode="L2"):
        data = {
            "GremlinQuery": query,
            "LayerKeyMode": layer_key_mode,
        }

        if name:
            data["Name"] = name
        if description:
            data["Description"] = description
        if extra_tcp_metric:
            data["ExtraTCPMetric"] = True
        if ip_defrag:
            data["IPDefrag"] = True
        if reassemble_tcp:
            data["ReassembleTCP"] = True

        c = self.request("/api/capture", method="POST", data=json.dumps(data))
        return Capture.from_object(c)
Example #2
0
    def capture_create(
        self,
        query,
        name="",
        description="",
        extra_tcp_metric=False,
        ip_defrag=False,
        reassemble_tcp=False,
        layer_key_mode="L2",
        bpf_filter="",
        capture_type="",
        port=0,
        raw_pkt_limit=0,
        header_size=0,
        target="",
        target_type="",
        polling_interval=10,
        sampling_rate=1,
    ):
        data = {
            "GremlinQuery": query,
            "LayerKeyMode": layer_key_mode,
            "PollingInterval": polling_interval,
            "SamplingRate": sampling_rate,
        }

        if name:
            data["Name"] = name
        if description:
            data["Description"] = description
        if extra_tcp_metric:
            data["ExtraTCPMetric"] = True
        if ip_defrag:
            data["IPDefrag"] = True
        if reassemble_tcp:
            data["ReassembleTCP"] = True
        if bpf_filter:
            data["BPFFilter"] = bpf_filter
        if capture_type:
            data["Type"] = capture_type
        if raw_pkt_limit:
            data["RawPacketLimit"] = raw_pkt_limit
        if header_size:
            data["HeaderSize"] = header_size
        if port:
            data["Port"] = port
        if target:
            data["Target"] = target
        if target_type:
            data["TargetType"] = target_type

        c = self.request("/api/capture", method="POST", data=json.dumps(data))
        return Capture.from_object(c)
Example #3
0
 def capture_list(self):
     objs = self.request("/api/capture")
     return [Capture.from_object(o) for o in objs.values()]