Code Duplication    Length = 38-42 lines in 2 locations

gvm/protocols/gmpv9/gmpv9.py 2 locations

@@ 618-659 (lines=42) @@
615
            preferences=preferences,
616
        )
617
618
    def create_tls_certificate(
619
        self,
620
        name: str,
621
        certificate: str,
622
        *,
623
        comment: Optional[str] = None,
624
        trust: Optional[bool] = None
625
    ) -> Any:
626
        """Create a new TLS certificate
627
628
        Arguments:
629
            name: Name of the TLS certificate, defaulting to the MD5
630
                fingerprint.
631
            certificate: The Base64 encoded certificate data (x.509 DER or PEM).
632
            comment: Comment for the TLS certificate.
633
            trust: Whether the certificate is trusted.
634
635
        Returns:
636
            The response. See :py:meth:`send_command` for details.
637
        """
638
        if not name:
639
            raise RequiredArgument(
640
                function=self.create_tls_certificate.__name__, argument='name'
641
            )
642
        if not certificate:
643
            raise RequiredArgument(
644
                function=self.create_tls_certificate.__name__,
645
                argument='certificate',
646
            )
647
648
        cmd = XmlCommand("create_tls_certificate")
649
650
        if comment:
651
            cmd.add_element("comment", comment)
652
653
        cmd.add_element("name", name)
654
        cmd.add_element("certificate", certificate)
655
656
        if trust:
657
            cmd.add_element("trust", _to_bool(trust))
658
659
        return self._send_xml_command(cmd)
660
661
    def get_tls_certificates(
662
        self,
@@ 1173-1210 (lines=38) @@
1170
1171
        return self._send_xml_command(cmd)
1172
1173
    def modify_tls_certificate(
1174
        self,
1175
        tls_certificate_id: str,
1176
        *,
1177
        name: Optional[str] = None,
1178
        comment: Optional[str] = None,
1179
        trust: Optional[bool] = None
1180
    ) -> Any:
1181
        """Modifies an existing TLS certificate.
1182
1183
        Arguments:
1184
            tls_certificate_id: UUID of the TLS certificate to be modified.
1185
            name: Name of the TLS certificate, defaulting to the MD5 fingerprint
1186
            comment: Comment for the TLS certificate.
1187
            trust: Whether the certificate is trusted.
1188
1189
        Returns:
1190
            The response. See :py:meth:`send_command` for details.
1191
        """
1192
        if not tls_certificate_id:
1193
            raise RequiredArgument(
1194
                function=self.modify_tls_certificate.__name__,
1195
                argument='tls_certificate_id',
1196
            )
1197
1198
        cmd = XmlCommand("modify_tls_certificate")
1199
        cmd.set_attribute("tls_certificate_id", str(tls_certificate_id))
1200
1201
        if comment:
1202
            cmd.add_element("comment", comment)
1203
1204
        if name:
1205
            cmd.add_element("name", name)
1206
1207
        if trust:
1208
            cmd.add_element("trust", _to_bool(trust))
1209
1210
        return self._send_xml_command(cmd)
1211
1212
    def clone_tls_certificate(self, tls_certificate_id: str) -> Any:
1213
        """Modifies an existing TLS certificate.