Code Duplication    Length = 44-48 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 2 locations

@@ 2909-2956 (lines=48) @@
2906
2907
        return self._send_xml_command(cmd)
2908
2909
    def modify_filter(
2910
        self,
2911
        filter_id: str,
2912
        *,
2913
        comment: Optional[str] = None,
2914
        name: Optional[str] = None,
2915
        term: Optional[str] = None,
2916
        filter_type: Optional[FilterType] = None,
2917
    ) -> Any:
2918
        """Modifies an existing filter.
2919
2920
        Arguments:
2921
            filter_id: UUID of the filter to be modified
2922
            comment: Comment on filter.
2923
            name: Name of filter.
2924
            term: Filter term.
2925
            filter_type: Resource type filter applies to.
2926
2927
        Returns:
2928
            The response. See :py:meth:`send_command` for details.
2929
        """
2930
        if not filter_id:
2931
            raise RequiredArgument(
2932
                function=self.modify_filter.__name__, argument='filter_id'
2933
            )
2934
2935
        cmd = XmlCommand("modify_filter")
2936
        cmd.set_attribute("filter_id", filter_id)
2937
2938
        if comment:
2939
            cmd.add_element("comment", comment)
2940
2941
        if name:
2942
            cmd.add_element("name", name)
2943
2944
        if term:
2945
            cmd.add_element("term", term)
2946
2947
        if filter_type:
2948
            if not isinstance(filter_type, self.types.FilterType):
2949
                raise InvalidArgumentType(
2950
                    function=self.modify_filter.__name__,
2951
                    argument='filter_type',
2952
                    arg_type=FilterType.__name__,
2953
                )
2954
            cmd.add_element("type", filter_type.value)
2955
2956
        return self._send_xml_command(cmd)
2957
2958
    def create_schedule(
2959
        self,
@@ 2864-2907 (lines=44) @@
2861
2862
        return self._send_xml_command(cmd)
2863
2864
    def create_filter(
2865
        self,
2866
        name: str,
2867
        *,
2868
        filter_type: Optional[FilterType] = None,
2869
        comment: Optional[str] = None,
2870
        term: Optional[str] = None,
2871
    ) -> Any:
2872
        """Create a new filter
2873
2874
        Arguments:
2875
            name: Name of the new filter
2876
            filter_type: Filter for entity type
2877
            comment: Comment for the filter
2878
            term: Filter term e.g. 'name=foo'
2879
2880
        Returns:
2881
            The response. See :py:meth:`send_command` for details.
2882
        """
2883
        if not name:
2884
            raise RequiredArgument(
2885
                function=self.create_filter.__name__, argument="name"
2886
            )
2887
2888
        cmd = XmlCommand("create_filter")
2889
        _xmlname = cmd.add_element("name", name)
2890
2891
        if comment:
2892
            cmd.add_element("comment", comment)
2893
2894
        if term:
2895
            cmd.add_element("term", term)
2896
2897
        if filter_type:
2898
            if not isinstance(filter_type, self.types.FilterType):
2899
                raise InvalidArgumentType(
2900
                    function=self.create_filter.__name__,
2901
                    argument="filter_type",
2902
                    arg_type=self.types.FilterType.__name__,
2903
                )
2904
2905
            cmd.add_element("type", filter_type.value)
2906
2907
        return self._send_xml_command(cmd)
2908
2909
    def modify_filter(
2910
        self,