Code Duplication    Length = 50-50 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 2840-2889 (lines=50) @@
2837
2838
        return self._send_xml_command(cmd)
2839
2840
    def create_ticket(
2841
        self,
2842
        *,
2843
        result_id: str,
2844
        assigned_to_user_id: str,
2845
        note: str,
2846
        comment: Optional[str] = None,
2847
    ) -> Any:
2848
        """Create a new ticket
2849
2850
        Arguments:
2851
            result_id: UUID of the result the ticket applies to
2852
            assigned_to_user_id: UUID of a user the ticket should be assigned to
2853
            note: A note about opening the ticket
2854
            comment: Comment for the ticket
2855
2856
        Returns:
2857
            The response. See :py:meth:`send_command` for details.
2858
        """
2859
        if not result_id:
2860
            raise RequiredArgument(
2861
                function=self.create_ticket.__name__, argument='result_id'
2862
            )
2863
2864
        if not assigned_to_user_id:
2865
            raise RequiredArgument(
2866
                function=self.create_ticket.__name__,
2867
                argument='assigned_to_user_id',
2868
            )
2869
2870
        if not note:
2871
            raise RequiredArgument(
2872
                function=self.create_ticket.__name__, argument='note'
2873
            )
2874
2875
        cmd = XmlCommand("create_ticket")
2876
2877
        _result = cmd.add_element("result")
2878
        _result.set_attribute("id", result_id)
2879
2880
        _assigned = cmd.add_element("assigned_to")
2881
        _user = _assigned.add_element("user")
2882
        _user.set_attribute("id", assigned_to_user_id)
2883
2884
        _note = cmd.add_element("open_note", note)
2885
2886
        if comment:
2887
            cmd.add_element("comment", comment)
2888
2889
        return self._send_xml_command(cmd)
2890
2891
    def delete_ticket(
2892
        self, ticket_id: str, *, ultimate: Optional[bool] = False

gvm/protocols/gmpv8/gmpv8.py 1 location

@@ 671-720 (lines=50) @@
668
669
        return self._send_xml_command(cmd)
670
671
    def create_ticket(
672
        self,
673
        *,
674
        result_id: str,
675
        assigned_to_user_id: str,
676
        note: str,
677
        comment: Optional[str] = None,
678
    ) -> Any:
679
        """Create a new ticket
680
681
        Arguments:
682
            result_id: UUID of the result the ticket applies to
683
            assigned_to_user_id: UUID of a user the ticket should be assigned to
684
            note: A note about opening the ticket
685
            comment: Comment for the ticket
686
687
        Returns:
688
            The response. See :py:meth:`send_command` for details.
689
        """
690
        if not result_id:
691
            raise RequiredArgument(
692
                function=self.create_ticket.__name__, argument='result_id'
693
            )
694
695
        if not assigned_to_user_id:
696
            raise RequiredArgument(
697
                function=self.create_ticket.__name__,
698
                argument='assigned_to_user_id',
699
            )
700
701
        if not note:
702
            raise RequiredArgument(
703
                function=self.create_ticket.__name__, argument='note'
704
            )
705
706
        cmd = XmlCommand("create_ticket")
707
708
        _result = cmd.add_element("result")
709
        _result.set_attribute("id", result_id)
710
711
        _assigned = cmd.add_element("assigned_to")
712
        _user = _assigned.add_element("user")
713
        _user.set_attribute("id", assigned_to_user_id)
714
715
        _note = cmd.add_element("open_note", note)
716
717
        if comment:
718
            cmd.add_element("comment", comment)
719
720
        return self._send_xml_command(cmd)
721
722
    def delete_ticket(
723
        self, ticket_id: str, *, ultimate: Optional[bool] = False