Code Duplication    Length = 29-31 lines in 6 locations

gvm/protocols/gmpv208/gmpv208.py 6 locations

@@ 5505-5535 (lines=31) @@
5502
        cmd.set_attribute("role_id", role_id)
5503
        return self._send_xml_command(cmd)
5504
5505
    def get_scanners(
5506
        self,
5507
        *,
5508
        filter: Optional[str] = None,
5509
        filter_id: Optional[str] = None,
5510
        trash: Optional[bool] = None,
5511
        details: Optional[bool] = None,
5512
    ) -> Any:
5513
        """Request a list of scanners
5514
5515
        Arguments:
5516
            filter: Filter term to use for the query
5517
            filter_id: UUID of an existing filter to use for the query
5518
            trash: Whether to get the trashcan scanners instead
5519
            details:  Whether to include extra details like tasks using this
5520
                scanner
5521
5522
        Returns:
5523
            The response. See :py:meth:`send_command` for details.
5524
        """
5525
        cmd = XmlCommand("get_scanners")
5526
5527
        _add_filter(cmd, filter, filter_id)
5528
5529
        if trash is not None:
5530
            cmd.set_attribute("trash", _to_bool(trash))
5531
5532
        if details is not None:
5533
            cmd.set_attribute("details", _to_bool(details))
5534
5535
        return self._send_xml_command(cmd)
5536
5537
    def get_scanner(self, scanner_id: str) -> Any:
5538
        """Request a single scanner
@@ 5752-5781 (lines=30) @@
5749
        cmd.set_attribute("tag_id", tag_id)
5750
        return self._send_xml_command(cmd)
5751
5752
    def get_targets(
5753
        self,
5754
        *,
5755
        filter: Optional[str] = None,
5756
        filter_id: Optional[str] = None,
5757
        trash: Optional[bool] = None,
5758
        tasks: Optional[bool] = None,
5759
    ) -> Any:
5760
        """Request a list of targets
5761
5762
        Arguments:
5763
            filter: Filter term to use for the query
5764
            filter_id: UUID of an existing filter to use for the query
5765
            trash: Whether to get the trashcan targets instead
5766
            tasks: Whether to include list of tasks that use the target
5767
5768
        Returns:
5769
            The response. See :py:meth:`send_command` for details.
5770
        """
5771
        cmd = XmlCommand("get_targets")
5772
5773
        _add_filter(cmd, filter, filter_id)
5774
5775
        if trash is not None:
5776
            cmd.set_attribute("trash", _to_bool(trash))
5777
5778
        if tasks is not None:
5779
            cmd.set_attribute("tasks", _to_bool(tasks))
5780
5781
        return self._send_xml_command(cmd)
5782
5783
    def get_target(
5784
        self, target_id: str, *, tasks: Optional[bool] = None
@@ 5702-5731 (lines=30) @@
5699
5700
        return self._send_xml_command(cmd)
5701
5702
    def get_tags(
5703
        self,
5704
        *,
5705
        filter: Optional[str] = None,
5706
        filter_id: Optional[str] = None,
5707
        trash: Optional[bool] = None,
5708
        names_only: Optional[bool] = None,
5709
    ) -> Any:
5710
        """Request a list of tags
5711
5712
        Arguments:
5713
            filter: Filter term to use for the query
5714
            filter_id: UUID of an existing filter to use for the query
5715
            trash: Whether to get tags from the trashcan instead
5716
            names_only: Whether to get only distinct tag names
5717
5718
        Returns:
5719
            The response. See :py:meth:`send_command` for details.
5720
        """
5721
        cmd = XmlCommand("get_tags")
5722
5723
        _add_filter(cmd, filter, filter_id)
5724
5725
        if trash is not None:
5726
            cmd.set_attribute("trash", _to_bool(trash))
5727
5728
        if names_only is not None:
5729
            cmd.set_attribute("names_only", _to_bool(names_only))
5730
5731
        return self._send_xml_command(cmd)
5732
5733
    def get_tag(self, tag_id: str) -> Any:
5734
        """Request a single tag
@@ 5559-5588 (lines=30) @@
5556
        cmd.set_attribute("details", "1")
5557
        return self._send_xml_command(cmd)
5558
5559
    def get_schedules(
5560
        self,
5561
        *,
5562
        filter: Optional[str] = None,
5563
        filter_id: Optional[str] = None,
5564
        trash: Optional[bool] = None,
5565
        tasks: Optional[bool] = None,
5566
    ) -> Any:
5567
        """Request a list of schedules
5568
5569
        Arguments:
5570
            filter: Filter term to use for the query
5571
            filter_id: UUID of an existing filter to use for the query
5572
            trash: Whether to get the trashcan schedules instead
5573
            tasks: Whether to include tasks using the schedules
5574
5575
        Returns:
5576
            The response. See :py:meth:`send_command` for details.
5577
        """
5578
        cmd = XmlCommand("get_schedules")
5579
5580
        _add_filter(cmd, filter, filter_id)
5581
5582
        if trash is not None:
5583
            cmd.set_attribute("trash", _to_bool(trash))
5584
5585
        if tasks is not None:
5586
            cmd.set_attribute("tasks", _to_bool(tasks))
5587
5588
        return self._send_xml_command(cmd)
5589
5590
    def get_schedule(
5591
        self, schedule_id: str, *, tasks: Optional[bool] = None
@@ 4757-4786 (lines=30) @@
4754
        """
4755
        return self._send_xml_command(XmlCommand("get_feeds"))
4756
4757
    def get_filters(
4758
        self,
4759
        *,
4760
        filter: Optional[str] = None,
4761
        filter_id: Optional[str] = None,
4762
        trash: Optional[bool] = None,
4763
        alerts: Optional[bool] = None,
4764
    ) -> Any:
4765
        """Request a list of filters
4766
4767
        Arguments:
4768
            filter: Filter term to use for the query
4769
            filter_id: UUID of an existing filter to use for the query
4770
            trash: Whether to get the trashcan filters instead
4771
            alerts: Whether to include list of alerts that use the filter.
4772
4773
        Returns:
4774
            The response. See :py:meth:`send_command` for details.
4775
        """
4776
        cmd = XmlCommand("get_filters")
4777
4778
        _add_filter(cmd, filter, filter_id)
4779
4780
        if trash is not None:
4781
            cmd.set_attribute("trash", _to_bool(trash))
4782
4783
        if alerts is not None:
4784
            cmd.set_attribute("alerts", _to_bool(alerts))
4785
4786
        return self._send_xml_command(cmd)
4787
4788
    def get_filter(
4789
        self, filter_id: str, *, alerts: Optional[bool] = None
@@ 4552-4580 (lines=29) @@
4549
        """
4550
        return self._send_xml_command(XmlCommand("empty_trashcan"))
4551
4552
    def get_alerts(
4553
        self,
4554
        *,
4555
        filter: Optional[str] = None,
4556
        filter_id: Optional[str] = None,
4557
        trash: Optional[bool] = None,
4558
        tasks: Optional[bool] = None,
4559
    ) -> Any:
4560
        """Request a list of alerts
4561
4562
        Arguments:
4563
            filter: Filter term to use for the query
4564
            filter_id: UUID of an existing filter to use for the query
4565
            trash: True to request the alerts in the trashcan
4566
            tasks: Whether to include the tasks using the alerts
4567
        Returns:
4568
            The response. See :py:meth:`send_command` for details.
4569
        """
4570
        cmd = XmlCommand("get_alerts")
4571
4572
        _add_filter(cmd, filter, filter_id)
4573
4574
        if trash is not None:
4575
            cmd.set_attribute("trash", _to_bool(trash))
4576
4577
        if tasks is not None:
4578
            cmd.set_attribute("tasks", _to_bool(tasks))
4579
4580
        return self._send_xml_command(cmd)
4581
4582
    def get_alert(self, alert_id: str, *, tasks: Optional[bool] = None) -> Any:
4583
        """Request a single alert