Code Duplication    Length = 44-44 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 3052-3095 (lines=44) @@
3049
3050
        return self._send_xml_command(cmd)
3051
3052
    def create_filter(
3053
        self,
3054
        name: str,
3055
        *,
3056
        filter_type: Optional[FilterType] = None,
3057
        comment: Optional[str] = None,
3058
        term: Optional[str] = None,
3059
    ) -> Any:
3060
        """Create a new filter
3061
3062
        Arguments:
3063
            name: Name of the new filter
3064
            filter_type: Filter for entity type
3065
            comment: Comment for the filter
3066
            term: Filter term e.g. 'name=foo'
3067
3068
        Returns:
3069
            The response. See :py:meth:`send_command` for details.
3070
        """
3071
        if not name:
3072
            raise RequiredArgument(
3073
                function=self.create_filter.__name__, argument="name"
3074
            )
3075
3076
        cmd = XmlCommand("create_filter")
3077
        _xmlname = cmd.add_element("name", name)
3078
3079
        if comment:
3080
            cmd.add_element("comment", comment)
3081
3082
        if term:
3083
            cmd.add_element("term", term)
3084
3085
        if filter_type:
3086
            if not isinstance(filter_type, self.types.FilterType):
3087
                raise InvalidArgumentType(
3088
                    function=self.create_filter.__name__,
3089
                    argument="filter_type",
3090
                    arg_type=self.types.FilterType.__name__,
3091
                )
3092
3093
            cmd.add_element("type", filter_type.value)
3094
3095
        return self._send_xml_command(cmd)
3096
3097
    def modify_filter(
3098
        self,

gvm/protocols/gmpv8/gmpv8.py 1 location

@@ 883-926 (lines=44) @@
880
881
        return self._send_xml_command(cmd)
882
883
    def create_filter(
884
        self,
885
        name: str,
886
        *,
887
        filter_type: Optional[FilterType] = None,
888
        comment: Optional[str] = None,
889
        term: Optional[str] = None,
890
    ) -> Any:
891
        """Create a new filter
892
893
        Arguments:
894
            name: Name of the new filter
895
            filter_type: Filter for entity type
896
            comment: Comment for the filter
897
            term: Filter term e.g. 'name=foo'
898
899
        Returns:
900
            The response. See :py:meth:`send_command` for details.
901
        """
902
        if not name:
903
            raise RequiredArgument(
904
                function=self.create_filter.__name__, argument="name"
905
            )
906
907
        cmd = XmlCommand("create_filter")
908
        _xmlname = cmd.add_element("name", name)
909
910
        if comment:
911
            cmd.add_element("comment", comment)
912
913
        if term:
914
            cmd.add_element("term", term)
915
916
        if filter_type:
917
            if not isinstance(filter_type, self.types.FilterType):
918
                raise InvalidArgumentType(
919
                    function=self.create_filter.__name__,
920
                    argument="filter_type",
921
                    arg_type=self.types.FilterType.__name__,
922
                )
923
924
            cmd.add_element("type", filter_type.value)
925
926
        return self._send_xml_command(cmd)
927
928
    def modify_filter(
929
        self,