Code Duplication    Length = 44-48 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 2 locations

@@ 954-1001 (lines=48) @@
951
952
        return self._send_xml_command(cmd)
953
954
    def modify_filter(
955
        self,
956
        filter_id: str,
957
        *,
958
        comment: Optional[str] = None,
959
        name: Optional[str] = None,
960
        term: Optional[str] = None,
961
        filter_type: Optional[FilterType] = None,
962
    ) -> Any:
963
        """Modifies an existing filter.
964
965
        Arguments:
966
            filter_id: UUID of the filter to be modified
967
            comment: Comment on filter.
968
            name: Name of filter.
969
            term: Filter term.
970
            filter_type: Resource type filter applies to.
971
972
        Returns:
973
            The response. See :py:meth:`send_command` for details.
974
        """
975
        if not filter_id:
976
            raise RequiredArgument(
977
                function=self.modify_filter.__name__, argument='filter_id'
978
            )
979
980
        cmd = XmlCommand("modify_filter")
981
        cmd.set_attribute("filter_id", filter_id)
982
983
        if comment:
984
            cmd.add_element("comment", comment)
985
986
        if name:
987
            cmd.add_element("name", name)
988
989
        if term:
990
            cmd.add_element("term", term)
991
992
        if filter_type:
993
            if not isinstance(filter_type, self.types.FilterType):
994
                raise InvalidArgumentType(
995
                    function=self.modify_filter.__name__,
996
                    argument='filter_type',
997
                    arg_type=FilterType.__name__,
998
                )
999
            cmd.add_element("type", filter_type.value)
1000
1001
        return self._send_xml_command(cmd)
1002
1003
    def create_schedule(
1004
        self,
@@ 909-952 (lines=44) @@
906
907
        return self._send_xml_command(cmd)
908
909
    def create_filter(
910
        self,
911
        name: str,
912
        *,
913
        filter_type: Optional[FilterType] = None,
914
        comment: Optional[str] = None,
915
        term: Optional[str] = None,
916
    ) -> Any:
917
        """Create a new filter
918
919
        Arguments:
920
            name: Name of the new filter
921
            filter_type: Filter for entity type
922
            comment: Comment for the filter
923
            term: Filter term e.g. 'name=foo'
924
925
        Returns:
926
            The response. See :py:meth:`send_command` for details.
927
        """
928
        if not name:
929
            raise RequiredArgument(
930
                function=self.create_filter.__name__, argument="name"
931
            )
932
933
        cmd = XmlCommand("create_filter")
934
        _xmlname = cmd.add_element("name", name)
935
936
        if comment:
937
            cmd.add_element("comment", comment)
938
939
        if term:
940
            cmd.add_element("term", term)
941
942
        if filter_type:
943
            if not isinstance(filter_type, self.types.FilterType):
944
                raise InvalidArgumentType(
945
                    function=self.create_filter.__name__,
946
                    argument="filter_type",
947
                    arg_type=self.types.FilterType.__name__,
948
                )
949
950
            cmd.add_element("type", filter_type.value)
951
952
        return self._send_xml_command(cmd)
953
954
    def modify_filter(
955
        self,