Code Duplication    Length = 50-50 lines in 2 locations

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

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 2872-2921 (lines=50) @@
2869
2870
        return self._send_xml_command(cmd)
2871
2872
    def create_ticket(
2873
        self,
2874
        *,
2875
        result_id: str,
2876
        assigned_to_user_id: str,
2877
        note: str,
2878
        comment: Optional[str] = None,
2879
    ) -> Any:
2880
        """Create a new ticket
2881
2882
        Arguments:
2883
            result_id: UUID of the result the ticket applies to
2884
            assigned_to_user_id: UUID of a user the ticket should be assigned to
2885
            note: A note about opening the ticket
2886
            comment: Comment for the ticket
2887
2888
        Returns:
2889
            The response. See :py:meth:`send_command` for details.
2890
        """
2891
        if not result_id:
2892
            raise RequiredArgument(
2893
                function=self.create_ticket.__name__, argument='result_id'
2894
            )
2895
2896
        if not assigned_to_user_id:
2897
            raise RequiredArgument(
2898
                function=self.create_ticket.__name__,
2899
                argument='assigned_to_user_id',
2900
            )
2901
2902
        if not note:
2903
            raise RequiredArgument(
2904
                function=self.create_ticket.__name__, argument='note'
2905
            )
2906
2907
        cmd = XmlCommand("create_ticket")
2908
2909
        _result = cmd.add_element("result")
2910
        _result.set_attribute("id", result_id)
2911
2912
        _assigned = cmd.add_element("assigned_to")
2913
        _user = _assigned.add_element("user")
2914
        _user.set_attribute("id", assigned_to_user_id)
2915
2916
        _note = cmd.add_element("open_note", note)
2917
2918
        if comment:
2919
            cmd.add_element("comment", comment)
2920
2921
        return self._send_xml_command(cmd)
2922
2923
    def delete_ticket(
2924
        self, ticket_id: str, *, ultimate: Optional[bool] = False