Code Duplication    Length = 38-42 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 2 locations

@@ 441-482 (lines=42) @@
438
439
        return self._send_xml_command(cmd)
440
441
    def create_tls_certificate(
442
        self,
443
        name: str,
444
        certificate: str,
445
        *,
446
        comment: Optional[str] = None,
447
        trust: Optional[bool] = None,
448
    ) -> Any:
449
        """Create a new TLS certificate
450
451
        Arguments:
452
            name: Name of the TLS certificate, defaulting to the MD5
453
                fingerprint.
454
            certificate: The Base64 encoded certificate data (x.509 DER or PEM).
455
            comment: Comment for the TLS certificate.
456
            trust: Whether the certificate is trusted.
457
458
        Returns:
459
            The response. See :py:meth:`send_command` for details.
460
        """
461
        if not name:
462
            raise RequiredArgument(
463
                function=self.create_tls_certificate.__name__, argument='name'
464
            )
465
        if not certificate:
466
            raise RequiredArgument(
467
                function=self.create_tls_certificate.__name__,
468
                argument='certificate',
469
            )
470
471
        cmd = XmlCommand("create_tls_certificate")
472
473
        if comment:
474
            cmd.add_element("comment", comment)
475
476
        cmd.add_element("name", name)
477
        cmd.add_element("certificate", certificate)
478
479
        if trust:
480
            cmd.add_element("trust", to_bool(trust))
481
482
        return self._send_xml_command(cmd)
483
484
    def get_aggregates(
485
        self,
@@ 1038-1075 (lines=38) @@
1035
1036
        return self._send_xml_command(cmd)
1037
1038
    def modify_tls_certificate(
1039
        self,
1040
        tls_certificate_id: str,
1041
        *,
1042
        name: Optional[str] = None,
1043
        comment: Optional[str] = None,
1044
        trust: Optional[bool] = None,
1045
    ) -> Any:
1046
        """Modifies an existing TLS certificate.
1047
1048
        Arguments:
1049
            tls_certificate_id: UUID of the TLS certificate to be modified.
1050
            name: Name of the TLS certificate, defaulting to the MD5 fingerprint
1051
            comment: Comment for the TLS certificate.
1052
            trust: Whether the certificate is trusted.
1053
1054
        Returns:
1055
            The response. See :py:meth:`send_command` for details.
1056
        """
1057
        if not tls_certificate_id:
1058
            raise RequiredArgument(
1059
                function=self.modify_tls_certificate.__name__,
1060
                argument='tls_certificate_id',
1061
            )
1062
1063
        cmd = XmlCommand("modify_tls_certificate")
1064
        cmd.set_attribute("tls_certificate_id", str(tls_certificate_id))
1065
1066
        if comment:
1067
            cmd.add_element("comment", comment)
1068
1069
        if name:
1070
            cmd.add_element("name", name)
1071
1072
        if trust:
1073
            cmd.add_element("trust", to_bool(trust))
1074
1075
        return self._send_xml_command(cmd)
1076
1077
    def clone_ticket(self, ticket_id: str) -> Any:
1078
        """Clone an existing ticket