Code Duplication    Length = 44-48 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 2 locations

@@ 782-829 (lines=48) @@
779
780
        return self._send_xml_command(cmd)
781
782
    def modify_filter(
783
        self,
784
        filter_id: str,
785
        *,
786
        comment: Optional[str] = None,
787
        name: Optional[str] = None,
788
        term: Optional[str] = None,
789
        filter_type: Optional[FilterType] = None,
790
    ) -> Any:
791
        """Modifies an existing filter.
792
793
        Arguments:
794
            filter_id: UUID of the filter to be modified
795
            comment: Comment on filter.
796
            name: Name of filter.
797
            term: Filter term.
798
            filter_type: Resource type filter applies to.
799
800
        Returns:
801
            The response. See :py:meth:`send_command` for details.
802
        """
803
        if not filter_id:
804
            raise RequiredArgument(
805
                function=self.modify_filter.__name__, argument='filter_id'
806
            )
807
808
        cmd = XmlCommand("modify_filter")
809
        cmd.set_attribute("filter_id", filter_id)
810
811
        if comment:
812
            cmd.add_element("comment", comment)
813
814
        if name:
815
            cmd.add_element("name", name)
816
817
        if term:
818
            cmd.add_element("term", term)
819
820
        if filter_type:
821
            if not isinstance(filter_type, self.types.FilterType):
822
                raise InvalidArgumentType(
823
                    function=self.modify_filter.__name__,
824
                    argument='filter_type',
825
                    arg_type=FilterType.__name__,
826
                )
827
            cmd.add_element("type", filter_type.value)
828
829
        return self._send_xml_command(cmd)
830
831
    def create_schedule(
832
        self,
@@ 737-780 (lines=44) @@
734
735
        return self._send_xml_command(cmd)
736
737
    def create_filter(
738
        self,
739
        name: str,
740
        *,
741
        filter_type: Optional[FilterType] = None,
742
        comment: Optional[str] = None,
743
        term: Optional[str] = None,
744
    ) -> Any:
745
        """Create a new filter
746
747
        Arguments:
748
            name: Name of the new filter
749
            filter_type: Filter for entity type
750
            comment: Comment for the filter
751
            term: Filter term e.g. 'name=foo'
752
753
        Returns:
754
            The response. See :py:meth:`send_command` for details.
755
        """
756
        if not name:
757
            raise RequiredArgument(
758
                function=self.create_filter.__name__, argument="name"
759
            )
760
761
        cmd = XmlCommand("create_filter")
762
        _xmlname = cmd.add_element("name", name)
763
764
        if comment:
765
            cmd.add_element("comment", comment)
766
767
        if term:
768
            cmd.add_element("term", term)
769
770
        if filter_type:
771
            if not isinstance(filter_type, self.types.FilterType):
772
                raise InvalidArgumentType(
773
                    function=self.create_filter.__name__,
774
                    argument="filter_type",
775
                    arg_type=self.types.FilterType.__name__,
776
                )
777
778
            cmd.add_element("type", filter_type.value)
779
780
        return self._send_xml_command(cmd)
781
782
    def modify_filter(
783
        self,