Code Duplication    Length = 60-60 lines in 2 locations

gvm/protocols/gmpv7.py 2 locations

@@ 851-910 (lines=60) @@
848
849
        return self._send_xml_command(cmd)
850
851
    def create_note(
852
        self,
853
        text,
854
        nvt_oid,
855
        *,
856
        seconds_active=None,
857
        hosts=None,
858
        result_id=None,
859
        severity=None,
860
        task_id=None,
861
        threat=None,
862
        port=None,
863
    ):
864
        """Create a new note
865
866
        Arguments:
867
            text (str): Text of the new note
868
            nvt_id (str): OID of the nvt to which note applies
869
            seconds_active (int, optional): Seconds note will be active. -1 on
870
                always, 0 off
871
            hosts (list, optional): A list of hosts addresses
872
            port (int, optional): Port to which the note applies
873
            result_id (str, optional): UUID of a result to which note applies
874
            severity (decimal, optional): Severity to which note applies
875
            task_id (str, optional): UUID of task to which note applies
876
            threat (str, optional): Threat level to which note applies. One of
877
                High, Medium, Low, Alarm, Log or Debug. Will be converted to
878
                severity.
879
880
        Returns:
881
            The response. See :py:meth:`send_command` for details.
882
        """
883
        if not text:
884
            raise RequiredArgument("create_note requires a text argument")
885
886
        if not nvt_oid:
887
            raise RequiredArgument("create_note requires a nvt_oid argument")
888
889
        cmd = XmlCommand("create_note")
890
        cmd.add_element("text", text)
891
        cmd.add_element("nvt", attrs={"oid": nvt_oid})
892
893
        if not seconds_active is None:
894
            cmd.add_element("active", str(seconds_active))
895
896
        if hosts:
897
            cmd.add_element("hosts", _to_comma_list(hosts))
898
899
        if port:
900
            cmd.add_element("port", str(port))
901
902
        if result_id:
903
            cmd.add_element("result", attrs={"id": result_id})
904
905
        if severity:
906
            cmd.add_element("severity", str(severity))
907
908
        if task_id:
909
            cmd.add_element("task", attrs={"id": task_id})
910
911
        if threat is not None:
912
            if threat not in THREAD_TYPES:
913
                raise InvalidArgument(
@@ 4543-4602 (lines=60) @@
4540
4541
        return self._send_xml_command(cmd)
4542
4543
    def modify_note(
4544
        self,
4545
        note_id,
4546
        text,
4547
        *,
4548
        seconds_active=None,
4549
        hosts=None,
4550
        port=None,
4551
        result_id=None,
4552
        severity=None,
4553
        task_id=None,
4554
        threat=None,
4555
    ):
4556
        """Modifies an existing note.
4557
4558
        Arguments:
4559
            note_id (str): UUID of note to modify.
4560
            text (str): The text of the note.
4561
            seconds_active (int, optional): Seconds note will be active.
4562
                -1 on always, 0 off.
4563
            hosts (list, optional): A list of hosts addresses
4564
            port (int, optional): Port to which note applies.
4565
            result_id (str, optional): Result to which note applies.
4566
            severity (descimal, optional): Severity to which note applies.
4567
            task_id (str, optional): Task to which note applies.
4568
            threat (str, optional): Threat level to which note applies. One of
4569
                High, Medium, Low, Alarm, Log or Debug. Will be converted to
4570
                severity.
4571
4572
        Returns:
4573
            The response. See :py:meth:`send_command` for details.
4574
        """
4575
        if not note_id:
4576
            raise RequiredArgument("modify_note requires a note_id attribute")
4577
4578
        if not text:
4579
            raise RequiredArgument("modify_note requires a text element")
4580
4581
        cmd = XmlCommand("modify_note")
4582
        cmd.set_attribute("note_id", note_id)
4583
        cmd.add_element("text", text)
4584
4585
        if not seconds_active is None:
4586
            cmd.add_element("active", str(seconds_active))
4587
4588
        if hosts:
4589
            cmd.add_element("hosts", _to_comma_list(hosts))
4590
4591
        if port:
4592
            cmd.add_element("port", str(port))
4593
4594
        if result_id:
4595
            cmd.add_element("result", attrs={"id": result_id})
4596
4597
        if severity:
4598
            cmd.add_element("severity", str(severity))
4599
4600
        if task_id:
4601
            cmd.add_element("task", attrs={"id": task_id})
4602
4603
        if threat is not None:
4604
            cmd.add_element("threat", threat)
4605