Code Duplication    Length = 45-45 lines in 2 locations

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 2969-3013 (lines=45) @@
2966
2967
        return self._send_xml_command(cmd)
2968
2969
    def get_credential(
2970
        self,
2971
        credential_id: str,
2972
        *,
2973
        scanners: Optional[bool] = None,
2974
        targets: Optional[bool] = None,
2975
        credential_format: Optional[CredentialFormat] = None,
2976
    ) -> Any:
2977
        """Request a single credential
2978
2979
        Arguments:
2980
            credential_id: UUID of an existing credential
2981
            scanners: Whether to include a list of scanners using the
2982
                credentials
2983
            targets: Whether to include a list of targets using the credentials
2984
            credential_format: One of "key", "rpm", "deb", "exe" or "pem"
2985
2986
        Returns:
2987
            The response. See :py:meth:`send_command` for details.
2988
        """
2989
        if not credential_id:
2990
            raise RequiredArgument(
2991
                function=self.get_credential.__name__, argument='credential_id'
2992
            )
2993
2994
        cmd = XmlCommand("get_credentials")
2995
        cmd.set_attribute("credential_id", credential_id)
2996
2997
        if credential_format:
2998
            if not isinstance(credential_format, CredentialFormat):
2999
                raise InvalidArgumentType(
3000
                    function=self.get_credential.__name__,
3001
                    argument='credential_format',
3002
                    arg_type=CredentialFormat.__name__,
3003
                )
3004
3005
            cmd.set_attribute("format", credential_format.value)
3006
3007
        if scanners is not None:
3008
            cmd.set_attribute("scanners", _to_bool(scanners))
3009
3010
        if targets is not None:
3011
            cmd.set_attribute("targets", _to_bool(targets))
3012
3013
        return self._send_xml_command(cmd)
3014
3015
    def get_configs(
3016
        self,

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 4826-4870 (lines=45) @@
4823
4824
        return self._send_xml_command(cmd)
4825
4826
    def get_credential(
4827
        self,
4828
        credential_id: str,
4829
        *,
4830
        scanners: Optional[bool] = None,
4831
        targets: Optional[bool] = None,
4832
        credential_format: Optional[CredentialFormat] = None,
4833
    ) -> Any:
4834
        """Request a single credential
4835
4836
        Arguments:
4837
            credential_id: UUID of an existing credential
4838
            scanners: Whether to include a list of scanners using the
4839
                credentials
4840
            targets: Whether to include a list of targets using the credentials
4841
            credential_format: One of "key", "rpm", "deb", "exe" or "pem"
4842
4843
        Returns:
4844
            The response. See :py:meth:`send_command` for details.
4845
        """
4846
        if not credential_id:
4847
            raise RequiredArgument(
4848
                function=self.get_credential.__name__, argument='credential_id'
4849
            )
4850
4851
        cmd = XmlCommand("get_credentials")
4852
        cmd.set_attribute("credential_id", credential_id)
4853
4854
        if credential_format:
4855
            if not isinstance(credential_format, CredentialFormat):
4856
                raise InvalidArgumentType(
4857
                    function=self.get_credential.__name__,
4858
                    argument='credential_format',
4859
                    arg_type=CredentialFormat.__name__,
4860
                )
4861
4862
            cmd.set_attribute("format", credential_format.value)
4863
4864
        if scanners is not None:
4865
            cmd.set_attribute("scanners", _to_bool(scanners))
4866
4867
        if targets is not None:
4868
            cmd.set_attribute("targets", _to_bool(targets))
4869
4870
        return self._send_xml_command(cmd)
4871
4872
    def get_feeds(self) -> Any:
4873
        """Request the list of feeds