Code Duplication    Length = 66-66 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 6672-6737 (lines=66) @@
6669
6670
        return self._send_xml_command(cmd)
6671
6672
    def modify_scanner(
6673
        self,
6674
        scanner_id: str,
6675
        *,
6676
        scanner_type: Optional[ScannerType] = None,
6677
        host: Optional[str] = None,
6678
        port: Optional[int] = None,
6679
        comment: Optional[str] = None,
6680
        name: Optional[str] = None,
6681
        ca_pub: Optional[str] = None,
6682
        credential_id: Optional[str] = None,
6683
    ) -> Any:
6684
        """Modifies an existing scanner.
6685
6686
        Arguments:
6687
            scanner_id: UUID of scanner to modify.
6688
            scanner_type: New type of the Scanner.
6689
            host: Host of the scanner.
6690
            port: Port of the scanner.
6691
            comment: Comment on scanner.
6692
            name: Name of scanner.
6693
            ca_pub: Certificate of CA to verify scanner's certificate.
6694
            credential_id: UUID of the client certificate credential for the
6695
                Scanner.
6696
6697
        Returns:
6698
            The response. See :py:meth:`send_command` for details.
6699
        """
6700
        if not scanner_id:
6701
            raise RequiredArgument(
6702
                function=self.modify_scanner.__name__,
6703
                argument='scanner_id argument',
6704
            )
6705
6706
        cmd = XmlCommand("modify_scanner")
6707
        cmd.set_attribute("scanner_id", scanner_id)
6708
6709
        if scanner_type is not None:
6710
            if not isinstance(scanner_type, self.types.ScannerType):
6711
                raise InvalidArgumentType(
6712
                    function=self.modify_scanner.__name__,
6713
                    argument='scanner_type',
6714
                    arg_type=self.types.ScannerType.__name__,
6715
                )
6716
6717
            cmd.add_element("type", scanner_type.value)
6718
6719
        if host:
6720
            cmd.add_element("host", host)
6721
6722
        if port:
6723
            cmd.add_element("port", str(port))
6724
6725
        if comment:
6726
            cmd.add_element("comment", comment)
6727
6728
        if name:
6729
            cmd.add_element("name", name)
6730
6731
        if ca_pub:
6732
            cmd.add_element("ca_pub", ca_pub)
6733
6734
        if credential_id:
6735
            cmd.add_element("credential", attrs={"id": str(credential_id)})
6736
6737
        return self._send_xml_command(cmd)
6738
6739
    def modify_setting(
6740
        self,

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 5476-5541 (lines=66) @@
5473
5474
        return self._send_xml_command(cmd)
5475
5476
    def modify_scanner(
5477
        self,
5478
        scanner_id: str,
5479
        *,
5480
        scanner_type: Optional[ScannerType] = None,
5481
        host: Optional[str] = None,
5482
        port: Optional[int] = None,
5483
        comment: Optional[str] = None,
5484
        name: Optional[str] = None,
5485
        ca_pub: Optional[str] = None,
5486
        credential_id: Optional[str] = None,
5487
    ) -> Any:
5488
        """Modifies an existing scanner.
5489
5490
        Arguments:
5491
            scanner_id: UUID of scanner to modify.
5492
            scanner_type: New type of the Scanner.
5493
            host: Host of the scanner.
5494
            port: Port of the scanner.
5495
            comment: Comment on scanner.
5496
            name: Name of scanner.
5497
            ca_pub: Certificate of CA to verify scanner's certificate.
5498
            credential_id: UUID of the client certificate credential for the
5499
                Scanner.
5500
5501
        Returns:
5502
            The response. See :py:meth:`send_command` for details.
5503
        """
5504
        if not scanner_id:
5505
            raise RequiredArgument(
5506
                function=self.modify_scanner.__name__,
5507
                argument='scanner_id argument',
5508
            )
5509
5510
        cmd = XmlCommand("modify_scanner")
5511
        cmd.set_attribute("scanner_id", scanner_id)
5512
5513
        if scanner_type is not None:
5514
            if not isinstance(scanner_type, self.types.ScannerType):
5515
                raise InvalidArgumentType(
5516
                    function=self.modify_scanner.__name__,
5517
                    argument='scanner_type',
5518
                    arg_type=self.types.ScannerType.__name__,
5519
                )
5520
5521
            cmd.add_element("type", scanner_type.value)
5522
5523
        if host:
5524
            cmd.add_element("host", host)
5525
5526
        if port:
5527
            cmd.add_element("port", str(port))
5528
5529
        if comment:
5530
            cmd.add_element("comment", comment)
5531
5532
        if name:
5533
            cmd.add_element("name", name)
5534
5535
        if ca_pub:
5536
            cmd.add_element("ca_pub", ca_pub)
5537
5538
        if credential_id:
5539
            cmd.add_element("credential", attrs={"id": str(credential_id)})
5540
5541
        return self._send_xml_command(cmd)
5542
5543
    def modify_schedule(
5544
        self,