Code Duplication    Length = 38-42 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 2 locations

@@ 647-688 (lines=42) @@
644
645
        return self._send_xml_command(cmd)
646
647
    def create_tls_certificate(
648
        self,
649
        name: str,
650
        certificate: str,
651
        *,
652
        comment: Optional[str] = None,
653
        trust: Optional[bool] = None,
654
    ) -> Any:
655
        """Create a new TLS certificate
656
657
        Arguments:
658
            name: Name of the TLS certificate, defaulting to the MD5
659
                fingerprint.
660
            certificate: The Base64 encoded certificate data (x.509 DER or PEM).
661
            comment: Comment for the TLS certificate.
662
            trust: Whether the certificate is trusted.
663
664
        Returns:
665
            The response. See :py:meth:`send_command` for details.
666
        """
667
        if not name:
668
            raise RequiredArgument(
669
                function=self.create_tls_certificate.__name__, argument='name'
670
            )
671
        if not certificate:
672
            raise RequiredArgument(
673
                function=self.create_tls_certificate.__name__,
674
                argument='certificate',
675
            )
676
677
        cmd = XmlCommand("create_tls_certificate")
678
679
        if comment:
680
            cmd.add_element("comment", comment)
681
682
        cmd.add_element("name", name)
683
        cmd.add_element("certificate", certificate)
684
685
        if trust:
686
            cmd.add_element("trust", to_bool(trust))
687
688
        return self._send_xml_command(cmd)
689
690
    def get_aggregates(
691
        self,
@@ 1352-1389 (lines=38) @@
1349
1350
        return self._send_xml_command(cmd)
1351
1352
    def modify_tls_certificate(
1353
        self,
1354
        tls_certificate_id: str,
1355
        *,
1356
        name: Optional[str] = None,
1357
        comment: Optional[str] = None,
1358
        trust: Optional[bool] = None,
1359
    ) -> Any:
1360
        """Modifies an existing TLS certificate.
1361
1362
        Arguments:
1363
            tls_certificate_id: UUID of the TLS certificate to be modified.
1364
            name: Name of the TLS certificate, defaulting to the MD5 fingerprint
1365
            comment: Comment for the TLS certificate.
1366
            trust: Whether the certificate is trusted.
1367
1368
        Returns:
1369
            The response. See :py:meth:`send_command` for details.
1370
        """
1371
        if not tls_certificate_id:
1372
            raise RequiredArgument(
1373
                function=self.modify_tls_certificate.__name__,
1374
                argument='tls_certificate_id',
1375
            )
1376
1377
        cmd = XmlCommand("modify_tls_certificate")
1378
        cmd.set_attribute("tls_certificate_id", str(tls_certificate_id))
1379
1380
        if comment:
1381
            cmd.add_element("comment", comment)
1382
1383
        if name:
1384
            cmd.add_element("name", name)
1385
1386
        if trust:
1387
            cmd.add_element("trust", to_bool(trust))
1388
1389
        return self._send_xml_command(cmd)
1390
1391
    def clone_alert(self, alert_id: str) -> Any:
1392
        """Clone an existing alert