Code Duplication    Length = 38-42 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 2 locations

@@ 741-782 (lines=42) @@
738
            preferences=preferences,
739
        )
740
741
    def create_tls_certificate(
742
        self,
743
        name: str,
744
        certificate: str,
745
        *,
746
        comment: Optional[str] = None,
747
        trust: Optional[bool] = None,
748
    ) -> Any:
749
        """Create a new TLS certificate
750
751
        Arguments:
752
            name: Name of the TLS certificate, defaulting to the MD5
753
                fingerprint.
754
            certificate: The Base64 encoded certificate data (x.509 DER or PEM).
755
            comment: Comment for the TLS certificate.
756
            trust: Whether the certificate is trusted.
757
758
        Returns:
759
            The response. See :py:meth:`send_command` for details.
760
        """
761
        if not name:
762
            raise RequiredArgument(
763
                function=self.create_tls_certificate.__name__, argument='name'
764
            )
765
        if not certificate:
766
            raise RequiredArgument(
767
                function=self.create_tls_certificate.__name__,
768
                argument='certificate',
769
            )
770
771
        cmd = XmlCommand("create_tls_certificate")
772
773
        if comment:
774
            cmd.add_element("comment", comment)
775
776
        cmd.add_element("name", name)
777
        cmd.add_element("certificate", certificate)
778
779
        if trust:
780
            cmd.add_element("trust", _to_bool(trust))
781
782
        return self._send_xml_command(cmd)
783
784
    def get_aggregates(
785
        self,
@@ 1446-1483 (lines=38) @@
1443
1444
        return self._send_xml_command(cmd)
1445
1446
    def modify_tls_certificate(
1447
        self,
1448
        tls_certificate_id: str,
1449
        *,
1450
        name: Optional[str] = None,
1451
        comment: Optional[str] = None,
1452
        trust: Optional[bool] = None,
1453
    ) -> Any:
1454
        """Modifies an existing TLS certificate.
1455
1456
        Arguments:
1457
            tls_certificate_id: UUID of the TLS certificate to be modified.
1458
            name: Name of the TLS certificate, defaulting to the MD5 fingerprint
1459
            comment: Comment for the TLS certificate.
1460
            trust: Whether the certificate is trusted.
1461
1462
        Returns:
1463
            The response. See :py:meth:`send_command` for details.
1464
        """
1465
        if not tls_certificate_id:
1466
            raise RequiredArgument(
1467
                function=self.modify_tls_certificate.__name__,
1468
                argument='tls_certificate_id',
1469
            )
1470
1471
        cmd = XmlCommand("modify_tls_certificate")
1472
        cmd.set_attribute("tls_certificate_id", str(tls_certificate_id))
1473
1474
        if comment:
1475
            cmd.add_element("comment", comment)
1476
1477
        if name:
1478
            cmd.add_element("name", name)
1479
1480
        if trust:
1481
            cmd.add_element("trust", _to_bool(trust))
1482
1483
        return self._send_xml_command(cmd)
1484
1485
    def clone_alert(self, alert_id: str) -> Any:
1486
        """Clone an existing alert