Code Duplication    Length = 33-48 lines in 2 locations

gvm/protocols/gmpv9/gmpv9.py 1 location

@@ 755-787 (lines=33) @@
752
        cmd.add_element("usage_type", usage_type.value)
753
        return self._send_xml_command(cmd)
754
755
    def __get_configs(
756
        self,
757
        usage_type: UsageType,
758
        *,
759
        filter: Optional[str] = None,
760
        filter_id: Optional[str] = None,
761
        trash: Optional[bool] = None,
762
        details: Optional[bool] = None,
763
        families: Optional[bool] = None,
764
        preferences: Optional[bool] = None,
765
        tasks: Optional[bool] = None
766
    ) -> Any:
767
        cmd = XmlCommand("get_configs")
768
        cmd.set_attribute("usage_type", usage_type.value)
769
770
        _add_filter(cmd, filter, filter_id)
771
772
        if trash is not None:
773
            cmd.set_attribute("trash", _to_bool(trash))
774
775
        if details is not None:
776
            cmd.set_attribute("details", _to_bool(details))
777
778
        if families is not None:
779
            cmd.set_attribute("families", _to_bool(families))
780
781
        if preferences is not None:
782
            cmd.set_attribute("preferences", _to_bool(preferences))
783
784
        if tasks is not None:
785
            cmd.set_attribute("tasks", _to_bool(tasks))
786
787
        return self._send_xml_command(cmd)
788
789
    def __get_config(self, config_id: str, usage_type: UsageType) -> Any:
790
        if not config_id:

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 2929-2976 (lines=48) @@
2926
            cmd.set_attribute("format", credential_format.value)
2927
        return self._send_xml_command(cmd)
2928
2929
    def get_configs(
2930
        self,
2931
        *,
2932
        filter: Optional[str] = None,
2933
        filter_id: Optional[str] = None,
2934
        trash: Optional[bool] = None,
2935
        details: Optional[bool] = None,
2936
        families: Optional[bool] = None,
2937
        preferences: Optional[bool] = None,
2938
        tasks: Optional[bool] = None
2939
    ) -> Any:
2940
        """Request a list of scan configs
2941
2942
        Arguments:
2943
            filter: Filter term to use for the query
2944
            filter_id: UUID of an existing filter to use for the query
2945
            trash: Whether to get the trashcan scan configs instead
2946
            details: Whether to get config families, preferences, nvt selectors
2947
                and tasks.
2948
            families: Whether to include the families if no details are
2949
                requested
2950
            preferences: Whether to include the preferences if no details are
2951
                requested
2952
            tasks: Whether to get tasks using this config
2953
2954
        Returns:
2955
            The response. See :py:meth:`send_command` for details.
2956
        """
2957
        cmd = XmlCommand("get_configs")
2958
2959
        _add_filter(cmd, filter, filter_id)
2960
2961
        if trash is not None:
2962
            cmd.set_attribute("trash", _to_bool(trash))
2963
2964
        if details is not None:
2965
            cmd.set_attribute("details", _to_bool(details))
2966
2967
        if families is not None:
2968
            cmd.set_attribute("families", _to_bool(families))
2969
2970
        if preferences is not None:
2971
            cmd.set_attribute("preferences", _to_bool(preferences))
2972
2973
        if tasks is not None:
2974
            cmd.set_attribute("tasks", _to_bool(tasks))
2975
2976
        return self._send_xml_command(cmd)
2977
2978
    def get_config(self, config_id: str) -> Any:
2979
        """Request a single scan config