Code Duplication    Length = 24-24 lines in 2 locations

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 3414-3437 (lines=24) @@
3411
        cmd.add_element("copy", group_id)
3412
        return self._send_xml_command(cmd)
3413
3414
    def create_host(self, name: str, *, comment: Optional[str] = None) -> Any:
3415
        """Create a new host asset
3416
3417
        Arguments:
3418
            name: Name for the new host asset
3419
            comment: Comment for the new host asset
3420
3421
        Returns:
3422
            The response. See :py:meth:`send_command` for details.
3423
        """
3424
        if not name:
3425
            raise RequiredArgument(
3426
                function=self.create_host.__name__, argument='name'
3427
            )
3428
3429
        cmd = XmlCommand("create_asset")
3430
        asset = cmd.add_element("asset")
3431
        asset.add_element("type", "host")  # ignored for gmp7, required for gmp8
3432
        asset.add_element("name", name)
3433
3434
        if comment:
3435
            asset.add_element("comment", comment)
3436
3437
        return self._send_xml_command(cmd)
3438
3439
    def create_note(
3440
        self,

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 865-888 (lines=24) @@
862
        cmd.add_element("copy", group_id)
863
        return self._send_xml_command(cmd)
864
865
    def create_host(self, name: str, *, comment: Optional[str] = None) -> Any:
866
        """Create a new host asset
867
868
        Arguments:
869
            name: Name for the new host asset
870
            comment: Comment for the new host asset
871
872
        Returns:
873
            The response. See :py:meth:`send_command` for details.
874
        """
875
        if not name:
876
            raise RequiredArgument(
877
                function=self.create_host.__name__, argument='name'
878
            )
879
880
        cmd = XmlCommand("create_asset")
881
        asset = cmd.add_element("asset")
882
        asset.add_element("type", "host")  # ignored for gmp7, required for gmp8
883
        asset.add_element("name", name)
884
885
        if comment:
886
            asset.add_element("comment", comment)
887
888
        return self._send_xml_command(cmd)
889
890
    def create_note(
891
        self,