Code Duplication    Length = 38-42 lines in 2 locations

gvm/protocols/gmpv9/gmpv9.py 2 locations

@@ 620-661 (lines=42) @@
617
            preferences=preferences,
618
        )
619
620
    def create_tls_certificate(
621
        self,
622
        name: str,
623
        certificate: str,
624
        *,
625
        comment: Optional[str] = None,
626
        trust: Optional[bool] = None,
627
    ) -> Any:
628
        """Create a new TLS certificate
629
630
        Arguments:
631
            name: Name of the TLS certificate, defaulting to the MD5
632
                fingerprint.
633
            certificate: The Base64 encoded certificate data (x.509 DER or PEM).
634
            comment: Comment for the TLS certificate.
635
            trust: Whether the certificate is trusted.
636
637
        Returns:
638
            The response. See :py:meth:`send_command` for details.
639
        """
640
        if not name:
641
            raise RequiredArgument(
642
                function=self.create_tls_certificate.__name__, argument='name'
643
            )
644
        if not certificate:
645
            raise RequiredArgument(
646
                function=self.create_tls_certificate.__name__,
647
                argument='certificate',
648
            )
649
650
        cmd = XmlCommand("create_tls_certificate")
651
652
        if comment:
653
            cmd.add_element("comment", comment)
654
655
        cmd.add_element("name", name)
656
        cmd.add_element("certificate", certificate)
657
658
        if trust:
659
            cmd.add_element("trust", _to_bool(trust))
660
661
        return self._send_xml_command(cmd)
662
663
    def get_aggregates(
664
        self,
@@ 1325-1362 (lines=38) @@
1322
1323
        return self._send_xml_command(cmd)
1324
1325
    def modify_tls_certificate(
1326
        self,
1327
        tls_certificate_id: str,
1328
        *,
1329
        name: Optional[str] = None,
1330
        comment: Optional[str] = None,
1331
        trust: Optional[bool] = None,
1332
    ) -> Any:
1333
        """Modifies an existing TLS certificate.
1334
1335
        Arguments:
1336
            tls_certificate_id: UUID of the TLS certificate to be modified.
1337
            name: Name of the TLS certificate, defaulting to the MD5 fingerprint
1338
            comment: Comment for the TLS certificate.
1339
            trust: Whether the certificate is trusted.
1340
1341
        Returns:
1342
            The response. See :py:meth:`send_command` for details.
1343
        """
1344
        if not tls_certificate_id:
1345
            raise RequiredArgument(
1346
                function=self.modify_tls_certificate.__name__,
1347
                argument='tls_certificate_id',
1348
            )
1349
1350
        cmd = XmlCommand("modify_tls_certificate")
1351
        cmd.set_attribute("tls_certificate_id", str(tls_certificate_id))
1352
1353
        if comment:
1354
            cmd.add_element("comment", comment)
1355
1356
        if name:
1357
            cmd.add_element("name", name)
1358
1359
        if trust:
1360
            cmd.add_element("trust", _to_bool(trust))
1361
1362
        return self._send_xml_command(cmd)
1363
1364
    def clone_tls_certificate(self, tls_certificate_id: str) -> Any:
1365
        """Modifies an existing TLS certificate.