Code Duplication    Length = 66-66 lines in 2 locations

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,

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 6704-6769 (lines=66) @@
6701
6702
        return self._send_xml_command(cmd)
6703
6704
    def modify_scanner(
6705
        self,
6706
        scanner_id: str,
6707
        *,
6708
        scanner_type: Optional[ScannerType] = None,
6709
        host: Optional[str] = None,
6710
        port: Optional[int] = None,
6711
        comment: Optional[str] = None,
6712
        name: Optional[str] = None,
6713
        ca_pub: Optional[str] = None,
6714
        credential_id: Optional[str] = None,
6715
    ) -> Any:
6716
        """Modifies an existing scanner.
6717
6718
        Arguments:
6719
            scanner_id: UUID of scanner to modify.
6720
            scanner_type: New type of the Scanner.
6721
            host: Host of the scanner.
6722
            port: Port of the scanner.
6723
            comment: Comment on scanner.
6724
            name: Name of scanner.
6725
            ca_pub: Certificate of CA to verify scanner's certificate.
6726
            credential_id: UUID of the client certificate credential for the
6727
                Scanner.
6728
6729
        Returns:
6730
            The response. See :py:meth:`send_command` for details.
6731
        """
6732
        if not scanner_id:
6733
            raise RequiredArgument(
6734
                function=self.modify_scanner.__name__,
6735
                argument='scanner_id argument',
6736
            )
6737
6738
        cmd = XmlCommand("modify_scanner")
6739
        cmd.set_attribute("scanner_id", scanner_id)
6740
6741
        if scanner_type is not None:
6742
            if not isinstance(scanner_type, self.types.ScannerType):
6743
                raise InvalidArgumentType(
6744
                    function=self.modify_scanner.__name__,
6745
                    argument='scanner_type',
6746
                    arg_type=self.types.ScannerType.__name__,
6747
                )
6748
6749
            cmd.add_element("type", scanner_type.value)
6750
6751
        if host:
6752
            cmd.add_element("host", host)
6753
6754
        if port:
6755
            cmd.add_element("port", str(port))
6756
6757
        if comment:
6758
            cmd.add_element("comment", comment)
6759
6760
        if name:
6761
            cmd.add_element("name", name)
6762
6763
        if ca_pub:
6764
            cmd.add_element("ca_pub", ca_pub)
6765
6766
        if credential_id:
6767
            cmd.add_element("credential", attrs={"id": str(credential_id)})
6768
6769
        return self._send_xml_command(cmd)
6770
6771
    def modify_setting(
6772
        self,