Code Duplication    Length = 35-42 lines in 3 locations

gvm/protocols/gmpv7.py 3 locations

@@ 3141-3182 (lines=42) @@
3138
        """
3139
        return self._send_xml_command(XmlCommand("empty_trashcan"))
3140
3141
    def get_agents(
3142
        self,
3143
        *,
3144
        filter: Optional[str] = None,
3145
        filter_id: Optional[str] = None,
3146
        trash: Optional[bool] = None,
3147
        details: Optional[bool] = None,
3148
        format: Optional[str] = None
3149
    ) -> Any:
3150
        """Request a list of agents
3151
3152
        Arguments:
3153
            filter: Filter term to use for the query
3154
            filter_id: UUID of an existing filter to use for the query
3155
            trash: True to request the agents in the trashcan
3156
            details: Whether to include agents packageinformation when no format
3157
                was provided
3158
            format: One of "installer", "howto_install" or "howto_use"
3159
3160
        Returns:
3161
            The response. See :py:meth:`send_command` for details.
3162
        """
3163
        cmd = XmlCommand("get_agents")
3164
3165
        _add_filter(cmd, filter, filter_id)
3166
3167
        if not trash is None:
3168
            cmd.set_attribute("trash", _to_bool(trash))
3169
3170
        if not details is None:
3171
            cmd.set_attribute("details", _to_bool(details))
3172
3173
        if format:
3174
            if not format in ("installer", "howto_install", "howto_use"):
3175
                raise InvalidArgument(
3176
                    "installer argument needs to be one of installer, "
3177
                    "howto_install or howto_use"
3178
                )
3179
3180
            cmd.set_attribute("format", format)
3181
3182
        return self._send_xml_command(cmd)
3183
3184
    def get_agent(self, agent_id: str) -> Any:
3185
        """Request a single agent
@@ 4527-4562 (lines=36) @@
4524
        cmd.set_attribute("target_id", target_id)
4525
        return self._send_xml_command(cmd)
4526
4527
    def get_tasks(
4528
        self,
4529
        *,
4530
        filter: Optional[str] = None,
4531
        filter_id: Optional[str] = None,
4532
        trash: Optional[bool] = None,
4533
        details: Optional[bool] = None,
4534
        schedules_only: Optional[bool] = None
4535
    ) -> Any:
4536
        """Request a list of tasks
4537
4538
        Arguments:
4539
            filter: Filter term to use for the query
4540
            filter_id: UUID of an existing filter to use for the query
4541
            trash: Whether to get the trashcan tasks instead
4542
            details: Whether to include full task details
4543
            schedules_only: Whether to only include id, name and schedule
4544
                details
4545
4546
        Returns:
4547
            The response. See :py:meth:`send_command` for details.
4548
        """
4549
        cmd = XmlCommand("get_tasks")
4550
4551
        _add_filter(cmd, filter, filter_id)
4552
4553
        if not trash is None:
4554
            cmd.set_attribute("trash", _to_bool(trash))
4555
4556
        if not details is None:
4557
            cmd.set_attribute("details", _to_bool(details))
4558
4559
        if not schedules_only is None:
4560
            cmd.set_attribute("schedules_only", _to_bool(schedules_only))
4561
4562
        return self._send_xml_command(cmd)
4563
4564
    def get_task(self, task_id: str) -> Any:
4565
        """Request a single task
@@ 3902-3936 (lines=35) @@
3899
        cmd.set_attribute("permission_id", permission_id)
3900
        return self._send_xml_command(cmd)
3901
3902
    def get_port_lists(
3903
        self,
3904
        *,
3905
        filter: Optional[str] = None,
3906
        filter_id: Optional[str] = None,
3907
        details: Optional[bool] = None,
3908
        targets: Optional[bool] = None,
3909
        trash: Optional[bool] = None
3910
    ) -> Any:
3911
        """Request a list of port lists
3912
3913
        Arguments:
3914
            filter: Filter term to use for the query
3915
            filter_id: UUID of an existing filter to use for the query
3916
            details: Whether to include full port list details
3917
            targets: Whether to include targets using this port list
3918
            trash: Whether to get port lists in the trashcan instead
3919
3920
        Returns:
3921
            The response. See :py:meth:`send_command` for details.
3922
        """
3923
        cmd = XmlCommand("get_port_lists")
3924
3925
        _add_filter(cmd, filter, filter_id)
3926
3927
        if not details is None:
3928
            cmd.set_attribute("details", _to_bool(details))
3929
3930
        if not targets is None:
3931
            cmd.set_attribute("targets", _to_bool(targets))
3932
3933
        if not trash is None:
3934
            cmd.set_attribute("trash", _to_bool(trash))
3935
3936
        return self._send_xml_command(cmd)
3937
3938
    def get_port_list(self, port_list_id: str):
3939
        """Request a single port list