Code Duplication    Length = 38-42 lines in 2 locations

gvm/protocols/gmpv9/__init__.py 2 locations

@@ 208-249 (lines=42) @@
205
            preferences=preferences,
206
        )
207
208
    def create_tls_certificate(
209
        self,
210
        name: str,
211
        certificate: str,
212
        *,
213
        comment: Optional[str] = None,
214
        trust: Optional[bool] = None
215
    ) -> Any:
216
        """Create a new TLS certificate
217
218
        Arguments:
219
            name: Name of the TLS certificate, defaulting to the MD5
220
                fingerprint.
221
            certificate: The Base64 encoded certificate data (x.509 DER or PEM).
222
            comment: Comment for the TLS certificate.
223
            trust: Whether the certificate is trusted.
224
225
        Returns:
226
            The response. See :py:meth:`send_command` for details.
227
        """
228
        if not name:
229
            raise RequiredArgument(
230
                argument='name', function=self.create_tls_certificate.__name__
231
            )
232
        if not certificate:
233
            raise RequiredArgument(
234
                argument="certificate",
235
                function=self.create_tls_certificate.__name__,
236
            )
237
238
        cmd = XmlCommand("create_tls_certificate")
239
240
        if comment:
241
            cmd.add_element("comment", comment)
242
243
        cmd.add_element("name", name)
244
        cmd.add_element("certificate", certificate)
245
246
        if trust:
247
            cmd.add_element("trust", _to_bool(trust))
248
249
        return self._send_xml_command(cmd)
250
251
    def get_tls_certificates(
252
        self,
@@ 302-339 (lines=38) @@
299
        cmd.set_attribute("include_certificate_data", "1")
300
        return self._send_xml_command(cmd)
301
302
    def modify_tls_certificate(
303
        self,
304
        tls_certificate_id: str,
305
        *,
306
        name: Optional[str] = None,
307
        comment: Optional[str] = None,
308
        trust: Optional[bool] = None
309
    ) -> Any:
310
        """Modifies an existing TLS certificate.
311
312
        Arguments:
313
            tls_certificate_id: UUID of the TLS certificate to be modified.
314
            name: Name of the TLS certificate, defaulting to the MD5 fingerprint
315
            comment: Comment for the TLS certificate.
316
            trust: Whether the certificate is trusted.
317
318
        Returns:
319
            The response. See :py:meth:`send_command` for details.
320
        """
321
        if not tls_certificate_id:
322
            raise RequiredArgument(
323
                argument="tls_certificate_id",
324
                function=self.modify_tls_certificate.__name__,
325
            )
326
327
        cmd = XmlCommand("modify_tls_certificate")
328
        cmd.set_attribute("tls_certificate_id", str(tls_certificate_id))
329
330
        if comment:
331
            cmd.add_element("comment", comment)
332
333
        if name:
334
            cmd.add_element("name", name)
335
336
        if trust:
337
            cmd.add_element("trust", _to_bool(trust))
338
339
        return self._send_xml_command(cmd)
340
341
    def clone_tls_certificate(self, tls_certificate_id: str) -> Any:
342
        """Modifies an existing TLS certificate.