Code Duplication    Length = 33-48 lines in 2 locations

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

gvm/protocols/gmpv9/gmpv9.py 1 location

@@ 1054-1086 (lines=33) @@
1051
        cmd.add_element("usage_type", usage_type.value)
1052
        return self._send_xml_command(cmd)
1053
1054
    def __get_configs(
1055
        self,
1056
        usage_type: UsageType,
1057
        *,
1058
        filter: Optional[str] = None,
1059
        filter_id: Optional[str] = None,
1060
        trash: Optional[bool] = None,
1061
        details: Optional[bool] = None,
1062
        families: Optional[bool] = None,
1063
        preferences: Optional[bool] = None,
1064
        tasks: Optional[bool] = None
1065
    ) -> Any:
1066
        cmd = XmlCommand("get_configs")
1067
        cmd.set_attribute("usage_type", usage_type.value)
1068
1069
        _add_filter(cmd, filter, filter_id)
1070
1071
        if trash is not None:
1072
            cmd.set_attribute("trash", _to_bool(trash))
1073
1074
        if details is not None:
1075
            cmd.set_attribute("details", _to_bool(details))
1076
1077
        if families is not None:
1078
            cmd.set_attribute("families", _to_bool(families))
1079
1080
        if preferences is not None:
1081
            cmd.set_attribute("preferences", _to_bool(preferences))
1082
1083
        if tasks is not None:
1084
            cmd.set_attribute("tasks", _to_bool(tasks))
1085
1086
        return self._send_xml_command(cmd)
1087
1088
    def __get_config(self, config_id: str, usage_type: UsageType) -> Any:
1089
        if not config_id: