Code Duplication    Length = 35-42 lines in 3 locations

gvm/protocols/gmpv7/__init__.py 3 locations

@@ 2645-2686 (lines=42) @@
2642
        """
2643
        return self._send_xml_command(XmlCommand("empty_trashcan"))
2644
2645
    def get_agents(
2646
        self,
2647
        *,
2648
        filter: Optional[str] = None,
2649
        filter_id: Optional[str] = None,
2650
        trash: Optional[bool] = None,
2651
        details: Optional[bool] = None,
2652
        format: Optional[str] = None
2653
    ) -> Any:
2654
        """Request a list of agents
2655
2656
        Arguments:
2657
            filter: Filter term to use for the query
2658
            filter_id: UUID of an existing filter to use for the query
2659
            trash: True to request the agents in the trashcan
2660
            details: Whether to include agents packageinformation when no format
2661
                was provided
2662
            format: One of "installer", "howto_install" or "howto_use"
2663
2664
        Returns:
2665
            The response. See :py:meth:`send_command` for details.
2666
        """
2667
        cmd = XmlCommand("get_agents")
2668
2669
        _add_filter(cmd, filter, filter_id)
2670
2671
        if not trash is None:
2672
            cmd.set_attribute("trash", _to_bool(trash))
2673
2674
        if not details is None:
2675
            cmd.set_attribute("details", _to_bool(details))
2676
2677
        if format:
2678
            if not format in ("installer", "howto_install", "howto_use"):
2679
                raise InvalidArgument(
2680
                    "installer argument needs to be one of installer, "
2681
                    "howto_install or howto_use"
2682
                )
2683
2684
            cmd.set_attribute("format", format)
2685
2686
        return self._send_xml_command(cmd)
2687
2688
    def get_agent(self, agent_id: str) -> Any:
2689
        """Request a single agent
@@ 4101-4136 (lines=36) @@
4098
        cmd.set_attribute("target_id", target_id)
4099
        return self._send_xml_command(cmd)
4100
4101
    def get_tasks(
4102
        self,
4103
        *,
4104
        filter: Optional[str] = None,
4105
        filter_id: Optional[str] = None,
4106
        trash: Optional[bool] = None,
4107
        details: Optional[bool] = None,
4108
        schedules_only: Optional[bool] = None
4109
    ) -> Any:
4110
        """Request a list of tasks
4111
4112
        Arguments:
4113
            filter: Filter term to use for the query
4114
            filter_id: UUID of an existing filter to use for the query
4115
            trash: Whether to get the trashcan tasks instead
4116
            details: Whether to include full task details
4117
            schedules_only: Whether to only include id, name and schedule
4118
                details
4119
4120
        Returns:
4121
            The response. See :py:meth:`send_command` for details.
4122
        """
4123
        cmd = XmlCommand("get_tasks")
4124
4125
        _add_filter(cmd, filter, filter_id)
4126
4127
        if not trash is None:
4128
            cmd.set_attribute("trash", _to_bool(trash))
4129
4130
        if not details is None:
4131
            cmd.set_attribute("details", _to_bool(details))
4132
4133
        if not schedules_only is None:
4134
            cmd.set_attribute("schedules_only", _to_bool(schedules_only))
4135
4136
        return self._send_xml_command(cmd)
4137
4138
    def get_task(self, task_id: str) -> Any:
4139
        """Request a single task
@@ 3448-3482 (lines=35) @@
3445
        cmd.set_attribute("permission_id", permission_id)
3446
        return self._send_xml_command(cmd)
3447
3448
    def get_port_lists(
3449
        self,
3450
        *,
3451
        filter: Optional[str] = None,
3452
        filter_id: Optional[str] = None,
3453
        details: Optional[bool] = None,
3454
        targets: Optional[bool] = None,
3455
        trash: Optional[bool] = None
3456
    ) -> Any:
3457
        """Request a list of port lists
3458
3459
        Arguments:
3460
            filter: Filter term to use for the query
3461
            filter_id: UUID of an existing filter to use for the query
3462
            details: Whether to include full port list details
3463
            targets: Whether to include targets using this port list
3464
            trash: Whether to get port lists in the trashcan instead
3465
3466
        Returns:
3467
            The response. See :py:meth:`send_command` for details.
3468
        """
3469
        cmd = XmlCommand("get_port_lists")
3470
3471
        _add_filter(cmd, filter, filter_id)
3472
3473
        if not details is None:
3474
            cmd.set_attribute("details", _to_bool(details))
3475
3476
        if not targets is None:
3477
            cmd.set_attribute("targets", _to_bool(targets))
3478
3479
        if not trash is None:
3480
            cmd.set_attribute("trash", _to_bool(trash))
3481
3482
        return self._send_xml_command(cmd)
3483
3484
    def get_port_list(self, port_list_id: str):
3485
        """Request a single port list