Code Duplication    Length = 44-48 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 2 locations

@@ 3049-3096 (lines=48) @@
3046
3047
        return self._send_xml_command(cmd)
3048
3049
    def modify_filter(
3050
        self,
3051
        filter_id: str,
3052
        *,
3053
        comment: Optional[str] = None,
3054
        name: Optional[str] = None,
3055
        term: Optional[str] = None,
3056
        filter_type: Optional[FilterType] = None,
3057
    ) -> Any:
3058
        """Modifies an existing filter.
3059
3060
        Arguments:
3061
            filter_id: UUID of the filter to be modified
3062
            comment: Comment on filter.
3063
            name: Name of filter.
3064
            term: Filter term.
3065
            filter_type: Resource type filter applies to.
3066
3067
        Returns:
3068
            The response. See :py:meth:`send_command` for details.
3069
        """
3070
        if not filter_id:
3071
            raise RequiredArgument(
3072
                function=self.modify_filter.__name__, argument='filter_id'
3073
            )
3074
3075
        cmd = XmlCommand("modify_filter")
3076
        cmd.set_attribute("filter_id", filter_id)
3077
3078
        if comment:
3079
            cmd.add_element("comment", comment)
3080
3081
        if name:
3082
            cmd.add_element("name", name)
3083
3084
        if term:
3085
            cmd.add_element("term", term)
3086
3087
        if filter_type:
3088
            if not isinstance(filter_type, self.types.FilterType):
3089
                raise InvalidArgumentType(
3090
                    function=self.modify_filter.__name__,
3091
                    argument='filter_type',
3092
                    arg_type=FilterType.__name__,
3093
                )
3094
            cmd.add_element("type", filter_type.value)
3095
3096
        return self._send_xml_command(cmd)
3097
3098
    def create_schedule(
3099
        self,
@@ 3004-3047 (lines=44) @@
3001
3002
        return self._send_xml_command(cmd)
3003
3004
    def create_filter(
3005
        self,
3006
        name: str,
3007
        *,
3008
        filter_type: Optional[FilterType] = None,
3009
        comment: Optional[str] = None,
3010
        term: Optional[str] = None,
3011
    ) -> Any:
3012
        """Create a new filter
3013
3014
        Arguments:
3015
            name: Name of the new filter
3016
            filter_type: Filter for entity type
3017
            comment: Comment for the filter
3018
            term: Filter term e.g. 'name=foo'
3019
3020
        Returns:
3021
            The response. See :py:meth:`send_command` for details.
3022
        """
3023
        if not name:
3024
            raise RequiredArgument(
3025
                function=self.create_filter.__name__, argument="name"
3026
            )
3027
3028
        cmd = XmlCommand("create_filter")
3029
        _xmlname = cmd.add_element("name", name)
3030
3031
        if comment:
3032
            cmd.add_element("comment", comment)
3033
3034
        if term:
3035
            cmd.add_element("term", term)
3036
3037
        if filter_type:
3038
            if not isinstance(filter_type, self.types.FilterType):
3039
                raise InvalidArgumentType(
3040
                    function=self.create_filter.__name__,
3041
                    argument="filter_type",
3042
                    arg_type=self.types.FilterType.__name__,
3043
                )
3044
3045
            cmd.add_element("type", filter_type.value)
3046
3047
        return self._send_xml_command(cmd)
3048
3049
    def modify_filter(
3050
        self,